1 /*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org> 5 * Copyright (c) 2001 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Klaus Klein. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 #ifndef _MACHINE__STDINT_H_ 41 #define _MACHINE__STDINT_H_ 42 43 #define INT8_C(c) (c) 44 #define INT16_C(c) (c) 45 #define INT32_C(c) (c) 46 47 #define UINT8_C(c) (c) 48 #define UINT16_C(c) (c) 49 #define UINT32_C(c) (c ## U) 50 51 #ifdef __LP64__ 52 #define INT64_C(c) (c ## L) 53 #define UINT64_C(c) (c ## UL) 54 #else 55 #define INT64_C(c) (c ## LL) 56 #define UINT64_C(c) (c ## ULL) 57 #endif 58 59 #define INTMAX_C(c) INT64_C(c) 60 #define UINTMAX_C(c) UINT64_C(c) 61 62 #ifndef __INT64_C 63 #ifdef __LP64__ 64 #define __INT64_C(c) (c ## L) 65 #define __UINT64_C(c) (c ## UL) 66 #else 67 #define __INT64_C(c) (c ## LL) 68 #define __UINT64_C(c) (c ## ULL) 69 #endif 70 #endif 71 72 /* 73 * ISO/IEC 9899:1999 74 * 7.18.2.1 Limits of exact-width integer types 75 */ 76 /* Minimum values of exact-width signed integer types. */ 77 #define INT8_MIN (-0x7f-1) 78 #define INT16_MIN (-0x7fff-1) 79 #define INT32_MIN (-0x7fffffff-1) 80 #define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1) 81 82 /* Maximum values of exact-width signed integer types. */ 83 #define INT8_MAX 0x7f 84 #define INT16_MAX 0x7fff 85 #define INT32_MAX 0x7fffffff 86 #define INT64_MAX __INT64_C(0x7fffffffffffffff) 87 88 /* Maximum values of exact-width unsigned integer types. */ 89 #define UINT8_MAX 0xff 90 #define UINT16_MAX 0xffff 91 #define UINT32_MAX 0xffffffff 92 #define UINT64_MAX __UINT64_C(0xffffffffffffffff) 93 94 /* 95 * ISO/IEC 9899:1999 96 * 7.18.2.2 Limits of minimum-width integer types 97 */ 98 /* Minimum values of minimum-width signed integer types. */ 99 #define INT_LEAST8_MIN INT8_MIN 100 #define INT_LEAST16_MIN INT16_MIN 101 #define INT_LEAST32_MIN INT32_MIN 102 #define INT_LEAST64_MIN INT64_MIN 103 104 /* Maximum values of minimum-width signed integer types. */ 105 #define INT_LEAST8_MAX INT8_MAX 106 #define INT_LEAST16_MAX INT16_MAX 107 #define INT_LEAST32_MAX INT32_MAX 108 #define INT_LEAST64_MAX INT64_MAX 109 110 /* Maximum values of minimum-width unsigned integer types. */ 111 #define UINT_LEAST8_MAX UINT8_MAX 112 #define UINT_LEAST16_MAX UINT16_MAX 113 #define UINT_LEAST32_MAX UINT32_MAX 114 #define UINT_LEAST64_MAX UINT64_MAX 115 116 /* 117 * ISO/IEC 9899:1999 118 * 7.18.2.3 Limits of fastest minimum-width integer types 119 */ 120 /* Minimum values of fastest minimum-width signed integer types. */ 121 #define INT_FAST8_MIN INT32_MIN 122 #define INT_FAST16_MIN INT32_MIN 123 #define INT_FAST32_MIN INT32_MIN 124 #define INT_FAST64_MIN INT64_MIN 125 126 /* Maximum values of fastest minimum-width signed integer types. */ 127 #define INT_FAST8_MAX INT32_MAX 128 #define INT_FAST16_MAX INT32_MAX 129 #define INT_FAST32_MAX INT32_MAX 130 #define INT_FAST64_MAX INT64_MAX 131 132 /* Maximum values of fastest minimum-width unsigned integer types. */ 133 #define UINT_FAST8_MAX UINT32_MAX 134 #define UINT_FAST16_MAX UINT32_MAX 135 #define UINT_FAST32_MAX UINT32_MAX 136 #define UINT_FAST64_MAX UINT64_MAX 137 138 /* 139 * ISO/IEC 9899:1999 140 * 7.18.2.4 Limits of integer types capable of holding object pointers 141 */ 142 #ifdef __LP64__ 143 #define INTPTR_MIN INT64_MIN 144 #define INTPTR_MAX INT64_MAX 145 #define UINTPTR_MAX UINT64_MAX 146 #else 147 #define INTPTR_MIN INT32_MIN 148 #define INTPTR_MAX INT32_MAX 149 #define UINTPTR_MAX UINT32_MAX 150 #endif 151 152 /* 153 * ISO/IEC 9899:1999 154 * 7.18.2.5 Limits of greatest-width integer types 155 */ 156 #define INTMAX_MIN INT64_MIN 157 #define INTMAX_MAX INT64_MAX 158 #define UINTMAX_MAX UINT64_MAX 159 160 /* 161 * ISO/IEC 9899:1999 162 * 7.18.3 Limits of other integer types 163 */ 164 /* Limits of sig_atomic_t. */ 165 #define SIG_ATOMIC_MIN INT32_MIN 166 #define SIG_ATOMIC_MAX INT32_MAX 167 168 #ifdef __LP64__ 169 /* Limits of ptrdiff_t. */ 170 #define PTRDIFF_MIN INT64_MIN 171 #define PTRDIFF_MAX INT64_MAX 172 173 /* Limit of size_t. */ 174 #define SIZE_MAX UINT64_MAX 175 #else 176 /* Limits of ptrdiff_t. */ 177 #define PTRDIFF_MIN INT32_MIN 178 #define PTRDIFF_MAX INT32_MAX 179 180 /* Limit of size_t. */ 181 #define SIZE_MAX UINT32_MAX 182 #endif 183 184 /* Limits of wint_t. */ 185 #define WINT_MIN INT32_MIN 186 #define WINT_MAX INT32_MAX 187 188 #if __ISO_C_VISIBLE >= 2023 189 /* 190 * ISO/IEC 9899:2023 191 * 7.22.2 Widths of specified-width integer types 192 */ 193 #define INT_FAST8_WIDTH INT32_WIDTH 194 #define INT_FAST16_WIDTH INT32_WIDTH 195 #define INT_FAST32_WIDTH INT32_WIDTH 196 #define INT_FAST64_WIDTH INT64_WIDTH 197 #ifdef __LP64__ 198 #define INTPTR_WIDTH INT64_WIDTH 199 #else 200 #define INTPTR_WIDTH INT32_WIDTH 201 #endif 202 #define INTMAX_WIDTH INT64_WIDTH 203 204 /* 205 * ISO/IEC 9899:2023 206 * 7.22.3 Width of other integer types 207 */ 208 #ifdef __LP64__ 209 #define PTRDIFF_WIDTH INT64_WIDTH 210 #define SIZE_WIDTH INT64_WIDTH 211 #else 212 #define PTRDIFF_WIDTH INT32_WIDTH 213 #define SIZE_WIDTH INT32_WIDTH 214 #endif 215 #define SIG_ATOMIC_WIDTH INT32_WIDTH 216 #define WCHAR_WIDTH INT32_WIDTH 217 #define WINT_WIDTH INT32_WIDTH 218 #endif /* __ISO_C_VISIBLE >= 2023 */ 219 220 #endif /* !_MACHINE__STDINT_H_ */ 221