1 | /*===---- stdint.h - Standard header for sized integer types --------------===*\ |
2 | * |
3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | * See https://llvm.org/LICENSE.txt for license information. |
5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | * |
7 | \*===----------------------------------------------------------------------===*/ |
8 | |
9 | #ifndef __CLANG_STDINT_H |
10 | // AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T |
11 | // is defined until an inclusion of it without _STD_TYPES_T occurs, in which |
12 | // case the header guard macro is defined. |
13 | #if !defined(_AIX) || !defined(_STD_TYPES_T) || !defined(__STDC_HOSTED__) |
14 | #define __CLANG_STDINT_H |
15 | #endif |
16 | |
17 | /* If we're hosted, fall back to the system's stdint.h, which might have |
18 | * additional definitions. |
19 | */ |
20 | #if __STDC_HOSTED__ && __has_include_next(<stdint.h>) |
21 | |
22 | // C99 7.18.3 Limits of other integer types |
23 | // |
24 | // Footnote 219, 220: C++ implementations should define these macros only when |
25 | // __STDC_LIMIT_MACROS is defined before <stdint.h> is included. |
26 | // |
27 | // Footnote 222: C++ implementations should define these macros only when |
28 | // __STDC_CONSTANT_MACROS is defined before <stdint.h> is included. |
29 | // |
30 | // C++11 [cstdint.syn]p2: |
31 | // |
32 | // The macros defined by <cstdint> are provided unconditionally. In particular, |
33 | // the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in |
34 | // footnotes 219, 220, and 222 in the C standard) play no role in C++. |
35 | // |
36 | // C11 removed the problematic footnotes. |
37 | // |
38 | // Work around this inconsistency by always defining those macros in C++ mode, |
39 | // so that a C library implementation which follows the C99 standard can be |
40 | // used in C++. |
41 | # ifdef __cplusplus |
42 | # if !defined(__STDC_LIMIT_MACROS) |
43 | # define __STDC_LIMIT_MACROS |
44 | # define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG |
45 | # endif |
46 | # if !defined(__STDC_CONSTANT_MACROS) |
47 | # define __STDC_CONSTANT_MACROS |
48 | # define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG |
49 | # endif |
50 | # endif |
51 | |
52 | # include_next <stdint.h> |
53 | |
54 | # ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG |
55 | # undef __STDC_LIMIT_MACROS |
56 | # undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG |
57 | # endif |
58 | # ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG |
59 | # undef __STDC_CONSTANT_MACROS |
60 | # undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG |
61 | # endif |
62 | |
63 | #else |
64 | |
65 | /* C99 7.18.1.1 Exact-width integer types. |
66 | * C99 7.18.1.2 Minimum-width integer types. |
67 | * C99 7.18.1.3 Fastest minimum-width integer types. |
68 | * |
69 | * The standard requires that exact-width type be defined for 8-, 16-, 32-, and |
70 | * 64-bit types if they are implemented. Other exact width types are optional. |
71 | * This implementation defines an exact-width types for every integer width |
72 | * that is represented in the standard integer types. |
73 | * |
74 | * The standard also requires minimum-width types be defined for 8-, 16-, 32-, |
75 | * and 64-bit widths regardless of whether there are corresponding exact-width |
76 | * types. |
77 | * |
78 | * To accommodate targets that are missing types that are exactly 8, 16, 32, or |
79 | * 64 bits wide, this implementation takes an approach of cascading |
80 | * redefinitions, redefining __int_leastN_t to successively smaller exact-width |
81 | * types. It is therefore important that the types are defined in order of |
82 | * descending widths. |
83 | * |
84 | * We currently assume that the minimum-width types and the fastest |
85 | * minimum-width types are the same. This is allowed by the standard, but is |
86 | * suboptimal. |
87 | * |
88 | * In violation of the standard, some targets do not implement a type that is |
89 | * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit). |
90 | * To accommodate these targets, a required minimum-width type is only |
91 | * defined if there exists an exact-width type of equal or greater width. |
92 | */ |
93 | |
94 | #ifdef __INT64_TYPE__ |
95 | # ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/ |
96 | typedef __INT64_TYPE__ int64_t; |
97 | # endif /* __int8_t_defined */ |
98 | typedef __UINT64_TYPE__ uint64_t; |
99 | # undef __int_least64_t |
100 | # define __int_least64_t int64_t |
101 | # undef __uint_least64_t |
102 | # define __uint_least64_t uint64_t |
103 | # undef __int_least32_t |
104 | # define __int_least32_t int64_t |
105 | # undef __uint_least32_t |
106 | # define __uint_least32_t uint64_t |
107 | # undef __int_least16_t |
108 | # define __int_least16_t int64_t |
109 | # undef __uint_least16_t |
110 | # define __uint_least16_t uint64_t |
111 | # undef __int_least8_t |
112 | # define __int_least8_t int64_t |
113 | # undef __uint_least8_t |
114 | # define __uint_least8_t uint64_t |
115 | #endif /* __INT64_TYPE__ */ |
116 | |
117 | #ifdef __int_least64_t |
118 | typedef __int_least64_t int_least64_t; |
119 | typedef __uint_least64_t uint_least64_t; |
120 | typedef __int_least64_t int_fast64_t; |
121 | typedef __uint_least64_t uint_fast64_t; |
122 | #endif /* __int_least64_t */ |
123 | |
124 | #ifdef __INT56_TYPE__ |
125 | typedef __INT56_TYPE__ int56_t; |
126 | typedef __UINT56_TYPE__ uint56_t; |
127 | typedef int56_t int_least56_t; |
128 | typedef uint56_t uint_least56_t; |
129 | typedef int56_t int_fast56_t; |
130 | typedef uint56_t uint_fast56_t; |
131 | # undef __int_least32_t |
132 | # define __int_least32_t int56_t |
133 | # undef __uint_least32_t |
134 | # define __uint_least32_t uint56_t |
135 | # undef __int_least16_t |
136 | # define __int_least16_t int56_t |
137 | # undef __uint_least16_t |
138 | # define __uint_least16_t uint56_t |
139 | # undef __int_least8_t |
140 | # define __int_least8_t int56_t |
141 | # undef __uint_least8_t |
142 | # define __uint_least8_t uint56_t |
143 | #endif /* __INT56_TYPE__ */ |
144 | |
145 | |
146 | #ifdef __INT48_TYPE__ |
147 | typedef __INT48_TYPE__ int48_t; |
148 | typedef __UINT48_TYPE__ uint48_t; |
149 | typedef int48_t int_least48_t; |
150 | typedef uint48_t uint_least48_t; |
151 | typedef int48_t int_fast48_t; |
152 | typedef uint48_t uint_fast48_t; |
153 | # undef __int_least32_t |
154 | # define __int_least32_t int48_t |
155 | # undef __uint_least32_t |
156 | # define __uint_least32_t uint48_t |
157 | # undef __int_least16_t |
158 | # define __int_least16_t int48_t |
159 | # undef __uint_least16_t |
160 | # define __uint_least16_t uint48_t |
161 | # undef __int_least8_t |
162 | # define __int_least8_t int48_t |
163 | # undef __uint_least8_t |
164 | # define __uint_least8_t uint48_t |
165 | #endif /* __INT48_TYPE__ */ |
166 | |
167 | |
168 | #ifdef __INT40_TYPE__ |
169 | typedef __INT40_TYPE__ int40_t; |
170 | typedef __UINT40_TYPE__ uint40_t; |
171 | typedef int40_t int_least40_t; |
172 | typedef uint40_t uint_least40_t; |
173 | typedef int40_t int_fast40_t; |
174 | typedef uint40_t uint_fast40_t; |
175 | # undef __int_least32_t |
176 | # define __int_least32_t int40_t |
177 | # undef __uint_least32_t |
178 | # define __uint_least32_t uint40_t |
179 | # undef __int_least16_t |
180 | # define __int_least16_t int40_t |
181 | # undef __uint_least16_t |
182 | # define __uint_least16_t uint40_t |
183 | # undef __int_least8_t |
184 | # define __int_least8_t int40_t |
185 | # undef __uint_least8_t |
186 | # define __uint_least8_t uint40_t |
187 | #endif /* __INT40_TYPE__ */ |
188 | |
189 | |
190 | #ifdef __INT32_TYPE__ |
191 | |
192 | # ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/ |
193 | typedef __INT32_TYPE__ int32_t; |
194 | # endif /* __int8_t_defined */ |
195 | |
196 | # ifndef __uint32_t_defined /* more glibc compatibility */ |
197 | # define __uint32_t_defined |
198 | typedef __UINT32_TYPE__ uint32_t; |
199 | # endif /* __uint32_t_defined */ |
200 | |
201 | # undef __int_least32_t |
202 | # define __int_least32_t int32_t |
203 | # undef __uint_least32_t |
204 | # define __uint_least32_t uint32_t |
205 | # undef __int_least16_t |
206 | # define __int_least16_t int32_t |
207 | # undef __uint_least16_t |
208 | # define __uint_least16_t uint32_t |
209 | # undef __int_least8_t |
210 | # define __int_least8_t int32_t |
211 | # undef __uint_least8_t |
212 | # define __uint_least8_t uint32_t |
213 | #endif /* __INT32_TYPE__ */ |
214 | |
215 | #ifdef __int_least32_t |
216 | typedef __int_least32_t int_least32_t; |
217 | typedef __uint_least32_t uint_least32_t; |
218 | typedef __int_least32_t int_fast32_t; |
219 | typedef __uint_least32_t uint_fast32_t; |
220 | #endif /* __int_least32_t */ |
221 | |
222 | #ifdef __INT24_TYPE__ |
223 | typedef __INT24_TYPE__ int24_t; |
224 | typedef __UINT24_TYPE__ uint24_t; |
225 | typedef int24_t int_least24_t; |
226 | typedef uint24_t uint_least24_t; |
227 | typedef int24_t int_fast24_t; |
228 | typedef uint24_t uint_fast24_t; |
229 | # undef __int_least16_t |
230 | # define __int_least16_t int24_t |
231 | # undef __uint_least16_t |
232 | # define __uint_least16_t uint24_t |
233 | # undef __int_least8_t |
234 | # define __int_least8_t int24_t |
235 | # undef __uint_least8_t |
236 | # define __uint_least8_t uint24_t |
237 | #endif /* __INT24_TYPE__ */ |
238 | |
239 | #ifdef __INT16_TYPE__ |
240 | #ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/ |
241 | typedef __INT16_TYPE__ int16_t; |
242 | #endif /* __int8_t_defined */ |
243 | typedef __UINT16_TYPE__ uint16_t; |
244 | # undef __int_least16_t |
245 | # define __int_least16_t int16_t |
246 | # undef __uint_least16_t |
247 | # define __uint_least16_t uint16_t |
248 | # undef __int_least8_t |
249 | # define __int_least8_t int16_t |
250 | # undef __uint_least8_t |
251 | # define __uint_least8_t uint16_t |
252 | #endif /* __INT16_TYPE__ */ |
253 | |
254 | #ifdef __int_least16_t |
255 | typedef __int_least16_t int_least16_t; |
256 | typedef __uint_least16_t uint_least16_t; |
257 | typedef __int_least16_t int_fast16_t; |
258 | typedef __uint_least16_t uint_fast16_t; |
259 | #endif /* __int_least16_t */ |
260 | |
261 | |
262 | #ifdef __INT8_TYPE__ |
263 | #ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/ |
264 | typedef __INT8_TYPE__ int8_t; |
265 | #endif /* __int8_t_defined */ |
266 | typedef __UINT8_TYPE__ uint8_t; |
267 | # undef __int_least8_t |
268 | # define __int_least8_t int8_t |
269 | # undef __uint_least8_t |
270 | # define __uint_least8_t uint8_t |
271 | #endif /* __INT8_TYPE__ */ |
272 | |
273 | #ifdef __int_least8_t |
274 | typedef __int_least8_t int_least8_t; |
275 | typedef __uint_least8_t uint_least8_t; |
276 | typedef __int_least8_t int_fast8_t; |
277 | typedef __uint_least8_t uint_fast8_t; |
278 | #endif /* __int_least8_t */ |
279 | |
280 | /* prevent glibc sys/types.h from defining conflicting types */ |
281 | #ifndef __int8_t_defined |
282 | # define __int8_t_defined |
283 | #endif /* __int8_t_defined */ |
284 | |
285 | /* C99 7.18.1.4 Integer types capable of holding object pointers. |
286 | */ |
287 | #define __stdint_join3(a,b,c) a ## b ## c |
288 | |
289 | #ifndef _INTPTR_T |
290 | #ifndef __intptr_t_defined |
291 | typedef __INTPTR_TYPE__ intptr_t; |
292 | #define __intptr_t_defined |
293 | #define _INTPTR_T |
294 | #endif |
295 | #endif |
296 | |
297 | #ifndef _UINTPTR_T |
298 | typedef __UINTPTR_TYPE__ uintptr_t; |
299 | #define _UINTPTR_T |
300 | #endif |
301 | |
302 | /* C99 7.18.1.5 Greatest-width integer types. |
303 | */ |
304 | typedef __INTMAX_TYPE__ intmax_t; |
305 | typedef __UINTMAX_TYPE__ uintmax_t; |
306 | |
307 | /* C99 7.18.4 Macros for minimum-width integer constants. |
308 | * |
309 | * The standard requires that integer constant macros be defined for all the |
310 | * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width |
311 | * types are required, the corresponding integer constant macros are defined |
312 | * here. This implementation also defines minimum-width types for every other |
313 | * integer width that the target implements, so corresponding macros are |
314 | * defined below, too. |
315 | * |
316 | * These macros are defined using the same successive-shrinking approach as |
317 | * the type definitions above. It is likewise important that macros are defined |
318 | * in order of decending width. |
319 | * |
320 | * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the |
321 | * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). |
322 | */ |
323 | |
324 | #define __int_c_join(a, b) a ## b |
325 | #define __int_c(v, suffix) __int_c_join(v, suffix) |
326 | #define __uint_c(v, suffix) __int_c_join(v##U, suffix) |
327 | |
328 | |
329 | #ifdef __INT64_TYPE__ |
330 | # undef __int64_c_suffix |
331 | # undef __int32_c_suffix |
332 | # undef __int16_c_suffix |
333 | # undef __int8_c_suffix |
334 | # ifdef __INT64_C_SUFFIX__ |
335 | # define __int64_c_suffix __INT64_C_SUFFIX__ |
336 | # define __int32_c_suffix __INT64_C_SUFFIX__ |
337 | # define __int16_c_suffix __INT64_C_SUFFIX__ |
338 | # define __int8_c_suffix __INT64_C_SUFFIX__ |
339 | # endif /* __INT64_C_SUFFIX__ */ |
340 | #endif /* __INT64_TYPE__ */ |
341 | |
342 | #ifdef __int_least64_t |
343 | # ifdef __int64_c_suffix |
344 | # define INT64_C(v) __int_c(v, __int64_c_suffix) |
345 | # define UINT64_C(v) __uint_c(v, __int64_c_suffix) |
346 | # else |
347 | # define INT64_C(v) v |
348 | # define UINT64_C(v) v ## U |
349 | # endif /* __int64_c_suffix */ |
350 | #endif /* __int_least64_t */ |
351 | |
352 | |
353 | #ifdef __INT56_TYPE__ |
354 | # undef __int32_c_suffix |
355 | # undef __int16_c_suffix |
356 | # undef __int8_c_suffix |
357 | # ifdef __INT56_C_SUFFIX__ |
358 | # define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__) |
359 | # define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__) |
360 | # define __int32_c_suffix __INT56_C_SUFFIX__ |
361 | # define __int16_c_suffix __INT56_C_SUFFIX__ |
362 | # define __int8_c_suffix __INT56_C_SUFFIX__ |
363 | # else |
364 | # define INT56_C(v) v |
365 | # define UINT56_C(v) v ## U |
366 | # endif /* __INT56_C_SUFFIX__ */ |
367 | #endif /* __INT56_TYPE__ */ |
368 | |
369 | |
370 | #ifdef __INT48_TYPE__ |
371 | # undef __int32_c_suffix |
372 | # undef __int16_c_suffix |
373 | # undef __int8_c_suffix |
374 | # ifdef __INT48_C_SUFFIX__ |
375 | # define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__) |
376 | # define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__) |
377 | # define __int32_c_suffix __INT48_C_SUFFIX__ |
378 | # define __int16_c_suffix __INT48_C_SUFFIX__ |
379 | # define __int8_c_suffix __INT48_C_SUFFIX__ |
380 | # else |
381 | # define INT48_C(v) v |
382 | # define UINT48_C(v) v ## U |
383 | # endif /* __INT48_C_SUFFIX__ */ |
384 | #endif /* __INT48_TYPE__ */ |
385 | |
386 | |
387 | #ifdef __INT40_TYPE__ |
388 | # undef __int32_c_suffix |
389 | # undef __int16_c_suffix |
390 | # undef __int8_c_suffix |
391 | # ifdef __INT40_C_SUFFIX__ |
392 | # define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__) |
393 | # define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__) |
394 | # define __int32_c_suffix __INT40_C_SUFFIX__ |
395 | # define __int16_c_suffix __INT40_C_SUFFIX__ |
396 | # define __int8_c_suffix __INT40_C_SUFFIX__ |
397 | # else |
398 | # define INT40_C(v) v |
399 | # define UINT40_C(v) v ## U |
400 | # endif /* __INT40_C_SUFFIX__ */ |
401 | #endif /* __INT40_TYPE__ */ |
402 | |
403 | |
404 | #ifdef __INT32_TYPE__ |
405 | # undef __int32_c_suffix |
406 | # undef __int16_c_suffix |
407 | # undef __int8_c_suffix |
408 | # ifdef __INT32_C_SUFFIX__ |
409 | # define __int32_c_suffix __INT32_C_SUFFIX__ |
410 | # define __int16_c_suffix __INT32_C_SUFFIX__ |
411 | # define __int8_c_suffix __INT32_C_SUFFIX__ |
412 | # endif /* __INT32_C_SUFFIX__ */ |
413 | #endif /* __INT32_TYPE__ */ |
414 | |
415 | #ifdef __int_least32_t |
416 | # ifdef __int32_c_suffix |
417 | # define INT32_C(v) __int_c(v, __int32_c_suffix) |
418 | # define UINT32_C(v) __uint_c(v, __int32_c_suffix) |
419 | # else |
420 | # define INT32_C(v) v |
421 | # define UINT32_C(v) v ## U |
422 | # endif /* __int32_c_suffix */ |
423 | #endif /* __int_least32_t */ |
424 | |
425 | |
426 | #ifdef __INT24_TYPE__ |
427 | # undef __int16_c_suffix |
428 | # undef __int8_c_suffix |
429 | # ifdef __INT24_C_SUFFIX__ |
430 | # define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__) |
431 | # define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__) |
432 | # define __int16_c_suffix __INT24_C_SUFFIX__ |
433 | # define __int8_c_suffix __INT24_C_SUFFIX__ |
434 | # else |
435 | # define INT24_C(v) v |
436 | # define UINT24_C(v) v ## U |
437 | # endif /* __INT24_C_SUFFIX__ */ |
438 | #endif /* __INT24_TYPE__ */ |
439 | |
440 | |
441 | #ifdef __INT16_TYPE__ |
442 | # undef __int16_c_suffix |
443 | # undef __int8_c_suffix |
444 | # ifdef __INT16_C_SUFFIX__ |
445 | # define __int16_c_suffix __INT16_C_SUFFIX__ |
446 | # define __int8_c_suffix __INT16_C_SUFFIX__ |
447 | # endif /* __INT16_C_SUFFIX__ */ |
448 | #endif /* __INT16_TYPE__ */ |
449 | |
450 | #ifdef __int_least16_t |
451 | # ifdef __int16_c_suffix |
452 | # define INT16_C(v) __int_c(v, __int16_c_suffix) |
453 | # define UINT16_C(v) __uint_c(v, __int16_c_suffix) |
454 | # else |
455 | # define INT16_C(v) v |
456 | # define UINT16_C(v) v ## U |
457 | # endif /* __int16_c_suffix */ |
458 | #endif /* __int_least16_t */ |
459 | |
460 | |
461 | #ifdef __INT8_TYPE__ |
462 | # undef __int8_c_suffix |
463 | # ifdef __INT8_C_SUFFIX__ |
464 | # define __int8_c_suffix __INT8_C_SUFFIX__ |
465 | # endif /* __INT8_C_SUFFIX__ */ |
466 | #endif /* __INT8_TYPE__ */ |
467 | |
468 | #ifdef __int_least8_t |
469 | # ifdef __int8_c_suffix |
470 | # define INT8_C(v) __int_c(v, __int8_c_suffix) |
471 | # define UINT8_C(v) __uint_c(v, __int8_c_suffix) |
472 | # else |
473 | # define INT8_C(v) v |
474 | # define UINT8_C(v) v ## U |
475 | # endif /* __int8_c_suffix */ |
476 | #endif /* __int_least8_t */ |
477 | |
478 | |
479 | /* C99 7.18.2.1 Limits of exact-width integer types. |
480 | * C99 7.18.2.2 Limits of minimum-width integer types. |
481 | * C99 7.18.2.3 Limits of fastest minimum-width integer types. |
482 | * |
483 | * The presence of limit macros are completely optional in C99. This |
484 | * implementation defines limits for all of the types (exact- and |
485 | * minimum-width) that it defines above, using the limits of the minimum-width |
486 | * type for any types that do not have exact-width representations. |
487 | * |
488 | * As in the type definitions, this section takes an approach of |
489 | * successive-shrinking to determine which limits to use for the standard (8, |
490 | * 16, 32, 64) bit widths when they don't have exact representations. It is |
491 | * therefore important that the definitions be kept in order of decending |
492 | * widths. |
493 | * |
494 | * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the |
495 | * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). |
496 | */ |
497 | |
498 | #ifdef __INT64_TYPE__ |
499 | # define INT64_MAX INT64_C( 9223372036854775807) |
500 | # define INT64_MIN (-INT64_C( 9223372036854775807)-1) |
501 | # define UINT64_MAX UINT64_C(18446744073709551615) |
502 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
503 | in C2x mode; switch to the correct values once they've been published. */ |
504 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
505 | # define UINT64_WIDTH 64 |
506 | # define INT64_WIDTH UINT64_WIDTH |
507 | |
508 | # define __UINT_LEAST64_WIDTH UINT64_WIDTH |
509 | # undef __UINT_LEAST32_WIDTH |
510 | # define __UINT_LEAST32_WIDTH UINT64_WIDTH |
511 | # undef __UINT_LEAST16_WIDTH |
512 | # define __UINT_LEAST16_WIDTH UINT64_WIDTH |
513 | # undef __UINT_LEAST8_MAX |
514 | # define __UINT_LEAST8_MAX UINT64_MAX |
515 | #endif /* __STDC_VERSION__ */ |
516 | |
517 | # define __INT_LEAST64_MIN INT64_MIN |
518 | # define __INT_LEAST64_MAX INT64_MAX |
519 | # define __UINT_LEAST64_MAX UINT64_MAX |
520 | # undef __INT_LEAST32_MIN |
521 | # define __INT_LEAST32_MIN INT64_MIN |
522 | # undef __INT_LEAST32_MAX |
523 | # define __INT_LEAST32_MAX INT64_MAX |
524 | # undef __UINT_LEAST32_MAX |
525 | # define __UINT_LEAST32_MAX UINT64_MAX |
526 | # undef __INT_LEAST16_MIN |
527 | # define __INT_LEAST16_MIN INT64_MIN |
528 | # undef __INT_LEAST16_MAX |
529 | # define __INT_LEAST16_MAX INT64_MAX |
530 | # undef __UINT_LEAST16_MAX |
531 | # define __UINT_LEAST16_MAX UINT64_MAX |
532 | # undef __INT_LEAST8_MIN |
533 | # define __INT_LEAST8_MIN INT64_MIN |
534 | # undef __INT_LEAST8_MAX |
535 | # define __INT_LEAST8_MAX INT64_MAX |
536 | # undef __UINT_LEAST8_MAX |
537 | # define __UINT_LEAST8_MAX UINT64_MAX |
538 | #endif /* __INT64_TYPE__ */ |
539 | |
540 | #ifdef __INT_LEAST64_MIN |
541 | # define INT_LEAST64_MIN __INT_LEAST64_MIN |
542 | # define INT_LEAST64_MAX __INT_LEAST64_MAX |
543 | # define UINT_LEAST64_MAX __UINT_LEAST64_MAX |
544 | # define INT_FAST64_MIN __INT_LEAST64_MIN |
545 | # define INT_FAST64_MAX __INT_LEAST64_MAX |
546 | # define UINT_FAST64_MAX __UINT_LEAST64_MAX |
547 | |
548 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
549 | in C2x mode; switch to the correct values once they've been published. */ |
550 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
551 | # define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH |
552 | # define INT_LEAST64_WIDTH UINT_LEAST64_WIDTH |
553 | # define UINT_FAST64_WIDTH __UINT_LEAST64_WIDTH |
554 | # define INT_FAST64_WIDTH UINT_FAST64_WIDTH |
555 | #endif /* __STDC_VERSION__ */ |
556 | #endif /* __INT_LEAST64_MIN */ |
557 | |
558 | |
559 | #ifdef __INT56_TYPE__ |
560 | # define INT56_MAX INT56_C(36028797018963967) |
561 | # define INT56_MIN (-INT56_C(36028797018963967)-1) |
562 | # define UINT56_MAX UINT56_C(72057594037927935) |
563 | # define INT_LEAST56_MIN INT56_MIN |
564 | # define INT_LEAST56_MAX INT56_MAX |
565 | # define UINT_LEAST56_MAX UINT56_MAX |
566 | # define INT_FAST56_MIN INT56_MIN |
567 | # define INT_FAST56_MAX INT56_MAX |
568 | # define UINT_FAST56_MAX UINT56_MAX |
569 | |
570 | # undef __INT_LEAST32_MIN |
571 | # define __INT_LEAST32_MIN INT56_MIN |
572 | # undef __INT_LEAST32_MAX |
573 | # define __INT_LEAST32_MAX INT56_MAX |
574 | # undef __UINT_LEAST32_MAX |
575 | # define __UINT_LEAST32_MAX UINT56_MAX |
576 | # undef __INT_LEAST16_MIN |
577 | # define __INT_LEAST16_MIN INT56_MIN |
578 | # undef __INT_LEAST16_MAX |
579 | # define __INT_LEAST16_MAX INT56_MAX |
580 | # undef __UINT_LEAST16_MAX |
581 | # define __UINT_LEAST16_MAX UINT56_MAX |
582 | # undef __INT_LEAST8_MIN |
583 | # define __INT_LEAST8_MIN INT56_MIN |
584 | # undef __INT_LEAST8_MAX |
585 | # define __INT_LEAST8_MAX INT56_MAX |
586 | # undef __UINT_LEAST8_MAX |
587 | # define __UINT_LEAST8_MAX UINT56_MAX |
588 | |
589 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
590 | in C2x mode; switch to the correct values once they've been published. */ |
591 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
592 | # define UINT56_WIDTH 56 |
593 | # define INT56_WIDTH UINT56_WIDTH |
594 | # define UINT_LEAST56_WIDTH UINT56_WIDTH |
595 | # define INT_LEAST56_WIDTH UINT_LEAST56_WIDTH |
596 | # define UINT_FAST56_WIDTH UINT56_WIDTH |
597 | # define INT_FAST56_WIDTH UINT_FAST56_WIDTH |
598 | # undef __UINT_LEAST32_WIDTH |
599 | # define __UINT_LEAST32_WIDTH UINT56_WIDTH |
600 | # undef __UINT_LEAST16_WIDTH |
601 | # define __UINT_LEAST16_WIDTH UINT56_WIDTH |
602 | # undef __UINT_LEAST8_WIDTH |
603 | # define __UINT_LEAST8_WIDTH UINT56_WIDTH |
604 | #endif /* __STDC_VERSION__ */ |
605 | #endif /* __INT56_TYPE__ */ |
606 | |
607 | |
608 | #ifdef __INT48_TYPE__ |
609 | # define INT48_MAX INT48_C(140737488355327) |
610 | # define INT48_MIN (-INT48_C(140737488355327)-1) |
611 | # define UINT48_MAX UINT48_C(281474976710655) |
612 | # define INT_LEAST48_MIN INT48_MIN |
613 | # define INT_LEAST48_MAX INT48_MAX |
614 | # define UINT_LEAST48_MAX UINT48_MAX |
615 | # define INT_FAST48_MIN INT48_MIN |
616 | # define INT_FAST48_MAX INT48_MAX |
617 | # define UINT_FAST48_MAX UINT48_MAX |
618 | |
619 | # undef __INT_LEAST32_MIN |
620 | # define __INT_LEAST32_MIN INT48_MIN |
621 | # undef __INT_LEAST32_MAX |
622 | # define __INT_LEAST32_MAX INT48_MAX |
623 | # undef __UINT_LEAST32_MAX |
624 | # define __UINT_LEAST32_MAX UINT48_MAX |
625 | # undef __INT_LEAST16_MIN |
626 | # define __INT_LEAST16_MIN INT48_MIN |
627 | # undef __INT_LEAST16_MAX |
628 | # define __INT_LEAST16_MAX INT48_MAX |
629 | # undef __UINT_LEAST16_MAX |
630 | # define __UINT_LEAST16_MAX UINT48_MAX |
631 | # undef __INT_LEAST8_MIN |
632 | # define __INT_LEAST8_MIN INT48_MIN |
633 | # undef __INT_LEAST8_MAX |
634 | # define __INT_LEAST8_MAX INT48_MAX |
635 | # undef __UINT_LEAST8_MAX |
636 | # define __UINT_LEAST8_MAX UINT48_MAX |
637 | |
638 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
639 | in C2x mode; switch to the correct values once they've been published. */ |
640 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
641 | #define UINT48_WIDTH 48 |
642 | #define INT48_WIDTH UINT48_WIDTH |
643 | #define UINT_LEAST48_WIDTH UINT48_WIDTH |
644 | #define INT_LEAST48_WIDTH UINT_LEAST48_WIDTH |
645 | #define UINT_FAST48_WIDTH UINT48_WIDTH |
646 | #define INT_FAST48_WIDTH UINT_FAST48_WIDTH |
647 | #undef __UINT_LEAST32_WIDTH |
648 | #define __UINT_LEAST32_WIDTH UINT48_WIDTH |
649 | # undef __UINT_LEAST16_WIDTH |
650 | #define __UINT_LEAST16_WIDTH UINT48_WIDTH |
651 | # undef __UINT_LEAST8_WIDTH |
652 | #define __UINT_LEAST8_WIDTH UINT48_WIDTH |
653 | #endif /* __STDC_VERSION__ */ |
654 | #endif /* __INT48_TYPE__ */ |
655 | |
656 | |
657 | #ifdef __INT40_TYPE__ |
658 | # define INT40_MAX INT40_C(549755813887) |
659 | # define INT40_MIN (-INT40_C(549755813887)-1) |
660 | # define UINT40_MAX UINT40_C(1099511627775) |
661 | # define INT_LEAST40_MIN INT40_MIN |
662 | # define INT_LEAST40_MAX INT40_MAX |
663 | # define UINT_LEAST40_MAX UINT40_MAX |
664 | # define INT_FAST40_MIN INT40_MIN |
665 | # define INT_FAST40_MAX INT40_MAX |
666 | # define UINT_FAST40_MAX UINT40_MAX |
667 | |
668 | # undef __INT_LEAST32_MIN |
669 | # define __INT_LEAST32_MIN INT40_MIN |
670 | # undef __INT_LEAST32_MAX |
671 | # define __INT_LEAST32_MAX INT40_MAX |
672 | # undef __UINT_LEAST32_MAX |
673 | # define __UINT_LEAST32_MAX UINT40_MAX |
674 | # undef __INT_LEAST16_MIN |
675 | # define __INT_LEAST16_MIN INT40_MIN |
676 | # undef __INT_LEAST16_MAX |
677 | # define __INT_LEAST16_MAX INT40_MAX |
678 | # undef __UINT_LEAST16_MAX |
679 | # define __UINT_LEAST16_MAX UINT40_MAX |
680 | # undef __INT_LEAST8_MIN |
681 | # define __INT_LEAST8_MIN INT40_MIN |
682 | # undef __INT_LEAST8_MAX |
683 | # define __INT_LEAST8_MAX INT40_MAX |
684 | # undef __UINT_LEAST8_MAX |
685 | # define __UINT_LEAST8_MAX UINT40_MAX |
686 | |
687 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
688 | in C2x mode; switch to the correct values once they've been published. */ |
689 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
690 | # define UINT40_WIDTH 40 |
691 | # define INT40_WIDTH UINT40_WIDTH |
692 | # define UINT_LEAST40_WIDTH UINT40_WIDTH |
693 | # define INT_LEAST40_WIDTH UINT_LEAST40_WIDTH |
694 | # define UINT_FAST40_WIDTH UINT40_WIDTH |
695 | # define INT_FAST40_WIDTH UINT_FAST40_WIDTH |
696 | # undef __UINT_LEAST32_WIDTH |
697 | # define __UINT_LEAST32_WIDTH UINT40_WIDTH |
698 | # undef __UINT_LEAST16_WIDTH |
699 | # define __UINT_LEAST16_WIDTH UINT40_WIDTH |
700 | # undef __UINT_LEAST8_WIDTH |
701 | # define __UINT_LEAST8_WIDTH UINT40_WIDTH |
702 | #endif /* __STDC_VERSION__ */ |
703 | #endif /* __INT40_TYPE__ */ |
704 | |
705 | |
706 | #ifdef __INT32_TYPE__ |
707 | # define INT32_MAX INT32_C(2147483647) |
708 | # define INT32_MIN (-INT32_C(2147483647)-1) |
709 | # define UINT32_MAX UINT32_C(4294967295) |
710 | |
711 | # undef __INT_LEAST32_MIN |
712 | # define __INT_LEAST32_MIN INT32_MIN |
713 | # undef __INT_LEAST32_MAX |
714 | # define __INT_LEAST32_MAX INT32_MAX |
715 | # undef __UINT_LEAST32_MAX |
716 | # define __UINT_LEAST32_MAX UINT32_MAX |
717 | # undef __INT_LEAST16_MIN |
718 | # define __INT_LEAST16_MIN INT32_MIN |
719 | # undef __INT_LEAST16_MAX |
720 | # define __INT_LEAST16_MAX INT32_MAX |
721 | # undef __UINT_LEAST16_MAX |
722 | # define __UINT_LEAST16_MAX UINT32_MAX |
723 | # undef __INT_LEAST8_MIN |
724 | # define __INT_LEAST8_MIN INT32_MIN |
725 | # undef __INT_LEAST8_MAX |
726 | # define __INT_LEAST8_MAX INT32_MAX |
727 | # undef __UINT_LEAST8_MAX |
728 | # define __UINT_LEAST8_MAX UINT32_MAX |
729 | |
730 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
731 | in C2x mode; switch to the correct values once they've been published. */ |
732 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
733 | # define UINT32_WIDTH 32 |
734 | # define INT32_WIDTH UINT32_WIDTH |
735 | # undef __UINT_LEAST32_WIDTH |
736 | # define __UINT_LEAST32_WIDTH UINT32_WIDTH |
737 | # undef __UINT_LEAST16_WIDTH |
738 | # define __UINT_LEAST16_WIDTH UINT32_WIDTH |
739 | # undef __UINT_LEAST8_WIDTH |
740 | # define __UINT_LEAST8_WIDTH UINT32_WIDTH |
741 | #endif /* __STDC_VERSION__ */ |
742 | #endif /* __INT32_TYPE__ */ |
743 | |
744 | #ifdef __INT_LEAST32_MIN |
745 | # define INT_LEAST32_MIN __INT_LEAST32_MIN |
746 | # define INT_LEAST32_MAX __INT_LEAST32_MAX |
747 | # define UINT_LEAST32_MAX __UINT_LEAST32_MAX |
748 | # define INT_FAST32_MIN __INT_LEAST32_MIN |
749 | # define INT_FAST32_MAX __INT_LEAST32_MAX |
750 | # define UINT_FAST32_MAX __UINT_LEAST32_MAX |
751 | |
752 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
753 | in C2x mode; switch to the correct values once they've been published. */ |
754 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
755 | # define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH |
756 | # define INT_LEAST32_WIDTH UINT_LEAST32_WIDTH |
757 | # define UINT_FAST32_WIDTH __UINT_LEAST32_WIDTH |
758 | # define INT_FAST32_WIDTH UINT_FAST32_WIDTH |
759 | #endif /* __STDC_VERSION__ */ |
760 | #endif /* __INT_LEAST32_MIN */ |
761 | |
762 | |
763 | #ifdef __INT24_TYPE__ |
764 | # define INT24_MAX INT24_C(8388607) |
765 | # define INT24_MIN (-INT24_C(8388607)-1) |
766 | # define UINT24_MAX UINT24_C(16777215) |
767 | # define INT_LEAST24_MIN INT24_MIN |
768 | # define INT_LEAST24_MAX INT24_MAX |
769 | # define UINT_LEAST24_MAX UINT24_MAX |
770 | # define INT_FAST24_MIN INT24_MIN |
771 | # define INT_FAST24_MAX INT24_MAX |
772 | # define UINT_FAST24_MAX UINT24_MAX |
773 | |
774 | # undef __INT_LEAST16_MIN |
775 | # define __INT_LEAST16_MIN INT24_MIN |
776 | # undef __INT_LEAST16_MAX |
777 | # define __INT_LEAST16_MAX INT24_MAX |
778 | # undef __UINT_LEAST16_MAX |
779 | # define __UINT_LEAST16_MAX UINT24_MAX |
780 | # undef __INT_LEAST8_MIN |
781 | # define __INT_LEAST8_MIN INT24_MIN |
782 | # undef __INT_LEAST8_MAX |
783 | # define __INT_LEAST8_MAX INT24_MAX |
784 | # undef __UINT_LEAST8_MAX |
785 | # define __UINT_LEAST8_MAX UINT24_MAX |
786 | |
787 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
788 | in C2x mode; switch to the correct values once they've been published. */ |
789 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
790 | # define UINT24_WIDTH 24 |
791 | # define INT24_WIDTH UINT24_WIDTH |
792 | # define UINT_LEAST24_WIDTH UINT24_WIDTH |
793 | # define INT_LEAST24_WIDTH UINT_LEAST24_WIDTH |
794 | # define UINT_FAST24_WIDTH UINT24_WIDTH |
795 | # define INT_FAST24_WIDTH UINT_FAST24_WIDTH |
796 | # undef __UINT_LEAST16_WIDTH |
797 | # define __UINT_LEAST16_WIDTH UINT24_WIDTH |
798 | # undef __UINT_LEAST8_WIDTH |
799 | # define __UINT_LEAST8_WIDTH UINT24_WIDTH |
800 | #endif /* __STDC_VERSION__ */ |
801 | #endif /* __INT24_TYPE__ */ |
802 | |
803 | |
804 | #ifdef __INT16_TYPE__ |
805 | #define INT16_MAX INT16_C(32767) |
806 | #define INT16_MIN (-INT16_C(32767)-1) |
807 | #define UINT16_MAX UINT16_C(65535) |
808 | |
809 | # undef __INT_LEAST16_MIN |
810 | # define __INT_LEAST16_MIN INT16_MIN |
811 | # undef __INT_LEAST16_MAX |
812 | # define __INT_LEAST16_MAX INT16_MAX |
813 | # undef __UINT_LEAST16_MAX |
814 | # define __UINT_LEAST16_MAX UINT16_MAX |
815 | # undef __INT_LEAST8_MIN |
816 | # define __INT_LEAST8_MIN INT16_MIN |
817 | # undef __INT_LEAST8_MAX |
818 | # define __INT_LEAST8_MAX INT16_MAX |
819 | # undef __UINT_LEAST8_MAX |
820 | # define __UINT_LEAST8_MAX UINT16_MAX |
821 | |
822 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
823 | in C2x mode; switch to the correct values once they've been published. */ |
824 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
825 | # define UINT16_WIDTH 16 |
826 | # define INT16_WIDTH UINT16_WIDTH |
827 | # undef __UINT_LEAST16_WIDTH |
828 | # define __UINT_LEAST16_WIDTH UINT16_WIDTH |
829 | # undef __UINT_LEAST8_WIDTH |
830 | # define __UINT_LEAST8_WIDTH UINT16_WIDTH |
831 | #endif /* __STDC_VERSION__ */ |
832 | #endif /* __INT16_TYPE__ */ |
833 | |
834 | #ifdef __INT_LEAST16_MIN |
835 | # define INT_LEAST16_MIN __INT_LEAST16_MIN |
836 | # define INT_LEAST16_MAX __INT_LEAST16_MAX |
837 | # define UINT_LEAST16_MAX __UINT_LEAST16_MAX |
838 | # define INT_FAST16_MIN __INT_LEAST16_MIN |
839 | # define INT_FAST16_MAX __INT_LEAST16_MAX |
840 | # define UINT_FAST16_MAX __UINT_LEAST16_MAX |
841 | |
842 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
843 | in C2x mode; switch to the correct values once they've been published. */ |
844 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
845 | # define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH |
846 | # define INT_LEAST16_WIDTH UINT_LEAST16_WIDTH |
847 | # define UINT_FAST16_WIDTH __UINT_LEAST16_WIDTH |
848 | # define INT_FAST16_WIDTH UINT_FAST16_WIDTH |
849 | #endif /* __STDC_VERSION__ */ |
850 | #endif /* __INT_LEAST16_MIN */ |
851 | |
852 | |
853 | #ifdef __INT8_TYPE__ |
854 | # define INT8_MAX INT8_C(127) |
855 | # define INT8_MIN (-INT8_C(127)-1) |
856 | # define UINT8_MAX UINT8_C(255) |
857 | |
858 | # undef __INT_LEAST8_MIN |
859 | # define __INT_LEAST8_MIN INT8_MIN |
860 | # undef __INT_LEAST8_MAX |
861 | # define __INT_LEAST8_MAX INT8_MAX |
862 | # undef __UINT_LEAST8_MAX |
863 | # define __UINT_LEAST8_MAX UINT8_MAX |
864 | |
865 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
866 | in C2x mode; switch to the correct values once they've been published. */ |
867 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
868 | # define UINT8_WIDTH 8 |
869 | # define INT8_WIDTH UINT8_WIDTH |
870 | # undef __UINT_LEAST8_WIDTH |
871 | # define __UINT_LEAST8_WIDTH UINT8_WIDTH |
872 | #endif /* __STDC_VERSION__ */ |
873 | #endif /* __INT8_TYPE__ */ |
874 | |
875 | #ifdef __INT_LEAST8_MIN |
876 | # define INT_LEAST8_MIN __INT_LEAST8_MIN |
877 | # define INT_LEAST8_MAX __INT_LEAST8_MAX |
878 | # define UINT_LEAST8_MAX __UINT_LEAST8_MAX |
879 | # define INT_FAST8_MIN __INT_LEAST8_MIN |
880 | # define INT_FAST8_MAX __INT_LEAST8_MAX |
881 | # define UINT_FAST8_MAX __UINT_LEAST8_MAX |
882 | |
883 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
884 | in C2x mode; switch to the correct values once they've been published. */ |
885 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
886 | # define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH |
887 | # define INT_LEAST8_WIDTH UINT_LEAST8_WIDTH |
888 | # define UINT_FAST8_WIDTH __UINT_LEAST8_WIDTH |
889 | # define INT_FAST8_WIDTH UINT_FAST8_WIDTH |
890 | #endif /* __STDC_VERSION__ */ |
891 | #endif /* __INT_LEAST8_MIN */ |
892 | |
893 | /* Some utility macros */ |
894 | #define __INTN_MIN(n) __stdint_join3( INT, n, _MIN) |
895 | #define __INTN_MAX(n) __stdint_join3( INT, n, _MAX) |
896 | #define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX) |
897 | #define __INTN_C(n, v) __stdint_join3( INT, n, _C(v)) |
898 | #define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v)) |
899 | |
900 | /* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ |
901 | /* C99 7.18.3 Limits of other integer types. */ |
902 | |
903 | #define INTPTR_MIN (-__INTPTR_MAX__-1) |
904 | #define INTPTR_MAX __INTPTR_MAX__ |
905 | #define UINTPTR_MAX __UINTPTR_MAX__ |
906 | #define PTRDIFF_MIN (-__PTRDIFF_MAX__-1) |
907 | #define PTRDIFF_MAX __PTRDIFF_MAX__ |
908 | #define SIZE_MAX __SIZE_MAX__ |
909 | |
910 | /* C2x 7.20.2.4 Width of integer types capable of holding object pointers. */ |
911 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
912 | in C2x mode; switch to the correct values once they've been published. */ |
913 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
914 | /* NB: The C standard requires that these be the same value, but the compiler |
915 | exposes separate internal width macros. */ |
916 | #define INTPTR_WIDTH __INTPTR_WIDTH__ |
917 | #define UINTPTR_WIDTH __UINTPTR_WIDTH__ |
918 | #endif |
919 | |
920 | /* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ |
921 | * is enabled. */ |
922 | #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 |
923 | #define RSIZE_MAX (SIZE_MAX >> 1) |
924 | #endif |
925 | |
926 | /* C99 7.18.2.5 Limits of greatest-width integer types. */ |
927 | #define INTMAX_MIN (-__INTMAX_MAX__-1) |
928 | #define INTMAX_MAX __INTMAX_MAX__ |
929 | #define UINTMAX_MAX __UINTMAX_MAX__ |
930 | |
931 | /* C2x 7.20.2.5 Width of greatest-width integer types. */ |
932 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
933 | in C2x mode; switch to the correct values once they've been published. */ |
934 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
935 | /* NB: The C standard requires that these be the same value, but the compiler |
936 | exposes separate internal width macros. */ |
937 | #define INTMAX_WIDTH __INTMAX_WIDTH__ |
938 | #define UINTMAX_WIDTH __UINTMAX_WIDTH__ |
939 | #endif |
940 | |
941 | /* C99 7.18.3 Limits of other integer types. */ |
942 | #define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__) |
943 | #define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__) |
944 | #ifdef __WINT_UNSIGNED__ |
945 | # define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0) |
946 | # define WINT_MAX __UINTN_MAX(__WINT_WIDTH__) |
947 | #else |
948 | # define WINT_MIN __INTN_MIN(__WINT_WIDTH__) |
949 | # define WINT_MAX __INTN_MAX(__WINT_WIDTH__) |
950 | #endif |
951 | |
952 | #ifndef WCHAR_MAX |
953 | # define WCHAR_MAX __WCHAR_MAX__ |
954 | #endif |
955 | #ifndef WCHAR_MIN |
956 | # if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__) |
957 | # define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__) |
958 | # else |
959 | # define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0) |
960 | # endif |
961 | #endif |
962 | |
963 | /* 7.18.4.2 Macros for greatest-width integer constants. */ |
964 | #define INTMAX_C(v) __int_c(v, __INTMAX_C_SUFFIX__) |
965 | #define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__) |
966 | |
967 | /* C2x 7.20.3.x Width of other integer types. */ |
968 | /* FIXME: This is using the placeholder dates Clang produces for these macros |
969 | in C2x mode; switch to the correct values once they've been published. */ |
970 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L |
971 | #define PTRDIFF_WIDTH __PTRDIFF_WIDTH__ |
972 | #define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__ |
973 | #define SIZE_WIDTH __SIZE_WIDTH__ |
974 | #define WCHAR_WIDTH __WCHAR_WIDTH__ |
975 | #define WINT_WIDTH __WINT_WIDTH__ |
976 | #endif |
977 | |
978 | #endif /* __STDC_HOSTED__ */ |
979 | #endif /* __CLANG_STDINT_H */ |
980 | |