Rev 4930 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4930 | Rev 6099 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2004, 2005 by |
2 | * Copyright (c) 2004, 2005 by |
3 | * Ralf Corsepius, Ulm/Germany. All rights reserved. |
3 | * Ralf Corsepius, Ulm/Germany. All rights reserved. |
4 | * |
4 | * |
5 | * Permission to use, copy, modify, and distribute this software |
5 | * Permission to use, copy, modify, and distribute this software |
6 | * is freely granted, provided that this notice is preserved. |
6 | * is freely granted, provided that this notice is preserved. |
7 | */ |
7 | */ |
8 | 8 | ||
9 | #ifndef _STDINT_H |
9 | #ifndef _STDINT_H |
10 | #define _STDINT_H |
10 | #define _STDINT_H |
11 | 11 | ||
12 | #include |
12 | #include |
- | 13 | #include |
|
- | 14 | #include |
|
13 | 15 | ||
14 | #ifdef __cplusplus |
16 | #ifdef __cplusplus |
15 | extern "C" { |
17 | extern "C" { |
16 | #endif |
18 | #endif |
17 | - | ||
18 | #if __GNUC_PREREQ (3, 2) |
- | |
19 | /* gcc > 3.2 implicitly defines the values we are interested */ |
- | |
20 | #define __STDINT_EXP(x) __##x##__ |
- | |
21 | #else |
- | |
22 | #define __STDINT_EXP(x) x |
- | |
23 | #include |
- | |
24 | #endif |
- | |
25 | - | ||
26 | /* Check if "long long" is 64bit wide */ |
- | |
27 | /* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */ |
- | |
28 | #if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \ |
- | |
29 | || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) ) |
- | |
30 | #define __have_longlong64 1 |
- | |
31 | #endif |
- | |
32 | - | ||
33 | /* Check if "long" is 64bit or 32bit wide */ |
- | |
34 | #if __STDINT_EXP(LONG_MAX) > 0x7fffffff |
- | |
35 | #define __have_long64 1 |
- | |
36 | #elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__) |
- | |
37 | #define __have_long32 1 |
- | |
38 | #define __have_long64 0 |
- | |
39 | #endif |
- | |
40 | - | ||
41 | #ifdef ___int8_t_defined |
- | |
42 | typedef __int8_t int8_t ; |
- | |
43 | typedef __uint8_t uint8_t ; |
- | |
44 | #define __int8_t_defined 1 |
- | |
45 | #endif |
- | |
46 | 19 | ||
47 | #ifdef ___int_least8_t_defined |
20 | #ifdef ___int_least8_t_defined |
48 | typedef __int_least8_t int_least8_t; |
21 | typedef __int_least8_t int_least8_t; |
49 | typedef __uint_least8_t uint_least8_t; |
22 | typedef __uint_least8_t uint_least8_t; |
50 | #define __int_least8_t_defined 1 |
23 | #define __int_least8_t_defined 1 |
51 | #endif |
24 | #endif |
52 | - | ||
53 | #ifdef ___int16_t_defined |
- | |
54 | typedef __int16_t int16_t ; |
- | |
55 | typedef __uint16_t uint16_t ; |
- | |
56 | #define __int16_t_defined 1 |
- | |
57 | #endif |
- | |
58 | 25 | ||
59 | #ifdef ___int_least16_t_defined |
26 | #ifdef ___int_least16_t_defined |
60 | typedef __int_least16_t int_least16_t; |
27 | typedef __int_least16_t int_least16_t; |
61 | typedef __uint_least16_t uint_least16_t; |
28 | typedef __uint_least16_t uint_least16_t; |
62 | #define __int_least16_t_defined 1 |
29 | #define __int_least16_t_defined 1 |
63 | #endif |
30 | #endif |
64 | - | ||
65 | #ifdef ___int32_t_defined |
- | |
66 | typedef __int32_t int32_t ; |
- | |
67 | typedef __uint32_t uint32_t ; |
- | |
68 | #define __int32_t_defined 1 |
- | |
69 | #endif |
- | |
70 | 31 | ||
71 | #ifdef ___int_least32_t_defined |
32 | #ifdef ___int_least32_t_defined |
72 | typedef __int_least32_t int_least32_t; |
33 | typedef __int_least32_t int_least32_t; |
73 | typedef __uint_least32_t uint_least32_t; |
34 | typedef __uint_least32_t uint_least32_t; |
74 | #define __int_least32_t_defined 1 |
35 | #define __int_least32_t_defined 1 |
75 | #endif |
36 | #endif |
76 | - | ||
77 | #ifdef ___int64_t_defined |
- | |
78 | typedef __int64_t int64_t ; |
- | |
79 | typedef __uint64_t uint64_t ; |
- | |
80 | #define __int64_t_defined 1 |
- | |
81 | #endif |
- | |
82 | 37 | ||
83 | #ifdef ___int_least64_t_defined |
38 | #ifdef ___int_least64_t_defined |
84 | typedef __int_least64_t int_least64_t; |
39 | typedef __int_least64_t int_least64_t; |
85 | typedef __uint_least64_t uint_least64_t; |
40 | typedef __uint_least64_t uint_least64_t; |
86 | #define __int_least64_t_defined 1 |
41 | #define __int_least64_t_defined 1 |
87 | #endif |
42 | #endif |
88 | 43 | ||
89 | /* |
44 | /* |
90 | * Fastest minimum-width integer types |
45 | * Fastest minimum-width integer types |
91 | * |
46 | * |
92 | * Assume int to be the fastest type for all types with a width |
47 | * Assume int to be the fastest type for all types with a width |
93 | * less than __INT_MAX__ rsp. INT_MAX |
48 | * less than __INT_MAX__ rsp. INT_MAX |
94 | */ |
49 | */ |
95 | #ifdef __INT_FAST8_TYPE__ |
50 | #ifdef __INT_FAST8_TYPE__ |
96 | typedef __INT_FAST8_TYPE__ int_fast8_t; |
51 | typedef __INT_FAST8_TYPE__ int_fast8_t; |
97 | typedef __UINT_FAST8_TYPE__ uint_fast8_t; |
52 | typedef __UINT_FAST8_TYPE__ uint_fast8_t; |
98 | #define __int_fast8_t_defined 1 |
53 | #define __int_fast8_t_defined 1 |
99 | #elif __STDINT_EXP(INT_MAX) >= 0x7f |
54 | #elif __STDINT_EXP(INT_MAX) >= 0x7f |
100 | typedef signed int int_fast8_t; |
55 | typedef signed int int_fast8_t; |
101 | typedef unsigned int uint_fast8_t; |
56 | typedef unsigned int uint_fast8_t; |
102 | #define __int_fast8_t_defined 1 |
57 | #define __int_fast8_t_defined 1 |
103 | #endif |
58 | #endif |
104 | 59 | ||
105 | #ifdef __INT_FAST16_TYPE__ |
60 | #ifdef __INT_FAST16_TYPE__ |
106 | typedef __INT_FAST16_TYPE__ int_fast16_t; |
61 | typedef __INT_FAST16_TYPE__ int_fast16_t; |
107 | typedef __UINT_FAST16_TYPE__ uint_fast16_t; |
62 | typedef __UINT_FAST16_TYPE__ uint_fast16_t; |
108 | #define __int_fast16_t_defined 1 |
63 | #define __int_fast16_t_defined 1 |
109 | #elif __STDINT_EXP(INT_MAX) >= 0x7fff |
64 | #elif __STDINT_EXP(INT_MAX) >= 0x7fff |
110 | typedef signed int int_fast16_t; |
65 | typedef signed int int_fast16_t; |
111 | typedef unsigned int uint_fast16_t; |
66 | typedef unsigned int uint_fast16_t; |
112 | #define __int_fast16_t_defined 1 |
67 | #define __int_fast16_t_defined 1 |
113 | #endif |
68 | #endif |
114 | 69 | ||
115 | #ifdef __INT_FAST32_TYPE__ |
70 | #ifdef __INT_FAST32_TYPE__ |
116 | typedef __INT_FAST32_TYPE__ int_fast32_t; |
71 | typedef __INT_FAST32_TYPE__ int_fast32_t; |
117 | typedef __UINT_FAST32_TYPE__ uint_fast32_t; |
72 | typedef __UINT_FAST32_TYPE__ uint_fast32_t; |
118 | #define __int_fast32_t_defined 1 |
73 | #define __int_fast32_t_defined 1 |
119 | #elif __STDINT_EXP(INT_MAX) >= 0x7fffffff |
74 | #elif __STDINT_EXP(INT_MAX) >= 0x7fffffff |
120 | typedef signed int int_fast32_t; |
75 | typedef signed int int_fast32_t; |
121 | typedef unsigned int uint_fast32_t; |
76 | typedef unsigned int uint_fast32_t; |
122 | #define __int_fast32_t_defined 1 |
77 | #define __int_fast32_t_defined 1 |
123 | #endif |
78 | #endif |
124 | 79 | ||
125 | #ifdef __INT_FAST64_TYPE__ |
80 | #ifdef __INT_FAST64_TYPE__ |
126 | typedef __INT_FAST64_TYPE__ int_fast64_t; |
81 | typedef __INT_FAST64_TYPE__ int_fast64_t; |
127 | typedef __UINT_FAST64_TYPE__ uint_fast64_t; |
82 | typedef __UINT_FAST64_TYPE__ uint_fast64_t; |
128 | #define __int_fast64_t_defined 1 |
83 | #define __int_fast64_t_defined 1 |
129 | #elif __STDINT_EXP(INT_MAX) > 0x7fffffff |
84 | #elif __STDINT_EXP(INT_MAX) > 0x7fffffff |
130 | typedef signed int int_fast64_t; |
85 | typedef signed int int_fast64_t; |
131 | typedef unsigned int uint_fast64_t; |
86 | typedef unsigned int uint_fast64_t; |
132 | #define __int_fast64_t_defined 1 |
87 | #define __int_fast64_t_defined 1 |
133 | #endif |
88 | #endif |
134 | 89 | ||
135 | /* |
90 | /* |
136 | * Fall back to [u]int_least |
91 | * Fall back to [u]int_least |
137 | * not having been defined, yet. |
92 | * not having been defined, yet. |
138 | * Leave undefined, if [u]int_least |
93 | * Leave undefined, if [u]int_least |
139 | */ |
94 | */ |
140 | #if !__int_fast8_t_defined |
95 | #if !__int_fast8_t_defined |
141 | #if __int_least8_t_defined |
96 | #if __int_least8_t_defined |
142 | typedef int_least8_t int_fast8_t; |
97 | typedef int_least8_t int_fast8_t; |
143 | typedef uint_least8_t uint_fast8_t; |
98 | typedef uint_least8_t uint_fast8_t; |
144 | #define __int_fast8_t_defined 1 |
99 | #define __int_fast8_t_defined 1 |
145 | #endif |
100 | #endif |
146 | #endif |
101 | #endif |
147 | 102 | ||
148 | #if !__int_fast16_t_defined |
103 | #if !__int_fast16_t_defined |
149 | #if __int_least16_t_defined |
104 | #if __int_least16_t_defined |
150 | typedef int_least16_t int_fast16_t; |
105 | typedef int_least16_t int_fast16_t; |
151 | typedef uint_least16_t uint_fast16_t; |
106 | typedef uint_least16_t uint_fast16_t; |
152 | #define __int_fast16_t_defined 1 |
107 | #define __int_fast16_t_defined 1 |
153 | #endif |
108 | #endif |
154 | #endif |
109 | #endif |
155 | 110 | ||
156 | #if !__int_fast32_t_defined |
111 | #if !__int_fast32_t_defined |
157 | #if __int_least32_t_defined |
112 | #if __int_least32_t_defined |
158 | typedef int_least32_t int_fast32_t; |
113 | typedef int_least32_t int_fast32_t; |
159 | typedef uint_least32_t uint_fast32_t; |
114 | typedef uint_least32_t uint_fast32_t; |
160 | #define __int_fast32_t_defined 1 |
115 | #define __int_fast32_t_defined 1 |
161 | #endif |
116 | #endif |
162 | #endif |
117 | #endif |
163 | 118 | ||
164 | #if !__int_fast64_t_defined |
119 | #if !__int_fast64_t_defined |
165 | #if __int_least64_t_defined |
120 | #if __int_least64_t_defined |
166 | typedef int_least64_t int_fast64_t; |
121 | typedef int_least64_t int_fast64_t; |
167 | typedef uint_least64_t uint_fast64_t; |
122 | typedef uint_least64_t uint_fast64_t; |
168 | #define __int_fast64_t_defined 1 |
123 | #define __int_fast64_t_defined 1 |
169 | #endif |
124 | #endif |
170 | #endif |
125 | #endif |
171 | 126 | ||
172 | /* Greatest-width integer types */ |
127 | /* Greatest-width integer types */ |
173 | /* Modern GCCs provide __INTMAX_TYPE__ */ |
128 | /* Modern GCCs provide __INTMAX_TYPE__ */ |
174 | #if defined(__INTMAX_TYPE__) |
129 | #if defined(__INTMAX_TYPE__) |
175 | typedef __INTMAX_TYPE__ intmax_t; |
130 | typedef __INTMAX_TYPE__ intmax_t; |
176 | #elif __have_longlong64 |
131 | #elif __have_longlong64 |
177 | typedef signed long long intmax_t; |
132 | typedef signed long long intmax_t; |
178 | #else |
133 | #else |
179 | typedef signed long intmax_t; |
134 | typedef signed long intmax_t; |
180 | #endif |
135 | #endif |
181 | 136 | ||
182 | /* Modern GCCs provide __UINTMAX_TYPE__ */ |
137 | /* Modern GCCs provide __UINTMAX_TYPE__ */ |
183 | #if defined(__UINTMAX_TYPE__) |
138 | #if defined(__UINTMAX_TYPE__) |
184 | typedef __UINTMAX_TYPE__ uintmax_t; |
139 | typedef __UINTMAX_TYPE__ uintmax_t; |
185 | #elif __have_longlong64 |
140 | #elif __have_longlong64 |
186 | typedef unsigned long long uintmax_t; |
141 | typedef unsigned long long uintmax_t; |
187 | #else |
142 | #else |
188 | typedef unsigned long uintmax_t; |
143 | typedef unsigned long uintmax_t; |
189 | #endif |
144 | #endif |
190 | - | ||
191 | typedef __intptr_t intptr_t; |
- | |
192 | typedef __uintptr_t uintptr_t; |
- | |
193 | 145 | ||
194 | #ifdef __INTPTR_TYPE__ |
146 | #ifdef __INTPTR_TYPE__ |
195 | #define INTPTR_MIN (-__INTPTR_MAX__ - 1) |
147 | #define INTPTR_MIN (-__INTPTR_MAX__ - 1) |
196 | #define INTPTR_MAX __INTPTR_MAX__ |
148 | #define INTPTR_MAX (__INTPTR_MAX__) |
197 | #define UINTPTR_MAX __UINTPTR_MAX__ |
149 | #define UINTPTR_MAX (__UINTPTR_MAX__) |
198 | #elif defined(__PTRDIFF_TYPE__) |
150 | #elif defined(__PTRDIFF_TYPE__) |
199 | #define INTPTR_MAX PTRDIFF_MAX |
151 | #define INTPTR_MAX PTRDIFF_MAX |
200 | #define INTPTR_MIN PTRDIFF_MIN |
152 | #define INTPTR_MIN PTRDIFF_MIN |
201 | #ifdef __UINTPTR_MAX__ |
153 | #ifdef __UINTPTR_MAX__ |
202 | #define UINTPTR_MAX __UINTPTR_MAX__ |
154 | #define UINTPTR_MAX (__UINTPTR_MAX__) |
203 | #else |
155 | #else |
204 | #define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1) |
156 | #define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1) |
205 | #endif |
157 | #endif |
206 | #else |
158 | #else |
207 | /* |
159 | /* |
208 | * Fallback to hardcoded values, |
160 | * Fallback to hardcoded values, |
209 | * should be valid on cpu's with 32bit int/32bit void* |
161 | * should be valid on cpu's with 32bit int/32bit void* |
210 | */ |
162 | */ |
211 | #define INTPTR_MAX __STDINT_EXP(LONG_MAX) |
163 | #define INTPTR_MAX (__STDINT_EXP(LONG_MAX)) |
212 | #define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1) |
164 | #define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1) |
213 | #define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
165 | #define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
214 | #endif |
166 | #endif |
215 | 167 | ||
216 | /* Limits of Specified-Width Integer Types */ |
168 | /* Limits of Specified-Width Integer Types */ |
217 | 169 | ||
218 | #ifdef __INT8_MAX__ |
170 | #ifdef __INT8_MAX__ |
219 | #define INT8_MIN (-__INT8_MAX__ - 1) |
171 | #define INT8_MIN (-__INT8_MAX__ - 1) |
220 | #define INT8_MAX __INT8_MAX__ |
172 | #define INT8_MAX (__INT8_MAX__) |
221 | #define UINT8_MAX __UINT8_MAX__ |
173 | #define UINT8_MAX (__UINT8_MAX__) |
222 | #elif defined(__int8_t_defined) |
174 | #elif defined(__int8_t_defined) |
223 | #define INT8_MIN -128 |
175 | #define INT8_MIN (-128) |
224 | #define INT8_MAX 127 |
176 | #define INT8_MAX (127) |
225 | #define UINT8_MAX 255 |
177 | #define UINT8_MAX (255) |
226 | #endif |
178 | #endif |
227 | 179 | ||
228 | #ifdef __INT_LEAST8_MAX__ |
180 | #ifdef __INT_LEAST8_MAX__ |
229 | #define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1) |
181 | #define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1) |
230 | #define INT_LEAST8_MAX __INT_LEAST8_MAX__ |
182 | #define INT_LEAST8_MAX (__INT_LEAST8_MAX__) |
231 | #define UINT_LEAST8_MAX __UINT_LEAST8_MAX__ |
183 | #define UINT_LEAST8_MAX (__UINT_LEAST8_MAX__) |
232 | #elif defined(__int_least8_t_defined) |
184 | #elif defined(__int_least8_t_defined) |
233 | #define INT_LEAST8_MIN -128 |
185 | #define INT_LEAST8_MIN (-128) |
234 | #define INT_LEAST8_MAX 127 |
186 | #define INT_LEAST8_MAX (127) |
235 | #define UINT_LEAST8_MAX 255 |
187 | #define UINT_LEAST8_MAX (255) |
236 | #else |
188 | #else |
237 | #error required type int_least8_t missing |
189 | #error required type int_least8_t missing |
238 | #endif |
190 | #endif |
239 | 191 | ||
240 | #ifdef __INT16_MAX__ |
192 | #ifdef __INT16_MAX__ |
241 | #define INT16_MIN (-__INT16_MAX__ - 1) |
193 | #define INT16_MIN (-__INT16_MAX__ - 1) |
242 | #define INT16_MAX __INT16_MAX__ |
194 | #define INT16_MAX (__INT16_MAX__) |
243 | #define UINT16_MAX __UINT16_MAX__ |
195 | #define UINT16_MAX (__UINT16_MAX__) |
244 | #elif defined(__int16_t_defined) |
196 | #elif defined(__int16_t_defined) |
245 | #define INT16_MIN -32768 |
197 | #define INT16_MIN (-32768) |
246 | #define INT16_MAX 32767 |
198 | #define INT16_MAX (32767) |
247 | #define UINT16_MAX 65535 |
199 | #define UINT16_MAX (65535) |
248 | #endif |
200 | #endif |
249 | 201 | ||
250 | #ifdef __INT_LEAST16_MAX__ |
202 | #ifdef __INT_LEAST16_MAX__ |
251 | #define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1) |
203 | #define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1) |
252 | #define INT_LEAST16_MAX __INT_LEAST16_MAX__ |
204 | #define INT_LEAST16_MAX (__INT_LEAST16_MAX__) |
253 | #define UINT_LEAST16_MAX __UINT_LEAST16_MAX__ |
205 | #define UINT_LEAST16_MAX (__UINT_LEAST16_MAX__) |
254 | #elif defined(__int_least16_t_defined) |
206 | #elif defined(__int_least16_t_defined) |
255 | #define INT_LEAST16_MIN -32768 |
207 | #define INT_LEAST16_MIN (-32768) |
256 | #define INT_LEAST16_MAX 32767 |
208 | #define INT_LEAST16_MAX (32767) |
257 | #define UINT_LEAST16_MAX 65535 |
209 | #define UINT_LEAST16_MAX (65535) |
258 | #else |
210 | #else |
259 | #error required type int_least16_t missing |
211 | #error required type int_least16_t missing |
260 | #endif |
212 | #endif |
261 | 213 | ||
262 | #ifdef __INT32_MAX__ |
214 | #ifdef __INT32_MAX__ |
263 | #define INT32_MIN (-__INT32_MAX__ - 1) |
215 | #define INT32_MIN (-__INT32_MAX__ - 1) |
264 | #define INT32_MAX __INT32_MAX__ |
216 | #define INT32_MAX (__INT32_MAX__) |
265 | #define UINT32_MAX __UINT32_MAX__ |
217 | #define UINT32_MAX (__UINT32_MAX__) |
266 | #elif defined(__int32_t_defined) |
218 | #elif defined(__int32_t_defined) |
267 | #if __have_long32 |
219 | #if defined (_INT32_EQ_LONG) |
268 | #define INT32_MIN (-2147483647L-1) |
220 | #define INT32_MIN (-2147483647L-1) |
269 | #define INT32_MAX 2147483647L |
221 | #define INT32_MAX (2147483647L) |
270 | #define UINT32_MAX 4294967295UL |
222 | #define UINT32_MAX (4294967295UL) |
271 | #else |
223 | #else |
272 | #define INT32_MIN (-2147483647-1) |
224 | #define INT32_MIN (-2147483647-1) |
273 | #define INT32_MAX 2147483647 |
225 | #define INT32_MAX (2147483647) |
274 | #define UINT32_MAX 4294967295U |
226 | #define UINT32_MAX (4294967295U) |
275 | #endif |
227 | #endif |
276 | #endif |
228 | #endif |
277 | 229 | ||
278 | #ifdef __INT_LEAST32_MAX__ |
230 | #ifdef __INT_LEAST32_MAX__ |
279 | #define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1) |
231 | #define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1) |
280 | #define INT_LEAST32_MAX __INT_LEAST32_MAX__ |
232 | #define INT_LEAST32_MAX (__INT_LEAST32_MAX__) |
281 | #define UINT_LEAST32_MAX __UINT_LEAST32_MAX__ |
233 | #define UINT_LEAST32_MAX (__UINT_LEAST32_MAX__) |
282 | #elif defined(__int_least32_t_defined) |
234 | #elif defined(__int_least32_t_defined) |
283 | #if __have_long32 |
235 | #if defined (_INT32_EQ_LONG) |
284 | #define INT_LEAST32_MIN (-2147483647L-1) |
236 | #define INT_LEAST32_MIN (-2147483647L-1) |
285 | #define INT_LEAST32_MAX 2147483647L |
237 | #define INT_LEAST32_MAX (2147483647L) |
286 | #define UINT_LEAST32_MAX 4294967295UL |
238 | #define UINT_LEAST32_MAX (4294967295UL) |
287 | #else |
239 | #else |
288 | #define INT_LEAST32_MIN (-2147483647-1) |
240 | #define INT_LEAST32_MIN (-2147483647-1) |
289 | #define INT_LEAST32_MAX 2147483647 |
241 | #define INT_LEAST32_MAX (2147483647) |
290 | #define UINT_LEAST32_MAX 4294967295U |
242 | #define UINT_LEAST32_MAX (4294967295U) |
291 | #endif |
243 | #endif |
292 | #else |
244 | #else |
293 | #error required type int_least32_t missing |
245 | #error required type int_least32_t missing |
294 | #endif |
246 | #endif |
295 | 247 | ||
296 | #ifdef __INT64_MAX__ |
248 | #ifdef __INT64_MAX__ |
297 | #define INT64_MIN (-__INT64_MAX__ - 1) |
249 | #define INT64_MIN (-__INT64_MAX__ - 1) |
298 | #define INT64_MAX __INT64_MAX__ |
250 | #define INT64_MAX (__INT64_MAX__) |
299 | #define UINT64_MAX __UINT64_MAX__ |
251 | #define UINT64_MAX (__UINT64_MAX__) |
300 | #elif defined(__int64_t_defined) |
252 | #elif defined(__int64_t_defined) |
301 | #if __have_long64 |
253 | #if __have_long64 |
302 | #define INT64_MIN (-9223372036854775807L-1L) |
254 | #define INT64_MIN (-9223372036854775807L-1L) |
303 | #define INT64_MAX 9223372036854775807L |
255 | #define INT64_MAX (9223372036854775807L) |
304 | #define UINT64_MAX 18446744073709551615U |
256 | #define UINT64_MAX (18446744073709551615U) |
305 | #elif __have_longlong64 |
257 | #elif __have_longlong64 |
306 | #define INT64_MIN (-9223372036854775807LL-1LL) |
258 | #define INT64_MIN (-9223372036854775807LL-1LL) |
307 | #define INT64_MAX 9223372036854775807LL |
259 | #define INT64_MAX (9223372036854775807LL) |
308 | #define UINT64_MAX 18446744073709551615ULL |
260 | #define UINT64_MAX (18446744073709551615ULL) |
309 | #endif |
261 | #endif |
310 | #endif |
262 | #endif |
311 | 263 | ||
312 | #ifdef __INT_LEAST64_MAX__ |
264 | #ifdef __INT_LEAST64_MAX__ |
313 | #define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1) |
265 | #define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1) |
314 | #define INT_LEAST64_MAX __INT_LEAST64_MAX__ |
266 | #define INT_LEAST64_MAX (__INT_LEAST64_MAX__) |
315 | #define UINT_LEAST64_MAX __UINT_LEAST64_MAX__ |
267 | #define UINT_LEAST64_MAX (__UINT_LEAST64_MAX__) |
316 | #elif defined(__int_least64_t_defined) |
268 | #elif defined(__int_least64_t_defined) |
317 | #if __have_long64 |
269 | #if __have_long64 |
318 | #define INT_LEAST64_MIN (-9223372036854775807L-1L) |
270 | #define INT_LEAST64_MIN (-9223372036854775807L-1L) |
319 | #define INT_LEAST64_MAX 9223372036854775807L |
271 | #define INT_LEAST64_MAX (9223372036854775807L) |
320 | #define UINT_LEAST64_MAX 18446744073709551615U |
272 | #define UINT_LEAST64_MAX (18446744073709551615U) |
321 | #elif __have_longlong64 |
273 | #elif __have_longlong64 |
322 | #define INT_LEAST64_MIN (-9223372036854775807LL-1LL) |
274 | #define INT_LEAST64_MIN (-9223372036854775807LL-1LL) |
323 | #define INT_LEAST64_MAX 9223372036854775807LL |
275 | #define INT_LEAST64_MAX (9223372036854775807LL) |
324 | #define UINT_LEAST64_MAX 18446744073709551615ULL |
276 | #define UINT_LEAST64_MAX (18446744073709551615ULL) |
325 | #endif |
277 | #endif |
326 | #endif |
278 | #endif |
327 | 279 | ||
328 | #ifdef __INT_FAST8_MAX__ |
280 | #ifdef __INT_FAST8_MAX__ |
329 | #define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1) |
281 | #define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1) |
330 | #define INT_FAST8_MAX __INT_FAST8_MAX__ |
282 | #define INT_FAST8_MAX (__INT_FAST8_MAX__) |
331 | #define UINT_FAST8_MAX __UINT_FAST8_MAX__ |
283 | #define UINT_FAST8_MAX (__UINT_FAST8_MAX__) |
332 | #elif defined(__int_fast8_t_defined) |
284 | #elif defined(__int_fast8_t_defined) |
333 | #if __STDINT_EXP(INT_MAX) >= 0x7f |
285 | #if __STDINT_EXP(INT_MAX) >= 0x7f |
334 | #define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1) |
286 | #define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1) |
335 | #define INT_FAST8_MAX __STDINT_EXP(INT_MAX) |
287 | #define INT_FAST8_MAX (__STDINT_EXP(INT_MAX)) |
336 | #define UINT_FAST8_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
288 | #define UINT_FAST8_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
337 | #else |
289 | #else |
338 | #define INT_FAST8_MIN INT_LEAST8_MIN |
290 | #define INT_FAST8_MIN INT_LEAST8_MIN |
339 | #define INT_FAST8_MAX INT_LEAST8_MAX |
291 | #define INT_FAST8_MAX INT_LEAST8_MAX |
340 | #define UINT_FAST8_MAX UINT_LEAST8_MAX |
292 | #define UINT_FAST8_MAX UINT_LEAST8_MAX |
341 | #endif |
293 | #endif |
342 | #endif |
294 | #endif |
343 | 295 | ||
344 | #ifdef __INT_FAST16_MAX__ |
296 | #ifdef __INT_FAST16_MAX__ |
345 | #define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1) |
297 | #define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1) |
346 | #define INT_FAST16_MAX __INT_FAST16_MAX__ |
298 | #define INT_FAST16_MAX (__INT_FAST16_MAX__) |
347 | #define UINT_FAST16_MAX __UINT_FAST16_MAX__ |
299 | #define UINT_FAST16_MAX (__UINT_FAST16_MAX__) |
348 | #elif defined(__int_fast16_t_defined) |
300 | #elif defined(__int_fast16_t_defined) |
349 | #if __STDINT_EXP(INT_MAX) >= 0x7fff |
301 | #if __STDINT_EXP(INT_MAX) >= 0x7fff |
350 | #define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1) |
302 | #define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1) |
351 | #define INT_FAST16_MAX __STDINT_EXP(INT_MAX) |
303 | #define INT_FAST16_MAX (__STDINT_EXP(INT_MAX)) |
352 | #define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
304 | #define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
353 | #else |
305 | #else |
354 | #define INT_FAST16_MIN INT_LEAST16_MIN |
306 | #define INT_FAST16_MIN INT_LEAST16_MIN |
355 | #define INT_FAST16_MAX INT_LEAST16_MAX |
307 | #define INT_FAST16_MAX INT_LEAST16_MAX |
356 | #define UINT_FAST16_MAX UINT_LEAST16_MAX |
308 | #define UINT_FAST16_MAX UINT_LEAST16_MAX |
357 | #endif |
309 | #endif |
358 | #endif |
310 | #endif |
359 | 311 | ||
360 | #ifdef __INT_FAST32_MAX__ |
312 | #ifdef __INT_FAST32_MAX__ |
361 | #define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1) |
313 | #define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1) |
362 | #define INT_FAST32_MAX __INT_FAST32_MAX__ |
314 | #define INT_FAST32_MAX (__INT_FAST32_MAX__) |
363 | #define UINT_FAST32_MAX __UINT_FAST32_MAX__ |
315 | #define UINT_FAST32_MAX (__UINT_FAST32_MAX__) |
364 | #elif defined(__int_fast32_t_defined) |
316 | #elif defined(__int_fast32_t_defined) |
365 | #if __STDINT_EXP(INT_MAX) >= 0x7fffffff |
317 | #if __STDINT_EXP(INT_MAX) >= 0x7fffffff |
366 | #define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1) |
318 | #define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1) |
367 | #define INT_FAST32_MAX __STDINT_EXP(INT_MAX) |
319 | #define INT_FAST32_MAX (__STDINT_EXP(INT_MAX)) |
368 | #define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
320 | #define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
369 | #else |
321 | #else |
370 | #define INT_FAST32_MIN INT_LEAST32_MIN |
322 | #define INT_FAST32_MIN INT_LEAST32_MIN |
371 | #define INT_FAST32_MAX INT_LEAST32_MAX |
323 | #define INT_FAST32_MAX INT_LEAST32_MAX |
372 | #define UINT_FAST32_MAX UINT_LEAST32_MAX |
324 | #define UINT_FAST32_MAX UINT_LEAST32_MAX |
373 | #endif |
325 | #endif |
374 | #endif |
326 | #endif |
375 | 327 | ||
376 | #ifdef __INT_FAST64_MAX__ |
328 | #ifdef __INT_FAST64_MAX__ |
377 | #define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1) |
329 | #define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1) |
378 | #define INT_FAST64_MAX __INT_FAST64_MAX__ |
330 | #define INT_FAST64_MAX (__INT_FAST64_MAX__) |
379 | #define UINT_FAST64_MAX __UINT_FAST64_MAX__ |
331 | #define UINT_FAST64_MAX (__UINT_FAST64_MAX__) |
380 | #elif defined(__int_fast64_t_defined) |
332 | #elif defined(__int_fast64_t_defined) |
381 | #if __STDINT_EXP(INT_MAX) > 0x7fffffff |
333 | #if __STDINT_EXP(INT_MAX) > 0x7fffffff |
382 | #define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1) |
334 | #define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1) |
383 | #define INT_FAST64_MAX __STDINT_EXP(INT_MAX) |
335 | #define INT_FAST64_MAX (__STDINT_EXP(INT_MAX)) |
384 | #define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
336 | #define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U) |
385 | #else |
337 | #else |
386 | #define INT_FAST64_MIN INT_LEAST64_MIN |
338 | #define INT_FAST64_MIN INT_LEAST64_MIN |
387 | #define INT_FAST64_MAX INT_LEAST64_MAX |
339 | #define INT_FAST64_MAX INT_LEAST64_MAX |
388 | #define UINT_FAST64_MAX UINT_LEAST64_MAX |
340 | #define UINT_FAST64_MAX UINT_LEAST64_MAX |
389 | #endif |
341 | #endif |
390 | #endif |
342 | #endif |
391 | 343 | ||
392 | #ifdef __INTMAX_MAX__ |
344 | #ifdef __INTMAX_MAX__ |
393 | #define INTMAX_MAX __INTMAX_MAX__ |
345 | #define INTMAX_MAX (__INTMAX_MAX__) |
394 | #define INTMAX_MIN (-INTMAX_MAX - 1) |
346 | #define INTMAX_MIN (-INTMAX_MAX - 1) |
395 | #elif defined(__INTMAX_TYPE__) |
347 | #elif defined(__INTMAX_TYPE__) |
396 | /* All relevant GCC versions prefer long to long long for intmax_t. */ |
348 | /* All relevant GCC versions prefer long to long long for intmax_t. */ |
397 | #define INTMAX_MAX INT64_MAX |
349 | #define INTMAX_MAX INT64_MAX |
398 | #define INTMAX_MIN INT64_MIN |
350 | #define INTMAX_MIN INT64_MIN |
399 | #endif |
351 | #endif |
400 | 352 | ||
401 | #ifdef __UINTMAX_MAX__ |
353 | #ifdef __UINTMAX_MAX__ |
402 | #define UINTMAX_MAX __UINTMAX_MAX__ |
354 | #define UINTMAX_MAX (__UINTMAX_MAX__) |
403 | #elif defined(__UINTMAX_TYPE__) |
355 | #elif defined(__UINTMAX_TYPE__) |
404 | /* All relevant GCC versions prefer long to long long for intmax_t. */ |
356 | /* All relevant GCC versions prefer long to long long for intmax_t. */ |
405 | #define UINTMAX_MAX UINT64_MAX |
357 | #define UINTMAX_MAX UINT64_MAX |
406 | #endif |
358 | #endif |
407 | 359 | ||
408 | /* This must match size_t in stddef.h, currently long unsigned int */ |
360 | /* This must match size_t in stddef.h, currently long unsigned int */ |
409 | #ifdef __SIZE_MAX__ |
361 | #ifdef __SIZE_MAX__ |
410 | #define SIZE_MAX __SIZE_MAX__ |
362 | #define SIZE_MAX (__SIZE_MAX__) |
411 | #else |
363 | #else |
412 | #define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
364 | #define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) |
413 | #endif |
365 | #endif |
414 | 366 | ||
415 | /* This must match sig_atomic_t in |
367 | /* This must match sig_atomic_t in |
416 | #define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1) |
368 | #define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1) |
417 | #define SIG_ATOMIC_MAX __STDINT_EXP(INT_MAX) |
369 | #define SIG_ATOMIC_MAX (__STDINT_EXP(INT_MAX)) |
418 | 370 | ||
419 | /* This must match ptrdiff_t in |
371 | /* This must match ptrdiff_t in |
420 | #ifdef __PTRDIFF_MAX__ |
372 | #ifdef __PTRDIFF_MAX__ |
421 | #define PTRDIFF_MAX __PTRDIFF_MAX__ |
373 | #define PTRDIFF_MAX (__PTRDIFF_MAX__) |
422 | #else |
374 | #else |
423 | #define PTRDIFF_MAX __STDINT_EXP(LONG_MAX) |
375 | #define PTRDIFF_MAX (__STDINT_EXP(LONG_MAX)) |
424 | #endif |
376 | #endif |
425 | #define PTRDIFF_MIN (-PTRDIFF_MAX - 1) |
377 | #define PTRDIFF_MIN (-PTRDIFF_MAX - 1) |
- | 378 | ||
- | 379 | /* This must match definition in |
|
- | 380 | #ifndef WCHAR_MIN |
|
- | 381 | #ifdef __WCHAR_MIN__ |
|
- | 382 | #define WCHAR_MIN (__WCHAR_MIN__) |
|
- | 383 | #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0) |
|
- | 384 | #define WCHAR_MIN (0 + L'\0') |
|
- | 385 | #else |
|
- | 386 | #define WCHAR_MIN (-0x7fffffff - 1 + L'\0') |
|
- | 387 | #endif |
|
- | 388 | #endif |
|
- | 389 | ||
- | 390 | /* This must match definition in |
|
426 | 391 | #ifndef WCHAR_MAX |
|
427 | #ifdef __WCHAR_MAX__ |
392 | #ifdef __WCHAR_MAX__ |
- | 393 | #define WCHAR_MAX (__WCHAR_MAX__) |
|
- | 394 | #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0) |
|
- | 395 | #define WCHAR_MAX (0xffffffffu + L'\0') |
|
- | 396 | #else |
|
428 | #define WCHAR_MAX __WCHAR_MAX__ |
397 | #define WCHAR_MAX (0x7fffffff + L'\0') |
429 | #endif |
- | |
430 | #ifdef __WCHAR_MIN__ |
- | |
431 | #define WCHAR_MIN __WCHAR_MIN__ |
398 | #endif |
432 | #endif |
399 | #endif |
433 | 400 | ||
434 | /* wint_t is unsigned int on almost all GCC targets. */ |
401 | /* wint_t is unsigned int on almost all GCC targets. */ |
435 | #ifdef __WINT_MAX__ |
402 | #ifdef __WINT_MAX__ |
436 | #define WINT_MAX __WINT_MAX__ |
403 | #define WINT_MAX (__WINT_MAX__) |
437 | #else |
404 | #else |
438 | #define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U) |
405 | #define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U) |
439 | #endif |
406 | #endif |
440 | #ifdef __WINT_MIN__ |
407 | #ifdef __WINT_MIN__ |
441 | #define WINT_MIN __WINT_MIN__ |
408 | #define WINT_MIN (__WINT_MIN__) |
442 | #else |
409 | #else |
443 | #define WINT_MIN 0U |
410 | #define WINT_MIN (0U) |
444 | #endif |
411 | #endif |
445 | 412 | ||
446 | /** Macros for minimum-width integer constant expressions */ |
413 | /** Macros for minimum-width integer constant expressions */ |
447 | #ifdef __INT8_C |
414 | #ifdef __INT8_C |
448 | #define INT8_C(x) __INT8_C(x) |
415 | #define INT8_C(x) __INT8_C(x) |
449 | #define UINT8_C(x) __UINT8_C(x) |
416 | #define UINT8_C(x) __UINT8_C(x) |
450 | #else |
417 | #else |
451 | #define INT8_C(x) x |
418 | #define INT8_C(x) x |
452 | #if __STDINT_EXP(INT_MAX) > 0x7f |
419 | #if __STDINT_EXP(INT_MAX) > 0x7f |
453 | #define UINT8_C(x) x |
420 | #define UINT8_C(x) x |
454 | #else |
421 | #else |
455 | #define UINT8_C(x) x##U |
422 | #define UINT8_C(x) x##U |
456 | #endif |
423 | #endif |
457 | #endif |
424 | #endif |
458 | 425 | ||
459 | #ifdef __INT16_C |
426 | #ifdef __INT16_C |
460 | #define INT16_C(x) __INT16_C(x) |
427 | #define INT16_C(x) __INT16_C(x) |
461 | #define UINT16_C(x) __UINT16_C(x) |
428 | #define UINT16_C(x) __UINT16_C(x) |
462 | #else |
429 | #else |
463 | #define INT16_C(x) x |
430 | #define INT16_C(x) x |
464 | #if __STDINT_EXP(INT_MAX) > 0x7fff |
431 | #if __STDINT_EXP(INT_MAX) > 0x7fff |
465 | #define UINT16_C(x) x |
432 | #define UINT16_C(x) x |
466 | #else |
433 | #else |
467 | #define UINT16_C(x) x##U |
434 | #define UINT16_C(x) x##U |
468 | #endif |
435 | #endif |
469 | #endif |
436 | #endif |
470 | 437 | ||
471 | #ifdef __INT32_C |
438 | #ifdef __INT32_C |
472 | #define INT32_C(x) __INT32_C(x) |
439 | #define INT32_C(x) __INT32_C(x) |
473 | #define UINT32_C(x) __UINT32_C(x) |
440 | #define UINT32_C(x) __UINT32_C(x) |
474 | #else |
441 | #else |
475 | #if __have_long32 |
442 | #if defined (_INT32_EQ_LONG) |
476 | #define INT32_C(x) x##L |
443 | #define INT32_C(x) x##L |
477 | #define UINT32_C(x) x##UL |
444 | #define UINT32_C(x) x##UL |
478 | #else |
445 | #else |
479 | #define INT32_C(x) x |
446 | #define INT32_C(x) x |
480 | #define UINT32_C(x) x##U |
447 | #define UINT32_C(x) x##U |
481 | #endif |
448 | #endif |
482 | #endif |
449 | #endif |
483 | 450 | ||
484 | #ifdef __INT64_C |
451 | #ifdef __INT64_C |
485 | #define INT64_C(x) __INT64_C(x) |
452 | #define INT64_C(x) __INT64_C(x) |
486 | #define UINT64_C(x) __UINT64_C(x) |
453 | #define UINT64_C(x) __UINT64_C(x) |
487 | #else |
454 | #else |
488 | #if __int64_t_defined |
455 | #if __int64_t_defined |
489 | #if __have_long64 |
456 | #if __have_long64 |
490 | #define INT64_C(x) x##L |
457 | #define INT64_C(x) x##L |
491 | #define UINT64_C(x) x##UL |
458 | #define UINT64_C(x) x##UL |
492 | #else |
459 | #else |
493 | #define INT64_C(x) x##LL |
460 | #define INT64_C(x) x##LL |
494 | #define UINT64_C(x) x##ULL |
461 | #define UINT64_C(x) x##ULL |
495 | #endif |
462 | #endif |
496 | #endif |
463 | #endif |
497 | #endif |
464 | #endif |
498 | 465 | ||
499 | /** Macros for greatest-width integer constant expression */ |
466 | /** Macros for greatest-width integer constant expression */ |
500 | #ifdef __INTMAX_C |
467 | #ifdef __INTMAX_C |
501 | #define INTMAX_C(x) __INTMAX_C(x) |
468 | #define INTMAX_C(x) __INTMAX_C(x) |
502 | #define UINTMAX_C(x) __UINTMAX_C(x) |
469 | #define UINTMAX_C(x) __UINTMAX_C(x) |
503 | #else |
470 | #else |
504 | #if __have_long64 |
471 | #if __have_long64 |
505 | #define INTMAX_C(x) x##L |
472 | #define INTMAX_C(x) x##L |
506 | #define UINTMAX_C(x) x##UL |
473 | #define UINTMAX_C(x) x##UL |
507 | #else |
474 | #else |
508 | #define INTMAX_C(x) x##LL |
475 | #define INTMAX_C(x) x##LL |
509 | #define UINTMAX_C(x) x##ULL |
476 | #define UINTMAX_C(x) x##ULL |
510 | #endif |
477 | #endif |
511 | #endif |
478 | #endif |
512 | 479 | ||
513 | 480 | ||
514 | #ifdef __cplusplus |
481 | #ifdef __cplusplus |
515 | } |
482 | } |
516 | #endif |
483 | #endif |
517 | 484 | ||
518 | #endif /* _STDINT_H */ |
485 | #endif /* _STDINT_H */ |