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__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4)
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;
80 # define _UINT8_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
84 typedef short int16_t;
87 typedef unsigned short uint16_t;
94 typedef unsigned int uint32_t;
95 # define _UINT32_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
99 # define _STDINT_H_HAVE_INT64 1
101 # if @HAVE_LONG_64BIT@
102 typedef long int64_t;
103 # define _STDINT_H_HAVE_INT64 1
104 # elif @HAVE_LONG_LONG_64BIT@
105 typedef long long int64_t;
106 # define _STDINT_H_HAVE_INT64 1
107 # elif defined _MSC_VER
108 typedef __int64 int64_t;
109 # define _STDINT_H_HAVE_INT64 1
113 # define _STDINT_H_HAVE_UINT64 1
115 # if @HAVE_LONG_64BIT@
116 typedef unsigned long uint64_t;
117 # define _STDINT_H_HAVE_UINT64 1
118 # elif @HAVE_LONG_LONG_64BIT@
119 typedef unsigned long long uint64_t;
120 # define _UINT64_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
121 # define _STDINT_H_HAVE_UINT64 1
122 # elif defined _MSC_VER
123 typedef unsigned __int64 uint64_t;
124 # define _STDINT_H_HAVE_UINT64 1
128 /* 7.18.1.2. Minimum-width integer types */
130 /* Here we assume a standard architecture where the hardware integer
131 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
132 are the same as the corresponding N_t types. */
134 #if !@HAVE_INT_LEAST8_T@
135 typedef int8_t int_least8_t;
137 #if !@HAVE_UINT_LEAST8_T@
138 typedef uint8_t uint_least8_t;
141 #if !@HAVE_INT_LEAST16_T@
142 typedef int16_t int_least16_t;
144 #if !@HAVE_UINT_LEAST16_T@
145 typedef uint16_t uint_least16_t;
148 #if !@HAVE_INT_LEAST32_T@
149 typedef int32_t int_least32_t;
151 #if !@HAVE_UINT_LEAST32_T@
152 typedef uint32_t uint_least32_t;
155 #if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64
156 typedef int64_t int_least64_t;
158 #if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64
159 typedef uint64_t uint_least64_t;
162 /* 7.18.1.3. Fastest minimum-width integer types */
164 /* Note: Other <stdint.h> substitutes may define these types differently.
165 It is not recommended to use these types in public header files. */
167 /* Here we assume a standard architecture where the hardware integer
168 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
169 are taken from the same list of types. */
171 /* On alpha processors, int32_t variables are slower than int64_t variables,
172 due to the necessary zap instructions. */
174 # define _STDINT_H_INT64_FASTER_THAN_INT32 1
177 #if !@HAVE_INT_FAST8_T@
178 # if _STDINT_H_INT64_FASTER_THAN_INT32
179 typedef int64_t int_fast8_t;
181 typedef int32_t int_fast8_t;
184 #if !@HAVE_UINT_FAST8_T@
185 # if _STDINT_H_INT64_FASTER_THAN_INT32
186 typedef uint64_t uint_fast8_t;
188 typedef uint32_t uint_fast8_t;
192 #if !@HAVE_INT_FAST16_T@
193 # if _STDINT_H_INT64_FASTER_THAN_INT32
194 typedef int64_t int_fast16_t;
196 typedef int32_t int_fast16_t;
199 #if !@HAVE_UINT_FAST16_T@
200 # if _STDINT_H_INT64_FASTER_THAN_INT32
201 typedef uint64_t uint_fast16_t;
203 typedef uint32_t uint_fast16_t;
207 #if !@HAVE_INT_FAST32_T@
208 # if _STDINT_H_INT64_FASTER_THAN_INT32
209 typedef int64_t int_fast32_t;
211 typedef int32_t int_fast32_t;
214 #if !@HAVE_UINT_FAST32_T@
215 # if _STDINT_H_INT64_FASTER_THAN_INT32
216 typedef uint64_t uint_fast32_t;
218 typedef uint32_t uint_fast32_t;
222 #if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64
223 typedef int64_t int_fast64_t;
225 #if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64
226 typedef uint64_t uint_fast64_t;
229 /* 7.18.1.4. Integer types capable of holding object pointers */
231 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
232 but this doesn't matter here. */
234 typedef long intptr_t;
236 #if !@HAVE_UINTPTR_T@
237 typedef unsigned long uintptr_t;
240 /* 7.18.1.5. Greatest-width integer types */
242 /* Note: These types are compiler dependent. It may be unwise to use them in
243 public header files. */
246 # ifdef _STDINT_H_HAVE_INT64
247 typedef int64_t intmax_t;
249 typedef int32_t intmax_t;
252 #if !@HAVE_UINTMAX_T@
253 # ifdef _STDINT_H_HAVE_UINT64
254 typedef uint64_t uintmax_t;
256 typedef uint32_t uintmax_t;
260 /* 7.18.2. Limits of specified-width integer types */
262 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
264 /* 7.18.2.1. Limits of exact-width integer types */
266 /* Here we assume a standard architecture where the hardware integer
267 types have 8, 16, 32, optionally 64 bits. */
271 # define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1))
274 # define INT8_MIN -128
278 # define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1)))
281 # define INT8_MAX 127
285 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
286 # define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
288 # define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
292 # define UINT8_MAX 255
297 # define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1))
300 # define INT16_MIN -32768
304 # define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1)))
307 # define INT16_MAX 32767
311 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
312 # define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
314 # define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
318 # define UINT16_MAX 65535
323 # define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1))
326 # define INT32_MIN (~INT32_MAX)
330 # define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1)))
333 # define INT32_MAX 2147483647
337 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
338 # define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
340 # define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
344 # define UINT32_MAX 4294967295U
349 # if @HAVE_LONG_64BIT@
350 # define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1))
351 # elif @HAVE_LONG_LONG_64BIT@
352 # define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1))
353 # elif defined _MSC_VER
354 # define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1))
358 # ifdef _STDINT_H_HAVE_INT64
359 # define INT64_MIN (~INT64_MAX)
364 # if @HAVE_LONG_64BIT@
365 # define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1)))
366 # elif @HAVE_LONG_LONG_64BIT@
367 # define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1)))
368 # elif defined _MSC_VER
369 # define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1)))
373 # ifdef _STDINT_H_HAVE_INT64
374 # if @HAVE_LONG_64BIT@
375 # define INT64_MAX 9223372036854775807L
376 # elif @HAVE_LONG_LONG_64BIT@
377 # define INT64_MAX 9223372036854775807LL
378 # elif defined _MSC_VER
379 # define INT64_MAX 9223372036854775807i64
385 # if @HAVE_LONG_64BIT@
386 # define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
387 # elif @HAVE_LONG_LONG_64BIT@
388 # define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
389 # elif defined _MSC_VER
390 # define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
394 # ifdef _STDINT_H_HAVE_UINT64
395 # if @HAVE_LONG_64BIT@
396 # define UINT64_MAX 18446744073709551615UL
397 # elif @HAVE_LONG_LONG_64BIT@
398 # define UINT64_MAX 18446744073709551615ULL
399 # elif defined _MSC_VER
400 # define UINT64_MAX 18446744073709551615ui64
405 /* 7.18.2.2. Limits of minimum-width integer types */
407 /* Here we assume a standard architecture where the hardware integer
408 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
409 are the same as the corresponding N_t types. */
411 #if @HAVE_INT_LEAST8_T@
412 # ifndef INT_LEAST8_MIN
413 # define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))
416 # define INT_LEAST8_MIN INT8_MIN
418 #if @HAVE_INT_LEAST8_T@
419 # ifndef INT_LEAST8_MAX
420 # define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)))
423 # define INT_LEAST8_MAX INT8_MAX
425 #if @HAVE_UINT_LEAST8_T@
426 # ifndef UINT_LEAST8_MAX
427 # if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
428 # define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
430 # define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
434 # define UINT_LEAST8_MAX UINT8_MAX
437 #if @HAVE_INT_LEAST16_T@
438 # ifndef INT_LEAST16_MIN
439 # define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))
442 # define INT_LEAST16_MIN INT16_MIN
444 #if @HAVE_INT_LEAST16_T@
445 # ifndef INT_LEAST16_MAX
446 # define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)))
449 # define INT_LEAST16_MAX INT16_MAX
451 #if @HAVE_UINT_LEAST16_T@
452 # ifndef UINT_LEAST16_MAX
453 # if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
454 # define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
456 # define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
460 # define UINT_LEAST16_MAX UINT16_MAX
463 #if @HAVE_INT_LEAST32_T@
464 # ifndef INT_LEAST32_MIN
465 # define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))
468 # define INT_LEAST32_MIN INT32_MIN
470 #if @HAVE_INT_LEAST32_T@
471 # ifndef INT_LEAST32_MAX
472 # define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)))
475 # define INT_LEAST32_MAX INT32_MAX
477 #if @HAVE_UINT_LEAST32_T@
478 # ifndef UINT_LEAST32_MAX
479 # if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
480 # define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
482 # define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
486 # define UINT_LEAST32_MAX UINT32_MAX
489 #if @HAVE_INT_LEAST64_T@
490 # ifndef INT_LEAST64_MIN
491 # if @HAVE_LONG_64BIT@
492 # define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))
493 # elif @HAVE_LONG_LONG_64BIT@
494 # define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))
495 # elif defined _MSC_VER
496 # define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))
500 # ifdef _STDINT_H_HAVE_INT64
501 # define INT_LEAST64_MIN INT64_MIN
504 #if @HAVE_INT_LEAST64_T@
505 # ifndef INT_LEAST64_MAX
506 # if @HAVE_LONG_64BIT@
507 # define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
508 # elif @HAVE_LONG_LONG_64BIT@
509 # define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
510 # elif defined _MSC_VER
511 # define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
515 # ifdef _STDINT_H_HAVE_INT64
516 # define INT_LEAST64_MAX INT64_MAX
519 #if @HAVE_UINT_LEAST64_T@
520 # ifndef UINT_LEAST64_MAX
521 # if @HAVE_LONG_64BIT@
522 # define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
523 # elif @HAVE_LONG_LONG_64BIT@
524 # define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
525 # elif defined _MSC_VER
526 # define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
530 # ifdef _STDINT_H_HAVE_UINT64
531 # define UINT_LEAST64_MAX UINT64_MAX
535 /* 7.18.2.3. Limits of fastest minimum-width integer types */
537 /* Here we assume a standard architecture where the hardware integer
538 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
539 are taken from the same list of types. */
541 #if @HAVE_INT_FAST8_T@
542 # ifndef INT_FAST8_MIN
543 # define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))
546 # if _STDINT_H_INT64_FASTER_THAN_INT32
547 # define INT_FAST8_MIN INT64_MIN
549 # define INT_FAST8_MIN INT32_MIN
552 #if @HAVE_INT_FAST8_T@
553 # ifndef INT_FAST8_MAX
554 # define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)))
557 # if _STDINT_H_INT64_FASTER_THAN_INT32
558 # define INT_FAST8_MAX INT64_MAX
560 # define INT_FAST8_MAX INT32_MAX
563 #if @HAVE_UINT_FAST8_T@
564 # ifndef UINT_FAST8_MAX
565 # if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
566 # define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
568 # define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
572 # if _STDINT_H_INT64_FASTER_THAN_INT32
573 # define UINT_FAST8_MAX UINT64_MAX
575 # define UINT_FAST8_MAX UINT32_MAX
579 #if @HAVE_INT_FAST16_T@
580 # ifndef INT_FAST16_MIN
581 # define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))
584 # if _STDINT_H_INT64_FASTER_THAN_INT32
585 # define INT_FAST16_MIN INT64_MIN
587 # define INT_FAST16_MIN INT32_MIN
590 #if @HAVE_INT_FAST16_T@
591 # ifndef INT_FAST16_MAX
592 # define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)))
595 # if _STDINT_H_INT64_FASTER_THAN_INT32
596 # define INT_FAST16_MAX INT64_MAX
598 # define INT_FAST16_MAX INT32_MAX
601 #if @HAVE_UINT_FAST16_T@
602 # ifndef UINT_FAST16_MAX
603 # if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
604 # define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
606 # define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
610 # if _STDINT_H_INT64_FASTER_THAN_INT32
611 # define UINT_FAST16_MAX UINT64_MAX
613 # define UINT_FAST16_MAX UINT32_MAX
617 #if @HAVE_INT_FAST32_T@
618 # ifndef INT_FAST32_MIN
619 # define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))
622 # if _STDINT_H_INT64_FASTER_THAN_INT32
623 # define INT_FAST32_MIN INT64_MIN
625 # define INT_FAST32_MIN INT32_MIN
628 #if @HAVE_INT_FAST32_T@
629 # ifndef INT_FAST32_MAX
630 # define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)))
633 # if _STDINT_H_INT64_FASTER_THAN_INT32
634 # define INT_FAST32_MAX INT64_MAX
636 # define INT_FAST32_MAX INT32_MAX
639 #if @HAVE_UINT_FAST32_T@
640 # ifndef UINT_FAST32_MAX
641 # if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
642 # define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
644 # define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
648 # if _STDINT_H_INT64_FASTER_THAN_INT32
649 # define UINT_FAST32_MAX UINT64_MAX
651 # define UINT_FAST32_MAX UINT32_MAX
655 #if @HAVE_INT_FAST64_T@
656 # ifndef INT_FAST64_MIN
657 # if @HAVE_LONG_64BIT@
658 # define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))
659 # elif @HAVE_LONG_LONG_64BIT@
660 # define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))
661 # elif defined _MSC_VER
662 # define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))
666 # ifdef _STDINT_H_HAVE_INT64
667 # define INT_FAST64_MIN INT64_MIN
670 #if @HAVE_INT_FAST64_T@
671 # ifndef INT_FAST64_MAX
672 # if @HAVE_LONG_64BIT@
673 # define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)))
674 # elif @HAVE_LONG_LONG_64BIT@
675 # define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)))
676 # elif defined _MSC_VER
677 # define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)))
681 # ifdef _STDINT_H_HAVE_INT64
682 # define INT_FAST64_MAX INT64_MAX
685 #if @HAVE_UINT_FAST64_T@
686 # ifndef UINT_FAST64_MAX
687 # if @HAVE_LONG_64BIT@
688 # define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
689 # elif @HAVE_LONG_LONG_64BIT@
690 # define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
691 # elif defined _MSC_VER
692 # define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
696 # ifdef _STDINT_H_HAVE_UINT64
697 # define UINT_FAST64_MAX UINT64_MAX
701 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
705 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
706 # define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))
708 # define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1))
712 # define INTPTR_MIN LONG_MIN
716 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
717 # define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)))
719 # define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1)))
723 # define INTPTR_MAX LONG_MAX
727 # if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@
728 # define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
730 # define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
734 # define UINTPTR_MAX ULONG_MAX
737 /* 7.18.2.5. Limits of greatest-width integer types */
741 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
742 # define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))
744 # define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1))
748 # ifdef _STDINT_H_HAVE_INT64
749 # define INTMAX_MIN INT64_MIN
751 # define INTMAX_MIN INT32_MIN
756 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
757 # define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)))
759 # define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1)))
763 # ifdef _STDINT_H_HAVE_INT64
764 # define INTMAX_MAX INT64_MAX
766 # define INTMAX_MAX INT32_MAX
771 # if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@
772 # define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
774 # define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
778 # ifdef _STDINT_H_HAVE_INT64
779 # define UINTMAX_MAX UINT64_MAX
781 # define UINTMAX_MAX UINT32_MAX
785 /* 7.18.3. Limits of other integer types */
787 /* ptrdiff_t limits */
789 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
790 # define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))
792 # define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))
796 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
797 # define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)))
799 # define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)))
803 /* sig_atomic_t limits */
804 #ifndef SIG_ATOMIC_MIN
805 # if @HAVE_SIGNED_SIG_ATOMIC_T@
806 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
807 # define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
809 # define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
812 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
813 # define SIG_ATOMIC_MIN 0UL
814 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
815 # define SIG_ATOMIC_MIN 0U
817 # define SIG_ATOMIC_MIN 0
821 #ifndef SIG_ATOMIC_MAX
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_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
826 # define SIG_ATOMIC_MAX (~ (-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_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
831 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
832 # define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
834 # define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
840 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */
841 # if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@
842 # define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
844 # define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
848 /* wchar_t limits may already be defined in <stddef.h>. */
850 # if @HAVE_SIGNED_WCHAR_T@
851 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
852 # define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1))
854 # define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1))
857 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
858 # define WCHAR_MIN 0UL
859 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
860 # define WCHAR_MIN 0U
867 # if @HAVE_SIGNED_WCHAR_T@
868 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
869 # define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1)))
871 # define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1)))
874 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
875 # define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
876 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
877 # define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
879 # define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
886 # if @HAVE_SIGNED_WINT_T@
887 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
888 # define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1))
890 # define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1))
893 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
894 # define WINT_MIN 0UL
895 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
903 # if @HAVE_SIGNED_WINT_T@
904 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
905 # define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1)))
907 # define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1)))
910 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
911 # define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
912 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
913 # define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
915 # define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
922 /* 7.18.4. Macros for integer constants */
924 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
926 /* 7.18.4.1. Macros for minimum-width integer constants */
927 /* According to ISO C 99 Technical Corrigendum 1 */
933 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
934 # define UINT8_C(x) x
936 # define UINT8_C(x) x##U
939 # define UINT8_C(x) x
946 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
947 # define UINT16_C(x) x
949 # define UINT16_C(x) x##U
952 # define UINT16_C(x) x
959 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
960 # define UINT32_C(x) x
962 # define UINT32_C(x) x##U
965 # define UINT32_C(x) x
970 #if @HAVE_LONG_64BIT@
971 # define INT64_C(x) x##L
972 # define UINT64_C(x) x##UL
973 #elif @HAVE_LONG_LONG_64BIT@
974 # define INT64_C(x) x##LL
975 # define UINT64_C(x) x##ULL
976 #elif defined(_MSC_VER)
977 # define INT64_C(x) x##i64
978 # define UINT64_C(x) x##ui64
981 /* 7.18.4.2. Macros for greatest-width integer constants */
985 #if @HAVE_LONG_64BIT@
986 # define INTMAX_C(x) x##L
987 # define UINTMAX_C(x) x##UL
988 #elif @HAVE_LONG_LONG_64BIT@
989 # define INTMAX_C(x) x##LL
990 # define UINTMAX_C(x) x##ULL
991 #elif defined(_MSC_VER)
992 # define INTMAX_C(x) x##i64
993 # define UINTMAX_C(x) x##ui64
995 # define INTMAX_C(x) x
996 # define UINTMAX_C(x) x##U
1001 #endif /* _STDINT_H */