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