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 # define __int_least64_t int64_t
100 # define __uint_least64_t uint64_t
101 # define __int_least32_t int64_t
102 # define __uint_least32_t uint64_t
103 # define __int_least16_t int64_t
104 # define __uint_least16_t uint64_t
105 # define __int_least8_t int64_t
106 # define __uint_least8_t uint64_t
107 #endif /* __INT64_TYPE__ */
108 
109 #ifdef __int_least64_t
110 typedef __int_least64_t int_least64_t;
111 typedef __uint_least64_t uint_least64_t;
112 typedef __int_least64_t int_fast64_t;
113 typedef __uint_least64_t uint_fast64_t;
114 #endif /* __int_least64_t */
115 
116 #ifdef __INT56_TYPE__
117 typedef __INT56_TYPE__ int56_t;
118 typedef __UINT56_TYPE__ uint56_t;
119 typedef int56_t int_least56_t;
120 typedef uint56_t uint_least56_t;
121 typedef int56_t int_fast56_t;
122 typedef uint56_t uint_fast56_t;
123 # define __int_least32_t int56_t
124 # define __uint_least32_t uint56_t
125 # define __int_least16_t int56_t
126 # define __uint_least16_t uint56_t
127 # define __int_least8_t int56_t
128 # define __uint_least8_t uint56_t
129 #endif /* __INT56_TYPE__ */
130 
131 
132 #ifdef __INT48_TYPE__
133 typedef __INT48_TYPE__ int48_t;
134 typedef __UINT48_TYPE__ uint48_t;
135 typedef int48_t int_least48_t;
136 typedef uint48_t uint_least48_t;
137 typedef int48_t int_fast48_t;
138 typedef uint48_t uint_fast48_t;
139 # define __int_least32_t int48_t
140 # define __uint_least32_t uint48_t
141 # define __int_least16_t int48_t
142 # define __uint_least16_t uint48_t
143 # define __int_least8_t int48_t
144 # define __uint_least8_t uint48_t
145 #endif /* __INT48_TYPE__ */
146 
147 
148 #ifdef __INT40_TYPE__
149 typedef __INT40_TYPE__ int40_t;
150 typedef __UINT40_TYPE__ uint40_t;
151 typedef int40_t int_least40_t;
152 typedef uint40_t uint_least40_t;
153 typedef int40_t int_fast40_t;
154 typedef uint40_t uint_fast40_t;
155 # define __int_least32_t int40_t
156 # define __uint_least32_t uint40_t
157 # define __int_least16_t int40_t
158 # define __uint_least16_t uint40_t
159 # define __int_least8_t int40_t
160 # define __uint_least8_t uint40_t
161 #endif /* __INT40_TYPE__ */
162 
163 
164 #ifdef __INT32_TYPE__
165 
166 # ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/
167 typedef __INT32_TYPE__ int32_t;
168 # endif /* __int8_t_defined */
169 
170 # ifndef __uint32_t_defined  /* more glibc compatibility */
171 # define __uint32_t_defined
172 typedef __UINT32_TYPE__ uint32_t;
173 # endif /* __uint32_t_defined */
174 
175 # define __int_least32_t int32_t
176 # define __uint_least32_t uint32_t
177 # define __int_least16_t int32_t
178 # define __uint_least16_t uint32_t
179 # define __int_least8_t int32_t
180 # define __uint_least8_t uint32_t
181 #endif /* __INT32_TYPE__ */
182 
183 #ifdef __int_least32_t
184 typedef __int_least32_t int_least32_t;
185 typedef __uint_least32_t uint_least32_t;
186 typedef __int_least32_t int_fast32_t;
187 typedef __uint_least32_t uint_fast32_t;
188 #endif /* __int_least32_t */
189 
190 #ifdef __INT24_TYPE__
191 typedef __INT24_TYPE__ int24_t;
192 typedef __UINT24_TYPE__ uint24_t;
193 typedef int24_t int_least24_t;
194 typedef uint24_t uint_least24_t;
195 typedef int24_t int_fast24_t;
196 typedef uint24_t uint_fast24_t;
197 # define __int_least16_t int24_t
198 # define __uint_least16_t uint24_t
199 # define __int_least8_t int24_t
200 # define __uint_least8_t uint24_t
201 #endif /* __INT24_TYPE__ */
202 
203 #ifdef __INT16_TYPE__
204 #ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/
205 typedef __INT16_TYPE__ int16_t;
206 #endif /* __int8_t_defined */
207 typedef __UINT16_TYPE__ uint16_t;
208 # define __int_least16_t int16_t
209 # define __uint_least16_t uint16_t
210 # define __int_least8_t int16_t
211 # define __uint_least8_t uint16_t
212 #endif /* __INT16_TYPE__ */
213 
214 #ifdef __int_least16_t
215 typedef __int_least16_t int_least16_t;
216 typedef __uint_least16_t uint_least16_t;
217 typedef __int_least16_t int_fast16_t;
218 typedef __uint_least16_t uint_fast16_t;
219 #endif /* __int_least16_t */
220 
221 
222 #ifdef __INT8_TYPE__
223 #ifndef __int8_t_defined  /* glibc sys/types.h also defines int8_t*/
224 typedef __INT8_TYPE__ int8_t;
225 #endif /* __int8_t_defined */
226 typedef __UINT8_TYPE__ uint8_t;
227 # define __int_least8_t int8_t
228 # define __uint_least8_t uint8_t
229 #endif /* __INT8_TYPE__ */
230 
231 #ifdef __int_least8_t
232 typedef __int_least8_t int_least8_t;
233 typedef __uint_least8_t uint_least8_t;
234 typedef __int_least8_t int_fast8_t;
235 typedef __uint_least8_t uint_fast8_t;
236 #endif /* __int_least8_t */
237 
238 /* prevent glibc sys/types.h from defining conflicting types */
239 #ifndef __int8_t_defined
240 # define __int8_t_defined
241 #endif /* __int8_t_defined */
242 
243 /* C99 7.18.1.4 Integer types capable of holding object pointers.
244  */
245 #define __stdint_join3(a,b,c) a ## b ## c
246 
247 #ifndef _INTPTR_T
248 #ifndef __intptr_t_defined
249 typedef __INTPTR_TYPE__ intptr_t;
250 #define __intptr_t_defined
251 #define _INTPTR_T
252 #endif
253 #endif
254 
255 #ifndef _UINTPTR_T
256 typedef __UINTPTR_TYPE__ uintptr_t;
257 #define _UINTPTR_T
258 #endif
259 
260 /* C99 7.18.1.5 Greatest-width integer types.
261  */
262 typedef __INTMAX_TYPE__  intmax_t;
263 typedef __UINTMAX_TYPE__ uintmax_t;
264 
265 /* C99 7.18.4 Macros for minimum-width integer constants.
266  *
267  * The standard requires that integer constant macros be defined for all the
268  * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width
269  * types are required, the corresponding integer constant macros are defined
270  * here. This implementation also defines minimum-width types for every other
271  * integer width that the target implements, so corresponding macros are
272  * defined below, too.
273  *
274  * These macros are defined using the same successive-shrinking approach as
275  * the type definitions above. It is likewise important that macros are defined
276  * in order of decending width.
277  *
278  * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the
279  * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
280  */
281 
282 #define __int_c_join(a, b) a ## b
283 #define __int_c(v, suffix) __int_c_join(v, suffix)
284 #define __uint_c(v, suffix) __int_c_join(v##U, suffix)
285 
286 
287 #ifdef __INT64_TYPE__
288 # ifdef __INT64_C_SUFFIX__
289 #  define __int64_c_suffix __INT64_C_SUFFIX__
290 #  define __int32_c_suffix __INT64_C_SUFFIX__
291 #  define __int16_c_suffix __INT64_C_SUFFIX__
292 #  define  __int8_c_suffix __INT64_C_SUFFIX__
293 # else
294 #  undef __int64_c_suffix
295 #  undef __int32_c_suffix
296 #  undef __int16_c_suffix
297 #  undef  __int8_c_suffix
298 # endif /* __INT64_C_SUFFIX__ */
299 #endif /* __INT64_TYPE__ */
300 
301 #ifdef __int_least64_t
302 # ifdef __int64_c_suffix
303 #  define INT64_C(v) __int_c(v, __int64_c_suffix)
304 #  define UINT64_C(v) __uint_c(v, __int64_c_suffix)
305 # else
306 #  define INT64_C(v) v
307 #  define UINT64_C(v) v ## U
308 # endif /* __int64_c_suffix */
309 #endif /* __int_least64_t */
310 
311 
312 #ifdef __INT56_TYPE__
313 # ifdef __INT56_C_SUFFIX__
314 #  define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__)
315 #  define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__)
316 #  define __int32_c_suffix __INT56_C_SUFFIX__
317 #  define __int16_c_suffix __INT56_C_SUFFIX__
318 #  define __int8_c_suffix  __INT56_C_SUFFIX__
319 # else
320 #  define INT56_C(v) v
321 #  define UINT56_C(v) v ## U
322 #  undef __int32_c_suffix
323 #  undef __int16_c_suffix
324 #  undef  __int8_c_suffix
325 # endif /* __INT56_C_SUFFIX__ */
326 #endif /* __INT56_TYPE__ */
327 
328 
329 #ifdef __INT48_TYPE__
330 # ifdef __INT48_C_SUFFIX__
331 #  define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__)
332 #  define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__)
333 #  define __int32_c_suffix __INT48_C_SUFFIX__
334 #  define __int16_c_suffix __INT48_C_SUFFIX__
335 #  define __int8_c_suffix  __INT48_C_SUFFIX__
336 # else
337 #  define INT48_C(v) v
338 #  define UINT48_C(v) v ## U
339 #  undef __int32_c_suffix
340 #  undef __int16_c_suffix
341 #  undef  __int8_c_suffix
342 # endif /* __INT48_C_SUFFIX__ */
343 #endif /* __INT48_TYPE__ */
344 
345 
346 #ifdef __INT40_TYPE__
347 # ifdef __INT40_C_SUFFIX__
348 #  define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__)
349 #  define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__)
350 #  define __int32_c_suffix __INT40_C_SUFFIX__
351 #  define __int16_c_suffix __INT40_C_SUFFIX__
352 #  define __int8_c_suffix  __INT40_C_SUFFIX__
353 # else
354 #  define INT40_C(v) v
355 #  define UINT40_C(v) v ## U
356 #  undef __int32_c_suffix
357 #  undef __int16_c_suffix
358 #  undef  __int8_c_suffix
359 # endif /* __INT40_C_SUFFIX__ */
360 #endif /* __INT40_TYPE__ */
361 
362 
363 #ifdef __INT32_TYPE__
364 # ifdef __INT32_C_SUFFIX__
365 #  define __int32_c_suffix __INT32_C_SUFFIX__
366 #  define __int16_c_suffix __INT32_C_SUFFIX__
367 #  define __int8_c_suffix  __INT32_C_SUFFIX__
368 #else
369 #  undef __int32_c_suffix
370 #  undef __int16_c_suffix
371 #  undef  __int8_c_suffix
372 # endif /* __INT32_C_SUFFIX__ */
373 #endif /* __INT32_TYPE__ */
374 
375 #ifdef __int_least32_t
376 # ifdef __int32_c_suffix
377 #  define INT32_C(v) __int_c(v, __int32_c_suffix)
378 #  define UINT32_C(v) __uint_c(v, __int32_c_suffix)
379 # else
380 #  define INT32_C(v) v
381 #  define UINT32_C(v) v ## U
382 # endif /* __int32_c_suffix */
383 #endif /* __int_least32_t */
384 
385 
386 #ifdef __INT24_TYPE__
387 # ifdef __INT24_C_SUFFIX__
388 #  define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__)
389 #  define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__)
390 #  define __int16_c_suffix __INT24_C_SUFFIX__
391 #  define __int8_c_suffix  __INT24_C_SUFFIX__
392 # else
393 #  define INT24_C(v) v
394 #  define UINT24_C(v) v ## U
395 #  undef __int16_c_suffix
396 #  undef  __int8_c_suffix
397 # endif /* __INT24_C_SUFFIX__ */
398 #endif /* __INT24_TYPE__ */
399 
400 
401 #ifdef __INT16_TYPE__
402 # ifdef __INT16_C_SUFFIX__
403 #  define __int16_c_suffix __INT16_C_SUFFIX__
404 #  define __int8_c_suffix  __INT16_C_SUFFIX__
405 #else
406 #  undef __int16_c_suffix
407 #  undef  __int8_c_suffix
408 # endif /* __INT16_C_SUFFIX__ */
409 #endif /* __INT16_TYPE__ */
410 
411 #ifdef __int_least16_t
412 # ifdef __int16_c_suffix
413 #  define INT16_C(v) __int_c(v, __int16_c_suffix)
414 #  define UINT16_C(v) __uint_c(v, __int16_c_suffix)
415 # else
416 #  define INT16_C(v) v
417 #  define UINT16_C(v) v ## U
418 # endif /* __int16_c_suffix */
419 #endif /* __int_least16_t */
420 
421 
422 #ifdef __INT8_TYPE__
423 # ifdef __INT8_C_SUFFIX__
424 #  define __int8_c_suffix __INT8_C_SUFFIX__
425 #else
426 #  undef  __int8_c_suffix
427 # endif /* __INT8_C_SUFFIX__ */
428 #endif /* __INT8_TYPE__ */
429 
430 #ifdef __int_least8_t
431 # ifdef __int8_c_suffix
432 #  define INT8_C(v) __int_c(v, __int8_c_suffix)
433 #  define UINT8_C(v) __uint_c(v, __int8_c_suffix)
434 # else
435 #  define INT8_C(v) v
436 #  define UINT8_C(v) v ## U
437 # endif /* __int8_c_suffix */
438 #endif /* __int_least8_t */
439 
440 
441 /* C99 7.18.2.1 Limits of exact-width integer types.
442  * C99 7.18.2.2 Limits of minimum-width integer types.
443  * C99 7.18.2.3 Limits of fastest minimum-width integer types.
444  *
445  * The presence of limit macros are completely optional in C99.  This
446  * implementation defines limits for all of the types (exact- and
447  * minimum-width) that it defines above, using the limits of the minimum-width
448  * type for any types that do not have exact-width representations.
449  *
450  * As in the type definitions, this section takes an approach of
451  * successive-shrinking to determine which limits to use for the standard (8,
452  * 16, 32, 64) bit widths when they don't have exact representations. It is
453  * therefore important that the definitions be kept in order of decending
454  * widths.
455  *
456  * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the
457  * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
458  */
459 
460 #ifdef __INT64_TYPE__
461 # define INT64_MAX           INT64_C( 9223372036854775807)
462 # define INT64_MIN         (-INT64_C( 9223372036854775807)-1)
463 # define UINT64_MAX         UINT64_C(18446744073709551615)
464 /* FIXME: This is using the placeholder dates Clang produces for these macros
465    in C2x mode; switch to the correct values once they've been published. */
466 #if __STDC_VERSION__ >= 202000L
467 # define UINT64_WIDTH         64
468 # define INT64_WIDTH          UINT64_WIDTH
469 
470 # define __UINT_LEAST64_WIDTH UINT64_WIDTH
471 # define __UINT_LEAST32_WIDTH UINT64_WIDTH
472 # define __UINT_LEAST16_WIDTH UINT64_WIDTH
473 # define __UINT_LEAST8_MAX UINT64_MAX
474 #endif /* __STDC_VERSION__ */
475 
476 # define __INT_LEAST64_MIN   INT64_MIN
477 # define __INT_LEAST64_MAX   INT64_MAX
478 # define __UINT_LEAST64_MAX UINT64_MAX
479 # define __INT_LEAST32_MIN   INT64_MIN
480 # define __INT_LEAST32_MAX   INT64_MAX
481 # define __UINT_LEAST32_MAX UINT64_MAX
482 # define __INT_LEAST16_MIN   INT64_MIN
483 # define __INT_LEAST16_MAX   INT64_MAX
484 # define __UINT_LEAST16_MAX UINT64_MAX
485 # define __INT_LEAST8_MIN    INT64_MIN
486 # define __INT_LEAST8_MAX    INT64_MAX
487 # define __UINT_LEAST8_MAX  UINT64_MAX
488 #endif /* __INT64_TYPE__ */
489 
490 #ifdef __INT_LEAST64_MIN
491 # define INT_LEAST64_MIN   __INT_LEAST64_MIN
492 # define INT_LEAST64_MAX   __INT_LEAST64_MAX
493 # define UINT_LEAST64_MAX __UINT_LEAST64_MAX
494 # define INT_FAST64_MIN    __INT_LEAST64_MIN
495 # define INT_FAST64_MAX    __INT_LEAST64_MAX
496 # define UINT_FAST64_MAX  __UINT_LEAST64_MAX
497 
498 /* FIXME: This is using the placeholder dates Clang produces for these macros
499    in C2x mode; switch to the correct values once they've been published. */
500 #if __STDC_VERSION__ >= 202000L
501 # define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH
502 # define INT_LEAST64_WIDTH  UINT_LEAST64_WIDTH
503 # define UINT_FAST64_WIDTH  __UINT_LEAST64_WIDTH
504 # define INT_FAST64_WIDTH   UINT_FAST64_WIDTH
505 #endif /* __STDC_VERSION__ */
506 #endif /* __INT_LEAST64_MIN */
507 
508 
509 #ifdef __INT56_TYPE__
510 # define INT56_MAX           INT56_C(36028797018963967)
511 # define INT56_MIN         (-INT56_C(36028797018963967)-1)
512 # define UINT56_MAX         UINT56_C(72057594037927935)
513 # define INT_LEAST56_MIN     INT56_MIN
514 # define INT_LEAST56_MAX     INT56_MAX
515 # define UINT_LEAST56_MAX   UINT56_MAX
516 # define INT_FAST56_MIN      INT56_MIN
517 # define INT_FAST56_MAX      INT56_MAX
518 # define UINT_FAST56_MAX    UINT56_MAX
519 
520 # define __INT_LEAST32_MIN   INT56_MIN
521 # define __INT_LEAST32_MAX   INT56_MAX
522 # define __UINT_LEAST32_MAX UINT56_MAX
523 # define __INT_LEAST16_MIN   INT56_MIN
524 # define __INT_LEAST16_MAX   INT56_MAX
525 # define __UINT_LEAST16_MAX UINT56_MAX
526 # define __INT_LEAST8_MIN    INT56_MIN
527 # define __INT_LEAST8_MAX    INT56_MAX
528 # define __UINT_LEAST8_MAX  UINT56_MAX
529 
530 /* FIXME: This is using the placeholder dates Clang produces for these macros
531    in C2x mode; switch to the correct values once they've been published. */
532 #if __STDC_VERSION__ >= 202000L
533 # define UINT56_WIDTH         56
534 # define INT56_WIDTH          UINT56_WIDTH
535 # define UINT_LEAST56_WIDTH   UINT56_WIDTH
536 # define INT_LEAST56_WIDTH    UINT_LEAST56_WIDTH
537 # define UINT_FAST56_WIDTH    UINT56_WIDTH
538 # define INT_FAST56_WIDTH     UINT_FAST56_WIDTH
539 # define __UINT_LEAST32_WIDTH UINT56_WIDTH
540 # define __UINT_LEAST16_WIDTH UINT56_WIDTH
541 # define __UINT_LEAST8_WIDTH  UINT56_WIDTH
542 #endif /* __STDC_VERSION__ */
543 #endif /* __INT56_TYPE__ */
544 
545 
546 #ifdef __INT48_TYPE__
547 # define INT48_MAX           INT48_C(140737488355327)
548 # define INT48_MIN         (-INT48_C(140737488355327)-1)
549 # define UINT48_MAX         UINT48_C(281474976710655)
550 # define INT_LEAST48_MIN     INT48_MIN
551 # define INT_LEAST48_MAX     INT48_MAX
552 # define UINT_LEAST48_MAX   UINT48_MAX
553 # define INT_FAST48_MIN      INT48_MIN
554 # define INT_FAST48_MAX      INT48_MAX
555 # define UINT_FAST48_MAX    UINT48_MAX
556 
557 # define __INT_LEAST32_MIN   INT48_MIN
558 # define __INT_LEAST32_MAX   INT48_MAX
559 # define __UINT_LEAST32_MAX UINT48_MAX
560 # define __INT_LEAST16_MIN   INT48_MIN
561 # define __INT_LEAST16_MAX   INT48_MAX
562 # define __UINT_LEAST16_MAX UINT48_MAX
563 # define __INT_LEAST8_MIN    INT48_MIN
564 # define __INT_LEAST8_MAX    INT48_MAX
565 # define __UINT_LEAST8_MAX  UINT48_MAX
566 
567 /* FIXME: This is using the placeholder dates Clang produces for these macros
568    in C2x mode; switch to the correct values once they've been published. */
569 #if __STDC_VERSION__ >= 202000L
570 #define UINT48_WIDTH         48
571 #define INT48_WIDTH          UINT48_WIDTH
572 #define UINT_LEAST48_WIDTH   UINT48_WIDTH
573 #define INT_LEAST48_WIDTH    UINT_LEAST48_WIDTH
574 #define UINT_FAST48_WIDTH    UINT48_WIDTH
575 #define INT_FAST48_WIDTH     UINT_FAST48_WIDTH
576 #define __UINT_LEAST32_WIDTH UINT48_WIDTH
577 #define __UINT_LEAST16_WIDTH UINT48_WIDTH
578 #define __UINT_LEAST8_WIDTH  UINT48_WIDTH
579 #endif /* __STDC_VERSION__ */
580 #endif /* __INT48_TYPE__ */
581 
582 
583 #ifdef __INT40_TYPE__
584 # define INT40_MAX           INT40_C(549755813887)
585 # define INT40_MIN         (-INT40_C(549755813887)-1)
586 # define UINT40_MAX         UINT40_C(1099511627775)
587 # define INT_LEAST40_MIN     INT40_MIN
588 # define INT_LEAST40_MAX     INT40_MAX
589 # define UINT_LEAST40_MAX   UINT40_MAX
590 # define INT_FAST40_MIN      INT40_MIN
591 # define INT_FAST40_MAX      INT40_MAX
592 # define UINT_FAST40_MAX    UINT40_MAX
593 
594 # define __INT_LEAST32_MIN   INT40_MIN
595 # define __INT_LEAST32_MAX   INT40_MAX
596 # define __UINT_LEAST32_MAX UINT40_MAX
597 # define __INT_LEAST16_MIN   INT40_MIN
598 # define __INT_LEAST16_MAX   INT40_MAX
599 # define __UINT_LEAST16_MAX UINT40_MAX
600 # define __INT_LEAST8_MIN    INT40_MIN
601 # define __INT_LEAST8_MAX    INT40_MAX
602 # define __UINT_LEAST8_MAX  UINT40_MAX
603 
604 /* FIXME: This is using the placeholder dates Clang produces for these macros
605    in C2x mode; switch to the correct values once they've been published. */
606 #if __STDC_VERSION__ >= 202000L
607 # define UINT40_WIDTH         40
608 # define INT40_WIDTH          UINT40_WIDTH
609 # define UINT_LEAST40_WIDTH   UINT40_WIDTH
610 # define INT_LEAST40_WIDTH    UINT_LEAST40_WIDTH
611 # define UINT_FAST40_WIDTH    UINT40_WIDTH
612 # define INT_FAST40_WIDTH     UINT_FAST40_WIDTH
613 # define __UINT_LEAST32_WIDTH UINT40_WIDTH
614 # define __UINT_LEAST16_WIDTH UINT40_WIDTH
615 # define __UINT_LEAST8_WIDTH  UINT40_WIDTH
616 #endif /* __STDC_VERSION__ */
617 #endif /* __INT40_TYPE__ */
618 
619 
620 #ifdef __INT32_TYPE__
621 # define INT32_MAX           INT32_C(2147483647)
622 # define INT32_MIN         (-INT32_C(2147483647)-1)
623 # define UINT32_MAX         UINT32_C(4294967295)
624 
625 # define __INT_LEAST32_MIN   INT32_MIN
626 # define __INT_LEAST32_MAX   INT32_MAX
627 # define __UINT_LEAST32_MAX UINT32_MAX
628 # define __INT_LEAST16_MIN   INT32_MIN
629 # define __INT_LEAST16_MAX   INT32_MAX
630 # define __UINT_LEAST16_MAX UINT32_MAX
631 # define __INT_LEAST8_MIN    INT32_MIN
632 # define __INT_LEAST8_MAX    INT32_MAX
633 # define __UINT_LEAST8_MAX  UINT32_MAX
634 
635 /* FIXME: This is using the placeholder dates Clang produces for these macros
636    in C2x mode; switch to the correct values once they've been published. */
637 #if __STDC_VERSION__ >= 202000L
638 # define UINT32_WIDTH         32
639 # define INT32_WIDTH          UINT32_WIDTH
640 # define __UINT_LEAST32_WIDTH UINT32_WIDTH
641 # define __UINT_LEAST16_WIDTH UINT32_WIDTH
642 # define __UINT_LEAST8_WIDTH  UINT32_WIDTH
643 #endif /* __STDC_VERSION__ */
644 #endif /* __INT32_TYPE__ */
645 
646 #ifdef __INT_LEAST32_MIN
647 # define INT_LEAST32_MIN   __INT_LEAST32_MIN
648 # define INT_LEAST32_MAX   __INT_LEAST32_MAX
649 # define UINT_LEAST32_MAX __UINT_LEAST32_MAX
650 # define INT_FAST32_MIN    __INT_LEAST32_MIN
651 # define INT_FAST32_MAX    __INT_LEAST32_MAX
652 # define UINT_FAST32_MAX  __UINT_LEAST32_MAX
653 
654 /* FIXME: This is using the placeholder dates Clang produces for these macros
655    in C2x mode; switch to the correct values once they've been published. */
656 #if __STDC_VERSION__ >= 202000L
657 # define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH
658 # define INT_LEAST32_WIDTH  UINT_LEAST32_WIDTH
659 # define UINT_FAST32_WIDTH  __UINT_LEAST32_WIDTH
660 # define INT_FAST32_WIDTH   UINT_FAST32_WIDTH
661 #endif /* __STDC_VERSION__ */
662 #endif /* __INT_LEAST32_MIN */
663 
664 
665 #ifdef __INT24_TYPE__
666 # define INT24_MAX           INT24_C(8388607)
667 # define INT24_MIN         (-INT24_C(8388607)-1)
668 # define UINT24_MAX         UINT24_C(16777215)
669 # define INT_LEAST24_MIN     INT24_MIN
670 # define INT_LEAST24_MAX     INT24_MAX
671 # define UINT_LEAST24_MAX   UINT24_MAX
672 # define INT_FAST24_MIN      INT24_MIN
673 # define INT_FAST24_MAX      INT24_MAX
674 # define UINT_FAST24_MAX    UINT24_MAX
675 
676 # define __INT_LEAST16_MIN   INT24_MIN
677 # define __INT_LEAST16_MAX   INT24_MAX
678 # define __UINT_LEAST16_MAX UINT24_MAX
679 # define __INT_LEAST8_MIN    INT24_MIN
680 # define __INT_LEAST8_MAX    INT24_MAX
681 # define __UINT_LEAST8_MAX  UINT24_MAX
682 
683 /* FIXME: This is using the placeholder dates Clang produces for these macros
684    in C2x mode; switch to the correct values once they've been published. */
685 #if __STDC_VERSION__ >= 202000L
686 # define UINT24_WIDTH         24
687 # define INT24_WIDTH          UINT24_WIDTH
688 # define UINT_LEAST24_WIDTH   UINT24_WIDTH
689 # define INT_LEAST24_WIDTH    UINT_LEAST24_WIDTH
690 # define UINT_FAST24_WIDTH    UINT24_WIDTH
691 # define INT_FAST24_WIDTH     UINT_FAST24_WIDTH
692 # define __UINT_LEAST16_WIDTH UINT24_WIDTH
693 # define __UINT_LEAST8_WIDTH  UINT24_WIDTH
694 #endif /* __STDC_VERSION__ */
695 #endif /* __INT24_TYPE__ */
696 
697 
698 #ifdef __INT16_TYPE__
699 #define INT16_MAX            INT16_C(32767)
700 #define INT16_MIN          (-INT16_C(32767)-1)
701 #define UINT16_MAX          UINT16_C(65535)
702 
703 # define __INT_LEAST16_MIN   INT16_MIN
704 # define __INT_LEAST16_MAX   INT16_MAX
705 # define __UINT_LEAST16_MAX UINT16_MAX
706 # define __INT_LEAST8_MIN    INT16_MIN
707 # define __INT_LEAST8_MAX    INT16_MAX
708 # define __UINT_LEAST8_MAX  UINT16_MAX
709 
710 /* FIXME: This is using the placeholder dates Clang produces for these macros
711    in C2x mode; switch to the correct values once they've been published. */
712 #if __STDC_VERSION__ >= 202000L
713 # define UINT16_WIDTH         16
714 # define INT16_WIDTH          UINT16_WIDTH
715 # define __UINT_LEAST16_WIDTH UINT16_WIDTH
716 # define __UINT_LEAST8_WIDTH  UINT16_WIDTH
717 #endif /* __STDC_VERSION__ */
718 #endif /* __INT16_TYPE__ */
719 
720 #ifdef __INT_LEAST16_MIN
721 # define INT_LEAST16_MIN   __INT_LEAST16_MIN
722 # define INT_LEAST16_MAX   __INT_LEAST16_MAX
723 # define UINT_LEAST16_MAX __UINT_LEAST16_MAX
724 # define INT_FAST16_MIN    __INT_LEAST16_MIN
725 # define INT_FAST16_MAX    __INT_LEAST16_MAX
726 # define UINT_FAST16_MAX  __UINT_LEAST16_MAX
727 
728 /* FIXME: This is using the placeholder dates Clang produces for these macros
729    in C2x mode; switch to the correct values once they've been published. */
730 #if __STDC_VERSION__ >= 202000L
731 # define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH
732 # define INT_LEAST16_WIDTH  UINT_LEAST16_WIDTH
733 # define UINT_FAST16_WIDTH  __UINT_LEAST16_WIDTH
734 # define INT_FAST16_WIDTH   UINT_FAST16_WIDTH
735 #endif /* __STDC_VERSION__ */
736 #endif /* __INT_LEAST16_MIN */
737 
738 
739 #ifdef __INT8_TYPE__
740 # define INT8_MAX            INT8_C(127)
741 # define INT8_MIN          (-INT8_C(127)-1)
742 # define UINT8_MAX          UINT8_C(255)
743 
744 # define __INT_LEAST8_MIN    INT8_MIN
745 # define __INT_LEAST8_MAX    INT8_MAX
746 # define __UINT_LEAST8_MAX  UINT8_MAX
747 
748 /* FIXME: This is using the placeholder dates Clang produces for these macros
749    in C2x mode; switch to the correct values once they've been published. */
750 #if __STDC_VERSION__ >= 202000L
751 # define UINT8_WIDTH         8
752 # define INT8_WIDTH          UINT8_WIDTH
753 # define __UINT_LEAST8_WIDTH UINT8_WIDTH
754 #endif /* __STDC_VERSION__ */
755 #endif /* __INT8_TYPE__ */
756 
757 #ifdef __INT_LEAST8_MIN
758 # define INT_LEAST8_MIN   __INT_LEAST8_MIN
759 # define INT_LEAST8_MAX   __INT_LEAST8_MAX
760 # define UINT_LEAST8_MAX __UINT_LEAST8_MAX
761 # define INT_FAST8_MIN    __INT_LEAST8_MIN
762 # define INT_FAST8_MAX    __INT_LEAST8_MAX
763 # define UINT_FAST8_MAX  __UINT_LEAST8_MAX
764 
765 /* FIXME: This is using the placeholder dates Clang produces for these macros
766    in C2x mode; switch to the correct values once they've been published. */
767 #if __STDC_VERSION__ >= 202000L
768 # define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH
769 # define INT_LEAST8_WIDTH  UINT_LEAST8_WIDTH
770 # define UINT_FAST8_WIDTH  __UINT_LEAST8_WIDTH
771 # define INT_FAST8_WIDTH   UINT_FAST8_WIDTH
772 #endif /* __STDC_VERSION__ */
773 #endif /* __INT_LEAST8_MIN */
774 
775 /* Some utility macros */
776 #define  __INTN_MIN(n)  __stdint_join3( INT, n, _MIN)
777 #define  __INTN_MAX(n)  __stdint_join3( INT, n, _MAX)
778 #define __UINTN_MAX(n)  __stdint_join3(UINT, n, _MAX)
779 #define  __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
780 #define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
781 
782 /* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */
783 /* C99 7.18.3 Limits of other integer types. */
784 
785 #define  INTPTR_MIN  (-__INTPTR_MAX__-1)
786 #define  INTPTR_MAX    __INTPTR_MAX__
787 #define UINTPTR_MAX   __UINTPTR_MAX__
788 #define PTRDIFF_MIN (-__PTRDIFF_MAX__-1)
789 #define PTRDIFF_MAX   __PTRDIFF_MAX__
790 #define    SIZE_MAX      __SIZE_MAX__
791 
792 /* C2x 7.20.2.4 Width of integer types capable of holding object pointers. */
793 /* FIXME: This is using the placeholder dates Clang produces for these macros
794    in C2x mode; switch to the correct values once they've been published. */
795 #if __STDC_VERSION__ >= 202000L
796 /* NB: The C standard requires that these be the same value, but the compiler
797    exposes separate internal width macros. */
798 #define INTPTR_WIDTH  __INTPTR_WIDTH__
799 #define UINTPTR_WIDTH __UINTPTR_WIDTH__
800 #endif
801 
802 /* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__
803  * is enabled. */
804 #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
805 #define   RSIZE_MAX            (SIZE_MAX >> 1)
806 #endif
807 
808 /* C99 7.18.2.5 Limits of greatest-width integer types. */
809 #define  INTMAX_MIN (-__INTMAX_MAX__-1)
810 #define  INTMAX_MAX   __INTMAX_MAX__
811 #define UINTMAX_MAX  __UINTMAX_MAX__
812 
813 /* C2x 7.20.2.5 Width of greatest-width integer types. */
814 /* FIXME: This is using the placeholder dates Clang produces for these macros
815    in C2x mode; switch to the correct values once they've been published. */
816 #if __STDC_VERSION__ >= 202000L
817 /* NB: The C standard requires that these be the same value, but the compiler
818    exposes separate internal width macros. */
819 #define INTMAX_WIDTH __INTMAX_WIDTH__
820 #define UINTMAX_WIDTH __UINTMAX_WIDTH__
821 #endif
822 
823 /* C99 7.18.3 Limits of other integer types. */
824 #define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
825 #define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
826 #ifdef __WINT_UNSIGNED__
827 # define WINT_MIN       __UINTN_C(__WINT_WIDTH__, 0)
828 # define WINT_MAX       __UINTN_MAX(__WINT_WIDTH__)
829 #else
830 # define WINT_MIN       __INTN_MIN(__WINT_WIDTH__)
831 # define WINT_MAX       __INTN_MAX(__WINT_WIDTH__)
832 #endif
833 
834 #ifndef WCHAR_MAX
835 # define WCHAR_MAX __WCHAR_MAX__
836 #endif
837 #ifndef WCHAR_MIN
838 # if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)
839 #  define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
840 # else
841 #  define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)
842 # endif
843 #endif
844 
845 /* 7.18.4.2 Macros for greatest-width integer constants. */
846 #define  INTMAX_C(v) __int_c(v,  __INTMAX_C_SUFFIX__)
847 #define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__)
848 
849 /* C2x 7.20.3.x Width of other integer types. */
850 /* FIXME: This is using the placeholder dates Clang produces for these macros
851    in C2x mode; switch to the correct values once they've been published. */
852 #if __STDC_VERSION__ >= 202000L
853 #define PTRDIFF_WIDTH    __PTRDIFF_WIDTH__
854 #define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__
855 #define SIZE_WIDTH       __SIZE_WIDTH__
856 #define WCHAR_WIDTH      __WCHAR_WIDTH__
857 #define WINT_WIDTH       __WINT_WIDTH__
858 #endif
859 
860 #endif /* __STDC_HOSTED__ */
861 #endif /* __CLANG_STDINT_H */
862