2 * Copyright (c) 2000, 2001, 2003, 2004 Apple Computer, Inc.
9 /* from ISO/IEC 988:1999 spec */
11 /* 7.18.1.1 Exact-width integer types */
14 typedef signed char int8_t;
19 typedef short int16_t;
29 typedef long long int64_t;
34 typedef unsigned char uint8_t;
39 typedef unsigned short uint16_t;
40 #endif /* _UINT16_T */
44 typedef unsigned int uint32_t;
45 #endif /* _UINT32_T */
49 typedef unsigned long long uint64_t;
50 #endif /* _UINT64_T */
52 /* 7.18.1.2 Minimum-width integer types */
53 typedef int8_t int_least8_t;
54 typedef int16_t int_least16_t;
55 typedef int32_t int_least32_t;
56 typedef int64_t int_least64_t;
57 typedef uint8_t uint_least8_t;
58 typedef uint16_t uint_least16_t;
59 typedef uint32_t uint_least32_t;
60 typedef uint64_t uint_least64_t;
63 /* 7.18.1.3 Fastest-width integer types */
64 typedef int8_t int_fast8_t;
65 typedef int16_t int_fast16_t;
66 typedef int32_t int_fast32_t;
67 typedef int64_t int_fast64_t;
68 typedef uint8_t uint_fast8_t;
69 typedef uint16_t uint_fast16_t;
70 typedef uint32_t uint_fast32_t;
71 typedef uint64_t uint_fast64_t;
74 /* 7.18.1.4 Integer types capable of holding object pointers */
78 typedef long intptr_t;
79 #endif /* _INTPTR_T */
83 typedef unsigned long uintptr_t;
84 #endif /* _UINTPTR_T */
87 /* 7.18.1.5 Greatest-width integer types */
90 #ifdef __INTMAX_TYPE__
91 typedef __INTMAX_TYPE__ intmax_t;
92 #else /* __INTMAX_TYPE__ */
93 typedef long long intmax_t;
94 #endif /* __INTMAX_TYPE__ */
95 #endif /* _INTMAX_T */
99 #ifdef __UINTMAX_TYPE__
100 typedef __UINTMAX_TYPE__ uintmax_t;
101 #else /* __UINTMAX_TYPE__ */
102 typedef unsigned long long uintmax_t;
103 #endif /* __UINTMAX_TYPE__ */
104 #endif /* _UINTMAX_T */
106 /* "C++ implementations should define these macros only when
107 * __STDC_LIMIT_MACROS is defined before <stdint.h> is included."
108 * In other words, if C++, then __STDC_LIMIT_MACROS enables the
109 * macros below. (Note that there also exists a different enabling
110 * macro (__STDC_CONSTANT_MACROS) for the last few, below.)
112 #if (! defined(__cplusplus)) || defined(__STDC_LIMIT_MACROS)
115 /* 7.18.2 Limits of specified-width integer types:
116 * These #defines specify the minimum and maximum limits
117 * of each of the types declared above.
121 /* 7.18.2.1 Limits of exact-width integer types */
123 #define INT16_MAX 32767
124 #define INT32_MAX 2147483647
125 #define INT64_MAX 9223372036854775807LL
127 #define INT8_MIN -128
128 #define INT16_MIN -32768
130 Note: the literal "most negative int" cannot be written in C --
131 the rules in the standard (section 6.4.4.1 in C99) will give it
132 an unsigned type, so INT32_MIN (and the most negative member of
133 any larger signed type) must be written via a constant expression.
135 #define INT32_MIN (-INT32_MAX-1)
136 #define INT64_MIN (-INT64_MAX-1)
138 #define UINT8_MAX 255
139 #define UINT16_MAX 65535
140 #define UINT32_MAX 4294967295U
141 #define UINT64_MAX 18446744073709551615ULL
143 /* 7.18.2.2 Limits of minimum-width integer types */
144 #define INT_LEAST8_MIN INT8_MIN
145 #define INT_LEAST16_MIN INT16_MIN
146 #define INT_LEAST32_MIN INT32_MIN
147 #define INT_LEAST64_MIN INT64_MIN
149 #define INT_LEAST8_MAX INT8_MAX
150 #define INT_LEAST16_MAX INT16_MAX
151 #define INT_LEAST32_MAX INT32_MAX
152 #define INT_LEAST64_MAX INT64_MAX
154 #define UINT_LEAST8_MAX UINT8_MAX
155 #define UINT_LEAST16_MAX UINT16_MAX
156 #define UINT_LEAST32_MAX UINT32_MAX
157 #define UINT_LEAST64_MAX UINT64_MAX
159 /* 7.18.2.3 Limits of fastest minimum-width integer types */
160 #define INT_FAST8_MIN INT8_MIN
161 #define INT_FAST16_MIN INT16_MIN
162 #define INT_FAST32_MIN INT32_MIN
163 #define INT_FAST64_MIN INT64_MIN
165 #define INT_FAST8_MAX INT8_MAX
166 #define INT_FAST16_MAX INT16_MAX
167 #define INT_FAST32_MAX INT32_MAX
168 #define INT_FAST64_MAX INT64_MAX
170 #define UINT_FAST8_MAX UINT8_MAX
171 #define UINT_FAST16_MAX UINT16_MAX
172 #define UINT_FAST32_MAX UINT32_MAX
173 #define UINT_FAST64_MAX UINT64_MAX
175 /* 7.18.2.4 Limits of integer types capable of holding object pointers */
177 #define INTPTR_MIN INT32_MIN
178 #define INTPTR_MAX INT32_MAX
180 #define UINTPTR_MAX UINT32_MAX
182 /* 7.18.2.5 Limits of greatest-width integer types */
183 #define INTMAX_MIN INT64_MIN
184 #define INTMAX_MAX INT64_MAX
186 #define UINTMAX_MAX UINT64_MAX
189 #define PTRDIFF_MIN INT32_MIN
190 #define PTRDIFF_MAX INT32_MAX
192 /* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}.
193 Should end up being {-127,127} or {0,255} ... or bigger.
194 My bet would be on one of {U}INT32_{MIN,MAX}. */
196 #define SIZE_MAX UINT32_MAX
199 # ifdef __WCHAR_MAX__
200 # define WCHAR_MAX __WCHAR_MAX__
202 # define WCHAR_MAX 0x7fffffff
206 /* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
207 (-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
208 it turns out that -fshort-wchar changes the signedness of
211 # if WCHAR_MAX == 0xffff
214 # define WCHAR_MIN (-WCHAR_MAX-1)
218 #define WINT_MIN INT32_MIN
219 #define WINT_MAX INT32_MAX
221 #define SIG_ATOMIC_MIN INT32_MIN
222 #define SIG_ATOMIC_MAX INT32_MAX
224 #endif /* if C++, then __STDC_LIMIT_MACROS enables the above macros */
226 /* "C++ implementations should define these macros only when
227 * __STDC_CONSTANT_MACROS is defined before <stdint.h> is included."
229 #if (! defined(__cplusplus)) || defined(__STDC_CONSTANT_MACROS)
231 /* 7.18.4 Macros for integer constants */
232 #define INT8_C(v) (v)
233 #define INT16_C(v) (v)
234 #define INT32_C(v) (v)
235 #define INT64_C(v) (v ## LL)
237 #define UINT8_C(v) (v ## U)
238 #define UINT16_C(v) (v ## U)
239 #define UINT32_C(v) (v ## U)
240 #define UINT64_C(v) (v ## ULL)
242 #define INTMAX_C(v) (v ## LL)
243 #define UINTMAX_C(v) (v ## ULL)
245 #endif /* if C++, then __STDC_CONSTANT_MACROS enables the above macros */
247 #endif /* _STDINT_H_ */