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__) || defined(__bsdi__) || defined(__sgi)
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 /* BSD/OS 4.2 is similar, but doesn't have <inttypes.h> */
42 /* IRIX 6.5 has <inttypes.h>, and <sys/types.h> defines some of these
44 # include <sys/types.h>
45 # if @HAVE_INTTYPES_H@
46 # include @FULL_PATH_INTTYPES_H@
49 #if defined(__linux__) && @HAVE_SYS_BITYPES_H@
50 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
51 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
52 included by <sys/types.h>. */
53 # include <sys/bitypes.h>
55 #if defined(__sun) && @HAVE_SYS_INTTYPES_H@
56 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
57 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.
58 But note that <sys/int_types.h> contains only the type definitions! */
59 # include <sys/inttypes.h>
61 #if (defined(__hpux) || defined(_AIX)) && @HAVE_INTTYPES_H@
62 /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX,
63 UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
64 /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX,
65 UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */
66 # include @FULL_PATH_INTTYPES_H@
69 /* Other systems may have an incomplete <stdint.h>. */
70 /* On some versions of IRIX, the SGI C compiler comes with an <stdint.h>,
72 - in c99 mode, <inttypes.h> includes <stdint.h>,
73 - in c89 mode, <stdint.h> spews warnings. <inttypes.h> defines only
74 a subset of the types and macros that are defined in <stdint.h>.
75 So we rely only on <inttypes.h> (included above). It means that in
76 c89 mode, we shadow the contents of warning-spewing <stdint.h>. */
77 # if !(defined(__sgi) && @HAVE_INTTYPES_H@ && !defined(_c99))
78 # include @FULL_PATH_STDINT_H@
82 /* 7.18.1.1. Exact-width integer types */
84 /* Here we assume a standard architecture where the hardware integer
85 types have 8, 16, 32, optionally 64 bits. */
88 typedef signed char int8_t;
91 typedef unsigned char uint8_t;
92 # define _UINT8_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
96 typedef short int16_t;
99 typedef unsigned short uint16_t;
106 typedef unsigned int uint32_t;
107 # define _UINT32_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
111 # define _STDINT_H_HAVE_INT64 1
113 # if @HAVE_LONG_64BIT@
114 typedef long int64_t;
115 # define _STDINT_H_HAVE_INT64 1
116 # elif @HAVE_LONG_LONG_64BIT@
117 typedef long long int64_t;
118 # define _STDINT_H_HAVE_INT64 1
119 # elif defined _MSC_VER
120 typedef __int64 int64_t;
121 # define _STDINT_H_HAVE_INT64 1
125 # define _STDINT_H_HAVE_UINT64 1
127 # if @HAVE_LONG_64BIT@
128 typedef unsigned long uint64_t;
129 # define _STDINT_H_HAVE_UINT64 1
130 # elif @HAVE_LONG_LONG_64BIT@
131 typedef unsigned long long uint64_t;
132 # define _UINT64_T /* avoid collision with Solaris 2.5.1 <pthread.h> */
133 # define _STDINT_H_HAVE_UINT64 1
134 # elif defined _MSC_VER
135 typedef unsigned __int64 uint64_t;
136 # define _STDINT_H_HAVE_UINT64 1
140 /* 7.18.1.2. Minimum-width integer types */
142 /* Here we assume a standard architecture where the hardware integer
143 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
144 are the same as the corresponding N_t types. */
146 #if !@HAVE_INT_LEAST8_T@
147 typedef int8_t int_least8_t;
149 #if !@HAVE_UINT_LEAST8_T@
150 typedef uint8_t uint_least8_t;
153 #if !@HAVE_INT_LEAST16_T@
154 typedef int16_t int_least16_t;
156 #if !@HAVE_UINT_LEAST16_T@
157 typedef uint16_t uint_least16_t;
160 #if !@HAVE_INT_LEAST32_T@
161 typedef int32_t int_least32_t;
163 #if !@HAVE_UINT_LEAST32_T@
164 typedef uint32_t uint_least32_t;
167 #if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64
168 typedef int64_t int_least64_t;
170 #if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64
171 typedef uint64_t uint_least64_t;
174 /* 7.18.1.3. Fastest minimum-width integer types */
176 /* Note: Other <stdint.h> substitutes may define these types differently.
177 It is not recommended to use these types in public header files. */
179 /* Here we assume a standard architecture where the hardware integer
180 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
181 are taken from the same list of types. */
183 /* On alpha processors, int32_t variables are slower than int64_t variables,
184 due to the necessary zap instructions. */
186 # define _STDINT_H_INT64_FASTER_THAN_INT32 1
189 #if !@HAVE_INT_FAST8_T@
190 # if _STDINT_H_INT64_FASTER_THAN_INT32
191 typedef int64_t int_fast8_t;
193 typedef int32_t int_fast8_t;
196 #if !@HAVE_UINT_FAST8_T@
197 # if _STDINT_H_INT64_FASTER_THAN_INT32
198 typedef uint64_t uint_fast8_t;
200 typedef uint32_t uint_fast8_t;
204 #if !@HAVE_INT_FAST16_T@
205 # if _STDINT_H_INT64_FASTER_THAN_INT32
206 typedef int64_t int_fast16_t;
208 typedef int32_t int_fast16_t;
211 #if !@HAVE_UINT_FAST16_T@
212 # if _STDINT_H_INT64_FASTER_THAN_INT32
213 typedef uint64_t uint_fast16_t;
215 typedef uint32_t uint_fast16_t;
219 #if !@HAVE_INT_FAST32_T@
220 # if _STDINT_H_INT64_FASTER_THAN_INT32
221 typedef int64_t int_fast32_t;
223 typedef int32_t int_fast32_t;
226 #if !@HAVE_UINT_FAST32_T@
227 # if _STDINT_H_INT64_FASTER_THAN_INT32
228 typedef uint64_t uint_fast32_t;
230 typedef uint32_t uint_fast32_t;
234 #if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64
235 typedef int64_t int_fast64_t;
237 #if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64
238 typedef uint64_t uint_fast64_t;
241 /* 7.18.1.4. Integer types capable of holding object pointers */
243 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
244 but this doesn't matter here. */
246 typedef long intptr_t;
248 #if !@HAVE_UINTPTR_T@
249 typedef unsigned long uintptr_t;
252 /* 7.18.1.5. Greatest-width integer types */
254 /* Note: These types are compiler dependent. It may be unwise to use them in
255 public header files. */
258 # ifdef _STDINT_H_HAVE_INT64
259 typedef int64_t intmax_t;
261 typedef int32_t intmax_t;
264 #if !@HAVE_UINTMAX_T@
265 # ifdef _STDINT_H_HAVE_UINT64
266 typedef uint64_t uintmax_t;
268 typedef uint32_t uintmax_t;
272 /* 7.18.2. Limits of specified-width integer types */
274 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
276 /* 7.18.2.1. Limits of exact-width integer types */
278 /* Here we assume a standard architecture where the hardware integer
279 types have 8, 16, 32, optionally 64 bits. */
283 # define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1))
286 # define INT8_MIN -128
290 # define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1)))
293 # define INT8_MAX 127
297 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
298 # define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
300 # define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1)
304 # define UINT8_MAX 255
309 # define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1))
312 # define INT16_MIN -32768
316 # define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1)))
319 # define INT16_MAX 32767
323 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
324 # define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
326 # define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1)
330 # define UINT16_MAX 65535
335 # define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1))
338 # define INT32_MIN (~INT32_MAX)
342 # define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1)))
345 # define INT32_MAX 2147483647
349 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
350 # define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
352 # define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1)
356 # define UINT32_MAX 4294967295U
361 # if @HAVE_LONG_64BIT@
362 # define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1))
363 # elif @HAVE_LONG_LONG_64BIT@
364 # define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1))
365 # elif defined _MSC_VER
366 # define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1))
370 # ifdef _STDINT_H_HAVE_INT64
371 # define INT64_MIN (~INT64_MAX)
376 # if @HAVE_LONG_64BIT@
377 # define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1)))
378 # elif @HAVE_LONG_LONG_64BIT@
379 # define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1)))
380 # elif defined _MSC_VER
381 # define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1)))
385 # ifdef _STDINT_H_HAVE_INT64
386 # if @HAVE_LONG_64BIT@
387 # define INT64_MAX 9223372036854775807L
388 # elif @HAVE_LONG_LONG_64BIT@
389 # define INT64_MAX 9223372036854775807LL
390 # elif defined _MSC_VER
391 # define INT64_MAX 9223372036854775807i64
397 # if @HAVE_LONG_64BIT@
398 # define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
399 # elif @HAVE_LONG_LONG_64BIT@
400 # define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
401 # elif defined _MSC_VER
402 # define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1)
406 # ifdef _STDINT_H_HAVE_UINT64
407 # if @HAVE_LONG_64BIT@
408 # define UINT64_MAX 18446744073709551615UL
409 # elif @HAVE_LONG_LONG_64BIT@
410 # define UINT64_MAX 18446744073709551615ULL
411 # elif defined _MSC_VER
412 # define UINT64_MAX 18446744073709551615ui64
417 /* 7.18.2.2. Limits of minimum-width integer types */
419 /* Here we assume a standard architecture where the hardware integer
420 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
421 are the same as the corresponding N_t types. */
423 #if @HAVE_INT_LEAST8_T@
424 # ifndef INT_LEAST8_MIN
425 # define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))
428 # define INT_LEAST8_MIN INT8_MIN
430 #if @HAVE_INT_LEAST8_T@
431 # ifndef INT_LEAST8_MAX
432 # define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)))
435 # define INT_LEAST8_MAX INT8_MAX
437 #if @HAVE_UINT_LEAST8_T@
438 # ifndef UINT_LEAST8_MAX
439 # if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
440 # define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
442 # define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1)
446 # define UINT_LEAST8_MAX UINT8_MAX
449 #if @HAVE_INT_LEAST16_T@
450 # ifndef INT_LEAST16_MIN
451 # define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))
454 # define INT_LEAST16_MIN INT16_MIN
456 #if @HAVE_INT_LEAST16_T@
457 # ifndef INT_LEAST16_MAX
458 # define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)))
461 # define INT_LEAST16_MAX INT16_MAX
463 #if @HAVE_UINT_LEAST16_T@
464 # ifndef UINT_LEAST16_MAX
465 # if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
466 # define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
468 # define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1)
472 # define UINT_LEAST16_MAX UINT16_MAX
475 #if @HAVE_INT_LEAST32_T@
476 # ifndef INT_LEAST32_MIN
477 # define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))
480 # define INT_LEAST32_MIN INT32_MIN
482 #if @HAVE_INT_LEAST32_T@
483 # ifndef INT_LEAST32_MAX
484 # define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)))
487 # define INT_LEAST32_MAX INT32_MAX
489 #if @HAVE_UINT_LEAST32_T@
490 # ifndef UINT_LEAST32_MAX
491 # if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
492 # define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
494 # define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1)
498 # define UINT_LEAST32_MAX UINT32_MAX
501 #if @HAVE_INT_LEAST64_T@
502 # ifndef INT_LEAST64_MIN
503 # if @HAVE_LONG_64BIT@
504 # define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))
505 # elif @HAVE_LONG_LONG_64BIT@
506 # define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))
507 # elif defined _MSC_VER
508 # define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))
512 # ifdef _STDINT_H_HAVE_INT64
513 # define INT_LEAST64_MIN INT64_MIN
516 #if @HAVE_INT_LEAST64_T@
517 # ifndef INT_LEAST64_MAX
518 # if @HAVE_LONG_64BIT@
519 # define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
520 # elif @HAVE_LONG_LONG_64BIT@
521 # define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
522 # elif defined _MSC_VER
523 # define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)))
527 # ifdef _STDINT_H_HAVE_INT64
528 # define INT_LEAST64_MAX INT64_MAX
531 #if @HAVE_UINT_LEAST64_T@
532 # ifndef UINT_LEAST64_MAX
533 # if @HAVE_LONG_64BIT@
534 # define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
535 # elif @HAVE_LONG_LONG_64BIT@
536 # define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
537 # elif defined _MSC_VER
538 # define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1)
542 # ifdef _STDINT_H_HAVE_UINT64
543 # define UINT_LEAST64_MAX UINT64_MAX
547 /* 7.18.2.3. Limits of fastest minimum-width integer types */
549 /* Here we assume a standard architecture where the hardware integer
550 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
551 are taken from the same list of types. */
553 #if @HAVE_INT_FAST8_T@
554 # ifndef INT_FAST8_MIN
555 # define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))
558 # if _STDINT_H_INT64_FASTER_THAN_INT32
559 # define INT_FAST8_MIN INT64_MIN
561 # define INT_FAST8_MIN INT32_MIN
564 #if @HAVE_INT_FAST8_T@
565 # ifndef INT_FAST8_MAX
566 # define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)))
569 # if _STDINT_H_INT64_FASTER_THAN_INT32
570 # define INT_FAST8_MAX INT64_MAX
572 # define INT_FAST8_MAX INT32_MAX
575 #if @HAVE_UINT_FAST8_T@
576 # ifndef UINT_FAST8_MAX
577 # if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@
578 # define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
580 # define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1)
584 # if _STDINT_H_INT64_FASTER_THAN_INT32
585 # define UINT_FAST8_MAX UINT64_MAX
587 # define UINT_FAST8_MAX UINT32_MAX
591 #if @HAVE_INT_FAST16_T@
592 # ifndef INT_FAST16_MIN
593 # define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))
596 # if _STDINT_H_INT64_FASTER_THAN_INT32
597 # define INT_FAST16_MIN INT64_MIN
599 # define INT_FAST16_MIN INT32_MIN
602 #if @HAVE_INT_FAST16_T@
603 # ifndef INT_FAST16_MAX
604 # define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)))
607 # if _STDINT_H_INT64_FASTER_THAN_INT32
608 # define INT_FAST16_MAX INT64_MAX
610 # define INT_FAST16_MAX INT32_MAX
613 #if @HAVE_UINT_FAST16_T@
614 # ifndef UINT_FAST16_MAX
615 # if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@
616 # define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
618 # define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1)
622 # if _STDINT_H_INT64_FASTER_THAN_INT32
623 # define UINT_FAST16_MAX UINT64_MAX
625 # define UINT_FAST16_MAX UINT32_MAX
629 #if @HAVE_INT_FAST32_T@
630 # ifndef INT_FAST32_MIN
631 # define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))
634 # if _STDINT_H_INT64_FASTER_THAN_INT32
635 # define INT_FAST32_MIN INT64_MIN
637 # define INT_FAST32_MIN INT32_MIN
640 #if @HAVE_INT_FAST32_T@
641 # ifndef INT_FAST32_MAX
642 # define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)))
645 # if _STDINT_H_INT64_FASTER_THAN_INT32
646 # define INT_FAST32_MAX INT64_MAX
648 # define INT_FAST32_MAX INT32_MAX
651 #if @HAVE_UINT_FAST32_T@
652 # ifndef UINT_FAST32_MAX
653 # if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@
654 # define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
656 # define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1)
660 # if _STDINT_H_INT64_FASTER_THAN_INT32
661 # define UINT_FAST32_MAX UINT64_MAX
663 # define UINT_FAST32_MAX UINT32_MAX
667 #if @HAVE_INT_FAST64_T@
668 # ifndef INT_FAST64_MIN
669 # if @HAVE_LONG_64BIT@
670 # define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))
671 # elif @HAVE_LONG_LONG_64BIT@
672 # define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))
673 # elif defined _MSC_VER
674 # define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))
678 # ifdef _STDINT_H_HAVE_INT64
679 # define INT_FAST64_MIN INT64_MIN
682 #if @HAVE_INT_FAST64_T@
683 # ifndef INT_FAST64_MAX
684 # if @HAVE_LONG_64BIT@
685 # define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)))
686 # elif @HAVE_LONG_LONG_64BIT@
687 # define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)))
688 # elif defined _MSC_VER
689 # define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)))
693 # ifdef _STDINT_H_HAVE_INT64
694 # define INT_FAST64_MAX INT64_MAX
697 #if @HAVE_UINT_FAST64_T@
698 # ifndef UINT_FAST64_MAX
699 # if @HAVE_LONG_64BIT@
700 # define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
701 # elif @HAVE_LONG_LONG_64BIT@
702 # define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
703 # elif defined _MSC_VER
704 # define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1)
708 # ifdef _STDINT_H_HAVE_UINT64
709 # define UINT_FAST64_MAX UINT64_MAX
713 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
717 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
718 # define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))
720 # define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1))
724 # define INTPTR_MIN LONG_MIN
728 # if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@
729 # define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)))
731 # define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1)))
735 # define INTPTR_MAX LONG_MAX
739 # if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@
740 # define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
742 # define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1)
746 # define UINTPTR_MAX ULONG_MAX
749 /* 7.18.2.5. Limits of greatest-width integer types */
753 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
754 # define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))
756 # define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1))
760 # ifdef _STDINT_H_HAVE_INT64
761 # define INTMAX_MIN INT64_MIN
763 # define INTMAX_MIN INT32_MIN
768 # if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@
769 # define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)))
771 # define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1)))
775 # ifdef _STDINT_H_HAVE_INT64
776 # define INTMAX_MAX INT64_MAX
778 # define INTMAX_MAX INT32_MAX
783 # if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@
784 # define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
786 # define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1)
790 # ifdef _STDINT_H_HAVE_INT64
791 # define UINTMAX_MAX UINT64_MAX
793 # define UINTMAX_MAX UINT32_MAX
797 /* 7.18.3. Limits of other integer types */
799 /* ptrdiff_t limits */
801 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
802 # define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))
804 # define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))
808 # if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@
809 # define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)))
811 # define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)))
815 /* sig_atomic_t limits */
816 #ifndef SIG_ATOMIC_MIN
817 # if @HAVE_SIGNED_SIG_ATOMIC_T@
818 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
819 # define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
821 # define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))
824 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
825 # define SIG_ATOMIC_MIN 0UL
826 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
827 # define SIG_ATOMIC_MIN 0U
829 # define SIG_ATOMIC_MIN 0
833 #ifndef SIG_ATOMIC_MAX
834 # if @HAVE_SIGNED_SIG_ATOMIC_T@
835 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@
836 # define SIG_ATOMIC_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
838 # define SIG_ATOMIC_MAX (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)))
841 # if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@
842 # define SIG_ATOMIC_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
843 # elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@
844 # define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
846 # define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1)
852 #ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */
853 # if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@
854 # define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
856 # define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1)
860 /* wchar_t limits may already be defined in <stddef.h>. */
862 # if @HAVE_SIGNED_WCHAR_T@
863 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
864 # define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1))
866 # define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1))
869 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
870 # define WCHAR_MIN 0UL
871 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
872 # define WCHAR_MIN 0U
879 # if @HAVE_SIGNED_WCHAR_T@
880 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@
881 # define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1)))
883 # define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1)))
886 # if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@
887 # define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
888 # elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@
889 # define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
891 # define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1)
898 # if @HAVE_SIGNED_WINT_T@
899 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
900 # define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1))
902 # define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1))
905 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
906 # define WINT_MIN 0UL
907 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
915 # if @HAVE_SIGNED_WINT_T@
916 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@
917 # define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1)))
919 # define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1)))
922 # if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@
923 # define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
924 # elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@
925 # define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
927 # define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1)
934 /* 7.18.4. Macros for integer constants */
936 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
938 /* 7.18.4.1. Macros for minimum-width integer constants */
939 /* According to ISO C 99 Technical Corrigendum 1 */
945 # if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@
946 # define UINT8_C(x) x
948 # define UINT8_C(x) x##U
951 # define UINT8_C(x) x
958 # if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@
959 # define UINT16_C(x) x
961 # define UINT16_C(x) x##U
964 # define UINT16_C(x) x
971 # if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@
972 # define UINT32_C(x) x
974 # define UINT32_C(x) x##U
977 # define UINT32_C(x) x
982 #if @HAVE_LONG_64BIT@
983 # define INT64_C(x) x##L
984 # define UINT64_C(x) x##UL
985 #elif @HAVE_LONG_LONG_64BIT@
986 # define INT64_C(x) x##LL
987 # define UINT64_C(x) x##ULL
988 #elif defined(_MSC_VER)
989 # define INT64_C(x) x##i64
990 # define UINT64_C(x) x##ui64
993 /* 7.18.4.2. Macros for greatest-width integer constants */
997 #if @HAVE_LONG_64BIT@
998 # define INTMAX_C(x) x##L
999 # define UINTMAX_C(x) x##UL
1000 #elif @HAVE_LONG_LONG_64BIT@
1001 # define INTMAX_C(x) x##LL
1002 # define UINTMAX_C(x) x##ULL
1003 #elif defined(_MSC_VER)
1004 # define INTMAX_C(x) x##i64
1005 # define UINTMAX_C(x) x##ui64
1007 # define INTMAX_C(x) x
1008 # define UINTMAX_C(x) x##U
1013 #endif /* _STDINT_H */