]>
git.saurik.com Git - apple/libc.git/blob - include/stdint.h
a9e312d3b6d3e4a5f72a60a2bf102bd8cc1b32fe
2 * Copyright (c) 2000-2010 Apple Inc.
15 /* from ISO/IEC 988:1999 spec */
17 /* 7.18.1.1 Exact-width integer types */
20 typedef signed char int8_t;
25 typedef short int16_t;
35 typedef long long int64_t;
40 typedef unsigned char uint8_t;
45 typedef unsigned short uint16_t;
46 #endif /* _UINT16_T */
50 typedef unsigned int uint32_t;
51 #endif /* _UINT32_T */
55 typedef unsigned long long uint64_t;
56 #endif /* _UINT64_T */
58 /* 7.18.1.2 Minimum-width integer types */
59 typedef int8_t int_least8_t;
60 typedef int16_t int_least16_t;
61 typedef int32_t int_least32_t;
62 typedef int64_t int_least64_t;
63 typedef uint8_t uint_least8_t;
64 typedef uint16_t uint_least16_t;
65 typedef uint32_t uint_least32_t;
66 typedef uint64_t uint_least64_t;
69 /* 7.18.1.3 Fastest-width integer types */
70 typedef int8_t int_fast8_t;
71 typedef int16_t int_fast16_t;
72 typedef int32_t int_fast32_t;
73 typedef int64_t int_fast64_t;
74 typedef uint8_t uint_fast8_t;
75 typedef uint16_t uint_fast16_t;
76 typedef uint32_t uint_fast32_t;
77 typedef uint64_t uint_fast64_t;
80 /* 7.18.1.4 Integer types capable of holding object pointers */
84 typedef long intptr_t;
85 #endif /* _INTPTR_T */
89 typedef unsigned long uintptr_t;
90 #endif /* _UINTPTR_T */
93 /* 7.18.1.5 Greatest-width integer types */
96 #ifdef __INTMAX_TYPE__
97 typedef __INTMAX_TYPE__
intmax_t;
98 #else /* __INTMAX_TYPE__ */
99 typedef long long intmax_t;
100 #endif /* __INTMAX_TYPE__ */
101 #endif /* _INTMAX_T */
105 #ifdef __UINTMAX_TYPE__
106 typedef __UINTMAX_TYPE__
uintmax_t;
107 #else /* __UINTMAX_TYPE__ */
108 typedef unsigned long long uintmax_t;
109 #endif /* __UINTMAX_TYPE__ */
110 #endif /* _UINTMAX_T */
112 /* 7.18.2 Limits of specified-width integer types:
113 * These #defines specify the minimum and maximum limits
114 * of each of the types declared above.
118 /* 7.18.2.1 Limits of exact-width integer types */
120 #define INT16_MAX 32767
121 #define INT32_MAX 2147483647
122 #define INT64_MAX 9223372036854775807LL
124 #define INT8_MIN -128
125 #define INT16_MIN -32768
127 Note: the literal "most negative int" cannot be written in C --
128 the rules in the standard (section 6.4.4.1 in C99) will give it
129 an unsigned type, so INT32_MIN (and the most negative member of
130 any larger signed type) must be written via a constant expression.
132 #define INT32_MIN (-INT32_MAX-1)
133 #define INT64_MIN (-INT64_MAX-1)
135 #define UINT8_MAX 255
136 #define UINT16_MAX 65535
137 #define UINT32_MAX 4294967295U
138 #define UINT64_MAX 18446744073709551615ULL
140 /* 7.18.2.2 Limits of minimum-width integer types */
141 #define INT_LEAST8_MIN INT8_MIN
142 #define INT_LEAST16_MIN INT16_MIN
143 #define INT_LEAST32_MIN INT32_MIN
144 #define INT_LEAST64_MIN INT64_MIN
146 #define INT_LEAST8_MAX INT8_MAX
147 #define INT_LEAST16_MAX INT16_MAX
148 #define INT_LEAST32_MAX INT32_MAX
149 #define INT_LEAST64_MAX INT64_MAX
151 #define UINT_LEAST8_MAX UINT8_MAX
152 #define UINT_LEAST16_MAX UINT16_MAX
153 #define UINT_LEAST32_MAX UINT32_MAX
154 #define UINT_LEAST64_MAX UINT64_MAX
156 /* 7.18.2.3 Limits of fastest minimum-width integer types */
157 #define INT_FAST8_MIN INT8_MIN
158 #define INT_FAST16_MIN INT16_MIN
159 #define INT_FAST32_MIN INT32_MIN
160 #define INT_FAST64_MIN INT64_MIN
162 #define INT_FAST8_MAX INT8_MAX
163 #define INT_FAST16_MAX INT16_MAX
164 #define INT_FAST32_MAX INT32_MAX
165 #define INT_FAST64_MAX INT64_MAX
167 #define UINT_FAST8_MAX UINT8_MAX
168 #define UINT_FAST16_MAX UINT16_MAX
169 #define UINT_FAST32_MAX UINT32_MAX
170 #define UINT_FAST64_MAX UINT64_MAX
172 /* 7.18.2.4 Limits of integer types capable of holding object pointers */
175 #define INTPTR_MIN INT64_MIN
176 #define INTPTR_MAX INT64_MAX
178 #define INTPTR_MIN INT32_MIN
179 #define INTPTR_MAX INT32_MAX
183 #define UINTPTR_MAX UINT64_MAX
185 #define UINTPTR_MAX UINT32_MAX
188 /* 7.18.2.5 Limits of greatest-width integer types */
189 #define INTMAX_MIN INT64_MIN
190 #define INTMAX_MAX INT64_MAX
192 #define UINTMAX_MAX UINT64_MAX
196 #define PTRDIFF_MIN INT64_MIN
197 #define PTRDIFF_MAX INT64_MAX
199 #define PTRDIFF_MIN INT32_MIN
200 #define PTRDIFF_MAX INT32_MAX
203 /* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}.
204 Should end up being {-127,127} or {0,255} ... or bigger.
205 My bet would be on one of {U}INT32_{MIN,MAX}. */
208 #define SIZE_MAX UINT64_MAX
210 #define SIZE_MAX UINT32_MAX
214 # ifdef __WCHAR_MAX__
215 # define WCHAR_MAX __WCHAR_MAX__
217 # define WCHAR_MAX 0x7fffffff
221 /* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
222 (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
223 it turns out that -fshort-wchar changes the signedness of
226 # if WCHAR_MAX == 0xffff
229 # define WCHAR_MIN (-WCHAR_MAX-1)
233 #define WINT_MIN INT32_MIN
234 #define WINT_MAX INT32_MAX
236 #define SIG_ATOMIC_MIN INT32_MIN
237 #define SIG_ATOMIC_MAX INT32_MAX
239 /* 7.18.4 Macros for integer constants */
240 #define INT8_C(v) (v)
241 #define INT16_C(v) (v)
242 #define INT32_C(v) (v)
243 #define INT64_C(v) (v ## LL)
245 #define UINT8_C(v) (v ## U)
246 #define UINT16_C(v) (v ## U)
247 #define UINT32_C(v) (v ## U)
248 #define UINT64_C(v) (v ## ULL)
250 #define INTMAX_C(v) (v ## LL)
251 #define UINTMAX_C(v) (v ## ULL)
253 #endif /* _STDINT_H_ */