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 /* 63 * ISO/IEC 9899:1999 64 * 7.18.2.1 Limits of exact-width integer types 65 */ 66 #define INT8_MIN (-0x7f-1) 67 #define INT16_MIN (-0x7fff-1) 68 #define INT32_MIN (-0x7fffffff-1) 69 70 #define INT8_MAX 0x7f 71 #define INT16_MAX 0x7fff 72 #define INT32_MAX 0x7fffffff 73 74 #define UINT8_MAX 0xff 75 #define UINT16_MAX 0xffff 76 #define UINT32_MAX 0xffffffffU 77 78 #ifdef __LP64__ 79 #define INT64_MIN (-0x7fffffffffffffff-1) 80 #define INT64_MAX 0x7fffffffffffffff 81 #define UINT64_MAX 0xffffffffffffffff 82 #else 83 #define INT64_MIN (-0x7fffffffffffffffLL-1) 84 #define INT64_MAX 0x7fffffffffffffffLL 85 #define UINT64_MAX 0xffffffffffffffffULL 86 #endif 87 88 /* 89 * ISO/IEC 9899:1999 90 * 7.18.2.2 Limits of minimum-width integer types 91 */ 92 /* Minimum values of minimum-width signed integer types. */ 93 #define INT_LEAST8_MIN INT8_MIN 94 #define INT_LEAST16_MIN INT16_MIN 95 #define INT_LEAST32_MIN INT32_MIN 96 #define INT_LEAST64_MIN INT64_MIN 97 98 /* Maximum values of minimum-width signed integer types. */ 99 #define INT_LEAST8_MAX INT8_MAX 100 #define INT_LEAST16_MAX INT16_MAX 101 #define INT_LEAST32_MAX INT32_MAX 102 #define INT_LEAST64_MAX INT64_MAX 103 104 /* Maximum values of minimum-width unsigned integer types. */ 105 #define UINT_LEAST8_MAX UINT8_MAX 106 #define UINT_LEAST16_MAX UINT16_MAX 107 #define UINT_LEAST32_MAX UINT32_MAX 108 #define UINT_LEAST64_MAX UINT64_MAX 109 110 /* 111 * ISO/IEC 9899:1999 112 * 7.18.2.3 Limits of fastest minimum-width integer types 113 */ 114 /* Minimum values of fastest minimum-width signed integer types. */ 115 #define INT_FAST8_MIN INT32_MIN 116 #define INT_FAST16_MIN INT32_MIN 117 #define INT_FAST32_MIN INT32_MIN 118 #define INT_FAST64_MIN INT64_MIN 119 120 /* Maximum values of fastest minimum-width signed integer types. */ 121 #define INT_FAST8_MAX INT32_MAX 122 #define INT_FAST16_MAX INT32_MAX 123 #define INT_FAST32_MAX INT32_MAX 124 #define INT_FAST64_MAX INT64_MAX 125 126 /* Maximum values of fastest minimum-width unsigned integer types. */ 127 #define UINT_FAST8_MAX UINT32_MAX 128 #define UINT_FAST16_MAX UINT32_MAX 129 #define UINT_FAST32_MAX UINT32_MAX 130 #define UINT_FAST64_MAX UINT64_MAX 131 132 /* 133 * ISO/IEC 9899:1999 134 * 7.18.2.4 Limits of integer types capable of holding object pointers 135 */ 136 #ifdef __LP64__ 137 #define INTPTR_MIN INT64_MIN 138 #define INTPTR_MAX INT64_MAX 139 #define UINTPTR_MAX UINT64_MAX 140 #else 141 #define INTPTR_MIN INT32_MIN 142 #define INTPTR_MAX INT32_MAX 143 #define UINTPTR_MAX UINT32_MAX 144 #endif 145 146 /* 147 * ISO/IEC 9899:1999 148 * 7.18.2.5 Limits of greatest-width integer types 149 */ 150 #define INTMAX_MIN INT64_MIN 151 #define INTMAX_MAX INT64_MAX 152 #define UINTMAX_MAX UINT64_MAX 153 154 /* 155 * ISO/IEC 9899:1999 156 * 7.18.3 Limits of other integer types 157 */ 158 #ifdef __LP64__ 159 /* Limits of ptrdiff_t. */ 160 #define PTRDIFF_MIN INT64_MIN 161 #define PTRDIFF_MAX INT64_MAX 162 163 /* Limits of sig_atomic_t. */ 164 #define SIG_ATOMIC_MIN INT64_MIN 165 #define SIG_ATOMIC_MAX INT64_MAX 166 167 /* Limit of size_t. */ 168 #define SIZE_MAX UINT64_MAX 169 #else 170 #define PTRDIFF_MIN INT32_MIN 171 #define PTRDIFF_MAX INT32_MAX 172 #define SIG_ATOMIC_MIN INT32_MIN 173 #define SIG_ATOMIC_MAX INT32_MAX 174 #define SIZE_MAX UINT32_MAX 175 #endif 176 177 /* Limits of wint_t. */ 178 #define WINT_MIN INT32_MIN 179 #define WINT_MAX INT32_MAX 180 181 #if __ISO_C_VISIBLE >= 2023 182 /* 183 * ISO/IEC 9899:2023 184 * 7.22.2 Widths of specified-width integer types 185 */ 186 #define INT_FAST8_WIDTH INT32_WIDTH 187 #define INT_FAST16_WIDTH INT32_WIDTH 188 #define INT_FAST32_WIDTH INT32_WIDTH 189 #define INT_FAST64_WIDTH INT64_WIDTH 190 #ifdef __LP64__ 191 #define INTPTR_WIDTH INT64_WIDTH 192 #else 193 #define INTPTR_WIDTH INT32_WIDTH 194 #endif 195 #define INTMAX_WIDTH INT64_WIDTH 196 197 /* 198 * ISO/IEC 9899:2023 199 * 7.22.3 Width of other integer types 200 */ 201 #ifdef __LP64__ 202 #define PTRDIFF_WIDTH INT64_WIDTH 203 #define SIG_ATOMIC_WIDTH INT64_WIDTH 204 #define SIZE_WIDTH INT64_WIDTH 205 #else 206 #define PTRDIFF_WIDTH INT32_WIDTH 207 #define SIG_ATOMIC_WIDTH INT32_WIDTH 208 #define SIZE_WIDTH INT32_WIDTH 209 #endif 210 #define WCHAR_WIDTH INT32_WIDTH 211 #define WINT_WIDTH INT32_WIDTH 212 #endif /* __ISO_C_VISIBLE >= 2023 */ 213 214 #endif /* !_MACHINE__STDINT_H_ */ 215