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