X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstdint_.h;h=adab4d7c24e909f5f535c75d6e512c089f80f8b7;hb=91182f188f4d5d51f37a9f390aa210bef0ab6898;hp=8f96168af8075135ccf8d71c2082f99daae16586;hpb=04597d099c32b9b380b6c82eed97fb88ef467d2e;p=gnulib.git diff --git a/lib/stdint_.h b/lib/stdint_.h index 8f96168af..adab4d7c2 100644 --- a/lib/stdint_.h +++ b/lib/stdint_.h @@ -1,5 +1,5 @@ /* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. - Written by Bruno Haible, Sam Steingold, Peter Burwood. + Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. This program is free software; you can redistribute it and/or modify @@ -16,165 +16,153 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef _STDINT_H -#define _STDINT_H +#ifndef _GL_STDINT_H +#define _GL_STDINT_H /* * ISO C 99 for platforms that lack it. * */ -/* Get wchar_t, WCHAR_MIN, WCHAR_MAX. */ -#include -/* Some systems define WCHAR_MIN, WCHAR_MAX in , not . */ -#if !(defined(WCHAR_MIN) && defined(WCHAR_MAX)) && @HAVE_WCHAR_H@ -# include +/* Get those types that are already defined in other system include + files, so that we can "#define int8_t signed char" below without + worrying about a later system include file containing a "typedef + signed char int8_t;" that will get messed up by our macro. Our + macros should all be consistent with the system versions, except + for the "fast" types and macros, which we recommend against using + in public interfaces due to compiler differences. */ + +#if @HAVE_STDINT_H@ +# if defined __sgi && ! defined __c99 + /* Bypass IRIX's if in C89 mode, since it merely annoys users + with "This header file is to be used only for c99 mode compilations" + diagnostics. */ +# define __STDINT_H__ +# endif + /* Other systems may have an incomplete or buggy . + Include it before , since any "#include " + in would reinclude us, skipping our contents because + _GL_STDINT_H is defined. */ +# include @ABSOLUTE_STDINT_H@ +#endif + +/* defines some of the stdint.h types as well, on glibc, + IRIX 6.5, and OpenBSD 3.8 (via ). + MacOS X 10.4.6 includes (which is us), but + relies on the system definitions, so include + after @ABSOLUTE_STDINT_H@. */ +#if @HAVE_SYS_TYPES_H@ +# include #endif /* Get LONG_MIN, LONG_MAX, ULONG_MAX. */ #include -/* Get those types that are already defined in other system include files. */ -#if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4) -# include -#endif -#if defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi) - /* In OpenBSD 3.8, includes , which defines +#if @HAVE_INTTYPES_H@ + /* In OpenBSD 3.8, includes , which defines int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. - includes and also defines intptr_t and - uintptr_t. */ - /* BSD/OS 4.2 is similar, but doesn't have */ - /* IRIX 6.5 has , and defines some of these - types as well. */ -# include -# if @HAVE_INTTYPES_H@ -# include @FULL_PATH_INTTYPES_H@ -# endif + also defines intptr_t and uintptr_t. */ +# include +#elif @HAVE_SYS_INTTYPES_H@ + /* Solaris 7 has the types except the *_fast*_t types, and + the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ +# include #endif -#if defined(__linux__) && @HAVE_SYS_BITYPES_H@ + +#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ /* Linux libc4 >= 4.6.7 and libc5 have a that defines int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is included by . */ # include #endif -#if defined(__sun) && @HAVE_SYS_INTTYPES_H@ - /* Solaris 7 has the types except the *_fast*_t types, and - the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. - But note that contains only the type definitions! */ -# include -#endif -#if (defined(__hpux) || defined(_AIX)) && @HAVE_INTTYPES_H@ - /* HP-UX 10 has nearly everything, except UINT_LEAST8_MAX, - UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */ - /* AIX 4 has nearly everything, except INTPTR_MIN, INTPTR_MAX, - UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */ -# include @FULL_PATH_INTTYPES_H@ -#endif -#if @HAVE_STDINT_H@ - /* Other systems may have an incomplete . */ - /* On some versions of IRIX, the SGI C compiler comes with an , - but - - in c99 mode, includes , - - in c89 mode, spews warnings and defines nothing. - defines only a subset of the types and macros that - would define in c99 mode. - So we rely only on (included above). It means that in - c89 mode, we shadow the contents of warning-spewing . */ -# if !(defined(__sgi) && @HAVE_INTTYPES_H@ && !defined(__c99)) -# include @FULL_PATH_STDINT_H@ + +#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS + +/* Get WCHAR_MIN, WCHAR_MAX. */ +# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) + /* BSD/OS 4.1 has a bug: and must be included before + . */ +# include +# include +# include # endif + #endif +/* Minimum and maximum values for a integer type under the usual assumption. + Return an unspecified value if BITS == 0, adding a check to pacify + picky compilers. */ + +#define _STDINT_MIN(signed, bits, zero) \ + ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) + +#define _STDINT_MAX(signed, bits, zero) \ + ((signed) \ + ? ~ _STDINT_MIN (signed, bits, zero) \ + : ((((zero) + 1) << ((bits) ? (bits) - 1 : 0)) - 1) * 2 + 1) + /* 7.18.1.1. Exact-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. */ -#if !@HAVE_INT8_T@ -typedef signed char int8_t; -#endif -#if !@HAVE_UINT8_T@ -typedef unsigned char uint8_t; -# define _UINT8_T /* avoid collision with Solaris 2.5.1 */ -#endif +#undef int8_t +#undef uint8_t +#define int8_t signed char +#define uint8_t unsigned char -#if !@HAVE_INT16_T@ -typedef short int16_t; -#endif -#if !@HAVE_UINT16_T@ -typedef unsigned short uint16_t; -#endif +#undef int16_t +#undef uint16_t +#define int16_t short int +#define uint16_t unsigned short int -#if !@HAVE_INT32_T@ -typedef int int32_t; -#endif -#if !@HAVE_UINT32_T@ -typedef unsigned int uint32_t; -# define _UINT32_T /* avoid collision with Solaris 2.5.1 */ -#endif +#undef int32_t +#undef uint32_t +#define int32_t int +#define uint32_t unsigned int -#if @HAVE_INT64_T@ -# define _STDINT_H_HAVE_INT64 1 -#else -# if @HAVE_LONG_64BIT@ -typedef long int64_t; -# define _STDINT_H_HAVE_INT64 1 -# elif @HAVE_LONG_LONG_64BIT@ -typedef long long int64_t; -# define _STDINT_H_HAVE_INT64 1 -# elif defined _MSC_VER -typedef __int64 int64_t; -# define _STDINT_H_HAVE_INT64 1 -# endif -#endif -#if @HAVE_UINT64_T@ -# define _STDINT_H_HAVE_UINT64 1 -#else -# if @HAVE_LONG_64BIT@ -typedef unsigned long uint64_t; -# define _STDINT_H_HAVE_UINT64 1 -# elif @HAVE_LONG_LONG_64BIT@ -typedef unsigned long long uint64_t; -# define _UINT64_T /* avoid collision with Solaris 2.5.1 */ -# define _STDINT_H_HAVE_UINT64 1 -# elif defined _MSC_VER -typedef unsigned __int64 uint64_t; -# define _STDINT_H_HAVE_UINT64 1 -# endif +#undef int64_t +#undef uint64_t +#if LONG_MAX >> 31 >> 31 == 1 +# define int64_t long int +# define uint64_t unsigned long int +#elif defined _MSC_VER +# define int64_t __int64 +# define uint64_t unsigned __int64 +#elif @HAVE_LONG_LONG_INT@ +# define int64_t long long int +# define uint64_t unsigned long long int #endif +/* Avoid collision with Solaris 2.5.1 etc. */ +#define _UINT8_T +#define _UINT32_T +#define _UINT64_T + + /* 7.18.1.2. Minimum-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types are the same as the corresponding N_t types. */ -#if !@HAVE_INT_LEAST8_T@ -typedef int8_t int_least8_t; -#endif -#if !@HAVE_UINT_LEAST8_T@ -typedef uint8_t uint_least8_t; -#endif - -#if !@HAVE_INT_LEAST16_T@ -typedef int16_t int_least16_t; -#endif -#if !@HAVE_UINT_LEAST16_T@ -typedef uint16_t uint_least16_t; -#endif - -#if !@HAVE_INT_LEAST32_T@ -typedef int32_t int_least32_t; -#endif -#if !@HAVE_UINT_LEAST32_T@ -typedef uint32_t uint_least32_t; -#endif - -#if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64 -typedef int64_t int_least64_t; -#endif -#if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64 -typedef uint64_t uint_least64_t; +#undef int_least8_t +#undef uint_least8_t +#undef int_least16_t +#undef uint_least16_t +#undef int_least32_t +#undef uint_least32_t +#undef int_least64_t +#undef uint_least64_t +#define int_least8_t int8_t +#define uint_least8_t uint8_t +#define int_least16_t int16_t +#define uint_least16_t uint16_t +#define int_least32_t int32_t +#define uint_least32_t uint32_t +#ifdef int64_t +# define int_least64_t int64_t +# define uint_least64_t uint64_t #endif /* 7.18.1.3. Fastest minimum-width integer types */ @@ -184,240 +172,90 @@ typedef uint64_t uint_least64_t; /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types - are taken from the same list of types. */ - -/* On alpha processors, int32_t variables are slower than int64_t variables, - due to the necessary zap instructions. */ -#if defined __alpha -# define _STDINT_H_INT64_FASTER_THAN_INT32 1 -#endif - -#if !@HAVE_INT_FAST8_T@ -# if _STDINT_H_INT64_FASTER_THAN_INT32 -typedef int64_t int_fast8_t; -# else -typedef int32_t int_fast8_t; -# endif -#endif -#if !@HAVE_UINT_FAST8_T@ -# if _STDINT_H_INT64_FASTER_THAN_INT32 -typedef uint64_t uint_fast8_t; -# else -typedef uint32_t uint_fast8_t; -# endif -#endif - -#if !@HAVE_INT_FAST16_T@ -# if _STDINT_H_INT64_FASTER_THAN_INT32 -typedef int64_t int_fast16_t; -# else -typedef int32_t int_fast16_t; -# endif -#endif -#if !@HAVE_UINT_FAST16_T@ -# if _STDINT_H_INT64_FASTER_THAN_INT32 -typedef uint64_t uint_fast16_t; -# else -typedef uint32_t uint_fast16_t; -# endif -#endif - -#if !@HAVE_INT_FAST32_T@ -# if _STDINT_H_INT64_FASTER_THAN_INT32 -typedef int64_t int_fast32_t; -# else -typedef int32_t int_fast32_t; -# endif -#endif -#if !@HAVE_UINT_FAST32_T@ -# if _STDINT_H_INT64_FASTER_THAN_INT32 -typedef uint64_t uint_fast32_t; -# else -typedef uint32_t uint_fast32_t; -# endif -#endif - -#if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64 -typedef int64_t int_fast64_t; -#endif -#if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64 -typedef uint64_t uint_fast64_t; + are taken from the same list of types. Assume that 'long int' + is fast enough for all narrower integers. */ + +#undef int_fast8_t +#undef uint_fast8_t +#undef int_fast16_t +#undef uint_fast16_t +#undef int_fast32_t +#undef uint_fast32_t +#undef int_fast64_t +#undef uint_fast64_t +#define int_fast8_t long int +#define uint_fast8_t unsigned int_fast8_t +#define int_fast16_t long int +#define uint_fast16_t unsigned int_fast16_t +#define int_fast32_t long int +#define uint_fast32_t unsigned int_fast32_t +#ifdef int64_t +# define int_fast64_t int64_t +# define uint_fast64_t uint64_t #endif /* 7.18.1.4. Integer types capable of holding object pointers */ -/* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long), - but this doesn't matter here. */ -#if !@HAVE_INTPTR_T@ -typedef long intptr_t; -#endif -#if !@HAVE_UINTPTR_T@ -typedef unsigned long uintptr_t; -#endif +#undef intptr_t +#undef uintptr_t +#define intptr_t long int +#define uintptr_t unsigned long int /* 7.18.1.5. Greatest-width integer types */ /* Note: These types are compiler dependent. It may be unwise to use them in public header files. */ -#if !@HAVE_INTMAX_T@ -# ifdef _STDINT_H_HAVE_INT64 -typedef int64_t intmax_t; -# else -typedef int32_t intmax_t; -# endif -#endif -#if !@HAVE_UINTMAX_T@ -# ifdef _STDINT_H_HAVE_UINT64 -typedef uint64_t uintmax_t; -# else -typedef uint32_t uintmax_t; -# endif +#undef intmax_t +#undef uintmax_t +#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 +# define intmax_t long long int +# define uintmax_t unsigned long long int +#elif defined int64_t +# define intmax_t int64_t +# define uintmax_t uint64_t +#else +# define intmax_t long int +# define uintmax_t unsigned long int #endif /* 7.18.2. Limits of specified-width integer types */ -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) +#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS /* 7.18.2.1. Limits of exact-width integer types */ /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. */ -#if @HAVE_INT8_T@ -# ifndef INT8_MIN -# define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1)) -# endif -#else -# define INT8_MIN -128 -#endif -#if @HAVE_INT8_T@ -# ifndef INT8_MAX -# define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1))) -# endif -#else -# define INT8_MAX 127 -#endif -#if @HAVE_UINT8_T@ -# ifndef UINT8_MAX -# if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# define UINT8_MAX 255 -#endif - -#if @HAVE_INT16_T@ -# ifndef INT16_MIN -# define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1)) -# endif -#else -# define INT16_MIN -32768 -#endif -#if @HAVE_INT16_T@ -# ifndef INT16_MAX -# define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1))) -# endif -#else -# define INT16_MAX 32767 -#endif -#if @HAVE_UINT16_T@ -# ifndef UINT16_MAX -# if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# define UINT16_MAX 65535 -#endif - -#if @HAVE_INT32_T@ -# ifndef INT32_MIN -# define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1)) -# endif -#else -# define INT32_MIN (~INT32_MAX) -#endif -#if @HAVE_INT32_T@ -# ifndef INT32_MAX -# define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1))) -# endif -#else -# define INT32_MAX 2147483647 -#endif -#if @HAVE_UINT32_T@ -# ifndef UINT32_MAX -# if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# define UINT32_MAX 4294967295U -#endif - -#if @HAVE_INT64_T@ -# ifndef INT64_MIN -# if @HAVE_LONG_64BIT@ -# define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1)) -# elif @HAVE_LONG_LONG_64BIT@ -# define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1)) -# elif defined _MSC_VER -# define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1)) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# define INT64_MIN (~INT64_MAX) -# endif -#endif -#if @HAVE_INT64_T@ -# ifndef INT64_MAX -# if @HAVE_LONG_64BIT@ -# define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1))) -# elif @HAVE_LONG_LONG_64BIT@ -# define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1))) -# elif defined _MSC_VER -# define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1))) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# if @HAVE_LONG_64BIT@ -# define INT64_MAX 9223372036854775807L -# elif @HAVE_LONG_LONG_64BIT@ -# define INT64_MAX 9223372036854775807LL -# elif defined _MSC_VER -# define INT64_MAX 9223372036854775807i64 -# endif -# endif -#endif -#if @HAVE_UINT64_T@ -# ifndef UINT64_MAX -# if @HAVE_LONG_64BIT@ -# define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1) -# elif @HAVE_LONG_LONG_64BIT@ -# define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1) -# elif defined _MSC_VER -# define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_UINT64 -# if @HAVE_LONG_64BIT@ -# define UINT64_MAX 18446744073709551615UL -# elif @HAVE_LONG_LONG_64BIT@ -# define UINT64_MAX 18446744073709551615ULL -# elif defined _MSC_VER -# define UINT64_MAX 18446744073709551615ui64 -# endif -# endif +#undef INT8_MIN +#undef INT8_MAX +#undef UINT8_MAX +#define INT8_MIN (~ INT8_MAX) +#define INT8_MAX 127 +#define UINT8_MAX 255 + +#undef INT16_MIN +#undef INT16_MAX +#undef UINT16_MAX +#define INT16_MIN (~ INT16_MAX) +#define INT16_MAX 32767 +#define UINT16_MAX 65535 + +#undef INT32_MIN +#undef INT32_MAX +#undef UINT32_MAX +#define INT32_MIN (~ INT32_MAX) +#define INT32_MAX 2147483647 +#define UINT32_MAX 4294967295U + +#undef INT64_MIN +#undef INT64_MAX +#undef UINT64_MAX +#ifdef int64_t +# define INT64_MIN (~ INT64_MAX) +# define INT64_MAX INTMAX_C (9223372036854775807) +# define UINT64_MAX UINTMAX_C (18446744073709551615) #endif /* 7.18.2.2. Limits of minimum-width integer types */ @@ -426,128 +264,34 @@ typedef uint32_t uintmax_t; types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types are the same as the corresponding N_t types. */ -#if @HAVE_INT_LEAST8_T@ -# ifndef INT_LEAST8_MIN -# define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)) -# endif -#else -# define INT_LEAST8_MIN INT8_MIN -#endif -#if @HAVE_INT_LEAST8_T@ -# ifndef INT_LEAST8_MAX -# define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))) -# endif -#else -# define INT_LEAST8_MAX INT8_MAX -#endif -#if @HAVE_UINT_LEAST8_T@ -# ifndef UINT_LEAST8_MAX -# if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# define UINT_LEAST8_MAX UINT8_MAX -#endif - -#if @HAVE_INT_LEAST16_T@ -# ifndef INT_LEAST16_MIN -# define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)) -# endif -#else -# define INT_LEAST16_MIN INT16_MIN -#endif -#if @HAVE_INT_LEAST16_T@ -# ifndef INT_LEAST16_MAX -# define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))) -# endif -#else -# define INT_LEAST16_MAX INT16_MAX -#endif -#if @HAVE_UINT_LEAST16_T@ -# ifndef UINT_LEAST16_MAX -# if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# define UINT_LEAST16_MAX UINT16_MAX -#endif - -#if @HAVE_INT_LEAST32_T@ -# ifndef INT_LEAST32_MIN -# define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)) -# endif -#else -# define INT_LEAST32_MIN INT32_MIN -#endif -#if @HAVE_INT_LEAST32_T@ -# ifndef INT_LEAST32_MAX -# define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))) -# endif -#else -# define INT_LEAST32_MAX INT32_MAX -#endif -#if @HAVE_UINT_LEAST32_T@ -# ifndef UINT_LEAST32_MAX -# if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# define UINT_LEAST32_MAX UINT32_MAX -#endif - -#if @HAVE_INT_LEAST64_T@ -# ifndef INT_LEAST64_MIN -# if @HAVE_LONG_64BIT@ -# define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)) -# elif @HAVE_LONG_LONG_64BIT@ -# define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)) -# elif defined _MSC_VER -# define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# define INT_LEAST64_MIN INT64_MIN -# endif -#endif -#if @HAVE_INT_LEAST64_T@ -# ifndef INT_LEAST64_MAX -# if @HAVE_LONG_64BIT@ -# define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))) -# elif @HAVE_LONG_LONG_64BIT@ -# define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))) -# elif defined _MSC_VER -# define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# define INT_LEAST64_MAX INT64_MAX -# endif -#endif -#if @HAVE_UINT_LEAST64_T@ -# ifndef UINT_LEAST64_MAX -# if @HAVE_LONG_64BIT@ -# define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1) -# elif @HAVE_LONG_LONG_64BIT@ -# define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1) -# elif defined _MSC_VER -# define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_UINT64 -# define UINT_LEAST64_MAX UINT64_MAX -# endif +#undef INT_LEAST8_MIN +#undef INT_LEAST8_MAX +#undef UINT_LEAST8_MAX +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define UINT_LEAST8_MAX UINT8_MAX + +#undef INT_LEAST16_MIN +#undef INT_LEAST16_MAX +#undef UINT_LEAST16_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define UINT_LEAST16_MAX UINT16_MAX + +#undef INT_LEAST32_MIN +#undef INT_LEAST32_MAX +#undef UINT_LEAST32_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define UINT_LEAST32_MAX UINT32_MAX + +#undef INT_LEAST64_MIN +#undef INT_LEAST64_MAX +#undef UINT_LEAST64_MAX +#ifdef int64_t +# define INT_LEAST64_MIN INT64_MIN +# define INT_LEAST64_MAX INT64_MAX +# define UINT_LEAST64_MAX UINT64_MAX #endif /* 7.18.2.3. Limits of fastest minimum-width integer types */ @@ -556,464 +300,151 @@ typedef uint32_t uintmax_t; types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types are taken from the same list of types. */ -#if @HAVE_INT_FAST8_T@ -# ifndef INT_FAST8_MIN -# define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)) -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define INT_FAST8_MIN INT64_MIN -# else -# define INT_FAST8_MIN INT32_MIN -# endif -#endif -#if @HAVE_INT_FAST8_T@ -# ifndef INT_FAST8_MAX -# define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))) -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define INT_FAST8_MAX INT64_MAX -# else -# define INT_FAST8_MAX INT32_MAX -# endif -#endif -#if @HAVE_UINT_FAST8_T@ -# ifndef UINT_FAST8_MAX -# if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define UINT_FAST8_MAX UINT64_MAX -# else -# define UINT_FAST8_MAX UINT32_MAX -# endif -#endif - -#if @HAVE_INT_FAST16_T@ -# ifndef INT_FAST16_MIN -# define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)) -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define INT_FAST16_MIN INT64_MIN -# else -# define INT_FAST16_MIN INT32_MIN -# endif -#endif -#if @HAVE_INT_FAST16_T@ -# ifndef INT_FAST16_MAX -# define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))) -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define INT_FAST16_MAX INT64_MAX -# else -# define INT_FAST16_MAX INT32_MAX -# endif -#endif -#if @HAVE_UINT_FAST16_T@ -# ifndef UINT_FAST16_MAX -# if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define UINT_FAST16_MAX UINT64_MAX -# else -# define UINT_FAST16_MAX UINT32_MAX -# endif -#endif - -#if @HAVE_INT_FAST32_T@ -# ifndef INT_FAST32_MIN -# define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)) -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define INT_FAST32_MIN INT64_MIN -# else -# define INT_FAST32_MIN INT32_MIN -# endif -#endif -#if @HAVE_INT_FAST32_T@ -# ifndef INT_FAST32_MAX -# define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))) -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define INT_FAST32_MAX INT64_MAX -# else -# define INT_FAST32_MAX INT32_MAX -# endif -#endif -#if @HAVE_UINT_FAST32_T@ -# ifndef UINT_FAST32_MAX -# if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1) -# else -# define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# if _STDINT_H_INT64_FASTER_THAN_INT32 -# define UINT_FAST32_MAX UINT64_MAX -# else -# define UINT_FAST32_MAX UINT32_MAX -# endif -#endif - -#if @HAVE_INT_FAST64_T@ -# ifndef INT_FAST64_MIN -# if @HAVE_LONG_64BIT@ -# define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)) -# elif @HAVE_LONG_LONG_64BIT@ -# define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)) -# elif defined _MSC_VER -# define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# define INT_FAST64_MIN INT64_MIN -# endif -#endif -#if @HAVE_INT_FAST64_T@ -# ifndef INT_FAST64_MAX -# if @HAVE_LONG_64BIT@ -# define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))) -# elif @HAVE_LONG_LONG_64BIT@ -# define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))) -# elif defined _MSC_VER -# define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# define INT_FAST64_MAX INT64_MAX -# endif -#endif -#if @HAVE_UINT_FAST64_T@ -# ifndef UINT_FAST64_MAX -# if @HAVE_LONG_64BIT@ -# define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1) -# elif @HAVE_LONG_LONG_64BIT@ -# define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1) -# elif defined _MSC_VER -# define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_UINT64 -# define UINT_FAST64_MAX UINT64_MAX -# endif +#undef INT_FAST8_MIN +#undef INT_FAST8_MAX +#undef UINT_FAST8_MAX +#define INT_FAST8_MIN LONG_MIN +#define INT_FAST8_MAX LONG_MAX +#define UINT_FAST8_MAX ULONG_MAX + +#undef INT_FAST16_MIN +#undef INT_FAST16_MAX +#undef UINT_FAST16_MAX +#define INT_FAST16_MIN LONG_MIN +#define INT_FAST16_MAX LONG_MAX +#define UINT_FAST16_MAX ULONG_MAX + +#undef INT_FAST32_MIN +#undef INT_FAST32_MAX +#undef UINT_FAST32_MAX +#define INT_FAST32_MIN LONG_MIN +#define INT_FAST32_MAX LONG_MAX +#define UINT_FAST32_MAX ULONG_MAX + +#undef INT_FAST64_MIN +#undef INT_FAST64_MAX +#undef UINT_FAST64_MAX +#ifdef int64_t +# define INT_FAST64_MIN INT64_MIN +# define INT_FAST64_MAX INT64_MAX +# define UINT_FAST64_MAX UINT64_MAX #endif /* 7.18.2.4. Limits of integer types capable of holding object pointers */ -#if @HAVE_INTPTR_T@ -# ifndef INTPTR_MIN -# if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@ -# define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)) -# else -# define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1)) -# endif -# endif -#else -# define INTPTR_MIN LONG_MIN -#endif -#if @HAVE_INTPTR_T@ -# ifndef INTPTR_MAX -# if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@ -# define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))) -# else -# define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1))) -# endif -# endif -#else -# define INTPTR_MAX LONG_MAX -#endif -#if @HAVE_UINTPTR_T@ -# ifndef UINTPTR_MAX -# if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@ -# define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1) -# else -# define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#else -# define UINTPTR_MAX ULONG_MAX -#endif +#undef INTPTR_MIN +#undef INTPTR_MAX +#undef UINTPTR_MAX +#define INTPTR_MIN LONG_MIN +#define INTPTR_MAX LONG_MAX +#define UINTPTR_MAX ULONG_MAX /* 7.18.2.5. Limits of greatest-width integer types */ -#if @HAVE_INTMAX_T@ -# ifndef INTMAX_MIN -# if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@ -# define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)) -# else -# define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1)) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# define INTMAX_MIN INT64_MIN -# else -# define INTMAX_MIN INT32_MIN -# endif -#endif -#if @HAVE_INTMAX_T@ -# ifndef INTMAX_MAX -# if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@ -# define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))) -# else -# define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1))) -# endif -# endif -#else -# ifdef _STDINT_H_HAVE_INT64 -# define INTMAX_MAX INT64_MAX -# else -# define INTMAX_MAX INT32_MAX -# endif -#endif -#if @HAVE_UINTMAX_T@ -# ifndef UINTMAX_MAX -# if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@ -# define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1) -# else -# define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1) -# endif -# endif +#undef INTMAX_MIN +#undef INTMAX_MAX +#undef UINTMAX_MAX +#define INTMAX_MIN (~ INTMAX_MAX) +#ifdef INT64_MAX +# define INTMAX_MAX INT64_MAX +# define UINTMAX_MAX UINT64_MAX #else -# ifdef _STDINT_H_HAVE_INT64 -# define UINTMAX_MAX UINT64_MAX -# else -# define UINTMAX_MAX UINT32_MAX -# endif +# define INTMAX_MAX INT32_MAX +# define UINTMAX_MAX UINT32_MAX #endif /* 7.18.3. Limits of other integer types */ /* ptrdiff_t limits */ -#ifndef PTRDIFF_MIN -# if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@ -# define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)) -# else -# define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)) -# endif -#endif -#ifndef PTRDIFF_MAX -# if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@ -# define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))) -# else -# define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))) -# endif -#endif +#undef PTRDIFF_MIN +#undef PTRDIFF_MAX +#define PTRDIFF_MIN \ + _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) +#define PTRDIFF_MAX \ + _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) /* sig_atomic_t limits */ -#ifndef SIG_ATOMIC_MIN -# if @HAVE_SIGNED_SIG_ATOMIC_T@ -# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@ -# define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) -# else -# define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) -# endif -# else -# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@ -# define SIG_ATOMIC_MIN 0UL -# elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@ -# define SIG_ATOMIC_MIN 0U -# else -# define SIG_ATOMIC_MIN 0 -# endif -# endif -#endif -#ifndef SIG_ATOMIC_MAX -# if @HAVE_SIGNED_SIG_ATOMIC_T@ -# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@ -# define SIG_ATOMIC_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))) -# else -# define SIG_ATOMIC_MAX (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))) -# endif -# else -# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@ -# define SIG_ATOMIC_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1) -# elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@ -# define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1) -# else -# define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#endif +#undef SIG_ATOMIC_MIN +#undef SIG_ATOMIC_MAX +#define SIG_ATOMIC_MIN \ + _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ + 0@SIG_ATOMIC_T_SUFFIX@) +#define SIG_ATOMIC_MAX \ + _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ + 0@SIG_ATOMIC_T_SUFFIX@) + /* size_t limit */ -#ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */ -# if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@ -# define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1) -# else -# define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1) -# endif -#endif +#undef SIZE_MAX +#define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) -/* wchar_t limits may already be defined in . */ -#ifndef WCHAR_MIN -# if @HAVE_SIGNED_WCHAR_T@ -# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@ -# define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1)) -# else -# define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1)) -# endif -# else -# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@ -# define WCHAR_MIN 0UL -# elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@ -# define WCHAR_MIN 0U -# else -# define WCHAR_MIN 0 -# endif -# endif -#endif -#ifndef WCHAR_MAX -# if @HAVE_SIGNED_WCHAR_T@ -# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@ -# define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1))) -# else -# define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1))) -# endif -# else -# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@ -# define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1) -# elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@ -# define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1) -# else -# define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#endif +/* wchar_t limits */ +#undef WCHAR_MIN +#undef WCHAR_MAX +#define WCHAR_MIN \ + _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) +#define WCHAR_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) /* wint_t limits */ -#ifndef WINT_MIN -# if @HAVE_SIGNED_WINT_T@ -# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@ -# define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1)) -# else -# define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1)) -# endif -# else -# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@ -# define WINT_MIN 0UL -# elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@ -# define WINT_MIN 0U -# else -# define WINT_MIN 0 -# endif -# endif -#endif -#ifndef WINT_MAX -# if @HAVE_SIGNED_WINT_T@ -# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@ -# define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1))) -# else -# define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1))) -# endif -# else -# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@ -# define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1) -# elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@ -# define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1) -# else -# define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1) -# endif -# endif -#endif - -#endif +#undef WINT_MIN +#undef WINT_MAX +#define WINT_MIN \ + _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) +#define WINT_MAX \ + _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) /* 7.18.4. Macros for integer constants */ -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) - /* 7.18.4.1. Macros for minimum-width integer constants */ /* According to ISO C 99 Technical Corrigendum 1 */ +/* Here we assume a standard architecture where the hardware integer + types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ + #undef INT8_C #undef UINT8_C #define INT8_C(x) x -#if @HAVE_UINT8_T@ -# if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT8_C(x) x -# else -# define UINT8_C(x) x##U -# endif -#else -# define UINT8_C(x) x -#endif +#define UINT8_C(x) x #undef INT16_C #undef UINT16_C #define INT16_C(x) x -#if @HAVE_UINT16_T@ -# if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT16_C(x) x -# else -# define UINT16_C(x) x##U -# endif -#else -# define UINT16_C(x) x -#endif +#define UINT16_C(x) x #undef INT32_C #undef UINT32_C #define INT32_C(x) x -#if @HAVE_UINT32_T@ -# if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@ -# define UINT32_C(x) x -# else -# define UINT32_C(x) x##U -# endif -#else -# define UINT32_C(x) x -#endif +#define UINT32_C(x) x ## U #undef INT64_C #undef UINT64_C -#if @HAVE_LONG_64BIT@ +#if LONG_MAX >> 31 >> 31 == 1 # define INT64_C(x) x##L # define UINT64_C(x) x##UL -#elif @HAVE_LONG_LONG_64BIT@ -# define INT64_C(x) x##LL -# define UINT64_C(x) x##ULL -#elif defined(_MSC_VER) +#elif defined _MSC_VER # define INT64_C(x) x##i64 # define UINT64_C(x) x##ui64 +#elif @HAVE_LONG_LONG_INT@ +# define INT64_C(x) x##LL +# define UINT64_C(x) x##ULL #endif /* 7.18.4.2. Macros for greatest-width integer constants */ #undef INTMAX_C #undef UINTMAX_C -#if @HAVE_LONG_64BIT@ -# define INTMAX_C(x) x##L -# define UINTMAX_C(x) x##UL -#elif @HAVE_LONG_LONG_64BIT@ -# define INTMAX_C(x) x##LL -# define UINTMAX_C(x) x##ULL -#elif defined(_MSC_VER) -# define INTMAX_C(x) x##i64 -# define UINTMAX_C(x) x##ui64 +#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 +# define INTMAX_C(x) x##LL +# define UINTMAX_C(x) x##ULL +#elif defined int64_t +# define INTMAX_C(x) INT64_C(x) +# define UINTMAX_C(x) UINT64_C(x) #else -# define INTMAX_C(x) x -# define UINTMAX_C(x) x##U +# define INTMAX_C(x) x##L +# define UINTMAX_C(x) x##UL #endif -#endif +#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ -#endif /* _STDINT_H */ +#endif /* _GL_STDINT_H */