1*4b169a6bSchristos /* Copyright (C) 2001-2002, 2004-2022 Free Software Foundation, Inc. 28dffb485Schristos Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. 38dffb485Schristos This file is part of gnulib. 48dffb485Schristos 5*4b169a6bSchristos This file is free software: you can redistribute it and/or modify 6*4b169a6bSchristos it under the terms of the GNU Lesser General Public License as 7*4b169a6bSchristos published by the Free Software Foundation; either version 2.1 of the 8*4b169a6bSchristos License, or (at your option) any later version. 98dffb485Schristos 10*4b169a6bSchristos This file is distributed in the hope that it will be useful, 118dffb485Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 128dffb485Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*4b169a6bSchristos GNU Lesser General Public License for more details. 148dffb485Schristos 15*4b169a6bSchristos You should have received a copy of the GNU Lesser General Public License 16*4b169a6bSchristos along with this program. If not, see <https://www.gnu.org/licenses/>. */ 178dffb485Schristos 188dffb485Schristos /* 198dffb485Schristos * ISO C 99 <stdint.h> for platforms that lack it. 208dffb485Schristos * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html> 218dffb485Schristos */ 228dffb485Schristos 238dffb485Schristos #ifndef _@GUARD_PREFIX@_STDINT_H 248dffb485Schristos 258dffb485Schristos #if __GNUC__ >= 3 268dffb485Schristos @PRAGMA_SYSTEM_HEADER@ 278dffb485Schristos #endif 288dffb485Schristos @PRAGMA_COLUMNS@ 298dffb485Schristos 308dffb485Schristos /* When including a system file that in turn includes <inttypes.h>, 318dffb485Schristos use the system <inttypes.h>, not our substitute. This avoids 328dffb485Schristos problems with (for example) VMS, whose <sys/bitypes.h> includes 338dffb485Schristos <inttypes.h>. */ 348dffb485Schristos #define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 358dffb485Schristos 368dffb485Schristos /* On Android (Bionic libc), <sys/types.h> includes this file before 378dffb485Schristos having defined 'time_t'. Therefore in this case avoid including 388dffb485Schristos other system header files; just include the system's <stdint.h>. 398dffb485Schristos Ideally we should test __BIONIC__ here, but it is only defined after 408dffb485Schristos <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */ 418dffb485Schristos #if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H 428dffb485Schristos # @INCLUDE_NEXT@ @NEXT_STDINT_H@ 438dffb485Schristos #else 448dffb485Schristos 458dffb485Schristos /* Get those types that are already defined in other system include 468dffb485Schristos files, so that we can "#define int8_t signed char" below without 478dffb485Schristos worrying about a later system include file containing a "typedef 488dffb485Schristos signed char int8_t;" that will get messed up by our macro. Our 498dffb485Schristos macros should all be consistent with the system versions, except 508dffb485Schristos for the "fast" types and macros, which we recommend against using 518dffb485Schristos in public interfaces due to compiler differences. */ 528dffb485Schristos 538dffb485Schristos #if @HAVE_STDINT_H@ 548dffb485Schristos # if defined __sgi && ! defined __c99 558dffb485Schristos /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users 568dffb485Schristos with "This header file is to be used only for c99 mode compilations" 578dffb485Schristos diagnostics. */ 588dffb485Schristos # define __STDINT_H__ 598dffb485Schristos # endif 608dffb485Schristos 618dffb485Schristos /* Some pre-C++11 <stdint.h> implementations need this. */ 628dffb485Schristos # ifdef __cplusplus 638dffb485Schristos # ifndef __STDC_CONSTANT_MACROS 648dffb485Schristos # define __STDC_CONSTANT_MACROS 1 658dffb485Schristos # endif 668dffb485Schristos # ifndef __STDC_LIMIT_MACROS 678dffb485Schristos # define __STDC_LIMIT_MACROS 1 688dffb485Schristos # endif 698dffb485Schristos # endif 708dffb485Schristos 718dffb485Schristos /* Other systems may have an incomplete or buggy <stdint.h>. 728dffb485Schristos Include it before <inttypes.h>, since any "#include <stdint.h>" 738dffb485Schristos in <inttypes.h> would reinclude us, skipping our contents because 748dffb485Schristos _@GUARD_PREFIX@_STDINT_H is defined. 758dffb485Schristos The include_next requires a split double-inclusion guard. */ 768dffb485Schristos # @INCLUDE_NEXT@ @NEXT_STDINT_H@ 778dffb485Schristos #endif 788dffb485Schristos 798dffb485Schristos #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H 808dffb485Schristos #define _@GUARD_PREFIX@_STDINT_H 818dffb485Schristos 828dffb485Schristos /* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, 838dffb485Schristos LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */ 848dffb485Schristos #include <limits.h> 858dffb485Schristos 868dffb485Schristos /* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides 878dffb485Schristos wint_t. */ 88*4b169a6bSchristos #if @GNULIBHEADERS_OVERRIDE_WINT_T@ 898dffb485Schristos # undef WINT_MIN 908dffb485Schristos # undef WINT_MAX 918dffb485Schristos # define WINT_MIN 0x0U 928dffb485Schristos # define WINT_MAX 0xffffffffU 938dffb485Schristos #endif 948dffb485Schristos 958dffb485Schristos #if ! @HAVE_C99_STDINT_H@ 968dffb485Schristos 978dffb485Schristos /* <sys/types.h> defines some of the stdint.h types as well, on glibc, 988dffb485Schristos IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). 998dffb485Schristos AIX 5.2 <sys/types.h> isn't needed and causes troubles. 1008dffb485Schristos Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but 1018dffb485Schristos relies on the system <stdint.h> definitions, so include 1028dffb485Schristos <sys/types.h> after @NEXT_STDINT_H@. */ 1038dffb485Schristos # if @HAVE_SYS_TYPES_H@ && ! defined _AIX 1048dffb485Schristos # include <sys/types.h> 1058dffb485Schristos # endif 1068dffb485Schristos 1078dffb485Schristos # if @HAVE_INTTYPES_H@ 1088dffb485Schristos /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines 1098dffb485Schristos int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. 1108dffb485Schristos <inttypes.h> also defines intptr_t and uintptr_t. */ 1118dffb485Schristos # include <inttypes.h> 1128dffb485Schristos # elif @HAVE_SYS_INTTYPES_H@ 1138dffb485Schristos /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and 1148dffb485Schristos the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ 1158dffb485Schristos # include <sys/inttypes.h> 1168dffb485Schristos # endif 1178dffb485Schristos 1188dffb485Schristos # if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ 1198dffb485Schristos /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines 1208dffb485Schristos int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is 1218dffb485Schristos included by <sys/types.h>. */ 1228dffb485Schristos # include <sys/bitypes.h> 1238dffb485Schristos # endif 1248dffb485Schristos 1258dffb485Schristos # undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 1268dffb485Schristos 1278dffb485Schristos /* Minimum and maximum values for an integer type under the usual assumption. 1288dffb485Schristos Return an unspecified value if BITS == 0, adding a check to pacify 1298dffb485Schristos picky compilers. */ 1308dffb485Schristos 1318dffb485Schristos /* These are separate macros, because if you try to merge these macros into 1328dffb485Schristos a single one, HP-UX cc rejects the resulting expression in constant 1338dffb485Schristos expressions. */ 1348dffb485Schristos # define _STDINT_UNSIGNED_MIN(bits, zero) \ 1358dffb485Schristos (zero) 1368dffb485Schristos # define _STDINT_SIGNED_MIN(bits, zero) \ 1378dffb485Schristos (~ _STDINT_MAX (1, bits, zero)) 1388dffb485Schristos 1398dffb485Schristos # define _STDINT_MAX(signed, bits, zero) \ 1408dffb485Schristos (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) 1418dffb485Schristos 1428dffb485Schristos #if !GNULIB_defined_stdint_types 1438dffb485Schristos 1448dffb485Schristos /* 7.18.1.1. Exact-width integer types */ 1458dffb485Schristos 1468dffb485Schristos /* Here we assume a standard architecture where the hardware integer 1478dffb485Schristos types have 8, 16, 32, optionally 64 bits. */ 1488dffb485Schristos 1498dffb485Schristos # undef int8_t 1508dffb485Schristos # undef uint8_t 1518dffb485Schristos typedef signed char gl_int8_t; 1528dffb485Schristos typedef unsigned char gl_uint8_t; 1538dffb485Schristos # define int8_t gl_int8_t 1548dffb485Schristos # define uint8_t gl_uint8_t 1558dffb485Schristos 1568dffb485Schristos # undef int16_t 1578dffb485Schristos # undef uint16_t 1588dffb485Schristos typedef short int gl_int16_t; 1598dffb485Schristos typedef unsigned short int gl_uint16_t; 1608dffb485Schristos # define int16_t gl_int16_t 1618dffb485Schristos # define uint16_t gl_uint16_t 1628dffb485Schristos 1638dffb485Schristos # undef int32_t 1648dffb485Schristos # undef uint32_t 1658dffb485Schristos typedef int gl_int32_t; 1668dffb485Schristos typedef unsigned int gl_uint32_t; 1678dffb485Schristos # define int32_t gl_int32_t 1688dffb485Schristos # define uint32_t gl_uint32_t 1698dffb485Schristos 1708dffb485Schristos /* If the system defines INT64_MAX, assume int64_t works. That way, 1718dffb485Schristos if the underlying platform defines int64_t to be a 64-bit long long 1728dffb485Schristos int, the code below won't mistakenly define it to be a 64-bit long 1738dffb485Schristos int, which would mess up C++ name mangling. We must use #ifdef 1748dffb485Schristos rather than #if, to avoid an error with HP-UX 10.20 cc. */ 1758dffb485Schristos 1768dffb485Schristos # ifdef INT64_MAX 1778dffb485Schristos # define GL_INT64_T 1788dffb485Schristos # else 1798dffb485Schristos /* Do not undefine int64_t if gnulib is not being used with 64-bit 1808dffb485Schristos types, since otherwise it breaks platforms like Tandem/NSK. */ 1818dffb485Schristos # if LONG_MAX >> 31 >> 31 == 1 1828dffb485Schristos # undef int64_t 1838dffb485Schristos typedef long int gl_int64_t; 1848dffb485Schristos # define int64_t gl_int64_t 1858dffb485Schristos # define GL_INT64_T 1868dffb485Schristos # elif defined _MSC_VER 1878dffb485Schristos # undef int64_t 1888dffb485Schristos typedef __int64 gl_int64_t; 1898dffb485Schristos # define int64_t gl_int64_t 1908dffb485Schristos # define GL_INT64_T 1918dffb485Schristos # else 1928dffb485Schristos # undef int64_t 1938dffb485Schristos typedef long long int gl_int64_t; 1948dffb485Schristos # define int64_t gl_int64_t 1958dffb485Schristos # define GL_INT64_T 1968dffb485Schristos # endif 1978dffb485Schristos # endif 1988dffb485Schristos 1998dffb485Schristos # ifdef UINT64_MAX 2008dffb485Schristos # define GL_UINT64_T 2018dffb485Schristos # else 2028dffb485Schristos # if ULONG_MAX >> 31 >> 31 >> 1 == 1 2038dffb485Schristos # undef uint64_t 2048dffb485Schristos typedef unsigned long int gl_uint64_t; 2058dffb485Schristos # define uint64_t gl_uint64_t 2068dffb485Schristos # define GL_UINT64_T 2078dffb485Schristos # elif defined _MSC_VER 2088dffb485Schristos # undef uint64_t 2098dffb485Schristos typedef unsigned __int64 gl_uint64_t; 2108dffb485Schristos # define uint64_t gl_uint64_t 2118dffb485Schristos # define GL_UINT64_T 2128dffb485Schristos # else 2138dffb485Schristos # undef uint64_t 2148dffb485Schristos typedef unsigned long long int gl_uint64_t; 2158dffb485Schristos # define uint64_t gl_uint64_t 2168dffb485Schristos # define GL_UINT64_T 2178dffb485Schristos # endif 2188dffb485Schristos # endif 2198dffb485Schristos 2208dffb485Schristos /* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ 2218dffb485Schristos # define _UINT8_T 2228dffb485Schristos # define _UINT32_T 2238dffb485Schristos # define _UINT64_T 2248dffb485Schristos 2258dffb485Schristos 2268dffb485Schristos /* 7.18.1.2. Minimum-width integer types */ 2278dffb485Schristos 2288dffb485Schristos /* Here we assume a standard architecture where the hardware integer 2298dffb485Schristos types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 2308dffb485Schristos are the same as the corresponding N_t types. */ 2318dffb485Schristos 2328dffb485Schristos # undef int_least8_t 2338dffb485Schristos # undef uint_least8_t 2348dffb485Schristos # undef int_least16_t 2358dffb485Schristos # undef uint_least16_t 2368dffb485Schristos # undef int_least32_t 2378dffb485Schristos # undef uint_least32_t 2388dffb485Schristos # undef int_least64_t 2398dffb485Schristos # undef uint_least64_t 2408dffb485Schristos # define int_least8_t int8_t 2418dffb485Schristos # define uint_least8_t uint8_t 2428dffb485Schristos # define int_least16_t int16_t 2438dffb485Schristos # define uint_least16_t uint16_t 2448dffb485Schristos # define int_least32_t int32_t 2458dffb485Schristos # define uint_least32_t uint32_t 2468dffb485Schristos # ifdef GL_INT64_T 2478dffb485Schristos # define int_least64_t int64_t 2488dffb485Schristos # endif 2498dffb485Schristos # ifdef GL_UINT64_T 2508dffb485Schristos # define uint_least64_t uint64_t 2518dffb485Schristos # endif 2528dffb485Schristos 2538dffb485Schristos /* 7.18.1.3. Fastest minimum-width integer types */ 2548dffb485Schristos 2558dffb485Schristos /* Note: Other <stdint.h> substitutes may define these types differently. 2568dffb485Schristos It is not recommended to use these types in public header files. */ 2578dffb485Schristos 2588dffb485Schristos /* Here we assume a standard architecture where the hardware integer 2598dffb485Schristos types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 2608dffb485Schristos are taken from the same list of types. The following code normally 2618dffb485Schristos uses types consistent with glibc, as that lessens the chance of 2628dffb485Schristos incompatibility with older GNU hosts. */ 2638dffb485Schristos 2648dffb485Schristos # undef int_fast8_t 2658dffb485Schristos # undef uint_fast8_t 2668dffb485Schristos # undef int_fast16_t 2678dffb485Schristos # undef uint_fast16_t 2688dffb485Schristos # undef int_fast32_t 2698dffb485Schristos # undef uint_fast32_t 2708dffb485Schristos # undef int_fast64_t 2718dffb485Schristos # undef uint_fast64_t 2728dffb485Schristos typedef signed char gl_int_fast8_t; 2738dffb485Schristos typedef unsigned char gl_uint_fast8_t; 2748dffb485Schristos 2758dffb485Schristos # ifdef __sun 2768dffb485Schristos /* Define types compatible with SunOS 5.10, so that code compiled under 2778dffb485Schristos earlier SunOS versions works with code compiled under SunOS 5.10. */ 2788dffb485Schristos typedef int gl_int_fast32_t; 2798dffb485Schristos typedef unsigned int gl_uint_fast32_t; 2808dffb485Schristos # else 2818dffb485Schristos typedef long int gl_int_fast32_t; 2828dffb485Schristos typedef unsigned long int gl_uint_fast32_t; 2838dffb485Schristos # endif 2848dffb485Schristos typedef gl_int_fast32_t gl_int_fast16_t; 2858dffb485Schristos typedef gl_uint_fast32_t gl_uint_fast16_t; 2868dffb485Schristos 2878dffb485Schristos # define int_fast8_t gl_int_fast8_t 2888dffb485Schristos # define uint_fast8_t gl_uint_fast8_t 2898dffb485Schristos # define int_fast16_t gl_int_fast16_t 2908dffb485Schristos # define uint_fast16_t gl_uint_fast16_t 2918dffb485Schristos # define int_fast32_t gl_int_fast32_t 2928dffb485Schristos # define uint_fast32_t gl_uint_fast32_t 2938dffb485Schristos # ifdef GL_INT64_T 2948dffb485Schristos # define int_fast64_t int64_t 2958dffb485Schristos # endif 2968dffb485Schristos # ifdef GL_UINT64_T 2978dffb485Schristos # define uint_fast64_t uint64_t 2988dffb485Schristos # endif 2998dffb485Schristos 3008dffb485Schristos /* 7.18.1.4. Integer types capable of holding object pointers */ 3018dffb485Schristos 3028dffb485Schristos /* kLIBC's <stdint.h> defines _INTPTR_T_DECLARED and needs its own 3038dffb485Schristos definitions of intptr_t and uintptr_t (which use int and unsigned) 3048dffb485Schristos to avoid clashes with declarations of system functions like sbrk. 305*4b169a6bSchristos Similarly, MinGW WSL-5.4.1 <stdint.h> needs its own intptr_t and 3068dffb485Schristos uintptr_t to avoid conflicting declarations of system functions like 3078dffb485Schristos _findclose in <io.h>. */ 3088dffb485Schristos # if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \ 309*4b169a6bSchristos || defined __MINGW32__) 3108dffb485Schristos # undef intptr_t 3118dffb485Schristos # undef uintptr_t 3128dffb485Schristos # ifdef _WIN64 3138dffb485Schristos typedef long long int gl_intptr_t; 3148dffb485Schristos typedef unsigned long long int gl_uintptr_t; 3158dffb485Schristos # else 3168dffb485Schristos typedef long int gl_intptr_t; 3178dffb485Schristos typedef unsigned long int gl_uintptr_t; 3188dffb485Schristos # endif 3198dffb485Schristos # define intptr_t gl_intptr_t 3208dffb485Schristos # define uintptr_t gl_uintptr_t 3218dffb485Schristos # endif 3228dffb485Schristos 3238dffb485Schristos /* 7.18.1.5. Greatest-width integer types */ 3248dffb485Schristos 3258dffb485Schristos /* Note: These types are compiler dependent. It may be unwise to use them in 3268dffb485Schristos public header files. */ 3278dffb485Schristos 3288dffb485Schristos /* If the system defines INTMAX_MAX, assume that intmax_t works, and 3298dffb485Schristos similarly for UINTMAX_MAX and uintmax_t. This avoids problems with 3308dffb485Schristos assuming one type where another is used by the system. */ 3318dffb485Schristos 3328dffb485Schristos # ifndef INTMAX_MAX 3338dffb485Schristos # undef INTMAX_C 3348dffb485Schristos # undef intmax_t 3358dffb485Schristos # if LONG_MAX >> 30 == 1 3368dffb485Schristos typedef long long int gl_intmax_t; 3378dffb485Schristos # define intmax_t gl_intmax_t 3388dffb485Schristos # elif defined GL_INT64_T 3398dffb485Schristos # define intmax_t int64_t 3408dffb485Schristos # else 3418dffb485Schristos typedef long int gl_intmax_t; 3428dffb485Schristos # define intmax_t gl_intmax_t 3438dffb485Schristos # endif 3448dffb485Schristos # endif 3458dffb485Schristos 3468dffb485Schristos # ifndef UINTMAX_MAX 3478dffb485Schristos # undef UINTMAX_C 3488dffb485Schristos # undef uintmax_t 3498dffb485Schristos # if ULONG_MAX >> 31 == 1 3508dffb485Schristos typedef unsigned long long int gl_uintmax_t; 3518dffb485Schristos # define uintmax_t gl_uintmax_t 3528dffb485Schristos # elif defined GL_UINT64_T 3538dffb485Schristos # define uintmax_t uint64_t 3548dffb485Schristos # else 3558dffb485Schristos typedef unsigned long int gl_uintmax_t; 3568dffb485Schristos # define uintmax_t gl_uintmax_t 3578dffb485Schristos # endif 3588dffb485Schristos # endif 3598dffb485Schristos 3608dffb485Schristos /* Verify that intmax_t and uintmax_t have the same size. Too much code 3618dffb485Schristos breaks if this is not the case. If this check fails, the reason is likely 3628dffb485Schristos to be found in the autoconf macros. */ 3638dffb485Schristos typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) 3648dffb485Schristos ? 1 : -1]; 3658dffb485Schristos 3668dffb485Schristos # define GNULIB_defined_stdint_types 1 3678dffb485Schristos # endif /* !GNULIB_defined_stdint_types */ 3688dffb485Schristos 3698dffb485Schristos /* 7.18.2. Limits of specified-width integer types */ 3708dffb485Schristos 3718dffb485Schristos /* 7.18.2.1. Limits of exact-width integer types */ 3728dffb485Schristos 3738dffb485Schristos /* Here we assume a standard architecture where the hardware integer 3748dffb485Schristos types have 8, 16, 32, optionally 64 bits. */ 3758dffb485Schristos 3768dffb485Schristos # undef INT8_MIN 3778dffb485Schristos # undef INT8_MAX 3788dffb485Schristos # undef UINT8_MAX 3798dffb485Schristos # define INT8_MIN (~ INT8_MAX) 3808dffb485Schristos # define INT8_MAX 127 3818dffb485Schristos # define UINT8_MAX 255 3828dffb485Schristos 3838dffb485Schristos # undef INT16_MIN 3848dffb485Schristos # undef INT16_MAX 3858dffb485Schristos # undef UINT16_MAX 3868dffb485Schristos # define INT16_MIN (~ INT16_MAX) 3878dffb485Schristos # define INT16_MAX 32767 3888dffb485Schristos # define UINT16_MAX 65535 3898dffb485Schristos 3908dffb485Schristos # undef INT32_MIN 3918dffb485Schristos # undef INT32_MAX 3928dffb485Schristos # undef UINT32_MAX 3938dffb485Schristos # define INT32_MIN (~ INT32_MAX) 3948dffb485Schristos # define INT32_MAX 2147483647 3958dffb485Schristos # define UINT32_MAX 4294967295U 3968dffb485Schristos 3978dffb485Schristos # if defined GL_INT64_T && ! defined INT64_MAX 3988dffb485Schristos /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 3998dffb485Schristos evaluates the latter incorrectly in preprocessor expressions. */ 4008dffb485Schristos # define INT64_MIN (- INTMAX_C (1) << 63) 4018dffb485Schristos # define INT64_MAX INTMAX_C (9223372036854775807) 4028dffb485Schristos # endif 4038dffb485Schristos 4048dffb485Schristos # if defined GL_UINT64_T && ! defined UINT64_MAX 4058dffb485Schristos # define UINT64_MAX UINTMAX_C (18446744073709551615) 4068dffb485Schristos # endif 4078dffb485Schristos 4088dffb485Schristos /* 7.18.2.2. Limits of minimum-width integer types */ 4098dffb485Schristos 4108dffb485Schristos /* Here we assume a standard architecture where the hardware integer 4118dffb485Schristos types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 4128dffb485Schristos are the same as the corresponding N_t types. */ 4138dffb485Schristos 4148dffb485Schristos # undef INT_LEAST8_MIN 4158dffb485Schristos # undef INT_LEAST8_MAX 4168dffb485Schristos # undef UINT_LEAST8_MAX 4178dffb485Schristos # define INT_LEAST8_MIN INT8_MIN 4188dffb485Schristos # define INT_LEAST8_MAX INT8_MAX 4198dffb485Schristos # define UINT_LEAST8_MAX UINT8_MAX 4208dffb485Schristos 4218dffb485Schristos # undef INT_LEAST16_MIN 4228dffb485Schristos # undef INT_LEAST16_MAX 4238dffb485Schristos # undef UINT_LEAST16_MAX 4248dffb485Schristos # define INT_LEAST16_MIN INT16_MIN 4258dffb485Schristos # define INT_LEAST16_MAX INT16_MAX 4268dffb485Schristos # define UINT_LEAST16_MAX UINT16_MAX 4278dffb485Schristos 4288dffb485Schristos # undef INT_LEAST32_MIN 4298dffb485Schristos # undef INT_LEAST32_MAX 4308dffb485Schristos # undef UINT_LEAST32_MAX 4318dffb485Schristos # define INT_LEAST32_MIN INT32_MIN 4328dffb485Schristos # define INT_LEAST32_MAX INT32_MAX 4338dffb485Schristos # define UINT_LEAST32_MAX UINT32_MAX 4348dffb485Schristos 4358dffb485Schristos # undef INT_LEAST64_MIN 4368dffb485Schristos # undef INT_LEAST64_MAX 4378dffb485Schristos # ifdef GL_INT64_T 4388dffb485Schristos # define INT_LEAST64_MIN INT64_MIN 4398dffb485Schristos # define INT_LEAST64_MAX INT64_MAX 4408dffb485Schristos # endif 4418dffb485Schristos 4428dffb485Schristos # undef UINT_LEAST64_MAX 4438dffb485Schristos # ifdef GL_UINT64_T 4448dffb485Schristos # define UINT_LEAST64_MAX UINT64_MAX 4458dffb485Schristos # endif 4468dffb485Schristos 4478dffb485Schristos /* 7.18.2.3. Limits of fastest minimum-width integer types */ 4488dffb485Schristos 4498dffb485Schristos /* Here we assume a standard architecture where the hardware integer 4508dffb485Schristos types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 4518dffb485Schristos are taken from the same list of types. */ 4528dffb485Schristos 4538dffb485Schristos # undef INT_FAST8_MIN 4548dffb485Schristos # undef INT_FAST8_MAX 4558dffb485Schristos # undef UINT_FAST8_MAX 4568dffb485Schristos # define INT_FAST8_MIN SCHAR_MIN 4578dffb485Schristos # define INT_FAST8_MAX SCHAR_MAX 4588dffb485Schristos # define UINT_FAST8_MAX UCHAR_MAX 4598dffb485Schristos 4608dffb485Schristos # undef INT_FAST16_MIN 4618dffb485Schristos # undef INT_FAST16_MAX 4628dffb485Schristos # undef UINT_FAST16_MAX 4638dffb485Schristos # define INT_FAST16_MIN INT_FAST32_MIN 4648dffb485Schristos # define INT_FAST16_MAX INT_FAST32_MAX 4658dffb485Schristos # define UINT_FAST16_MAX UINT_FAST32_MAX 4668dffb485Schristos 4678dffb485Schristos # undef INT_FAST32_MIN 4688dffb485Schristos # undef INT_FAST32_MAX 4698dffb485Schristos # undef UINT_FAST32_MAX 4708dffb485Schristos # ifdef __sun 4718dffb485Schristos # define INT_FAST32_MIN INT_MIN 4728dffb485Schristos # define INT_FAST32_MAX INT_MAX 4738dffb485Schristos # define UINT_FAST32_MAX UINT_MAX 4748dffb485Schristos # else 4758dffb485Schristos # define INT_FAST32_MIN LONG_MIN 4768dffb485Schristos # define INT_FAST32_MAX LONG_MAX 4778dffb485Schristos # define UINT_FAST32_MAX ULONG_MAX 4788dffb485Schristos # endif 4798dffb485Schristos 4808dffb485Schristos # undef INT_FAST64_MIN 4818dffb485Schristos # undef INT_FAST64_MAX 4828dffb485Schristos # ifdef GL_INT64_T 4838dffb485Schristos # define INT_FAST64_MIN INT64_MIN 4848dffb485Schristos # define INT_FAST64_MAX INT64_MAX 4858dffb485Schristos # endif 4868dffb485Schristos 4878dffb485Schristos # undef UINT_FAST64_MAX 4888dffb485Schristos # ifdef GL_UINT64_T 4898dffb485Schristos # define UINT_FAST64_MAX UINT64_MAX 4908dffb485Schristos # endif 4918dffb485Schristos 4928dffb485Schristos /* 7.18.2.4. Limits of integer types capable of holding object pointers */ 4938dffb485Schristos 4948dffb485Schristos # undef INTPTR_MIN 4958dffb485Schristos # undef INTPTR_MAX 4968dffb485Schristos # undef UINTPTR_MAX 4978dffb485Schristos # ifdef _WIN64 4988dffb485Schristos # define INTPTR_MIN LLONG_MIN 4998dffb485Schristos # define INTPTR_MAX LLONG_MAX 5008dffb485Schristos # define UINTPTR_MAX ULLONG_MAX 5018dffb485Schristos # else 5028dffb485Schristos # define INTPTR_MIN LONG_MIN 5038dffb485Schristos # define INTPTR_MAX LONG_MAX 5048dffb485Schristos # define UINTPTR_MAX ULONG_MAX 5058dffb485Schristos # endif 5068dffb485Schristos 5078dffb485Schristos /* 7.18.2.5. Limits of greatest-width integer types */ 5088dffb485Schristos 5098dffb485Schristos # ifndef INTMAX_MAX 5108dffb485Schristos # undef INTMAX_MIN 5118dffb485Schristos # ifdef INT64_MAX 5128dffb485Schristos # define INTMAX_MIN INT64_MIN 5138dffb485Schristos # define INTMAX_MAX INT64_MAX 5148dffb485Schristos # else 5158dffb485Schristos # define INTMAX_MIN INT32_MIN 5168dffb485Schristos # define INTMAX_MAX INT32_MAX 5178dffb485Schristos # endif 5188dffb485Schristos # endif 5198dffb485Schristos 5208dffb485Schristos # ifndef UINTMAX_MAX 5218dffb485Schristos # ifdef UINT64_MAX 5228dffb485Schristos # define UINTMAX_MAX UINT64_MAX 5238dffb485Schristos # else 5248dffb485Schristos # define UINTMAX_MAX UINT32_MAX 5258dffb485Schristos # endif 5268dffb485Schristos # endif 5278dffb485Schristos 5288dffb485Schristos /* 7.18.3. Limits of other integer types */ 5298dffb485Schristos 5308dffb485Schristos /* ptrdiff_t limits */ 5318dffb485Schristos # undef PTRDIFF_MIN 5328dffb485Schristos # undef PTRDIFF_MAX 5338dffb485Schristos # if @APPLE_UNIVERSAL_BUILD@ 5348dffb485Schristos # ifdef _LP64 5358dffb485Schristos # define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l) 5368dffb485Schristos # define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) 5378dffb485Schristos # else 5388dffb485Schristos # define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0) 5398dffb485Schristos # define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) 5408dffb485Schristos # endif 5418dffb485Schristos # else 5428dffb485Schristos # define PTRDIFF_MIN \ 5438dffb485Schristos _STDINT_SIGNED_MIN (@BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) 5448dffb485Schristos # define PTRDIFF_MAX \ 5458dffb485Schristos _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) 5468dffb485Schristos # endif 5478dffb485Schristos 5488dffb485Schristos /* sig_atomic_t limits */ 5498dffb485Schristos # undef SIG_ATOMIC_MIN 5508dffb485Schristos # undef SIG_ATOMIC_MAX 5518dffb485Schristos # if @HAVE_SIGNED_SIG_ATOMIC_T@ 5528dffb485Schristos # define SIG_ATOMIC_MIN \ 5538dffb485Schristos _STDINT_SIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@) 5548dffb485Schristos # else 5558dffb485Schristos # define SIG_ATOMIC_MIN \ 5568dffb485Schristos _STDINT_UNSIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@) 5578dffb485Schristos # endif 5588dffb485Schristos # define SIG_ATOMIC_MAX \ 5598dffb485Schristos _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ 5608dffb485Schristos 0@SIG_ATOMIC_T_SUFFIX@) 5618dffb485Schristos 5628dffb485Schristos 5638dffb485Schristos /* size_t limit */ 5648dffb485Schristos # undef SIZE_MAX 5658dffb485Schristos # if @APPLE_UNIVERSAL_BUILD@ 5668dffb485Schristos # ifdef _LP64 5678dffb485Schristos # define SIZE_MAX _STDINT_MAX (0, 64, 0ul) 5688dffb485Schristos # else 5698dffb485Schristos # define SIZE_MAX _STDINT_MAX (0, 32, 0ul) 5708dffb485Schristos # endif 5718dffb485Schristos # else 5728dffb485Schristos # define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) 5738dffb485Schristos # endif 5748dffb485Schristos 5758dffb485Schristos /* wchar_t limits */ 5768dffb485Schristos /* Get WCHAR_MIN, WCHAR_MAX. 5778dffb485Schristos This include is not on the top, above, because on OSF/1 4.0 we have a 5788dffb485Schristos sequence of nested includes 5798dffb485Schristos <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes 5808dffb485Schristos <stdint.h> and assumes its types are already defined. */ 5818dffb485Schristos # if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) 5828dffb485Schristos # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 5838dffb485Schristos # include <wchar.h> 5848dffb485Schristos # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 5858dffb485Schristos # endif 5868dffb485Schristos # undef WCHAR_MIN 5878dffb485Schristos # undef WCHAR_MAX 5888dffb485Schristos # if @HAVE_SIGNED_WCHAR_T@ 5898dffb485Schristos # define WCHAR_MIN \ 5908dffb485Schristos _STDINT_SIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) 5918dffb485Schristos # else 5928dffb485Schristos # define WCHAR_MIN \ 5938dffb485Schristos _STDINT_UNSIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) 5948dffb485Schristos # endif 5958dffb485Schristos # define WCHAR_MAX \ 5968dffb485Schristos _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) 5978dffb485Schristos 5988dffb485Schristos /* wint_t limits */ 5998dffb485Schristos /* If gnulib's <wchar.h> or <wctype.h> overrides wint_t, @WINT_T_SUFFIX@ is not 6008dffb485Schristos accurate, therefore use the definitions from above. */ 601*4b169a6bSchristos # if !@GNULIBHEADERS_OVERRIDE_WINT_T@ 6028dffb485Schristos # undef WINT_MIN 6038dffb485Schristos # undef WINT_MAX 6048dffb485Schristos # if @HAVE_SIGNED_WINT_T@ 6058dffb485Schristos # define WINT_MIN \ 6068dffb485Schristos _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 6078dffb485Schristos # else 6088dffb485Schristos # define WINT_MIN \ 6098dffb485Schristos _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 6108dffb485Schristos # endif 6118dffb485Schristos # define WINT_MAX \ 6128dffb485Schristos _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 6138dffb485Schristos # endif 6148dffb485Schristos 6158dffb485Schristos /* 7.18.4. Macros for integer constants */ 6168dffb485Schristos 6178dffb485Schristos /* 7.18.4.1. Macros for minimum-width integer constants */ 6188dffb485Schristos /* According to ISO C 99 Technical Corrigendum 1 */ 6198dffb485Schristos 6208dffb485Schristos /* Here we assume a standard architecture where the hardware integer 6218dffb485Schristos types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ 6228dffb485Schristos 6238dffb485Schristos # undef INT8_C 6248dffb485Schristos # undef UINT8_C 6258dffb485Schristos # define INT8_C(x) x 6268dffb485Schristos # define UINT8_C(x) x 6278dffb485Schristos 6288dffb485Schristos # undef INT16_C 6298dffb485Schristos # undef UINT16_C 6308dffb485Schristos # define INT16_C(x) x 6318dffb485Schristos # define UINT16_C(x) x 6328dffb485Schristos 6338dffb485Schristos # undef INT32_C 6348dffb485Schristos # undef UINT32_C 6358dffb485Schristos # define INT32_C(x) x 6368dffb485Schristos # define UINT32_C(x) x ## U 6378dffb485Schristos 6388dffb485Schristos # undef INT64_C 6398dffb485Schristos # undef UINT64_C 6408dffb485Schristos # if LONG_MAX >> 31 >> 31 == 1 6418dffb485Schristos # define INT64_C(x) x##L 6428dffb485Schristos # elif defined _MSC_VER 6438dffb485Schristos # define INT64_C(x) x##i64 6448dffb485Schristos # else 6458dffb485Schristos # define INT64_C(x) x##LL 6468dffb485Schristos # endif 6478dffb485Schristos # if ULONG_MAX >> 31 >> 31 >> 1 == 1 6488dffb485Schristos # define UINT64_C(x) x##UL 6498dffb485Schristos # elif defined _MSC_VER 6508dffb485Schristos # define UINT64_C(x) x##ui64 6518dffb485Schristos # else 6528dffb485Schristos # define UINT64_C(x) x##ULL 6538dffb485Schristos # endif 6548dffb485Schristos 6558dffb485Schristos /* 7.18.4.2. Macros for greatest-width integer constants */ 6568dffb485Schristos 6578dffb485Schristos # ifndef INTMAX_C 6588dffb485Schristos # if LONG_MAX >> 30 == 1 6598dffb485Schristos # define INTMAX_C(x) x##LL 6608dffb485Schristos # elif defined GL_INT64_T 6618dffb485Schristos # define INTMAX_C(x) INT64_C(x) 6628dffb485Schristos # else 6638dffb485Schristos # define INTMAX_C(x) x##L 6648dffb485Schristos # endif 6658dffb485Schristos # endif 6668dffb485Schristos 6678dffb485Schristos # ifndef UINTMAX_C 6688dffb485Schristos # if ULONG_MAX >> 31 == 1 6698dffb485Schristos # define UINTMAX_C(x) x##ULL 6708dffb485Schristos # elif defined GL_UINT64_T 6718dffb485Schristos # define UINTMAX_C(x) UINT64_C(x) 6728dffb485Schristos # else 6738dffb485Schristos # define UINTMAX_C(x) x##UL 6748dffb485Schristos # endif 6758dffb485Schristos # endif 6768dffb485Schristos 6778dffb485Schristos #endif /* !@HAVE_C99_STDINT_H@ */ 6788dffb485Schristos 6798dffb485Schristos /* Macros specified by ISO/IEC TS 18661-1:2014. */ 6808dffb485Schristos 6818dffb485Schristos #if (!defined UINTMAX_WIDTH \ 6828dffb485Schristos && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) 6838dffb485Schristos # ifdef INT8_MAX 6848dffb485Schristos # define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX) 6858dffb485Schristos # endif 6868dffb485Schristos # ifdef UINT8_MAX 6878dffb485Schristos # define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX) 6888dffb485Schristos # endif 6898dffb485Schristos # ifdef INT16_MAX 6908dffb485Schristos # define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX) 6918dffb485Schristos # endif 6928dffb485Schristos # ifdef UINT16_MAX 6938dffb485Schristos # define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX) 6948dffb485Schristos # endif 6958dffb485Schristos # ifdef INT32_MAX 6968dffb485Schristos # define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX) 6978dffb485Schristos # endif 6988dffb485Schristos # ifdef UINT32_MAX 6998dffb485Schristos # define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX) 7008dffb485Schristos # endif 7018dffb485Schristos # ifdef INT64_MAX 7028dffb485Schristos # define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX) 7038dffb485Schristos # endif 7048dffb485Schristos # ifdef UINT64_MAX 7058dffb485Schristos # define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX) 7068dffb485Schristos # endif 7078dffb485Schristos # define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX) 7088dffb485Schristos # define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX) 7098dffb485Schristos # define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX) 7108dffb485Schristos # define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX) 7118dffb485Schristos # define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX) 7128dffb485Schristos # define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX) 7138dffb485Schristos # define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX) 7148dffb485Schristos # define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX) 7158dffb485Schristos # define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX) 7168dffb485Schristos # define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX) 7178dffb485Schristos # define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX) 7188dffb485Schristos # define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX) 7198dffb485Schristos # define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX) 7208dffb485Schristos # define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX) 7218dffb485Schristos # define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX) 7228dffb485Schristos # define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX) 7238dffb485Schristos # define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX) 7248dffb485Schristos # define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX) 7258dffb485Schristos # define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX) 7268dffb485Schristos # define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX) 7278dffb485Schristos # define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX) 7288dffb485Schristos # define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX) 7298dffb485Schristos # define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX) 7308dffb485Schristos # ifdef WINT_MAX 7318dffb485Schristos # define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX) 7328dffb485Schristos # endif 7338dffb485Schristos # ifdef SIG_ATOMIC_MAX 7348dffb485Schristos # define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX) 7358dffb485Schristos # endif 7368dffb485Schristos #endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ 7378dffb485Schristos 7388dffb485Schristos #endif /* _@GUARD_PREFIX@_STDINT_H */ 7398dffb485Schristos #endif /* !(defined __ANDROID__ && ...) */ 7408dffb485Schristos #endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ 741