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 /* Some systems define 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. <inttypes.h> defines only
79 a subset of the types and macros that are defined in <stdint.h>.
80 So we rely only on <inttypes.h> (included above). It means that in
81 c89 mode, we shadow the contents of warning-spewing <stdint.h>. */
82 # if !(defined(__sgi) && @HAVE_INTTYPES_H@ && !defined(_c99))
83 # include @FULL_PATH_STDINT_H@
87 /* 7.18.1.1. Exact-width integer types */
89 /* Here we assume a standard architecture where the hardware integer
90 types have 8, 16, 32, optionally 64 bits. */
93 typedef signed char int8_t;
96 typedef unsigned char uint8_t;
97 # define _UINT8_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
101 typedef short int16_t;
104 typedef unsigned short uint16_t;
111 typedef unsigned int uint32_t;
112 # define _UINT32_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
116 # define _STDINT_H_HAVE_INT64 1
118 # if @HAVE_LONG_64BIT@
119 typedef long int64_t;
120 # define _STDINT_H_HAVE_INT64 1
121 # elif @HAVE_LONG_LONG_64BIT@
122 typedef long long int64_t;
123 # define _STDINT_H_HAVE_INT64 1
124 # elif defined _MSC_VER
125 typedef __int64 int64_t;
126 # define _STDINT_H_HAVE_INT64 1
130 # define _STDINT_H_HAVE_UINT64 1
132 # if @HAVE_LONG_64BIT@
133 typedef unsigned long uint64_t;
134 # define _STDINT_H_HAVE_UINT64 1
135 # elif @HAVE_LONG_LONG_64BIT@
136 typedef unsigned long long uint64_t;
137 # define _UINT64_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
138 # define _STDINT_H_HAVE_UINT64 1
139 # elif defined _MSC_VER
140 typedef unsigned __int64 uint64_t;
141 # define _STDINT_H_HAVE_UINT64 1
145 /* 7.18.1.2. Minimum-width integer types */
147 /* Here we assume a standard architecture where the hardware integer
148 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
149 are the same as the corresponding N_t types. */
151 #if !@HAVE_INT_LEAST8_T@
152 typedef int8_t int_least8_t;
154 #if !@HAVE_UINT_LEAST8_T@
155 typedef uint8_t uint_least8_t;
158 #if !@HAVE_INT_LEAST16_T@
159 typedef int16_t int_least16_t;
161 #if !@HAVE_UINT_LEAST16_T@
162 typedef uint16_t uint_least16_t;
165 #if !@HAVE_INT_LEAST32_T@
166 typedef int32_t int_least32_t;
168 #if !@HAVE_UINT_LEAST32_T@
169 typedef uint32_t uint_least32_t;
172 #if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64
173 typedef int64_t int_least64_t;
175 #if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64
176 typedef uint64_t uint_least64_t;
179 /* 7.18.1.3. Fastest minimum-width integer types */
181 /* Note: Other <stdint.h> substitutes may define these types differently.
182 It is not recommended to use these types in public header files. */
184 /* Here we assume a standard architecture where the hardware integer
185 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
186 are taken from the same list of types. */
188 /* On alpha processors, int32_t variables are slower than int64_t variables,
189 due to the necessary zap instructions. */
191 # define _STDINT_H_INT64_FASTER_THAN_INT32 1
194 #if !@HAVE_INT_FAST8_T@
195 # if _STDINT_H_INT64_FASTER_THAN_INT32
196 typedef int64_t int_fast8_t;
198 typedef int32_t int_fast8_t;
201 #if !@HAVE_UINT_FAST8_T@
202 # if _STDINT_H_INT64_FASTER_THAN_INT32
203 typedef uint64_t uint_fast8_t;
205 typedef uint32_t uint_fast8_t;
209 #if !@HAVE_INT_FAST16_T@
210 # if _STDINT_H_INT64_FASTER_THAN_INT32
211 typedef int64_t int_fast16_t;
213 typedef int32_t int_fast16_t;
216 #if !@HAVE_UINT_FAST16_T@
217 # if _STDINT_H_INT64_FASTER_THAN_INT32
218 typedef uint64_t uint_fast16_t;
220 typedef uint32_t uint_fast16_t;
224 #if !@HAVE_INT_FAST32_T@
225 # if _STDINT_H_INT64_FASTER_THAN_INT32
226 typedef int64_t int_fast32_t;
228 typedef int32_t int_fast32_t;
231 #if !@HAVE_UINT_FAST32_T@
232 # if _STDINT_H_INT64_FASTER_THAN_INT32
233 typedef uint64_t uint_fast32_t;
235 typedef uint32_t uint_fast32_t;
239 #if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64
240 typedef int64_t int_fast64_t;
242 #if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64
243 typedef uint64_t uint_fast64_t;
246 /* 7.18.1.4. Integer types capable of holding object pointers */
248 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
249 but this doesn't matter here. */
251 typedef long intptr_t;
253 #if !@HAVE_UINTPTR_T@
254 typedef unsigned long uintptr_t;
257 /* 7.18.1.5. Greatest-width integer types */
259 /* Note: These types are compiler dependent. It may be unwise to use them in
260 public header files. */
263 # ifdef _STDINT_H_HAVE_INT64
264 typedef int64_t intmax_t;
266 typedef int32_t intmax_t;
269 #if !@HAVE_UINTMAX_T@
270 # ifdef _STDINT_H_HAVE_UINT64
271 typedef uint64_t uintmax_t;
273 typedef uint32_t uintmax_t;
277 /* 7.18.2. Limits of specified-width integer types */
279 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
281 /* 7.18.2.1. Limits of exact-width integer types */
283 /* Here we assume a standard architecture where the hardware integer
284 types have 8, 16, 32, optionally 64 bits. */
288 # define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1))
291 # define INT8_MIN -128
295 # define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1)))
298 # define INT8_MAX 127
302 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
303 # define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
305 # define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
309 # define UINT8_MAX 255
314 # define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1))
317 # define INT16_MIN -32768
321 # define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1)))
324 # define INT16_MAX 32767
328 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
329 # define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
331 # define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
335 # define UINT16_MAX 65535
340 # define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1))
343 # define INT32_MIN (~INT32_MAX)
347 # define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1)))
350 # define INT32_MAX 2147483647
354 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
355 # define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
357 # define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
361 # define UINT32_MAX 4294967295U
366 # if @HAVE_LONG_64BIT@
367 # define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1))
368 # elif @HAVE_LONG_LONG_64BIT@
369 # define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1))
370 # elif defined _MSC_VER
371 # define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1))
375 # ifdef _STDINT_H_HAVE_INT64
376 # define INT64_MIN (~INT64_MAX)
381 # if @HAVE_LONG_64BIT@
382 # define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1)))
383 # elif @HAVE_LONG_LONG_64BIT@
384 # define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1)))
385 # elif defined _MSC_VER
386 # define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1)))
390 # ifdef _STDINT_H_HAVE_INT64
391 # if @HAVE_LONG_64BIT@
392 # define INT64_MAX 9223372036854775807L
393 # elif @HAVE_LONG_LONG_64BIT@
394 # define INT64_MAX 9223372036854775807LL
395 # elif defined _MSC_VER
396 # define INT64_MAX 9223372036854775807i64
402 # if @HAVE_LONG_64BIT@
403 # define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
404 # elif @HAVE_LONG_LONG_64BIT@
405 # define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
406 # elif defined _MSC_VER
407 # define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
411 # ifdef _STDINT_H_HAVE_UINT64
412 # if @HAVE_LONG_64BIT@
413 # define UINT64_MAX 18446744073709551615UL
414 # elif @HAVE_LONG_LONG_64BIT@
415 # define UINT64_MAX 18446744073709551615ULL
416 # elif defined _MSC_VER
417 # define UINT64_MAX 18446744073709551615ui64
422 /* 7.18.2.2. Limits of minimum-width integer types */
424 /* Here we assume a standard architecture where the hardware integer
425 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
426 are the same as the corresponding N_t types. */
428 #if @HAVE_INT_LEAST8_T@
429 # ifndef INT_LEAST8_MIN
430 # define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))
433 # define INT_LEAST8_MIN INT8_MIN
435 #if @HAVE_INT_LEAST8_T@
436 # ifndef INT_LEAST8_MAX
437 # define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)))
440 # define INT_LEAST8_MAX INT8_MAX
442 #if @HAVE_UINT_LEAST8_T@
443 # ifndef UINT_LEAST8_MAX
444 # if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
445 # define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
447 # define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
451 # define UINT_LEAST8_MAX UINT8_MAX
454 #if @HAVE_INT_LEAST16_T@
455 # ifndef INT_LEAST16_MIN
456 # define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))
459 # define INT_LEAST16_MIN INT16_MIN
461 #if @HAVE_INT_LEAST16_T@
462 # ifndef INT_LEAST16_MAX
463 # define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)))
466 # define INT_LEAST16_MAX INT16_MAX
468 #if @HAVE_UINT_LEAST16_T@
469 # ifndef UINT_LEAST16_MAX
470 # if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
471 # define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
473 # define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
477 # define UINT_LEAST16_MAX UINT16_MAX
480 #if @HAVE_INT_LEAST32_T@
481 # ifndef INT_LEAST32_MIN
482 # define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))
485 # define INT_LEAST32_MIN INT32_MIN
487 #if @HAVE_INT_LEAST32_T@
488 # ifndef INT_LEAST32_MAX
489 # define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)))
492 # define INT_LEAST32_MAX INT32_MAX
494 #if @HAVE_UINT_LEAST32_T@
495 # ifndef UINT_LEAST32_MAX
496 # if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
497 # define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
499 # define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
503 # define UINT_LEAST32_MAX UINT32_MAX
506 #if @HAVE_INT_LEAST64_T@
507 # ifndef INT_LEAST64_MIN
508 # if @HAVE_LONG_64BIT@
509 # define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))
510 # elif @HAVE_LONG_LONG_64BIT@
511 # define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))
512 # elif defined _MSC_VER
513 # define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))
517 # ifdef _STDINT_H_HAVE_INT64
518 # define INT_LEAST64_MIN INT64_MIN
521 #if @HAVE_INT_LEAST64_T@
522 # ifndef INT_LEAST64_MAX
523 # if @HAVE_LONG_64BIT@
524 # define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
525 # elif @HAVE_LONG_LONG_64BIT@
526 # define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
527 # elif defined _MSC_VER
528 # define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
532 # ifdef _STDINT_H_HAVE_INT64
533 # define INT_LEAST64_MAX INT64_MAX
536 #if @HAVE_UINT_LEAST64_T@
537 # ifndef UINT_LEAST64_MAX
538 # if @HAVE_LONG_64BIT@
539 # define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
540 # elif @HAVE_LONG_LONG_64BIT@
541 # define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
542 # elif defined _MSC_VER
543 # define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
547 # ifdef _STDINT_H_HAVE_UINT64
548 # define UINT_LEAST64_MAX UINT64_MAX
552 /* 7.18.2.3. Limits of fastest minimum-width integer types */
554 /* Here we assume a standard architecture where the hardware integer
555 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
556 are taken from the same list of types. */
558 #if @HAVE_INT_FAST8_T@
559 # ifndef INT_FAST8_MIN
560 # define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))
563 # if _STDINT_H_INT64_FASTER_THAN_INT32
564 # define INT_FAST8_MIN INT64_MIN
566 # define INT_FAST8_MIN INT32_MIN
569 #if @HAVE_INT_FAST8_T@
570 # ifndef INT_FAST8_MAX
571 # define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)))
574 # if _STDINT_H_INT64_FASTER_THAN_INT32
575 # define INT_FAST8_MAX INT64_MAX
577 # define INT_FAST8_MAX INT32_MAX
580 #if @HAVE_UINT_FAST8_T@
581 # ifndef UINT_FAST8_MAX
582 # if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
583 # define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
585 # define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
589 # if _STDINT_H_INT64_FASTER_THAN_INT32
590 # define UINT_FAST8_MAX UINT64_MAX
592 # define UINT_FAST8_MAX UINT32_MAX
596 #if @HAVE_INT_FAST16_T@
597 # ifndef INT_FAST16_MIN
598 # define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))
601 # if _STDINT_H_INT64_FASTER_THAN_INT32
602 # define INT_FAST16_MIN INT64_MIN
604 # define INT_FAST16_MIN INT32_MIN
607 #if @HAVE_INT_FAST16_T@
608 # ifndef INT_FAST16_MAX
609 # define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)))
612 # if _STDINT_H_INT64_FASTER_THAN_INT32
613 # define INT_FAST16_MAX INT64_MAX
615 # define INT_FAST16_MAX INT32_MAX
618 #if @HAVE_UINT_FAST16_T@
619 # ifndef UINT_FAST16_MAX
620 # if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
621 # define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
623 # define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
627 # if _STDINT_H_INT64_FASTER_THAN_INT32
628 # define UINT_FAST16_MAX UINT64_MAX
630 # define UINT_FAST16_MAX UINT32_MAX
634 #if @HAVE_INT_FAST32_T@
635 # ifndef INT_FAST32_MIN
636 # define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))
639 # if _STDINT_H_INT64_FASTER_THAN_INT32
640 # define INT_FAST32_MIN INT64_MIN
642 # define INT_FAST32_MIN INT32_MIN
645 #if @HAVE_INT_FAST32_T@
646 # ifndef INT_FAST32_MAX
647 # define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)))
650 # if _STDINT_H_INT64_FASTER_THAN_INT32
651 # define INT_FAST32_MAX INT64_MAX
653 # define INT_FAST32_MAX INT32_MAX
656 #if @HAVE_UINT_FAST32_T@
657 # ifndef UINT_FAST32_MAX
658 # if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
659 # define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
661 # define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
665 # if _STDINT_H_INT64_FASTER_THAN_INT32
666 # define UINT_FAST32_MAX UINT64_MAX
668 # define UINT_FAST32_MAX UINT32_MAX
672 #if @HAVE_INT_FAST64_T@
673 # ifndef INT_FAST64_MIN
674 # if @HAVE_LONG_64BIT@
675 # define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))
676 # elif @HAVE_LONG_LONG_64BIT@
677 # define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))
678 # elif defined _MSC_VER
679 # define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))
683 # ifdef _STDINT_H_HAVE_INT64
684 # define INT_FAST64_MIN INT64_MIN
687 #if @HAVE_INT_FAST64_T@
688 # ifndef INT_FAST64_MAX
689 # if @HAVE_LONG_64BIT@
690 # define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)))
691 # elif @HAVE_LONG_LONG_64BIT@
692 # define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)))
693 # elif defined _MSC_VER
694 # define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)))
698 # ifdef _STDINT_H_HAVE_INT64
699 # define INT_FAST64_MAX INT64_MAX
702 #if @HAVE_UINT_FAST64_T@
703 # ifndef UINT_FAST64_MAX
704 # if @HAVE_LONG_64BIT@
705 # define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
706 # elif @HAVE_LONG_LONG_64BIT@
707 # define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
708 # elif defined _MSC_VER
709 # define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
713 # ifdef _STDINT_H_HAVE_UINT64
714 # define UINT_FAST64_MAX UINT64_MAX
718 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
722 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
723 # define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))
725 # define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1))
729 # define INTPTR_MIN LONG_MIN
733 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
734 # define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)))
736 # define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1)))
740 # define INTPTR_MAX LONG_MAX
744 # if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@
745 # define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
747 # define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
751 # define UINTPTR_MAX ULONG_MAX
754 /* 7.18.2.5. Limits of greatest-width integer types */
758 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
759 # define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))
761 # define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1))
765 # ifdef _STDINT_H_HAVE_INT64
766 # define INTMAX_MIN INT64_MIN
768 # define INTMAX_MIN INT32_MIN
773 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
774 # define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)))
776 # define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1)))
780 # ifdef _STDINT_H_HAVE_INT64
781 # define INTMAX_MAX INT64_MAX
783 # define INTMAX_MAX INT32_MAX
788 # if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@
789 # define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
791 # define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
795 # ifdef _STDINT_H_HAVE_INT64
796 # define UINTMAX_MAX UINT64_MAX
798 # define UINTMAX_MAX UINT32_MAX
802 /* 7.18.3. Limits of other integer types */
804 /* ptrdiff_t limits */
806 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
807 # define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))
809 # define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))
813 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
814 # define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)))
816 # define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)))
820 /* sig_atomic_t limits */
821 #ifndef SIG_ATOMIC_MIN
822 # if @HAVE_SIGNED_SIG_ATOMIC_T@
823 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
824 # define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
826 # define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
829 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
830 # define SIG_ATOMIC_MIN 0UL
831 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
832 # define SIG_ATOMIC_MIN 0U
834 # define SIG_ATOMIC_MIN 0
838 #ifndef SIG_ATOMIC_MAX
839 # if @HAVE_SIGNED_SIG_ATOMIC_T@
840 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
841 # define SIG_ATOMIC_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
843 # define SIG_ATOMIC_MAX (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
846 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
847 # define SIG_ATOMIC_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
848 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
849 # define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
851 # define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
857 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */
858 # if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@
859 # define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
861 # define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
865 /* wchar_t limits may already be defined in <stddef.h>. */
867 # if @HAVE_SIGNED_WCHAR_T@
868 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
869 # define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1))
871 # define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1))
874 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
875 # define WCHAR_MIN 0UL
876 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
877 # define WCHAR_MIN 0U
884 # if @HAVE_SIGNED_WCHAR_T@
885 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
886 # define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1)))
888 # define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1)))
891 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
892 # define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
893 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
894 # define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
896 # define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
903 # if @HAVE_SIGNED_WINT_T@
904 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
905 # define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1))
907 # define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1))
910 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
911 # define WINT_MIN 0UL
912 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
920 # if @HAVE_SIGNED_WINT_T@
921 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
922 # define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1)))
924 # define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1)))
927 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
928 # define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
929 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
930 # define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
932 # define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
939 /* 7.18.4. Macros for integer constants */
941 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
943 /* 7.18.4.1. Macros for minimum-width integer constants */
944 /* According to ISO C 99 Technical Corrigendum 1 */
950 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
951 # define UINT8_C(x) x
953 # define UINT8_C(x) x##U
956 # define UINT8_C(x) x
963 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
964 # define UINT16_C(x) x
966 # define UINT16_C(x) x##U
969 # define UINT16_C(x) x
976 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
977 # define UINT32_C(x) x
979 # define UINT32_C(x) x##U
982 # define UINT32_C(x) x
987 #if @HAVE_LONG_64BIT@
988 # define INT64_C(x) x##L
989 # define UINT64_C(x) x##UL
990 #elif @HAVE_LONG_LONG_64BIT@
991 # define INT64_C(x) x##LL
992 # define UINT64_C(x) x##ULL
993 #elif defined(_MSC_VER)
994 # define INT64_C(x) x##i64
995 # define UINT64_C(x) x##ui64
998 /* 7.18.4.2. Macros for greatest-width integer constants */
1002 #if @HAVE_LONG_64BIT@
1003 # define INTMAX_C(x) x##L
1004 # define UINTMAX_C(x) x##UL
1005 #elif @HAVE_LONG_LONG_64BIT@
1006 # define INTMAX_C(x) x##LL
1007 # define UINTMAX_C(x) x##ULL
1008 #elif defined(_MSC_VER)
1009 # define INTMAX_C(x) x##i64
1010 # define UINTMAX_C(x) x##ui64
1012 # define INTMAX_C(x) x
1013 # define UINTMAX_C(x) x##U
1018 #endif /* _STDINT_H */