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 /* BSD/OS 4.2 defines WCHAR_MIN, WCHAR_MAX in <wchar.h>, not <stddef.h>. */
30 #if !(defined(WCHAR_MIN) && defined(WCHAR_MAX)) && @HAVE_WCHAR_H@
34 /* Get LONG_MIN, LONG_MAX, ULONG_MAX. */
37 /* Get those types that are already defined in other system include files. */
38 #if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4)
39 # include <sys/inttypes.h>
41 #if defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi)
42 /* In OpenBSD 3.8, <sys/types.h> includes <machine/types.h>, which defines
43 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
44 <inttypes.h> includes <machine/types.h> and also defines intptr_t and
46 /* BSD/OS 4.2 is similar, but doesn't have <inttypes.h> */
47 /* IRIX 6.5 has <inttypes.h>, and <sys/types.h> defines some of these
49 # include <sys/types.h>
50 # if @HAVE_INTTYPES_H@
51 # include @FULL_PATH_INTTYPES_H@
54 #if defined(__linux__) && @HAVE_SYS_BITYPES_H@
55 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
56 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
57 included by <sys/types.h>. */
58 # include <sys/bitypes.h>
60 #if defined(__sun) && @HAVE_SYS_INTTYPES_H@
61 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
62 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.
63 But note that <sys/int_types.h> contains only the type definitions! */
64 # include <sys/inttypes.h>
66 #if (defined(__hpux) || defined(_AIX)) && @HAVE_INTTYPES_H@
67 /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX,
68 UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
69 /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX,
70 UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
71 # include @FULL_PATH_INTTYPES_H@
74 /* Other systems may have an incomplete <stdint.h>. */
75 /* On some versions of IRIX, the SGI C compiler comes with an <stdint.h>,
77 - in c99 mode, <inttypes.h> includes <stdint.h>,
78 - in c89 mode, <stdint.h> spews warnings and defines nothing.
79 <inttypes.h> defines only a subset of the types and macros that
80 <stdint.h> would define in c99 mode.
81 So we rely only on <inttypes.h> (included above). It means that in
82 c89 mode, we shadow the contents of warning-spewing <stdint.h>. */
83 # if !(defined(__sgi) && @HAVE_INTTYPES_H@ && !defined(__c99))
84 # include @FULL_PATH_STDINT_H@
88 /* 7.18.1.1. Exact-width integer types */
90 /* Here we assume a standard architecture where the hardware integer
91 types have 8, 16, 32, optionally 64 bits. */
94 typedef signed char int8_t;
97 typedef unsigned char uint8_t;
98 # define _UINT8_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
102 typedef short int16_t;
105 typedef unsigned short uint16_t;
112 typedef unsigned int uint32_t;
113 # define _UINT32_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
117 # define _STDINT_H_HAVE_INT64 1
119 # if @HAVE_LONG_64BIT@
120 typedef long int64_t;
121 # define _STDINT_H_HAVE_INT64 1
122 # elif @HAVE_LONG_LONG_64BIT@
123 typedef long long int64_t;
124 # define _STDINT_H_HAVE_INT64 1
125 # elif defined _MSC_VER
126 typedef __int64 int64_t;
127 # define _STDINT_H_HAVE_INT64 1
131 # define _STDINT_H_HAVE_UINT64 1
133 # if @HAVE_LONG_64BIT@
134 typedef unsigned long uint64_t;
135 # define _STDINT_H_HAVE_UINT64 1
136 # elif @HAVE_LONG_LONG_64BIT@
137 typedef unsigned long long uint64_t;
138 # define _UINT64_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
139 # define _STDINT_H_HAVE_UINT64 1
140 # elif defined _MSC_VER
141 typedef unsigned __int64 uint64_t;
142 # define _STDINT_H_HAVE_UINT64 1
146 /* 7.18.1.2. Minimum-width integer types */
148 /* Here we assume a standard architecture where the hardware integer
149 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
150 are the same as the corresponding N_t types. */
152 #if !@HAVE_INT_LEAST8_T@
153 typedef int8_t int_least8_t;
155 #if !@HAVE_UINT_LEAST8_T@
156 typedef uint8_t uint_least8_t;
159 #if !@HAVE_INT_LEAST16_T@
160 typedef int16_t int_least16_t;
162 #if !@HAVE_UINT_LEAST16_T@
163 typedef uint16_t uint_least16_t;
166 #if !@HAVE_INT_LEAST32_T@
167 typedef int32_t int_least32_t;
169 #if !@HAVE_UINT_LEAST32_T@
170 typedef uint32_t uint_least32_t;
173 #if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64
174 typedef int64_t int_least64_t;
176 #if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64
177 typedef uint64_t uint_least64_t;
180 /* 7.18.1.3. Fastest minimum-width integer types */
182 /* Note: Other <stdint.h> substitutes may define these types differently.
183 It is not recommended to use these types in public header files. */
185 /* Here we assume a standard architecture where the hardware integer
186 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
187 are taken from the same list of types. */
189 /* On alpha processors, int32_t variables are slower than int64_t variables,
190 due to the necessary zap instructions. */
192 # define _STDINT_H_INT64_FASTER_THAN_INT32 1
195 #if !@HAVE_INT_FAST8_T@
196 # if _STDINT_H_INT64_FASTER_THAN_INT32
197 typedef int64_t int_fast8_t;
199 typedef int32_t int_fast8_t;
202 #if !@HAVE_UINT_FAST8_T@
203 # if _STDINT_H_INT64_FASTER_THAN_INT32
204 typedef uint64_t uint_fast8_t;
206 typedef uint32_t uint_fast8_t;
210 #if !@HAVE_INT_FAST16_T@
211 # if _STDINT_H_INT64_FASTER_THAN_INT32
212 typedef int64_t int_fast16_t;
214 typedef int32_t int_fast16_t;
217 #if !@HAVE_UINT_FAST16_T@
218 # if _STDINT_H_INT64_FASTER_THAN_INT32
219 typedef uint64_t uint_fast16_t;
221 typedef uint32_t uint_fast16_t;
225 #if !@HAVE_INT_FAST32_T@
226 # if _STDINT_H_INT64_FASTER_THAN_INT32
227 typedef int64_t int_fast32_t;
229 typedef int32_t int_fast32_t;
232 #if !@HAVE_UINT_FAST32_T@
233 # if _STDINT_H_INT64_FASTER_THAN_INT32
234 typedef uint64_t uint_fast32_t;
236 typedef uint32_t uint_fast32_t;
240 #if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64
241 typedef int64_t int_fast64_t;
243 #if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64
244 typedef uint64_t uint_fast64_t;
247 /* 7.18.1.4. Integer types capable of holding object pointers */
249 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
250 but this doesn't matter here. */
252 typedef long intptr_t;
254 #if !@HAVE_UINTPTR_T@
255 typedef unsigned long uintptr_t;
258 /* 7.18.1.5. Greatest-width integer types */
260 /* Note: These types are compiler dependent. It may be unwise to use them in
261 public header files. */
264 /* Remove possible redundant definition from gnulib's config.h first. */
266 # ifdef _STDINT_H_HAVE_INT64
267 typedef int64_t intmax_t;
269 typedef int32_t intmax_t;
272 #if !@HAVE_UINTMAX_T@
273 /* Remove possible redundant definition from gnulib's config.h first. */
275 # ifdef _STDINT_H_HAVE_UINT64
276 typedef uint64_t uintmax_t;
278 typedef uint32_t uintmax_t;
282 /* 7.18.2. Limits of specified-width integer types */
284 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
286 /* 7.18.2.1. Limits of exact-width integer types */
288 /* Here we assume a standard architecture where the hardware integer
289 types have 8, 16, 32, optionally 64 bits. */
293 # define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1))
296 # define INT8_MIN -128
300 # define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1)))
303 # define INT8_MAX 127
307 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
308 # define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
310 # define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
314 # define UINT8_MAX 255
319 # define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1))
322 # define INT16_MIN -32768
326 # define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1)))
329 # define INT16_MAX 32767
333 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
334 # define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
336 # define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
340 # define UINT16_MAX 65535
345 # define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1))
348 # define INT32_MIN (~INT32_MAX)
352 # define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1)))
355 # define INT32_MAX 2147483647
359 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
360 # define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
362 # define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
366 # define UINT32_MAX 4294967295U
371 # if @HAVE_LONG_64BIT@
372 # define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1))
373 # elif @HAVE_LONG_LONG_64BIT@
374 # define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1))
375 # elif defined _MSC_VER
376 # define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1))
380 # ifdef _STDINT_H_HAVE_INT64
381 # define INT64_MIN (~INT64_MAX)
386 # if @HAVE_LONG_64BIT@
387 # define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1)))
388 # elif @HAVE_LONG_LONG_64BIT@
389 # define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1)))
390 # elif defined _MSC_VER
391 # define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1)))
395 # ifdef _STDINT_H_HAVE_INT64
396 # if @HAVE_LONG_64BIT@
397 # define INT64_MAX 9223372036854775807L
398 # elif @HAVE_LONG_LONG_64BIT@
399 # define INT64_MAX 9223372036854775807LL
400 # elif defined _MSC_VER
401 # define INT64_MAX 9223372036854775807i64
407 # if @HAVE_LONG_64BIT@
408 # define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
409 # elif @HAVE_LONG_LONG_64BIT@
410 # define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
411 # elif defined _MSC_VER
412 # define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
416 # ifdef _STDINT_H_HAVE_UINT64
417 # if @HAVE_LONG_64BIT@
418 # define UINT64_MAX 18446744073709551615UL
419 # elif @HAVE_LONG_LONG_64BIT@
420 # define UINT64_MAX 18446744073709551615ULL
421 # elif defined _MSC_VER
422 # define UINT64_MAX 18446744073709551615ui64
427 /* 7.18.2.2. Limits of minimum-width integer types */
429 /* Here we assume a standard architecture where the hardware integer
430 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
431 are the same as the corresponding N_t types. */
433 #if @HAVE_INT_LEAST8_T@
434 # ifndef INT_LEAST8_MIN
435 # define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))
438 # define INT_LEAST8_MIN INT8_MIN
440 #if @HAVE_INT_LEAST8_T@
441 # ifndef INT_LEAST8_MAX
442 # define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)))
445 # define INT_LEAST8_MAX INT8_MAX
447 #if @HAVE_UINT_LEAST8_T@
448 # ifndef UINT_LEAST8_MAX
449 # if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
450 # define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
452 # define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
456 # define UINT_LEAST8_MAX UINT8_MAX
459 #if @HAVE_INT_LEAST16_T@
460 # ifndef INT_LEAST16_MIN
461 # define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))
464 # define INT_LEAST16_MIN INT16_MIN
466 #if @HAVE_INT_LEAST16_T@
467 # ifndef INT_LEAST16_MAX
468 # define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)))
471 # define INT_LEAST16_MAX INT16_MAX
473 #if @HAVE_UINT_LEAST16_T@
474 # ifndef UINT_LEAST16_MAX
475 # if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
476 # define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
478 # define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
482 # define UINT_LEAST16_MAX UINT16_MAX
485 #if @HAVE_INT_LEAST32_T@
486 # ifndef INT_LEAST32_MIN
487 # define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))
490 # define INT_LEAST32_MIN INT32_MIN
492 #if @HAVE_INT_LEAST32_T@
493 # ifndef INT_LEAST32_MAX
494 # define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)))
497 # define INT_LEAST32_MAX INT32_MAX
499 #if @HAVE_UINT_LEAST32_T@
500 # ifndef UINT_LEAST32_MAX
501 # if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
502 # define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
504 # define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
508 # define UINT_LEAST32_MAX UINT32_MAX
511 #if @HAVE_INT_LEAST64_T@
512 # ifndef INT_LEAST64_MIN
513 # if @HAVE_LONG_64BIT@
514 # define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))
515 # elif @HAVE_LONG_LONG_64BIT@
516 # define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))
517 # elif defined _MSC_VER
518 # define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))
522 # ifdef _STDINT_H_HAVE_INT64
523 # define INT_LEAST64_MIN INT64_MIN
526 #if @HAVE_INT_LEAST64_T@
527 # ifndef INT_LEAST64_MAX
528 # if @HAVE_LONG_64BIT@
529 # define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
530 # elif @HAVE_LONG_LONG_64BIT@
531 # define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
532 # elif defined _MSC_VER
533 # define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
537 # ifdef _STDINT_H_HAVE_INT64
538 # define INT_LEAST64_MAX INT64_MAX
541 #if @HAVE_UINT_LEAST64_T@
542 # ifndef UINT_LEAST64_MAX
543 # if @HAVE_LONG_64BIT@
544 # define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
545 # elif @HAVE_LONG_LONG_64BIT@
546 # define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
547 # elif defined _MSC_VER
548 # define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
552 # ifdef _STDINT_H_HAVE_UINT64
553 # define UINT_LEAST64_MAX UINT64_MAX
557 /* 7.18.2.3. Limits of fastest minimum-width integer types */
559 /* Here we assume a standard architecture where the hardware integer
560 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
561 are taken from the same list of types. */
563 #if @HAVE_INT_FAST8_T@
564 # ifndef INT_FAST8_MIN
565 # define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))
568 # if _STDINT_H_INT64_FASTER_THAN_INT32
569 # define INT_FAST8_MIN INT64_MIN
571 # define INT_FAST8_MIN INT32_MIN
574 #if @HAVE_INT_FAST8_T@
575 # ifndef INT_FAST8_MAX
576 # define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)))
579 # if _STDINT_H_INT64_FASTER_THAN_INT32
580 # define INT_FAST8_MAX INT64_MAX
582 # define INT_FAST8_MAX INT32_MAX
585 #if @HAVE_UINT_FAST8_T@
586 # ifndef UINT_FAST8_MAX
587 # if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
588 # define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
590 # define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
594 # if _STDINT_H_INT64_FASTER_THAN_INT32
595 # define UINT_FAST8_MAX UINT64_MAX
597 # define UINT_FAST8_MAX UINT32_MAX
601 #if @HAVE_INT_FAST16_T@
602 # ifndef INT_FAST16_MIN
603 # define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))
606 # if _STDINT_H_INT64_FASTER_THAN_INT32
607 # define INT_FAST16_MIN INT64_MIN
609 # define INT_FAST16_MIN INT32_MIN
612 #if @HAVE_INT_FAST16_T@
613 # ifndef INT_FAST16_MAX
614 # define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)))
617 # if _STDINT_H_INT64_FASTER_THAN_INT32
618 # define INT_FAST16_MAX INT64_MAX
620 # define INT_FAST16_MAX INT32_MAX
623 #if @HAVE_UINT_FAST16_T@
624 # ifndef UINT_FAST16_MAX
625 # if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
626 # define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
628 # define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
632 # if _STDINT_H_INT64_FASTER_THAN_INT32
633 # define UINT_FAST16_MAX UINT64_MAX
635 # define UINT_FAST16_MAX UINT32_MAX
639 #if @HAVE_INT_FAST32_T@
640 # ifndef INT_FAST32_MIN
641 # define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))
644 # if _STDINT_H_INT64_FASTER_THAN_INT32
645 # define INT_FAST32_MIN INT64_MIN
647 # define INT_FAST32_MIN INT32_MIN
650 #if @HAVE_INT_FAST32_T@
651 # ifndef INT_FAST32_MAX
652 # define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)))
655 # if _STDINT_H_INT64_FASTER_THAN_INT32
656 # define INT_FAST32_MAX INT64_MAX
658 # define INT_FAST32_MAX INT32_MAX
661 #if @HAVE_UINT_FAST32_T@
662 # ifndef UINT_FAST32_MAX
663 # if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
664 # define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
666 # define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
670 # if _STDINT_H_INT64_FASTER_THAN_INT32
671 # define UINT_FAST32_MAX UINT64_MAX
673 # define UINT_FAST32_MAX UINT32_MAX
677 #if @HAVE_INT_FAST64_T@
678 # ifndef INT_FAST64_MIN
679 # if @HAVE_LONG_64BIT@
680 # define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))
681 # elif @HAVE_LONG_LONG_64BIT@
682 # define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))
683 # elif defined _MSC_VER
684 # define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))
688 # ifdef _STDINT_H_HAVE_INT64
689 # define INT_FAST64_MIN INT64_MIN
692 #if @HAVE_INT_FAST64_T@
693 # ifndef INT_FAST64_MAX
694 # if @HAVE_LONG_64BIT@
695 # define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)))
696 # elif @HAVE_LONG_LONG_64BIT@
697 # define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)))
698 # elif defined _MSC_VER
699 # define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)))
703 # ifdef _STDINT_H_HAVE_INT64
704 # define INT_FAST64_MAX INT64_MAX
707 #if @HAVE_UINT_FAST64_T@
708 # ifndef UINT_FAST64_MAX
709 # if @HAVE_LONG_64BIT@
710 # define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
711 # elif @HAVE_LONG_LONG_64BIT@
712 # define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
713 # elif defined _MSC_VER
714 # define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
718 # ifdef _STDINT_H_HAVE_UINT64
719 # define UINT_FAST64_MAX UINT64_MAX
723 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
727 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
728 # define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))
730 # define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1))
734 # define INTPTR_MIN LONG_MIN
738 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
739 # define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)))
741 # define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1)))
745 # define INTPTR_MAX LONG_MAX
749 # if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@
750 # define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
752 # define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
756 # define UINTPTR_MAX ULONG_MAX
759 /* 7.18.2.5. Limits of greatest-width integer types */
763 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
764 # define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))
766 # define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1))
770 # ifdef _STDINT_H_HAVE_INT64
771 # define INTMAX_MIN INT64_MIN
773 # define INTMAX_MIN INT32_MIN
778 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
779 # define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)))
781 # define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1)))
785 # ifdef _STDINT_H_HAVE_INT64
786 # define INTMAX_MAX INT64_MAX
788 # define INTMAX_MAX INT32_MAX
793 # if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@
794 # define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
796 # define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
800 # ifdef _STDINT_H_HAVE_INT64
801 # define UINTMAX_MAX UINT64_MAX
803 # define UINTMAX_MAX UINT32_MAX
807 /* 7.18.3. Limits of other integer types */
809 /* ptrdiff_t limits */
811 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
812 # define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))
814 # define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))
818 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
819 # define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)))
821 # define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)))
825 /* sig_atomic_t limits */
826 #ifndef SIG_ATOMIC_MIN
827 # if @HAVE_SIGNED_SIG_ATOMIC_T@
828 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
829 # define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
831 # define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
834 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
835 # define SIG_ATOMIC_MIN 0UL
836 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
837 # define SIG_ATOMIC_MIN 0U
839 # define SIG_ATOMIC_MIN 0
843 #ifndef SIG_ATOMIC_MAX
844 # if @HAVE_SIGNED_SIG_ATOMIC_T@
845 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
846 # define SIG_ATOMIC_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
848 # define SIG_ATOMIC_MAX (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
851 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
852 # define SIG_ATOMIC_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
853 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
854 # define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
856 # define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
862 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */
863 # if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@
864 # define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
866 # define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
870 /* wchar_t limits may already be defined in <stddef.h>. */
872 # if @HAVE_SIGNED_WCHAR_T@
873 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
874 # define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1))
876 # define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1))
879 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
880 # define WCHAR_MIN 0UL
881 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
882 # define WCHAR_MIN 0U
889 # if @HAVE_SIGNED_WCHAR_T@
890 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
891 # define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1)))
893 # define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1)))
896 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
897 # define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
898 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
899 # define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
901 # define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
908 # if @HAVE_SIGNED_WINT_T@
909 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
910 # define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1))
912 # define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1))
915 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
916 # define WINT_MIN 0UL
917 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
925 # if @HAVE_SIGNED_WINT_T@
926 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
927 # define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1)))
929 # define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1)))
932 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
933 # define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
934 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
935 # define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
937 # define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
944 /* 7.18.4. Macros for integer constants */
946 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
948 /* 7.18.4.1. Macros for minimum-width integer constants */
949 /* According to ISO C 99 Technical Corrigendum 1 */
955 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
956 # define UINT8_C(x) x
958 # define UINT8_C(x) x##U
961 # define UINT8_C(x) x
968 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
969 # define UINT16_C(x) x
971 # define UINT16_C(x) x##U
974 # define UINT16_C(x) x
981 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
982 # define UINT32_C(x) x
984 # define UINT32_C(x) x##U
987 # define UINT32_C(x) x
992 #if @HAVE_LONG_64BIT@
993 # define INT64_C(x) x##L
994 # define UINT64_C(x) x##UL
995 #elif @HAVE_LONG_LONG_64BIT@
996 # define INT64_C(x) x##LL
997 # define UINT64_C(x) x##ULL
998 #elif defined(_MSC_VER)
999 # define INT64_C(x) x##i64
1000 # define UINT64_C(x) x##ui64
1003 /* 7.18.4.2. Macros for greatest-width integer constants */
1007 #if @HAVE_LONG_64BIT@
1008 # define INTMAX_C(x) x##L
1009 # define UINTMAX_C(x) x##UL
1010 #elif @HAVE_LONG_LONG_64BIT@
1011 # define INTMAX_C(x) x##LL
1012 # define UINTMAX_C(x) x##ULL
1013 #elif defined(_MSC_VER)
1014 # define INTMAX_C(x) x##i64
1015 # define UINTMAX_C(x) x##ui64
1017 # define INTMAX_C(x) x
1018 # define UINTMAX_C(x) x##U
1023 #endif /* _STDINT_H */