1*d8b80295SApple OSS Distributions /* 2*d8b80295SApple OSS Distributions * Copyright (c) 2000-2010 Apple Inc. 3*d8b80295SApple OSS Distributions * All rights reserved. 4*d8b80295SApple OSS Distributions */ 5*d8b80295SApple OSS Distributions #if (defined(__has_include) && __has_include(<__xnu_libcxx_sentinel.h>) && !defined(XNU_LIBCXX_SDKROOT)) 6*d8b80295SApple OSS Distributions 7*d8b80295SApple OSS Distributions #if !__has_include_next(<stdint.h>) 8*d8b80295SApple OSS Distributions #error Do not build with -nostdinc (use GCC_USE_STANDARD_INCLUDE_SEARCHING=NO) 9*d8b80295SApple OSS Distributions #endif /* __has_include_next */ 10*d8b80295SApple OSS Distributions 11*d8b80295SApple OSS Distributions #include_next <stdint.h> 12*d8b80295SApple OSS Distributions 13*d8b80295SApple OSS Distributions #else /* (defined(__has_include) && __has_include(<__xnu_libcxx_sentinel.h>) && !defined(XNU_LIBCXX_SDKROOT)) */ 14*d8b80295SApple OSS Distributions 15*d8b80295SApple OSS Distributions #ifndef _KERNEL_STDINT_H_ 16*d8b80295SApple OSS Distributions #define _KERNEL_STDINT_H_ 17*d8b80295SApple OSS Distributions 18*d8b80295SApple OSS Distributions #ifndef KERNEL 19*d8b80295SApple OSS Distributions /* For user-space code that may include this header */ 20*d8b80295SApple OSS Distributions #include_next <stdint.h> 21*d8b80295SApple OSS Distributions #else /* KERNEL */ 22*d8b80295SApple OSS Distributions 23*d8b80295SApple OSS Distributions #include <machine/types.h> 24*d8b80295SApple OSS Distributions 25*d8b80295SApple OSS Distributions #if __LP64__ 26*d8b80295SApple OSS Distributions #define __WORDSIZE 64 27*d8b80295SApple OSS Distributions #else 28*d8b80295SApple OSS Distributions #define __WORDSIZE 32 29*d8b80295SApple OSS Distributions #endif 30*d8b80295SApple OSS Distributions 31*d8b80295SApple OSS Distributions /* from ISO/IEC 988:1999 spec */ 32*d8b80295SApple OSS Distributions 33*d8b80295SApple OSS Distributions /* 7.18.1.1 Exact-width integer types */ 34*d8b80295SApple OSS Distributions /* int8_t is defined in <machine/types.h> */ 35*d8b80295SApple OSS Distributions /* int16_t is defined in <machine/types.h> */ 36*d8b80295SApple OSS Distributions /* int32_t is defined in <machine/types.h> */ 37*d8b80295SApple OSS Distributions /* int64_t is defined in <machine/types.h> */ 38*d8b80295SApple OSS Distributions typedef u_int8_t uint8_t; /* u_int8_t is defined in <machine/types.h> */ 39*d8b80295SApple OSS Distributions typedef u_int16_t uint16_t; /* u_int16_t is defined in <machine/types.h> */ 40*d8b80295SApple OSS Distributions typedef u_int32_t uint32_t; /* u_int32_t is defined in <machine/types.h> */ 41*d8b80295SApple OSS Distributions typedef u_int64_t uint64_t; /* u_int64_t is defined in <machine/types.h> */ 42*d8b80295SApple OSS Distributions 43*d8b80295SApple OSS Distributions 44*d8b80295SApple OSS Distributions /* 7.18.1.2 Minimum-width integer types */ 45*d8b80295SApple OSS Distributions typedef int8_t int_least8_t; 46*d8b80295SApple OSS Distributions typedef int16_t int_least16_t; 47*d8b80295SApple OSS Distributions typedef int32_t int_least32_t; 48*d8b80295SApple OSS Distributions typedef int64_t int_least64_t; 49*d8b80295SApple OSS Distributions typedef uint8_t uint_least8_t; 50*d8b80295SApple OSS Distributions typedef uint16_t uint_least16_t; 51*d8b80295SApple OSS Distributions typedef uint32_t uint_least32_t; 52*d8b80295SApple OSS Distributions typedef uint64_t uint_least64_t; 53*d8b80295SApple OSS Distributions 54*d8b80295SApple OSS Distributions 55*d8b80295SApple OSS Distributions /* 7.18.1.3 Fastest-width integer types */ 56*d8b80295SApple OSS Distributions typedef int8_t int_fast8_t; 57*d8b80295SApple OSS Distributions typedef int16_t int_fast16_t; 58*d8b80295SApple OSS Distributions typedef int32_t int_fast32_t; 59*d8b80295SApple OSS Distributions typedef int64_t int_fast64_t; 60*d8b80295SApple OSS Distributions typedef uint8_t uint_fast8_t; 61*d8b80295SApple OSS Distributions typedef uint16_t uint_fast16_t; 62*d8b80295SApple OSS Distributions typedef uint32_t uint_fast32_t; 63*d8b80295SApple OSS Distributions typedef uint64_t uint_fast64_t; 64*d8b80295SApple OSS Distributions 65*d8b80295SApple OSS Distributions 66*d8b80295SApple OSS Distributions /* 7.18.1.4 Integer types capable of holding object pointers */ 67*d8b80295SApple OSS Distributions /* intptr_t is defined in <machine/types.h> */ 68*d8b80295SApple OSS Distributions /* uintptr_t is defined in <machine/types.h> */ 69*d8b80295SApple OSS Distributions 70*d8b80295SApple OSS Distributions 71*d8b80295SApple OSS Distributions /* 7.18.1.5 Greatest-width integer types */ 72*d8b80295SApple OSS Distributions #ifdef __INTMAX_TYPE__ 73*d8b80295SApple OSS Distributions typedef __INTMAX_TYPE__ intmax_t; 74*d8b80295SApple OSS Distributions #else 75*d8b80295SApple OSS Distributions #ifdef __LP64__ 76*d8b80295SApple OSS Distributions typedef long int intmax_t; 77*d8b80295SApple OSS Distributions #else 78*d8b80295SApple OSS Distributions typedef long long int intmax_t; 79*d8b80295SApple OSS Distributions #endif /* __LP64__ */ 80*d8b80295SApple OSS Distributions #endif /* __INTMAX_TYPE__ */ 81*d8b80295SApple OSS Distributions #ifdef __UINTMAX_TYPE__ 82*d8b80295SApple OSS Distributions typedef __UINTMAX_TYPE__ uintmax_t; 83*d8b80295SApple OSS Distributions #else 84*d8b80295SApple OSS Distributions #ifdef __LP64__ 85*d8b80295SApple OSS Distributions typedef long unsigned int uintmax_t; 86*d8b80295SApple OSS Distributions #else 87*d8b80295SApple OSS Distributions typedef long long unsigned int uintmax_t; 88*d8b80295SApple OSS Distributions #endif /* __LP64__ */ 89*d8b80295SApple OSS Distributions #endif /* __UINTMAX_TYPE__ */ 90*d8b80295SApple OSS Distributions 91*d8b80295SApple OSS Distributions /* 7.18.4 Macros for integer constants */ 92*d8b80295SApple OSS Distributions #define INT8_C(v) (v) 93*d8b80295SApple OSS Distributions #define INT16_C(v) (v) 94*d8b80295SApple OSS Distributions #define INT32_C(v) (v) 95*d8b80295SApple OSS Distributions #define INT64_C(v) (v ## LL) 96*d8b80295SApple OSS Distributions 97*d8b80295SApple OSS Distributions #define UINT8_C(v) (v) 98*d8b80295SApple OSS Distributions #define UINT16_C(v) (v) 99*d8b80295SApple OSS Distributions #define UINT32_C(v) (v ## U) 100*d8b80295SApple OSS Distributions #define UINT64_C(v) (v ## ULL) 101*d8b80295SApple OSS Distributions 102*d8b80295SApple OSS Distributions #ifdef __LP64__ 103*d8b80295SApple OSS Distributions #define INTMAX_C(v) (v ## L) 104*d8b80295SApple OSS Distributions #define UINTMAX_C(v) (v ## UL) 105*d8b80295SApple OSS Distributions #else 106*d8b80295SApple OSS Distributions #define INTMAX_C(v) (v ## LL) 107*d8b80295SApple OSS Distributions #define UINTMAX_C(v) (v ## ULL) 108*d8b80295SApple OSS Distributions #endif 109*d8b80295SApple OSS Distributions 110*d8b80295SApple OSS Distributions /* 7.18.2 Limits of specified-width integer types: 111*d8b80295SApple OSS Distributions * These #defines specify the minimum and maximum limits 112*d8b80295SApple OSS Distributions * of each of the types declared above. 113*d8b80295SApple OSS Distributions * 114*d8b80295SApple OSS Distributions * They must have "the same type as would an expression that is an 115*d8b80295SApple OSS Distributions * object of the corresponding type converted according to the integer 116*d8b80295SApple OSS Distributions * promotion". 117*d8b80295SApple OSS Distributions */ 118*d8b80295SApple OSS Distributions 119*d8b80295SApple OSS Distributions 120*d8b80295SApple OSS Distributions /* 7.18.2.1 Limits of exact-width integer types */ 121*d8b80295SApple OSS Distributions #define INT8_MAX 127 122*d8b80295SApple OSS Distributions #define INT16_MAX 32767 123*d8b80295SApple OSS Distributions #define INT32_MAX 2147483647 124*d8b80295SApple OSS Distributions #define INT64_MAX 9223372036854775807LL 125*d8b80295SApple OSS Distributions 126*d8b80295SApple OSS Distributions #define INT8_MIN -128 127*d8b80295SApple OSS Distributions #define INT16_MIN -32768 128*d8b80295SApple OSS Distributions /* 129*d8b80295SApple OSS Distributions * Note: the literal "most negative int" cannot be written in C -- 130*d8b80295SApple OSS Distributions * the rules in the standard (section 6.4.4.1 in C99) will give it 131*d8b80295SApple OSS Distributions * an unsigned type, so INT32_MIN (and the most negative member of 132*d8b80295SApple OSS Distributions * any larger signed type) must be written via a constant expression. 133*d8b80295SApple OSS Distributions */ 134*d8b80295SApple OSS Distributions #define INT32_MIN (-INT32_MAX-1) 135*d8b80295SApple OSS Distributions #define INT64_MIN (-INT64_MAX-1) 136*d8b80295SApple OSS Distributions 137*d8b80295SApple OSS Distributions #define UINT8_MAX 255 138*d8b80295SApple OSS Distributions #define UINT16_MAX 65535 139*d8b80295SApple OSS Distributions #define UINT32_MAX 4294967295U 140*d8b80295SApple OSS Distributions #define UINT64_MAX 18446744073709551615ULL 141*d8b80295SApple OSS Distributions 142*d8b80295SApple OSS Distributions /* 7.18.2.2 Limits of minimum-width integer types */ 143*d8b80295SApple OSS Distributions #define INT_LEAST8_MIN INT8_MIN 144*d8b80295SApple OSS Distributions #define INT_LEAST16_MIN INT16_MIN 145*d8b80295SApple OSS Distributions #define INT_LEAST32_MIN INT32_MIN 146*d8b80295SApple OSS Distributions #define INT_LEAST64_MIN INT64_MIN 147*d8b80295SApple OSS Distributions 148*d8b80295SApple OSS Distributions #define INT_LEAST8_MAX INT8_MAX 149*d8b80295SApple OSS Distributions #define INT_LEAST16_MAX INT16_MAX 150*d8b80295SApple OSS Distributions #define INT_LEAST32_MAX INT32_MAX 151*d8b80295SApple OSS Distributions #define INT_LEAST64_MAX INT64_MAX 152*d8b80295SApple OSS Distributions 153*d8b80295SApple OSS Distributions #define UINT_LEAST8_MAX UINT8_MAX 154*d8b80295SApple OSS Distributions #define UINT_LEAST16_MAX UINT16_MAX 155*d8b80295SApple OSS Distributions #define UINT_LEAST32_MAX UINT32_MAX 156*d8b80295SApple OSS Distributions #define UINT_LEAST64_MAX UINT64_MAX 157*d8b80295SApple OSS Distributions 158*d8b80295SApple OSS Distributions /* 7.18.2.3 Limits of fastest minimum-width integer types */ 159*d8b80295SApple OSS Distributions #define INT_FAST8_MIN INT8_MIN 160*d8b80295SApple OSS Distributions #define INT_FAST16_MIN INT16_MIN 161*d8b80295SApple OSS Distributions #define INT_FAST32_MIN INT32_MIN 162*d8b80295SApple OSS Distributions #define INT_FAST64_MIN INT64_MIN 163*d8b80295SApple OSS Distributions 164*d8b80295SApple OSS Distributions #define INT_FAST8_MAX INT8_MAX 165*d8b80295SApple OSS Distributions #define INT_FAST16_MAX INT16_MAX 166*d8b80295SApple OSS Distributions #define INT_FAST32_MAX INT32_MAX 167*d8b80295SApple OSS Distributions #define INT_FAST64_MAX INT64_MAX 168*d8b80295SApple OSS Distributions 169*d8b80295SApple OSS Distributions #define UINT_FAST8_MAX UINT8_MAX 170*d8b80295SApple OSS Distributions #define UINT_FAST16_MAX UINT16_MAX 171*d8b80295SApple OSS Distributions #define UINT_FAST32_MAX UINT32_MAX 172*d8b80295SApple OSS Distributions #define UINT_FAST64_MAX UINT64_MAX 173*d8b80295SApple OSS Distributions 174*d8b80295SApple OSS Distributions /* 7.18.2.4 Limits of integer types capable of holding object pointers */ 175*d8b80295SApple OSS Distributions 176*d8b80295SApple OSS Distributions #if __WORDSIZE == 64 177*d8b80295SApple OSS Distributions #define INTPTR_MAX 9223372036854775807L 178*d8b80295SApple OSS Distributions #else 179*d8b80295SApple OSS Distributions #define INTPTR_MAX 2147483647L 180*d8b80295SApple OSS Distributions #endif 181*d8b80295SApple OSS Distributions #define INTPTR_MIN (-INTPTR_MAX-1) 182*d8b80295SApple OSS Distributions 183*d8b80295SApple OSS Distributions #if __WORDSIZE == 64 184*d8b80295SApple OSS Distributions #define UINTPTR_MAX 18446744073709551615UL 185*d8b80295SApple OSS Distributions #else 186*d8b80295SApple OSS Distributions #define UINTPTR_MAX 4294967295UL 187*d8b80295SApple OSS Distributions #endif 188*d8b80295SApple OSS Distributions 189*d8b80295SApple OSS Distributions /* 7.18.2.5 Limits of greatest-width integer types */ 190*d8b80295SApple OSS Distributions #define INTMAX_MAX INTMAX_C(9223372036854775807) 191*d8b80295SApple OSS Distributions #define UINTMAX_MAX UINTMAX_C(18446744073709551615) 192*d8b80295SApple OSS Distributions #define INTMAX_MIN (-INTMAX_MAX-1) 193*d8b80295SApple OSS Distributions 194*d8b80295SApple OSS Distributions /* 7.18.3 "Other" */ 195*d8b80295SApple OSS Distributions #if __WORDSIZE == 64 196*d8b80295SApple OSS Distributions #define PTRDIFF_MIN INTMAX_MIN 197*d8b80295SApple OSS Distributions #define PTRDIFF_MAX INTMAX_MAX 198*d8b80295SApple OSS Distributions #else 199*d8b80295SApple OSS Distributions #define PTRDIFF_MIN INT32_MIN 200*d8b80295SApple OSS Distributions #define PTRDIFF_MAX INT32_MAX 201*d8b80295SApple OSS Distributions #endif 202*d8b80295SApple OSS Distributions 203*d8b80295SApple OSS Distributions #define SIZE_MAX UINTPTR_MAX 204*d8b80295SApple OSS Distributions 205*d8b80295SApple OSS Distributions #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 206*d8b80295SApple OSS Distributions #define RSIZE_MAX (SIZE_MAX >> 1) 207*d8b80295SApple OSS Distributions #endif 208*d8b80295SApple OSS Distributions 209*d8b80295SApple OSS Distributions #ifndef WCHAR_MAX 210*d8b80295SApple OSS Distributions # ifdef __WCHAR_MAX__ 211*d8b80295SApple OSS Distributions # define WCHAR_MAX __WCHAR_MAX__ 212*d8b80295SApple OSS Distributions # else 213*d8b80295SApple OSS Distributions # define WCHAR_MAX 0x7fffffff 214*d8b80295SApple OSS Distributions # endif 215*d8b80295SApple OSS Distributions #endif 216*d8b80295SApple OSS Distributions 217*d8b80295SApple OSS Distributions /* WCHAR_MIN should be 0 if wchar_t is an unsigned type and 218*d8b80295SApple OSS Distributions * (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately, 219*d8b80295SApple OSS Distributions * it turns out that -fshort-wchar changes the signedness of 220*d8b80295SApple OSS Distributions * the type. */ 221*d8b80295SApple OSS Distributions #ifndef WCHAR_MIN 222*d8b80295SApple OSS Distributions # if WCHAR_MAX == 0xffff 223*d8b80295SApple OSS Distributions # define WCHAR_MIN 0 224*d8b80295SApple OSS Distributions # else 225*d8b80295SApple OSS Distributions # define WCHAR_MIN (-WCHAR_MAX-1) 226*d8b80295SApple OSS Distributions # endif 227*d8b80295SApple OSS Distributions #endif 228*d8b80295SApple OSS Distributions 229*d8b80295SApple OSS Distributions #define WINT_MIN INT32_MIN 230*d8b80295SApple OSS Distributions #define WINT_MAX INT32_MAX 231*d8b80295SApple OSS Distributions 232*d8b80295SApple OSS Distributions #define SIG_ATOMIC_MIN INT32_MIN 233*d8b80295SApple OSS Distributions #define SIG_ATOMIC_MAX INT32_MAX 234*d8b80295SApple OSS Distributions 235*d8b80295SApple OSS Distributions #endif /* KERNEL */ 236*d8b80295SApple OSS Distributions 237*d8b80295SApple OSS Distributions #endif /* _KERNEL_STDINT_H_ */ 238*d8b80295SApple OSS Distributions 239*d8b80295SApple OSS Distributions #endif 240