]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/stdint.h
19ac69fb0f4cc70b58c01630269fecb2d2c3708e
2 * Copyright (c) 2000-2010 Apple Inc.
6 #ifndef _KERNEL_STDINT_H_
7 #define _KERNEL_STDINT_H_
10 /* For user-space code that may include this header */
11 #include_next <stdint.h>
14 #include <machine/types.h>
22 /* from ISO/IEC 988:1999 spec */
24 /* 7.18.1.1 Exact-width integer types */
25 /* int8_t is defined in <machine/types.h> */
26 /* int16_t is defined in <machine/types.h> */
27 /* int32_t is defined in <machine/types.h> */
28 /* int64_t is defined in <machine/types.h> */
29 typedef u_int8_t
uint8_t; /* u_int8_t is defined in <machine/types.h> */
30 typedef u_int16_t
uint16_t; /* u_int16_t is defined in <machine/types.h> */
31 typedef u_int32_t
uint32_t; /* u_int32_t is defined in <machine/types.h> */
32 typedef u_int64_t
uint64_t; /* u_int64_t is defined in <machine/types.h> */
35 /* 7.18.1.2 Minimum-width integer types */
36 typedef int8_t int_least8_t;
37 typedef int16_t int_least16_t;
38 typedef int32_t int_least32_t;
39 typedef int64_t int_least64_t;
40 typedef uint8_t uint_least8_t;
41 typedef uint16_t uint_least16_t;
42 typedef uint32_t uint_least32_t;
43 typedef uint64_t uint_least64_t;
46 /* 7.18.1.3 Fastest-width integer types */
47 typedef int8_t int_fast8_t;
48 typedef int16_t int_fast16_t;
49 typedef int32_t int_fast32_t;
50 typedef int64_t int_fast64_t;
51 typedef uint8_t uint_fast8_t;
52 typedef uint16_t uint_fast16_t;
53 typedef uint32_t uint_fast32_t;
54 typedef uint64_t uint_fast64_t;
57 /* 7.18.1.4 Integer types capable of holding object pointers */
58 /* intptr_t is defined in <machine/types.h> */
59 /* uintptr_t is defined in <machine/types.h> */
62 /* 7.18.1.5 Greatest-width integer types */
63 #ifdef __INTMAX_TYPE__
64 typedef __INTMAX_TYPE__
intmax_t;
67 typedef long int intmax_t;
69 typedef long long int intmax_t;
71 #endif /* __INTMAX_TYPE__ */
72 #ifdef __UINTMAX_TYPE__
73 typedef __UINTMAX_TYPE__
uintmax_t;
76 typedef long unsigned int uintmax_t;
78 typedef long long unsigned int uintmax_t;
80 #endif /* __UINTMAX_TYPE__ */
82 /* 7.18.4 Macros for integer constants */
84 #define INT16_C(v) (v)
85 #define INT32_C(v) (v)
86 #define INT64_C(v) (v ## LL)
88 #define UINT8_C(v) (v)
89 #define UINT16_C(v) (v)
90 #define UINT32_C(v) (v ## U)
91 #define UINT64_C(v) (v ## ULL)
94 #define INTMAX_C(v) (v ## L)
95 #define UINTMAX_C(v) (v ## UL)
97 #define INTMAX_C(v) (v ## LL)
98 #define UINTMAX_C(v) (v ## ULL)
101 /* 7.18.2 Limits of specified-width integer types:
102 * These #defines specify the minimum and maximum limits
103 * of each of the types declared above.
105 * They must have "the same type as would an expression that is an
106 * object of the corresponding type converted according to the integer
111 /* 7.18.2.1 Limits of exact-width integer types */
113 #define INT16_MAX 32767
114 #define INT32_MAX 2147483647
115 #define INT64_MAX 9223372036854775807LL
117 #define INT8_MIN -128
118 #define INT16_MIN -32768
120 Note: the literal "most negative int" cannot be written in C --
121 the rules in the standard (section 6.4.4.1 in C99) will give it
122 an unsigned type, so INT32_MIN (and the most negative member of
123 any larger signed type) must be written via a constant expression.
125 #define INT32_MIN (-INT32_MAX-1)
126 #define INT64_MIN (-INT64_MAX-1)
128 #define UINT8_MAX 255
129 #define UINT16_MAX 65535
130 #define UINT32_MAX 4294967295U
131 #define UINT64_MAX 18446744073709551615ULL
133 /* 7.18.2.2 Limits of minimum-width integer types */
134 #define INT_LEAST8_MIN INT8_MIN
135 #define INT_LEAST16_MIN INT16_MIN
136 #define INT_LEAST32_MIN INT32_MIN
137 #define INT_LEAST64_MIN INT64_MIN
139 #define INT_LEAST8_MAX INT8_MAX
140 #define INT_LEAST16_MAX INT16_MAX
141 #define INT_LEAST32_MAX INT32_MAX
142 #define INT_LEAST64_MAX INT64_MAX
144 #define UINT_LEAST8_MAX UINT8_MAX
145 #define UINT_LEAST16_MAX UINT16_MAX
146 #define UINT_LEAST32_MAX UINT32_MAX
147 #define UINT_LEAST64_MAX UINT64_MAX
149 /* 7.18.2.3 Limits of fastest minimum-width integer types */
150 #define INT_FAST8_MIN INT8_MIN
151 #define INT_FAST16_MIN INT16_MIN
152 #define INT_FAST32_MIN INT32_MIN
153 #define INT_FAST64_MIN INT64_MIN
155 #define INT_FAST8_MAX INT8_MAX
156 #define INT_FAST16_MAX INT16_MAX
157 #define INT_FAST32_MAX INT32_MAX
158 #define INT_FAST64_MAX INT64_MAX
160 #define UINT_FAST8_MAX UINT8_MAX
161 #define UINT_FAST16_MAX UINT16_MAX
162 #define UINT_FAST32_MAX UINT32_MAX
163 #define UINT_FAST64_MAX UINT64_MAX
165 /* 7.18.2.4 Limits of integer types capable of holding object pointers */
168 #define INTPTR_MAX 9223372036854775807L
170 #define INTPTR_MAX 2147483647L
172 #define INTPTR_MIN (-INTPTR_MAX-1)
175 #define UINTPTR_MAX 18446744073709551615UL
177 #define UINTPTR_MAX 4294967295UL
180 /* 7.18.2.5 Limits of greatest-width integer types */
181 #define INTMAX_MAX INTMAX_C(9223372036854775807)
182 #define UINTMAX_MAX UINTMAX_C(18446744073709551615)
183 #define INTMAX_MIN (-INTMAX_MAX-1)
187 #define PTRDIFF_MIN INTMAX_MIN
188 #define PTRDIFF_MAX INTMAX_MAX
190 #define PTRDIFF_MIN INT32_MIN
191 #define PTRDIFF_MAX INT32_MAX
194 #define SIZE_MAX UINTPTR_MAX
196 #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
197 #define RSIZE_MAX (SIZE_MAX >> 1)
201 # ifdef __WCHAR_MAX__
202 # define WCHAR_MAX __WCHAR_MAX__
204 # define WCHAR_MAX 0x7fffffff
208 /* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
209 (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
210 it turns out that -fshort-wchar changes the signedness of
213 # if WCHAR_MAX == 0xffff
216 # define WCHAR_MIN (-WCHAR_MAX-1)
220 #define WINT_MIN INT32_MIN
221 #define WINT_MAX INT32_MAX
223 #define SIG_ATOMIC_MIN INT32_MIN
224 #define SIG_ATOMIC_MAX INT32_MAX
228 #endif /* _KERNEL_STDINT_H_ */