• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 # define __INT_LEAST64_MIN   INT64_MIN
465 # define __INT_LEAST64_MAX   INT64_MAX
466 # define __UINT_LEAST64_MAX UINT64_MAX
467 # define __INT_LEAST32_MIN   INT64_MIN
468 # define __INT_LEAST32_MAX   INT64_MAX
469 # define __UINT_LEAST32_MAX UINT64_MAX
470 # define __INT_LEAST16_MIN   INT64_MIN
471 # define __INT_LEAST16_MAX   INT64_MAX
472 # define __UINT_LEAST16_MAX UINT64_MAX
473 # define __INT_LEAST8_MIN    INT64_MIN
474 # define __INT_LEAST8_MAX    INT64_MAX
475 # define __UINT_LEAST8_MAX  UINT64_MAX
476 #endif /* __INT64_TYPE__ */
477 
478 #ifdef __INT_LEAST64_MIN
479 # define INT_LEAST64_MIN   __INT_LEAST64_MIN
480 # define INT_LEAST64_MAX   __INT_LEAST64_MAX
481 # define UINT_LEAST64_MAX __UINT_LEAST64_MAX
482 # define INT_FAST64_MIN    __INT_LEAST64_MIN
483 # define INT_FAST64_MAX    __INT_LEAST64_MAX
484 # define UINT_FAST64_MAX  __UINT_LEAST64_MAX
485 #endif /* __INT_LEAST64_MIN */
486 
487 
488 #ifdef __INT56_TYPE__
489 # define INT56_MAX           INT56_C(36028797018963967)
490 # define INT56_MIN         (-INT56_C(36028797018963967)-1)
491 # define UINT56_MAX         UINT56_C(72057594037927935)
492 # define INT_LEAST56_MIN     INT56_MIN
493 # define INT_LEAST56_MAX     INT56_MAX
494 # define UINT_LEAST56_MAX   UINT56_MAX
495 # define INT_FAST56_MIN      INT56_MIN
496 # define INT_FAST56_MAX      INT56_MAX
497 # define UINT_FAST56_MAX    UINT56_MAX
498 # define __INT_LEAST32_MIN   INT56_MIN
499 # define __INT_LEAST32_MAX   INT56_MAX
500 # define __UINT_LEAST32_MAX UINT56_MAX
501 # define __INT_LEAST16_MIN   INT56_MIN
502 # define __INT_LEAST16_MAX   INT56_MAX
503 # define __UINT_LEAST16_MAX UINT56_MAX
504 # define __INT_LEAST8_MIN    INT56_MIN
505 # define __INT_LEAST8_MAX    INT56_MAX
506 # define __UINT_LEAST8_MAX  UINT56_MAX
507 #endif /* __INT56_TYPE__ */
508 
509 
510 #ifdef __INT48_TYPE__
511 # define INT48_MAX           INT48_C(140737488355327)
512 # define INT48_MIN         (-INT48_C(140737488355327)-1)
513 # define UINT48_MAX         UINT48_C(281474976710655)
514 # define INT_LEAST48_MIN     INT48_MIN
515 # define INT_LEAST48_MAX     INT48_MAX
516 # define UINT_LEAST48_MAX   UINT48_MAX
517 # define INT_FAST48_MIN      INT48_MIN
518 # define INT_FAST48_MAX      INT48_MAX
519 # define UINT_FAST48_MAX    UINT48_MAX
520 # define __INT_LEAST32_MIN   INT48_MIN
521 # define __INT_LEAST32_MAX   INT48_MAX
522 # define __UINT_LEAST32_MAX UINT48_MAX
523 # define __INT_LEAST16_MIN   INT48_MIN
524 # define __INT_LEAST16_MAX   INT48_MAX
525 # define __UINT_LEAST16_MAX UINT48_MAX
526 # define __INT_LEAST8_MIN    INT48_MIN
527 # define __INT_LEAST8_MAX    INT48_MAX
528 # define __UINT_LEAST8_MAX  UINT48_MAX
529 #endif /* __INT48_TYPE__ */
530 
531 
532 #ifdef __INT40_TYPE__
533 # define INT40_MAX           INT40_C(549755813887)
534 # define INT40_MIN         (-INT40_C(549755813887)-1)
535 # define UINT40_MAX         UINT40_C(1099511627775)
536 # define INT_LEAST40_MIN     INT40_MIN
537 # define INT_LEAST40_MAX     INT40_MAX
538 # define UINT_LEAST40_MAX   UINT40_MAX
539 # define INT_FAST40_MIN      INT40_MIN
540 # define INT_FAST40_MAX      INT40_MAX
541 # define UINT_FAST40_MAX    UINT40_MAX
542 # define __INT_LEAST32_MIN   INT40_MIN
543 # define __INT_LEAST32_MAX   INT40_MAX
544 # define __UINT_LEAST32_MAX UINT40_MAX
545 # define __INT_LEAST16_MIN   INT40_MIN
546 # define __INT_LEAST16_MAX   INT40_MAX
547 # define __UINT_LEAST16_MAX UINT40_MAX
548 # define __INT_LEAST8_MIN    INT40_MIN
549 # define __INT_LEAST8_MAX    INT40_MAX
550 # define __UINT_LEAST8_MAX  UINT40_MAX
551 #endif /* __INT40_TYPE__ */
552 
553 
554 #ifdef __INT32_TYPE__
555 # define INT32_MAX           INT32_C(2147483647)
556 # define INT32_MIN         (-INT32_C(2147483647)-1)
557 # define UINT32_MAX         UINT32_C(4294967295)
558 # define __INT_LEAST32_MIN   INT32_MIN
559 # define __INT_LEAST32_MAX   INT32_MAX
560 # define __UINT_LEAST32_MAX UINT32_MAX
561 # define __INT_LEAST16_MIN   INT32_MIN
562 # define __INT_LEAST16_MAX   INT32_MAX
563 # define __UINT_LEAST16_MAX UINT32_MAX
564 # define __INT_LEAST8_MIN    INT32_MIN
565 # define __INT_LEAST8_MAX    INT32_MAX
566 # define __UINT_LEAST8_MAX  UINT32_MAX
567 #endif /* __INT32_TYPE__ */
568 
569 #ifdef __INT_LEAST32_MIN
570 # define INT_LEAST32_MIN   __INT_LEAST32_MIN
571 # define INT_LEAST32_MAX   __INT_LEAST32_MAX
572 # define UINT_LEAST32_MAX __UINT_LEAST32_MAX
573 # define INT_FAST32_MIN    __INT_LEAST32_MIN
574 # define INT_FAST32_MAX    __INT_LEAST32_MAX
575 # define UINT_FAST32_MAX  __UINT_LEAST32_MAX
576 #endif /* __INT_LEAST32_MIN */
577 
578 
579 #ifdef __INT24_TYPE__
580 # define INT24_MAX           INT24_C(8388607)
581 # define INT24_MIN         (-INT24_C(8388607)-1)
582 # define UINT24_MAX         UINT24_C(16777215)
583 # define INT_LEAST24_MIN     INT24_MIN
584 # define INT_LEAST24_MAX     INT24_MAX
585 # define UINT_LEAST24_MAX   UINT24_MAX
586 # define INT_FAST24_MIN      INT24_MIN
587 # define INT_FAST24_MAX      INT24_MAX
588 # define UINT_FAST24_MAX    UINT24_MAX
589 # define __INT_LEAST16_MIN   INT24_MIN
590 # define __INT_LEAST16_MAX   INT24_MAX
591 # define __UINT_LEAST16_MAX UINT24_MAX
592 # define __INT_LEAST8_MIN    INT24_MIN
593 # define __INT_LEAST8_MAX    INT24_MAX
594 # define __UINT_LEAST8_MAX  UINT24_MAX
595 #endif /* __INT24_TYPE__ */
596 
597 
598 #ifdef __INT16_TYPE__
599 #define INT16_MAX            INT16_C(32767)
600 #define INT16_MIN          (-INT16_C(32767)-1)
601 #define UINT16_MAX          UINT16_C(65535)
602 # define __INT_LEAST16_MIN   INT16_MIN
603 # define __INT_LEAST16_MAX   INT16_MAX
604 # define __UINT_LEAST16_MAX UINT16_MAX
605 # define __INT_LEAST8_MIN    INT16_MIN
606 # define __INT_LEAST8_MAX    INT16_MAX
607 # define __UINT_LEAST8_MAX  UINT16_MAX
608 #endif /* __INT16_TYPE__ */
609 
610 #ifdef __INT_LEAST16_MIN
611 # define INT_LEAST16_MIN   __INT_LEAST16_MIN
612 # define INT_LEAST16_MAX   __INT_LEAST16_MAX
613 # define UINT_LEAST16_MAX __UINT_LEAST16_MAX
614 # define INT_FAST16_MIN    __INT_LEAST16_MIN
615 # define INT_FAST16_MAX    __INT_LEAST16_MAX
616 # define UINT_FAST16_MAX  __UINT_LEAST16_MAX
617 #endif /* __INT_LEAST16_MIN */
618 
619 
620 #ifdef __INT8_TYPE__
621 # define INT8_MAX            INT8_C(127)
622 # define INT8_MIN          (-INT8_C(127)-1)
623 # define UINT8_MAX          UINT8_C(255)
624 # define __INT_LEAST8_MIN    INT8_MIN
625 # define __INT_LEAST8_MAX    INT8_MAX
626 # define __UINT_LEAST8_MAX  UINT8_MAX
627 #endif /* __INT8_TYPE__ */
628 
629 #ifdef __INT_LEAST8_MIN
630 # define INT_LEAST8_MIN   __INT_LEAST8_MIN
631 # define INT_LEAST8_MAX   __INT_LEAST8_MAX
632 # define UINT_LEAST8_MAX __UINT_LEAST8_MAX
633 # define INT_FAST8_MIN    __INT_LEAST8_MIN
634 # define INT_FAST8_MAX    __INT_LEAST8_MAX
635 # define UINT_FAST8_MAX  __UINT_LEAST8_MAX
636 #endif /* __INT_LEAST8_MIN */
637 
638 /* Some utility macros */
639 #define  __INTN_MIN(n)  __stdint_join3( INT, n, _MIN)
640 #define  __INTN_MAX(n)  __stdint_join3( INT, n, _MAX)
641 #define __UINTN_MAX(n)  __stdint_join3(UINT, n, _MAX)
642 #define  __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
643 #define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
644 
645 /* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */
646 /* C99 7.18.3 Limits of other integer types. */
647 
648 #define  INTPTR_MIN  (-__INTPTR_MAX__-1)
649 #define  INTPTR_MAX    __INTPTR_MAX__
650 #define UINTPTR_MAX   __UINTPTR_MAX__
651 #define PTRDIFF_MIN (-__PTRDIFF_MAX__-1)
652 #define PTRDIFF_MAX   __PTRDIFF_MAX__
653 #define    SIZE_MAX      __SIZE_MAX__
654 
655 /* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__
656  * is enabled. */
657 #if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
658 #define   RSIZE_MAX            (SIZE_MAX >> 1)
659 #endif
660 
661 /* C99 7.18.2.5 Limits of greatest-width integer types. */
662 #define  INTMAX_MIN (-__INTMAX_MAX__-1)
663 #define  INTMAX_MAX   __INTMAX_MAX__
664 #define UINTMAX_MAX  __UINTMAX_MAX__
665 
666 /* C99 7.18.3 Limits of other integer types. */
667 #define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
668 #define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
669 #ifdef __WINT_UNSIGNED__
670 # define WINT_MIN       __UINTN_C(__WINT_WIDTH__, 0)
671 # define WINT_MAX       __UINTN_MAX(__WINT_WIDTH__)
672 #else
673 # define WINT_MIN       __INTN_MIN(__WINT_WIDTH__)
674 # define WINT_MAX       __INTN_MAX(__WINT_WIDTH__)
675 #endif
676 
677 #ifndef WCHAR_MAX
678 # define WCHAR_MAX __WCHAR_MAX__
679 #endif
680 #ifndef WCHAR_MIN
681 # if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)
682 #  define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
683 # else
684 #  define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)
685 # endif
686 #endif
687 
688 /* 7.18.4.2 Macros for greatest-width integer constants. */
689 #define  INTMAX_C(v) __int_c(v,  __INTMAX_C_SUFFIX__)
690 #define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__)
691 
692 #endif /* __STDC_HOSTED__ */
693 #endif /* __CLANG_STDINT_H */
694