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 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) 44 45 #define INT8_C(c) (c) 46 #define INT16_C(c) (c) 47 #define INT32_C(c) (c) 48 49 #define UINT8_C(c) (c) 50 #define UINT16_C(c) (c) 51 #define UINT32_C(c) (c ## U) 52 53 #ifdef __LP64__ 54 #define INT64_C(c) (c ## L) 55 #define UINT64_C(c) (c ## UL) 56 #else 57 #define INT64_C(c) (c ## LL) 58 #define UINT64_C(c) (c ## ULL) 59 #endif 60 61 #define INTMAX_C(c) INT64_C(c) 62 #define UINTMAX_C(c) UINT64_C(c) 63 64 #endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ 65 66 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) 67 68 #ifndef __INT64_C 69 #ifdef __LP64__ 70 #define __INT64_C(c) (c ## L) 71 #define __UINT64_C(c) (c ## UL) 72 #else 73 #define __INT64_C(c) (c ## LL) 74 #define __UINT64_C(c) (c ## ULL) 75 #endif 76 #endif 77 78 /* 79 * ISO/IEC 9899:1999 80 * 7.18.2.1 Limits of exact-width integer types 81 */ 82 /* Minimum values of exact-width signed integer types. */ 83 #define INT8_MIN (-0x7f-1) 84 #define INT16_MIN (-0x7fff-1) 85 #define INT32_MIN (-0x7fffffff-1) 86 #define INT64_MIN (-__INT64_C(0x7fffffffffffffff)-1) 87 88 /* Maximum values of exact-width signed integer types. */ 89 #define INT8_MAX 0x7f 90 #define INT16_MAX 0x7fff 91 #define INT32_MAX 0x7fffffff 92 #define INT64_MAX __INT64_C(0x7fffffffffffffff) 93 94 /* Maximum values of exact-width unsigned integer types. */ 95 #define UINT8_MAX 0xff 96 #define UINT16_MAX 0xffff 97 #define UINT32_MAX 0xffffffff 98 #define UINT64_MAX __UINT64_C(0xffffffffffffffff) 99 100 /* 101 * ISO/IEC 9899:1999 102 * 7.18.2.2 Limits of minimum-width integer types 103 */ 104 /* Minimum values of minimum-width signed integer types. */ 105 #define INT_LEAST8_MIN INT8_MIN 106 #define INT_LEAST16_MIN INT16_MIN 107 #define INT_LEAST32_MIN INT32_MIN 108 #define INT_LEAST64_MIN INT64_MIN 109 110 /* Maximum values of minimum-width signed integer types. */ 111 #define INT_LEAST8_MAX INT8_MAX 112 #define INT_LEAST16_MAX INT16_MAX 113 #define INT_LEAST32_MAX INT32_MAX 114 #define INT_LEAST64_MAX INT64_MAX 115 116 /* Maximum values of minimum-width unsigned integer types. */ 117 #define UINT_LEAST8_MAX UINT8_MAX 118 #define UINT_LEAST16_MAX UINT16_MAX 119 #define UINT_LEAST32_MAX UINT32_MAX 120 #define UINT_LEAST64_MAX UINT64_MAX 121 122 /* 123 * ISO/IEC 9899:1999 124 * 7.18.2.3 Limits of fastest minimum-width integer types 125 */ 126 /* Minimum values of fastest minimum-width signed integer types. */ 127 #define INT_FAST8_MIN INT32_MIN 128 #define INT_FAST16_MIN INT32_MIN 129 #define INT_FAST32_MIN INT32_MIN 130 #define INT_FAST64_MIN INT64_MIN 131 132 /* Maximum values of fastest minimum-width signed integer types. */ 133 #define INT_FAST8_MAX INT32_MAX 134 #define INT_FAST16_MAX INT32_MAX 135 #define INT_FAST32_MAX INT32_MAX 136 #define INT_FAST64_MAX INT64_MAX 137 138 /* Maximum values of fastest minimum-width unsigned integer types. */ 139 #define UINT_FAST8_MAX UINT32_MAX 140 #define UINT_FAST16_MAX UINT32_MAX 141 #define UINT_FAST32_MAX UINT32_MAX 142 #define UINT_FAST64_MAX UINT64_MAX 143 144 /* 145 * ISO/IEC 9899:1999 146 * 7.18.2.4 Limits of integer types capable of holding object pointers 147 */ 148 #ifdef __LP64__ 149 #define INTPTR_MIN INT64_MIN 150 #define INTPTR_MAX INT64_MAX 151 #define UINTPTR_MAX UINT64_MAX 152 #else 153 #define INTPTR_MIN INT32_MIN 154 #define INTPTR_MAX INT32_MAX 155 #define UINTPTR_MAX UINT32_MAX 156 #endif 157 158 /* 159 * ISO/IEC 9899:1999 160 * 7.18.2.5 Limits of greatest-width integer types 161 */ 162 #define INTMAX_MIN INT64_MIN 163 #define INTMAX_MAX INT64_MAX 164 #define UINTMAX_MAX UINT64_MAX 165 166 /* 167 * ISO/IEC 9899:1999 168 * 7.18.3 Limits of other integer types 169 */ 170 #ifdef __LP64__ 171 /* Limits of ptrdiff_t. */ 172 #define PTRDIFF_MIN INT64_MIN 173 #define PTRDIFF_MAX INT64_MAX 174 175 /* Limits of sig_atomic_t. */ 176 #define SIG_ATOMIC_MIN INT64_MIN 177 #define SIG_ATOMIC_MAX INT64_MAX 178 179 /* Limit of size_t. */ 180 #define SIZE_MAX UINT64_MAX 181 #else 182 /* Limits of ptrdiff_t. */ 183 #define PTRDIFF_MIN INT32_MIN 184 #define PTRDIFF_MAX INT32_MAX 185 186 /* Limits of sig_atomic_t. */ 187 #define SIG_ATOMIC_MIN INT32_MIN 188 #define SIG_ATOMIC_MAX INT32_MAX 189 190 /* Limit of size_t. */ 191 #define SIZE_MAX UINT32_MAX 192 #endif 193 194 /* Limits of wint_t. */ 195 #define WINT_MIN INT32_MIN 196 #define WINT_MAX INT32_MAX 197 198 #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ 199 200 #endif /* !_MACHINE__STDINT_H_ */ 201