1 /* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc.
2 Written by Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
23 * ISO C 99 <stdint.h> for platforms that lack it.
24 * <http://www.opengroup.org/susv3xbd/stdint.h.html>
27 /* Get wchar_t, WCHAR_MIN, WCHAR_MAX. */
29 /* Get LONG_MIN, LONG_MAX, ULONG_MAX. */
32 /* Get those types that are already defined in other system include files. */
33 #if defined(__FreeBSD__)
34 # include <sys/inttypes.h>
36 #if defined(__OpenBSD__)
37 /* In OpenBSD 3.8, <sys/types.h> includes <machine/types.h>, which defines
38 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
39 <inttypes.h> includes <machine/types.h> and also defines intptr_t and
41 # include <sys/types.h>
42 # if @HAVE_INTTYPES_H@
43 # include @FULL_PATH_INTTYPES_H@
46 #if defined(__linux__) && @HAVE_SYS_BITYPES_H@
47 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
48 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
49 included by <sys/types.h>. */
50 # include <sys/bitypes.h>
52 #if defined(__sun) && @HAVE_SYS_INTTYPES_H@
53 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
54 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.
55 But note that <sys/int_types.h> contains only the type definitions! */
56 # include <sys/inttypes.h>
58 #if (defined(__hpux) || defined(_AIX)) && @HAVE_INTTYPES_H@
59 /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX,
60 UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
61 /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX,
62 UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
63 # include @FULL_PATH_INTTYPES_H@
66 /* Other systems may have an incomplete <stdint.h>. */
67 # include @FULL_PATH_STDINT_H@
70 /* 7.18.1.1. Exact-width integer types */
72 /* Here we assume a standard architecture where the hardware integer
73 types have 8, 16, 32, optionally 64 bits. */
76 typedef signed char int8_t;
79 typedef unsigned char uint8_t;
83 typedef short int16_t;
86 typedef unsigned short uint16_t;
93 typedef unsigned int uint32_t;
97 # define _STDINT_H_HAVE_INT64 1
99 # if @HAVE_LONG_64BIT@
100 typedef long int64_t;
101 # define _STDINT_H_HAVE_INT64 1
102 # elif @HAVE_LONG_LONG_64BIT@
103 typedef long long int64_t;
104 # define _STDINT_H_HAVE_INT64 1
105 # elif defined _MSC_VER
106 typedef __int64 int64_t;
107 # define _STDINT_H_HAVE_INT64 1
111 # define _STDINT_H_HAVE_UINT64 1
113 # if @HAVE_LONG_64BIT@
114 typedef unsigned long uint64_t;
115 # define _STDINT_H_HAVE_UINT64 1
116 # elif @HAVE_LONG_LONG_64BIT@
117 typedef unsigned long long uint64_t;
118 # define _STDINT_H_HAVE_UINT64 1
119 # elif defined _MSC_VER
120 typedef unsigned __int64 uint64_t;
121 # define _STDINT_H_HAVE_UINT64 1
125 /* 7.18.1.2. Minimum-width integer types */
127 /* Here we assume a standard architecture where the hardware integer
128 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
129 are the same as the corresponding N_t types. */
131 #if !@HAVE_INT_LEAST8_T@
132 typedef int8_t int_least8_t;
134 #if !@HAVE_UINT_LEAST8_T@
135 typedef uint8_t uint_least8_t;
138 #if !@HAVE_INT_LEAST16_T@
139 typedef int16_t int_least16_t;
141 #if !@HAVE_UINT_LEAST16_T@
142 typedef uint16_t uint_least16_t;
145 #if !@HAVE_INT_LEAST32_T@
146 typedef int32_t int_least32_t;
148 #if !@HAVE_UINT_LEAST32_T@
149 typedef uint32_t uint_least32_t;
152 #if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64
153 typedef int64_t int_least64_t;
155 #if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64
156 typedef uint64_t uint_least64_t;
159 /* 7.18.1.3. Fastest minimum-width integer types */
161 /* Note: Other <stdint.h> substitutes may define these types differently.
162 It is not recommended to use these types in public header files. */
164 /* Here we assume a standard architecture where the hardware integer
165 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
166 are taken from the same list of types. */
168 /* On alpha processors, int32_t variables are slower than int64_t variables,
169 due to the necessary zap instructions. */
171 # define _STDINT_H_INT64_FASTER_THAN_INT32 1
174 #if !@HAVE_INT_FAST8_T@
175 # if _STDINT_H_INT64_FASTER_THAN_INT32
176 typedef int64_t int_fast8_t;
178 typedef int32_t int_fast8_t;
181 #if !@HAVE_UINT_FAST8_T@
182 # if _STDINT_H_INT64_FASTER_THAN_INT32
183 typedef uint64_t uint_fast8_t;
185 typedef uint32_t uint_fast8_t;
189 #if !@HAVE_INT_FAST16_T@
190 # if _STDINT_H_INT64_FASTER_THAN_INT32
191 typedef int64_t int_fast16_t;
193 typedef int32_t int_fast16_t;
196 #if !@HAVE_UINT_FAST16_T@
197 # if _STDINT_H_INT64_FASTER_THAN_INT32
198 typedef uint64_t uint_fast16_t;
200 typedef uint32_t uint_fast16_t;
204 #if !@HAVE_INT_FAST32_T@
205 # if _STDINT_H_INT64_FASTER_THAN_INT32
206 typedef int64_t int_fast32_t;
208 typedef int32_t int_fast32_t;
211 #if !@HAVE_UINT_FAST32_T@
212 # if _STDINT_H_INT64_FASTER_THAN_INT32
213 typedef uint64_t uint_fast32_t;
215 typedef uint32_t uint_fast32_t;
219 #if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64
220 typedef int64_t int_fast64_t;
222 #if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64
223 typedef uint64_t uint_fast64_t;
226 /* 7.18.1.4. Integer types capable of holding object pointers */
228 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
229 but this doesn't matter here. */
231 typedef long intptr_t;
233 #if !@HAVE_UINTPTR_T@
234 typedef unsigned long uintptr_t;
237 /* 7.18.1.5. Greatest-width integer types */
239 /* Note: These types are compiler dependent. It may be unwise to use them in
240 public header files. */
243 # ifdef _STDINT_H_HAVE_INT64
244 typedef int64_t intmax_t;
246 typedef int32_t intmax_t;
249 #if !@HAVE_UINTMAX_T@
250 # ifdef _STDINT_H_HAVE_UINT64
251 typedef uint64_t uintmax_t;
253 typedef uint32_t uintmax_t;
257 /* 7.18.2. Limits of specified-width integer types */
259 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
261 /* 7.18.2.1. Limits of exact-width integer types */
263 /* Here we assume a standard architecture where the hardware integer
264 types have 8, 16, 32, optionally 64 bits. */
268 # define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1))
271 # define INT8_MIN -128
275 # define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1)))
278 # define INT8_MAX 127
282 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
283 # define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
285 # define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
289 # define UINT8_MAX 255
294 # define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1))
297 # define INT16_MIN -32768
301 # define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1)))
304 # define INT16_MAX 32767
308 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
309 # define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
311 # define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
315 # define UINT16_MAX 65535
320 # define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1))
323 # define INT32_MIN (~INT32_MAX)
327 # define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1)))
330 # define INT32_MAX 2147483647
334 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
335 # define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
337 # define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
341 # define UINT32_MAX 4294967295U
346 # if @HAVE_LONG_64BIT@
347 # define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1))
348 # elif @HAVE_LONG_LONG_64BIT@
349 # define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1))
350 # elif defined _MSC_VER
351 # define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1))
355 # ifdef _STDINT_H_HAVE_INT64
356 # define INT64_MIN (~INT64_MAX)
361 # if @HAVE_LONG_64BIT@
362 # define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1)))
363 # elif @HAVE_LONG_LONG_64BIT@
364 # define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1)))
365 # elif defined _MSC_VER
366 # define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1)))
370 # ifdef _STDINT_H_HAVE_INT64
371 # if @HAVE_LONG_64BIT@
372 # define INT64_MAX 9223372036854775807L
373 # elif @HAVE_LONG_LONG_64BIT@
374 # define INT64_MAX 9223372036854775807LL
375 # elif defined _MSC_VER
376 # define INT64_MAX 9223372036854775807i64
382 # if @HAVE_LONG_64BIT@
383 # define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
384 # elif @HAVE_LONG_LONG_64BIT@
385 # define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
386 # elif defined _MSC_VER
387 # define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
391 # ifdef _STDINT_H_HAVE_UINT64
392 # if @HAVE_LONG_64BIT@
393 # define UINT64_MAX 18446744073709551615UL
394 # elif @HAVE_LONG_LONG_64BIT@
395 # define UINT64_MAX 18446744073709551615ULL
396 # elif defined _MSC_VER
397 # define UINT64_MAX 18446744073709551615ui64
402 /* 7.18.2.2. Limits of minimum-width integer types */
404 /* Here we assume a standard architecture where the hardware integer
405 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
406 are the same as the corresponding N_t types. */
408 #if @HAVE_INT_LEAST8_T@
409 # ifndef INT_LEAST8_MIN
410 # define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))
413 # define INT_LEAST8_MIN INT8_MIN
415 #if @HAVE_INT_LEAST8_T@
416 # ifndef INT_LEAST8_MAX
417 # define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)))
420 # define INT_LEAST8_MAX INT8_MAX
422 #if @HAVE_UINT_LEAST8_T@
423 # ifndef UINT_LEAST8_MAX
424 # if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
425 # define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
427 # define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
431 # define UINT_LEAST8_MAX UINT8_MAX
434 #if @HAVE_INT_LEAST16_T@
435 # ifndef INT_LEAST16_MIN
436 # define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))
439 # define INT_LEAST16_MIN INT16_MIN
441 #if @HAVE_INT_LEAST16_T@
442 # ifndef INT_LEAST16_MAX
443 # define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)))
446 # define INT_LEAST16_MAX INT16_MAX
448 #if @HAVE_UINT_LEAST16_T@
449 # ifndef UINT_LEAST16_MAX
450 # if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
451 # define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
453 # define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
457 # define UINT_LEAST16_MAX UINT16_MAX
460 #if @HAVE_INT_LEAST32_T@
461 # ifndef INT_LEAST32_MIN
462 # define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))
465 # define INT_LEAST32_MIN INT32_MIN
467 #if @HAVE_INT_LEAST32_T@
468 # ifndef INT_LEAST32_MAX
469 # define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)))
472 # define INT_LEAST32_MAX INT32_MAX
474 #if @HAVE_UINT_LEAST32_T@
475 # ifndef UINT_LEAST32_MAX
476 # if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
477 # define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
479 # define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
483 # define UINT_LEAST32_MAX UINT32_MAX
486 #if @HAVE_INT_LEAST64_T@
487 # ifndef INT_LEAST64_MIN
488 # if @HAVE_LONG_64BIT@
489 # define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))
490 # elif @HAVE_LONG_LONG_64BIT@
491 # define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))
492 # elif defined _MSC_VER
493 # define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))
497 # ifdef _STDINT_H_HAVE_INT64
498 # define INT_LEAST64_MIN INT64_MIN
501 #if @HAVE_INT_LEAST64_T@
502 # ifndef INT_LEAST64_MAX
503 # if @HAVE_LONG_64BIT@
504 # define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
505 # elif @HAVE_LONG_LONG_64BIT@
506 # define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
507 # elif defined _MSC_VER
508 # define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
512 # ifdef _STDINT_H_HAVE_INT64
513 # define INT_LEAST64_MAX INT64_MAX
516 #if @HAVE_UINT_LEAST64_T@
517 # ifndef UINT_LEAST64_MAX
518 # if @HAVE_LONG_64BIT@
519 # define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
520 # elif @HAVE_LONG_LONG_64BIT@
521 # define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
522 # elif defined _MSC_VER
523 # define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
527 # ifdef _STDINT_H_HAVE_UINT64
528 # define UINT_LEAST64_MAX UINT64_MAX
532 /* 7.18.2.3. Limits of fastest minimum-width integer types */
534 /* Here we assume a standard architecture where the hardware integer
535 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
536 are taken from the same list of types. */
538 #if @HAVE_INT_FAST8_T@
539 # ifndef INT_FAST8_MIN
540 # define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))
543 # if _STDINT_H_INT64_FASTER_THAN_INT32
544 # define INT_FAST8_MIN INT64_MIN
546 # define INT_FAST8_MIN INT32_MIN
549 #if @HAVE_INT_FAST8_T@
550 # ifndef INT_FAST8_MAX
551 # define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)))
554 # if _STDINT_H_INT64_FASTER_THAN_INT32
555 # define INT_FAST8_MAX INT64_MAX
557 # define INT_FAST8_MAX INT32_MAX
560 #if @HAVE_UINT_FAST8_T@
561 # ifndef UINT_FAST8_MAX
562 # if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
563 # define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
565 # define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
569 # if _STDINT_H_INT64_FASTER_THAN_INT32
570 # define UINT_FAST8_MAX UINT64_MAX
572 # define UINT_FAST8_MAX UINT32_MAX
576 #if @HAVE_INT_FAST16_T@
577 # ifndef INT_FAST16_MIN
578 # define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))
581 # if _STDINT_H_INT64_FASTER_THAN_INT32
582 # define INT_FAST16_MIN INT64_MIN
584 # define INT_FAST16_MIN INT32_MIN
587 #if @HAVE_INT_FAST16_T@
588 # ifndef INT_FAST16_MAX
589 # define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)))
592 # if _STDINT_H_INT64_FASTER_THAN_INT32
593 # define INT_FAST16_MAX INT64_MAX
595 # define INT_FAST16_MAX INT32_MAX
598 #if @HAVE_UINT_FAST16_T@
599 # ifndef UINT_FAST16_MAX
600 # if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
601 # define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
603 # define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
607 # if _STDINT_H_INT64_FASTER_THAN_INT32
608 # define UINT_FAST16_MAX UINT64_MAX
610 # define UINT_FAST16_MAX UINT32_MAX
614 #if @HAVE_INT_FAST32_T@
615 # ifndef INT_FAST32_MIN
616 # define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))
619 # if _STDINT_H_INT64_FASTER_THAN_INT32
620 # define INT_FAST32_MIN INT64_MIN
622 # define INT_FAST32_MIN INT32_MIN
625 #if @HAVE_INT_FAST32_T@
626 # ifndef INT_FAST32_MAX
627 # define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)))
630 # if _STDINT_H_INT64_FASTER_THAN_INT32
631 # define INT_FAST32_MAX INT64_MAX
633 # define INT_FAST32_MAX INT32_MAX
636 #if @HAVE_UINT_FAST32_T@
637 # ifndef UINT_FAST32_MAX
638 # if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
639 # define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
641 # define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
645 # if _STDINT_H_INT64_FASTER_THAN_INT32
646 # define UINT_FAST32_MAX UINT64_MAX
648 # define UINT_FAST32_MAX UINT32_MAX
652 #if @HAVE_INT_FAST64_T@
653 # ifndef INT_FAST64_MIN
654 # if @HAVE_LONG_64BIT@
655 # define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))
656 # elif @HAVE_LONG_LONG_64BIT@
657 # define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))
658 # elif defined _MSC_VER
659 # define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))
663 # ifdef _STDINT_H_HAVE_INT64
664 # define INT_FAST64_MIN INT64_MIN
667 #if @HAVE_INT_FAST64_T@
668 # ifndef INT_FAST64_MAX
669 # if @HAVE_LONG_64BIT@
670 # define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)))
671 # elif @HAVE_LONG_LONG_64BIT@
672 # define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)))
673 # elif defined _MSC_VER
674 # define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)))
678 # ifdef _STDINT_H_HAVE_INT64
679 # define INT_FAST64_MAX INT64_MAX
682 #if @HAVE_UINT_FAST64_T@
683 # ifndef UINT_FAST64_MAX
684 # if @HAVE_LONG_64BIT@
685 # define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
686 # elif @HAVE_LONG_LONG_64BIT@
687 # define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
688 # elif defined _MSC_VER
689 # define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
693 # ifdef _STDINT_H_HAVE_UINT64
694 # define UINT_FAST64_MAX UINT64_MAX
698 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
702 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
703 # define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))
705 # define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1))
709 # define INTPTR_MIN LONG_MIN
713 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
714 # define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)))
716 # define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1)))
720 # define INTPTR_MAX LONG_MAX
724 # if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@
725 # define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
727 # define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
731 # define UINTPTR_MAX ULONG_MAX
734 /* 7.18.2.5. Limits of greatest-width integer types */
738 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
739 # define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))
741 # define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1))
745 # ifdef _STDINT_H_HAVE_INT64
746 # define INTMAX_MIN INT64_MIN
748 # define INTMAX_MIN INT32_MIN
753 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
754 # define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)))
756 # define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1)))
760 # ifdef _STDINT_H_HAVE_INT64
761 # define INTMAX_MAX INT64_MAX
763 # define INTMAX_MAX INT32_MAX
768 # if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@
769 # define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
771 # define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
775 # ifdef _STDINT_H_HAVE_INT64
776 # define UINTMAX_MAX UINT64_MAX
778 # define UINTMAX_MAX UINT32_MAX
782 /* 7.18.3. Limits of other integer types */
784 /* ptrdiff_t limits */
786 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
787 # define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))
789 # define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))
793 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
794 # define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)))
796 # define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)))
800 /* sig_atomic_t limits */
801 #ifndef SIG_ATOMIC_MIN
802 # if @HAVE_SIGNED_SIG_ATOMIC_T@
803 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
804 # define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
806 # define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
809 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
810 # define SIG_ATOMIC_MIN 0UL
811 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
812 # define SIG_ATOMIC_MIN 0U
814 # define SIG_ATOMIC_MIN 0
818 #ifndef SIG_ATOMIC_MAX
819 # if @HAVE_SIGNED_SIG_ATOMIC_T@
820 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
821 # define SIG_ATOMIC_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
823 # define SIG_ATOMIC_MAX (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
826 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
827 # define SIG_ATOMIC_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
828 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
829 # define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
831 # define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
837 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */
838 # if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@
839 # define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
841 # define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
845 /* wchar_t limits may already be defined in <stddef.h>. */
847 # if @HAVE_SIGNED_WCHAR_T@
848 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
849 # define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1))
851 # define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1))
854 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
855 # define WCHAR_MIN 0UL
856 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
857 # define WCHAR_MIN 0U
864 # if @HAVE_SIGNED_WCHAR_T@
865 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
866 # define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1)))
868 # define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1)))
871 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
872 # define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
873 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
874 # define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
876 # define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
883 # if @HAVE_SIGNED_WINT_T@
884 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
885 # define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1))
887 # define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1))
890 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
891 # define WINT_MIN 0UL
892 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
900 # if @HAVE_SIGNED_WINT_T@
901 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
902 # define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1)))
904 # define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1)))
907 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
908 # define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
909 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
910 # define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
912 # define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
919 /* 7.18.4. Macros for integer constants */
921 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
923 /* 7.18.4.1. Macros for minimum-width integer constants */
928 #define UINT8_C(x) x##U
933 #define UINT16_C(x) x##U
938 #define UINT32_C(x) x##U
942 #if @HAVE_LONG_64BIT@
943 # define INT64_C(x) x##L
944 # define UINT64_C(x) x##UL
945 #elif @HAVE_LONG_LONG_64BIT@
946 # define INT64_C(x) x##LL
947 # define UINT64_C(x) x##ULL
948 #elif defined(_MSC_VER)
949 # define INT64_C(x) x##i64
950 # define UINT64_C(x) x##ui64
953 /* 7.18.4.2. Macros for greatest-width integer constants */
957 #if @HAVE_LONG_64BIT@
958 # define INTMAX_C(x) x##L
959 # define UINTMAX_C(x) x##UL
960 #elif @HAVE_LONG_LONG_64BIT@
961 # define INTMAX_C(x) x##LL
962 # define UINTMAX_C(x) x##ULL
963 #elif defined(_MSC_VER)
964 # define INTMAX_C(x) x##i64
965 # define UINTMAX_C(x) x##ui64
967 # define INTMAX_C(x) x
968 # define UINTMAX_C(x) x##U
973 #endif /* _STDINT_H */