Discussion:
[PATCH 1/2] limits-h: new module
Paul Eggert
2016-09-15 22:45:14 UTC
Permalink
This adds ISO/IEC TS 18661-1:2014 support to limits.h.
* MODULES.html.sh: Add limits-h,and move size_max to stdint section.
* doc/posix-headers/limits.texi: Document new module.
* lib/limits.in.h, m4/limits-h.m4, modules/limits-h:
* modules/limit-h-tests, tests/test-limits-h.c: New files.
---
ChangeLog | 9 +++++++
MODULES.html.sh | 20 +++++++-------
doc/posix-headers/limits.texi | 3 +++
lib/limits.in.h | 63 +++++++++++++++++++++++++++++++++++++++++++
m4/limits-h.m4 | 29 ++++++++++++++++++++
modules/limits-h | 44 ++++++++++++++++++++++++++++++
modules/limits-h-tests | 12 +++++++++
tests/test-limits-h.c | 46 +++++++++++++++++++++++++++++++
8 files changed, 216 insertions(+), 10 deletions(-)
create mode 100644 lib/limits.in.h
create mode 100644 m4/limits-h.m4
create mode 100644 modules/limits-h
create mode 100644 modules/limits-h-tests
create mode 100644 tests/test-limits-h.c

diff --git a/ChangeLog b/ChangeLog
index 8d0b408..9006d19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-09-15 Paul Eggert <***@cs.ucla.edu>
+
+ limits-h: new module
+ This adds ISO/IEC TS 18661-1:2014 support to limits.h.
+ * MODULES.html.sh: Add limits-h,and move size_max to stdint section.
+ * doc/posix-headers/limits.texi: Document new module.
+ * lib/limits.in.h, m4/limits-h.m4, modules/limits-h:
+ * modules/limit-h-tests, tests/test-limits-h.c: New files.
+
2016-09-15 Eric Blake <***@redhat.com>

sys_types: avoid glibc 2.25 warnings about major()
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 06ee261..e7f2cd6 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -2049,16 +2049,6 @@ func_all_modules ()
func_module vla
func_end_table

- element="Sizes of integer types <limits.h>"
- element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"`
- func_section_wrap isoc_sup_limits
- func_wrap H3
- func_echo "$element"
-
- func_begin_table
- func_module size_max
- func_end_table
-
element="Variable arguments <stdarg.h>"
element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"`
func_section_wrap isoc_sup_stdarg
@@ -2096,6 +2086,7 @@ func_all_modules ()
func_echo "$element"

func_begin_table
+ func_module size_max
func_module stdint
func_end_table

@@ -2354,6 +2345,15 @@ func_all_modules ()
func_module stdalign
func_end_table

+ element="Support for standard extensions to ISO C 11"
+ func_section_wrap c11_ext
+ func_wrap H2
+ func_echo "$element"
+
+ func_begin_table
+ func_module limits-h
+ func_end_table
+
element="Support for obsolete systems lacking POSIX:2008"
func_section_wrap posix_sup_obsolete
func_wrap H2
diff --git a/doc/posix-headers/limits.texi b/doc/posix-headers/limits.texi
index 31207ac..7658326 100644
--- a/doc/posix-headers/limits.texi
+++ b/doc/posix-headers/limits.texi
@@ -11,6 +11,9 @@ Portability problems fixed by Gnulib:
The @code{HOST_NAME_MAX} macro is not defined on some platforms:
Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 5.1, HP-UX 11,
IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.5, BeOS.
+@item
+Macros like @code{CHAR_WIDTH} are not defined on some platforms:
+glibc 2.24, many others.
@end itemize

Portability problems not fixed by Gnulib:
diff --git a/lib/limits.in.h b/lib/limits.in.h
new file mode 100644
index 0000000..9a4f9f4
--- /dev/null
+++ b/lib/limits.in.h
@@ -0,0 +1,63 @@
+/* A GNU-like <limits.h>.
+
+ Copyright 2016 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef ***@GUARD_PREFIX@_LIMITS_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
+
+#ifndef ***@GUARD_PREFIX@_LIMITS_H
+#define ***@GUARD_PREFIX@_LIMITS_H
+
+/* The number of usable bits in an unsigned or signed integer type
+ with minimum value MIN and maximum value MAX, as an int expression
+ suitable in #if. Cover all known practical hosts. This
+ implementation exploits the fact that MAX is 1 less than a power of
+ 2, and merely counts the number of 1 bits in MAX; "COBn" means
+ "count the number of 1 bits in the low-order n bits"). */
+#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
+#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
+#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
+#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
+#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
+#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
+#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#if (! defined ULLONG_WIDTH \
+ && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
+# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
+# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
+# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
+# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
+# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
+# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
+# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
+# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
+# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
+# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
+#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
+
+#endif /* ***@GUARD_PREFIX@_LIMITS_H */
+#endif /* ***@GUARD_PREFIX@_LIMITS_H */
diff --git a/m4/limits-h.m4 b/m4/limits-h.m4
new file mode 100644
index 0000000..9130786
--- /dev/null
+++ b/m4/limits-h.m4
@@ -0,0 +1,29 @@
+dnl Check whether limits.h has needed features.
+
+dnl Copyright 2016 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Paul Eggert.
+
+AC_DEFUN_ONCE([gl_LIMITS_H],
+[
+ gl_CHECK_NEXT_HEADERS([limits.h])
+
+ AC_CACHE_CHECK([whether limits.h has ULLONG_WIDTH etc.],
+ [gl_cv_header_limits_width],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#define __STDC_WANT_IEC_60559_BFP_EXT__ 1
+ #include <limits.h>
+ int ullw = ULLONG_WIDTH;]])],
+ [gl_cv_header_limits_width=yes],
+ [gl_cv_header_limits_width=no])])
+ if test "$gl_cv_header_limits_width" = yes; then
+ LIMITS_H=
+ else
+ LIMITS_H=limits.h
+ fi
+ AC_SUBST([LIMITS_H])
+ AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"])
+])
diff --git a/modules/limits-h b/modules/limits-h
new file mode 100644
index 0000000..9c60ec9
--- /dev/null
+++ b/modules/limits-h
@@ -0,0 +1,44 @@
+Description:
+A GNU-like <limits.h>.
+
+Files:
+lib/limits.in.h
+m4/limits-h.m4
+
+Depends-on:
+include_next
+
+configure.ac:
+gl_LIMITS_H
+
+Makefile.am:
+BUILT_SOURCES += $(LIMITS_H)
+
+# We need the following in order to create <limits.h> when the system
+# doesn't have one that is compatible with GNU.
+if GL_GENERATE_LIMITS_H
+limits.h: limits.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
+ < $(srcdir)/limits.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+limits.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += limits.h limits.h-t
+
+Include:
+<limits.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/limits-h-tests b/modules/limits-h-tests
new file mode 100644
index 0000000..cda0de2
--- /dev/null
+++ b/modules/limits-h-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-limits-h.c
+
+Depends-on:
+extensions
+verify
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-limits-h
+check_PROGRAMS += test-limits-h
diff --git a/tests/test-limits-h.c b/tests/test-limits-h.c
new file mode 100644
index 0000000..597dabf
--- /dev/null
+++ b/tests/test-limits-h.c
@@ -0,0 +1,46 @@
+/* Test of <limits.h> substitute.
+ Copyright 2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+#include <limits.h>
+
+#include "verify.h"
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#define verify_width(width, min, max) \
+ verify ((max) >> ((width) - 1 - ((min) < 0)) == 1)
+
+verify_width (CHAR_WIDTH, CHAR_MIN, CHAR_MAX);
+verify_width (SCHAR_WIDTH, SCHAR_MIN, SCHAR_MAX);
+verify_width (UCHAR_WIDTH, 0, UCHAR_MAX);
+verify_width (SHRT_WIDTH, SHRT_MIN, SHRT_MAX);
+verify_width (USHRT_WIDTH, 0, USHRT_MAX);
+verify_width (INT_WIDTH, INT_MIN, INT_MAX);
+verify_width (UINT_WIDTH, 0, UINT_MAX);
+verify_width (LONG_WIDTH, LONG_MIN, LONG_MAX);
+verify_width (ULONG_WIDTH, 0, ULONG_MAX);
+verify_width (LLONG_WIDTH, LLONG_MIN, LLONG_MAX);
+verify_width (ULLONG_WIDTH, 0, ULLONG_MAX);
+
+int
+main (void)
+{
+ return 0;
+}
--
2.7.4
Paul Eggert
2016-09-15 22:45:15 UTC
Permalink
* doc/posix-headers/stdint.texi: Document this.
* lib/stdint.in.h: Add support for INTMAX_WIDTH. etc.
* m4/stdint.m4 (gl_STDINT_H): Require gl_LIMITS_H. Check for
support for INTMAX_WIDTH, etc. as well as for support for just C99.
* modules/stdint (Depends-on): Add limits-h.
(Makefile.am): Substitute HAVE_C99_STDINT_H.
* modules/stdint-tests (Depends-on): Add extensions, so that
INTMAX_MAX etc. are defined.
* tests/test-stdint.c: Verify the new macros.
---
ChangeLog | 11 +
doc/posix-headers/stdint.texi | 3 +
lib/stdint.in.h | 747 +++++++++++++++++++++++-------------------
m4/stdint.m4 | 48 ++-
modules/stdint | 5 +-
modules/stdint-tests | 1 +
tests/test-stdint.c | 58 ++++
7 files changed, 514 insertions(+), 359 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9006d19..eabbc62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2016-09-15 Paul Eggert <***@cs.ucla.edu>

+ stdint: support new _WIDTH macros
+ * doc/posix-headers/stdint.texi: Document this.
+ * lib/stdint.in.h: Add support for INTMAX_WIDTH. etc.
+ * m4/stdint.m4 (gl_STDINT_H): Require gl_LIMITS_H. Check for
+ support for INTMAX_WIDTH, etc. as well as for support for just C99.
+ * modules/stdint (Depends-on): Add limits-h.
+ (Makefile.am): Substitute HAVE_C99_STDINT_H.
+ * modules/stdint-tests (Depends-on): Add extensions, so that
+ INTMAX_MAX etc. are defined.
+ * tests/test-stdint.c: Verify the new macros.
+
limits-h: new module
This adds ISO/IEC TS 18661-1:2014 support to limits.h.
* MODULES.html.sh: Add limits-h,and move size_max to stdint section.
diff --git a/doc/posix-headers/stdint.texi b/doc/posix-headers/stdint.texi
index ee1c60e..2cc083c 100644
--- a/doc/posix-headers/stdint.texi
+++ b/doc/posix-headers/stdint.texi
@@ -33,6 +33,9 @@ On some hosts that predate C++11, when using C++ one must define
constant macros such as @code{INTMAX_C}, and one must define
@code{__STDC_LIMIT_MACROS} to make visible the definitions of limit
macros such as @code{INTMAX_MAX}.
+@item
+Macros like @code{INTMAX_WIDTH} are not defined on some platforms:
+glibc 2.24, many others.
@end itemize

Portability problems not fixed by Gnulib:
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 51fee75..f168e3e 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -79,49 +79,51 @@
#if ! defined ***@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
#define ***@GUARD_PREFIX@_STDINT_H

+/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
+ LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
+#include <limits.h>
+
+#if ! @HAVE_C99_STDINT_H@
+
/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
AIX 5.2 <sys/types.h> isn't needed and causes troubles.
Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
relies on the system <stdint.h> definitions, so include
<sys/types.h> after @***@. */
-#if @HAVE_SYS_TYPES_H@ && ! defined _AIX
-# include <sys/types.h>
-#endif
-
-/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
- LONG_MIN, LONG_MAX, ULONG_MAX. */
-#include <limits.h>
+# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
+# include <sys/types.h>
+# endif

-#if @HAVE_INTTYPES_H@
+# if @HAVE_INTTYPES_H@
/* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
<inttypes.h> also defines intptr_t and uintptr_t. */
-# include <inttypes.h>
-#elif @HAVE_SYS_INTTYPES_H@
+# include <inttypes.h>
+# elif @HAVE_SYS_INTTYPES_H@
/* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
-# include <sys/inttypes.h>
-#endif
+# include <sys/inttypes.h>
+# endif

-#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
+# if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
/* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
included by <sys/types.h>. */
-# include <sys/bitypes.h>
-#endif
+# include <sys/bitypes.h>
+# endif

-#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H

/* Minimum and maximum values for an 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) ? ~ _STDINT_MAX (signed, bits, zero) : (zero))
+# define _STDINT_MIN(signed, bits, zero) \
+ ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (zero))

-#define _STDINT_MAX(signed, bits, zero) \
- (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
+# define _STDINT_MAX(signed, bits, zero) \
+ (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)

#if !GNULIB_defined_stdint_types

@@ -130,26 +132,26 @@
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. */

-#undef int8_t
-#undef uint8_t
+# undef int8_t
+# undef uint8_t
typedef signed char gl_int8_t;
typedef unsigned char gl_uint8_t;
-#define int8_t gl_int8_t
-#define uint8_t gl_uint8_t
+# define int8_t gl_int8_t
+# define uint8_t gl_uint8_t

-#undef int16_t
-#undef uint16_t
+# undef int16_t
+# undef uint16_t
typedef short int gl_int16_t;
typedef unsigned short int gl_uint16_t;
-#define int16_t gl_int16_t
-#define uint16_t gl_uint16_t
+# define int16_t gl_int16_t
+# define uint16_t gl_uint16_t

-#undef int32_t
-#undef uint32_t
+# undef int32_t
+# undef uint32_t
typedef int gl_int32_t;
typedef unsigned int gl_uint32_t;
-#define int32_t gl_int32_t
-#define uint32_t gl_uint32_t
+# define int32_t gl_int32_t
+# define uint32_t gl_uint32_t

/* If the system defines INT64_MAX, assume int64_t works. That way,
if the underlying platform defines int64_t to be a 64-bit long long
@@ -157,54 +159,54 @@ typedef unsigned int gl_uint32_t;
int, which would mess up C++ name mangling. We must use #ifdef
rather than #if, to avoid an error with HP-UX 10.20 cc. */

-#ifdef INT64_MAX
-# define GL_INT64_T
-#else
+# ifdef INT64_MAX
+# define GL_INT64_T
+# else
/* Do not undefine int64_t if gnulib is not being used with 64-bit
types, since otherwise it breaks platforms like Tandem/NSK. */
-# if LONG_MAX >> 31 >> 31 == 1
-# undef int64_t
+# if LONG_MAX >> 31 >> 31 == 1
+# undef int64_t
typedef long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-# elif defined _MSC_VER
-# undef int64_t
+# define int64_t gl_int64_t
+# define GL_INT64_T
+# elif defined _MSC_VER
+# undef int64_t
typedef __int64 gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-# elif @HAVE_LONG_LONG_INT@
-# undef int64_t
+# define int64_t gl_int64_t
+# define GL_INT64_T
+# elif @HAVE_LONG_LONG_INT@
+# undef int64_t
typedef long long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
+# define int64_t gl_int64_t
+# define GL_INT64_T
+# endif
# endif
-#endif

-#ifdef UINT64_MAX
-# define GL_UINT64_T
-#else
-# if ULONG_MAX >> 31 >> 31 >> 1 == 1
-# undef uint64_t
-typedef unsigned long int gl_uint64_t;
-# define uint64_t gl_uint64_t
+# ifdef UINT64_MAX
# define GL_UINT64_T
-# elif defined _MSC_VER
-# undef uint64_t
+# else
+# if ULONG_MAX >> 31 >> 31 >> 1 == 1
+# undef uint64_t
+typedef unsigned long int gl_uint64_t;
+# define uint64_t gl_uint64_t
+# define GL_UINT64_T
+# elif defined _MSC_VER
+# undef uint64_t
typedef unsigned __int64 gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
-# elif @HAVE_UNSIGNED_LONG_LONG_INT@
-# undef uint64_t
+# define uint64_t gl_uint64_t
+# define GL_UINT64_T
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@
+# undef uint64_t
typedef unsigned long long int gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
+# define uint64_t gl_uint64_t
+# define GL_UINT64_T
+# endif
# endif
-#endif

/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
-#define _UINT8_T
-#define _UINT32_T
-#define _UINT64_T
+# define _UINT8_T
+# define _UINT32_T
+# define _UINT64_T


/* 7.18.1.2. Minimum-width integer types */
@@ -213,26 +215,26 @@ typedef unsigned long long int gl_uint64_t;
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
are the same as the corresponding N_t types. */

-#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 GL_INT64_T
-# define int_least64_t int64_t
-#endif
-#ifdef GL_UINT64_T
-# define uint_least64_t uint64_t
-#endif
+# 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 GL_INT64_T
+# define int_least64_t int64_t
+# endif
+# ifdef GL_UINT64_T
+# define uint_least64_t uint64_t
+# endif

/* 7.18.1.3. Fastest minimum-width integer types */

@@ -245,55 +247,55 @@ typedef unsigned long long int gl_uint64_t;
uses types consistent with glibc, as that lessens the chance of
incompatibility with older GNU hosts. */

-#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
+# 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
typedef signed char gl_int_fast8_t;
typedef unsigned char gl_uint_fast8_t;

-#ifdef __sun
+# ifdef __sun
/* Define types compatible with SunOS 5.10, so that code compiled under
earlier SunOS versions works with code compiled under SunOS 5.10. */
typedef int gl_int_fast32_t;
typedef unsigned int gl_uint_fast32_t;
-#else
+# else
typedef long int gl_int_fast32_t;
typedef unsigned long int gl_uint_fast32_t;
-#endif
+# endif
typedef gl_int_fast32_t gl_int_fast16_t;
typedef gl_uint_fast32_t gl_uint_fast16_t;

-#define int_fast8_t gl_int_fast8_t
-#define uint_fast8_t gl_uint_fast8_t
-#define int_fast16_t gl_int_fast16_t
-#define uint_fast16_t gl_uint_fast16_t
-#define int_fast32_t gl_int_fast32_t
-#define uint_fast32_t gl_uint_fast32_t
-#ifdef GL_INT64_T
-# define int_fast64_t int64_t
-#endif
-#ifdef GL_UINT64_T
-# define uint_fast64_t uint64_t
-#endif
+# define int_fast8_t gl_int_fast8_t
+# define uint_fast8_t gl_uint_fast8_t
+# define int_fast16_t gl_int_fast16_t
+# define uint_fast16_t gl_uint_fast16_t
+# define int_fast32_t gl_int_fast32_t
+# define uint_fast32_t gl_uint_fast32_t
+# ifdef GL_INT64_T
+# define int_fast64_t int64_t
+# endif
+# ifdef GL_UINT64_T
+# define uint_fast64_t uint64_t
+# endif

/* 7.18.1.4. Integer types capable of holding object pointers */

/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
definitions of intptr_t and uintptr_t (which use int and unsigned)
to avoid clashes with declarations of system functions like sbrk. */
-#ifndef _INTPTR_T_DECLARED
-#undef intptr_t
-#undef uintptr_t
+# ifndef _INTPTR_T_DECLARED
+# undef intptr_t
+# undef uintptr_t
typedef long int gl_intptr_t;
typedef unsigned long int gl_uintptr_t;
-#define intptr_t gl_intptr_t
-#define uintptr_t gl_uintptr_t
-#endif
+# define intptr_t gl_intptr_t
+# define uintptr_t gl_uintptr_t
+# endif

/* 7.18.1.5. Greatest-width integer types */

@@ -304,33 +306,33 @@ typedef unsigned long int gl_uintptr_t;
similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
assuming one type where another is used by the system. */

-#ifndef INTMAX_MAX
-# undef INTMAX_C
-# undef intmax_t
-# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+# ifndef INTMAX_MAX
+# undef INTMAX_C
+# undef intmax_t
+# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
typedef long long int gl_intmax_t;
-# define intmax_t gl_intmax_t
-# elif defined GL_INT64_T
-# define intmax_t int64_t
-# else
+# define intmax_t gl_intmax_t
+# elif defined GL_INT64_T
+# define intmax_t int64_t
+# else
typedef long int gl_intmax_t;
-# define intmax_t gl_intmax_t
+# define intmax_t gl_intmax_t
+# endif
# endif
-#endif

-#ifndef UINTMAX_MAX
-# undef UINTMAX_C
-# undef uintmax_t
-# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+# ifndef UINTMAX_MAX
+# undef UINTMAX_C
+# undef uintmax_t
+# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
typedef unsigned long long int gl_uintmax_t;
-# define uintmax_t gl_uintmax_t
-# elif defined GL_UINT64_T
-# define uintmax_t uint64_t
-# else
+# define uintmax_t gl_uintmax_t
+# elif defined GL_UINT64_T
+# define uintmax_t uint64_t
+# else
typedef unsigned long int gl_uintmax_t;
-# define uintmax_t gl_uintmax_t
+# define uintmax_t gl_uintmax_t
+# endif
# endif
-#endif

/* Verify that intmax_t and uintmax_t have the same size. Too much code
breaks if this is not the case. If this check fails, the reason is likely
@@ -338,8 +340,8 @@ typedef unsigned long int gl_uintmax_t;
typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
? 1 : -1];

-#define GNULIB_defined_stdint_types 1
-#endif /* !GNULIB_defined_stdint_types */
+# define GNULIB_defined_stdint_types 1
+# endif /* !GNULIB_defined_stdint_types */

/* 7.18.2. Limits of specified-width integer types */

@@ -348,37 +350,37 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. */

-#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
-
-#if defined GL_INT64_T && ! defined INT64_MAX
+# 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
+
+# if defined GL_INT64_T && ! defined INT64_MAX
/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
evaluates the latter incorrectly in preprocessor expressions. */
-# define INT64_MIN (- INTMAX_C (1) << 63)
-# define INT64_MAX INTMAX_C (9223372036854775807)
-#endif
+# define INT64_MIN (- INTMAX_C (1) << 63)
+# define INT64_MAX INTMAX_C (9223372036854775807)
+# endif

-#if defined GL_UINT64_T && ! defined UINT64_MAX
-# define UINT64_MAX UINTMAX_C (18446744073709551615)
-#endif
+# if defined GL_UINT64_T && ! defined UINT64_MAX
+# define UINT64_MAX UINTMAX_C (18446744073709551615)
+# endif

/* 7.18.2.2. Limits of minimum-width integer types */

@@ -386,38 +388,38 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
are the same as the corresponding N_t types. */

-#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
-#ifdef GL_INT64_T
-# define INT_LEAST64_MIN INT64_MIN
-# define INT_LEAST64_MAX INT64_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
+# ifdef GL_INT64_T
+# define INT_LEAST64_MIN INT64_MIN
+# define INT_LEAST64_MAX INT64_MAX
+# endif

-#undef UINT_LEAST64_MAX
-#ifdef GL_UINT64_T
-# define UINT_LEAST64_MAX UINT64_MAX
-#endif
+# undef UINT_LEAST64_MAX
+# ifdef GL_UINT64_T
+# define UINT_LEAST64_MAX UINT64_MAX
+# endif

/* 7.18.2.3. Limits of fastest minimum-width integer types */

@@ -425,117 +427,117 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
are taken from the same list of types. */

-#undef INT_FAST8_MIN
-#undef INT_FAST8_MAX
-#undef UINT_FAST8_MAX
-#define INT_FAST8_MIN SCHAR_MIN
-#define INT_FAST8_MAX SCHAR_MAX
-#define UINT_FAST8_MAX UCHAR_MAX
-
-#undef INT_FAST16_MIN
-#undef INT_FAST16_MAX
-#undef UINT_FAST16_MAX
-#define INT_FAST16_MIN INT_FAST32_MIN
-#define INT_FAST16_MAX INT_FAST32_MAX
-#define UINT_FAST16_MAX UINT_FAST32_MAX
-
-#undef INT_FAST32_MIN
-#undef INT_FAST32_MAX
-#undef UINT_FAST32_MAX
-#ifdef __sun
-# define INT_FAST32_MIN INT_MIN
-# define INT_FAST32_MAX INT_MAX
-# define UINT_FAST32_MAX UINT_MAX
-#else
-# define INT_FAST32_MIN LONG_MIN
-# define INT_FAST32_MAX LONG_MAX
-# define UINT_FAST32_MAX ULONG_MAX
-#endif
+# undef INT_FAST8_MIN
+# undef INT_FAST8_MAX
+# undef UINT_FAST8_MAX
+# define INT_FAST8_MIN SCHAR_MIN
+# define INT_FAST8_MAX SCHAR_MAX
+# define UINT_FAST8_MAX UCHAR_MAX
+
+# undef INT_FAST16_MIN
+# undef INT_FAST16_MAX
+# undef UINT_FAST16_MAX
+# define INT_FAST16_MIN INT_FAST32_MIN
+# define INT_FAST16_MAX INT_FAST32_MAX
+# define UINT_FAST16_MAX UINT_FAST32_MAX
+
+# undef INT_FAST32_MIN
+# undef INT_FAST32_MAX
+# undef UINT_FAST32_MAX
+# ifdef __sun
+# define INT_FAST32_MIN INT_MIN
+# define INT_FAST32_MAX INT_MAX
+# define UINT_FAST32_MAX UINT_MAX
+# else
+# define INT_FAST32_MIN LONG_MIN
+# define INT_FAST32_MAX LONG_MAX
+# define UINT_FAST32_MAX ULONG_MAX
+# endif

-#undef INT_FAST64_MIN
-#undef INT_FAST64_MAX
-#ifdef GL_INT64_T
-# define INT_FAST64_MIN INT64_MIN
-# define INT_FAST64_MAX INT64_MAX
-#endif
+# undef INT_FAST64_MIN
+# undef INT_FAST64_MAX
+# ifdef GL_INT64_T
+# define INT_FAST64_MIN INT64_MIN
+# define INT_FAST64_MAX INT64_MAX
+# endif

-#undef UINT_FAST64_MAX
-#ifdef GL_UINT64_T
-# define UINT_FAST64_MAX UINT64_MAX
-#endif
+# undef UINT_FAST64_MAX
+# ifdef GL_UINT64_T
+# define UINT_FAST64_MAX UINT64_MAX
+# endif

/* 7.18.2.4. Limits of integer types capable of holding object pointers */

-#undef INTPTR_MIN
-#undef INTPTR_MAX
-#undef UINTPTR_MAX
-#define INTPTR_MIN LONG_MIN
-#define INTPTR_MAX LONG_MAX
-#define UINTPTR_MAX ULONG_MAX
+# 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 */

-#ifndef INTMAX_MAX
-# undef INTMAX_MIN
-# ifdef INT64_MAX
-# define INTMAX_MIN INT64_MIN
-# define INTMAX_MAX INT64_MAX
-# else
-# define INTMAX_MIN INT32_MIN
-# define INTMAX_MAX INT32_MAX
+# ifndef INTMAX_MAX
+# undef INTMAX_MIN
+# ifdef INT64_MAX
+# define INTMAX_MIN INT64_MIN
+# define INTMAX_MAX INT64_MAX
+# else
+# define INTMAX_MIN INT32_MIN
+# define INTMAX_MAX INT32_MAX
+# endif
# endif
-#endif

-#ifndef UINTMAX_MAX
-# ifdef UINT64_MAX
-# define UINTMAX_MAX UINT64_MAX
-# else
-# define UINTMAX_MAX UINT32_MAX
+# ifndef UINTMAX_MAX
+# ifdef UINT64_MAX
+# define UINTMAX_MAX UINT64_MAX
+# else
+# define UINTMAX_MAX UINT32_MAX
+# endif
# endif
-#endif

/* 7.18.3. Limits of other integer types */

/* ptrdiff_t limits */
-#undef PTRDIFF_MIN
-#undef PTRDIFF_MAX
-#if @APPLE_UNIVERSAL_BUILD@
-# ifdef _LP64
-# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l)
-# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
+# undef PTRDIFF_MIN
+# undef PTRDIFF_MAX
+# if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l)
+# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
+# else
+# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0)
+# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
+# endif
# else
-# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0)
-# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
-# endif
-#else
-# define PTRDIFF_MIN \
+# define PTRDIFF_MIN \
_STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, ***@PTRDIFF_T_SUFFIX@)
-# define PTRDIFF_MAX \
+# define PTRDIFF_MAX \
_STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, ***@PTRDIFF_T_SUFFIX@)
-#endif
+# endif

/* sig_atomic_t limits */
-#undef SIG_ATOMIC_MIN
-#undef SIG_ATOMIC_MAX
-#define SIG_ATOMIC_MIN \
+# undef SIG_ATOMIC_MIN
+# undef SIG_ATOMIC_MAX
+# define SIG_ATOMIC_MIN \
_STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
***@SIG_ATOMIC_T_SUFFIX@)
-#define SIG_ATOMIC_MAX \
+# define SIG_ATOMIC_MAX \
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
***@SIG_ATOMIC_T_SUFFIX@)


/* size_t limit */
-#undef SIZE_MAX
-#if @APPLE_UNIVERSAL_BUILD@
-# ifdef _LP64
-# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
+# undef SIZE_MAX
+# if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
+# else
+# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
+# endif
# else
-# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
+# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, ***@SIZE_T_SUFFIX@)
# endif
-#else
-# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, ***@SIZE_T_SUFFIX@)
-#endif

/* wchar_t limits */
/* Get WCHAR_MIN, WCHAR_MAX.
@@ -543,29 +545,29 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
sequence of nested includes
<wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
<stdint.h> and assumes its types are already defined. */
-#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
+# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
/* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
included before <wchar.h>. */
-# include <stddef.h>
-# include <stdio.h>
-# include <time.h>
-# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
-# include <wchar.h>
-# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
-#endif
-#undef WCHAR_MIN
-#undef WCHAR_MAX
-#define WCHAR_MIN \
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
+# include <wchar.h>
+# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
+# endif
+# undef WCHAR_MIN
+# undef WCHAR_MAX
+# define WCHAR_MIN \
_STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, ***@WCHAR_T_SUFFIX@)
-#define WCHAR_MAX \
+# define WCHAR_MAX \
_STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, ***@WCHAR_T_SUFFIX@)

/* wint_t limits */
-#undef WINT_MIN
-#undef WINT_MAX
-#define WINT_MIN \
+# undef WINT_MIN
+# undef WINT_MAX
+# define WINT_MIN \
_STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, ***@WINT_T_SUFFIX@)
-#define WINT_MAX \
+# define WINT_MAX \
_STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, ***@WINT_T_SUFFIX@)

/* 7.18.4. Macros for integer constants */
@@ -576,59 +578,120 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
/* 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
-#define UINT8_C(x) x
-
-#undef INT16_C
-#undef UINT16_C
-#define INT16_C(x) x
-#define UINT16_C(x) x
-
-#undef INT32_C
-#undef UINT32_C
-#define INT32_C(x) x
-#define UINT32_C(x) x ## U
-
-#undef INT64_C
-#undef UINT64_C
-#if LONG_MAX >> 31 >> 31 == 1
-# define INT64_C(x) x##L
-#elif defined _MSC_VER
-# define INT64_C(x) x##i64
-#elif @HAVE_LONG_LONG_INT@
-# define INT64_C(x) x##LL
-#endif
-#if ULONG_MAX >> 31 >> 31 >> 1 == 1
-# define UINT64_C(x) x##UL
-#elif defined _MSC_VER
-# define UINT64_C(x) x##ui64
-#elif @HAVE_UNSIGNED_LONG_LONG_INT@
-# define UINT64_C(x) x##ULL
-#endif
+# undef INT8_C
+# undef UINT8_C
+# define INT8_C(x) x
+# define UINT8_C(x) x
+
+# undef INT16_C
+# undef UINT16_C
+# define INT16_C(x) x
+# define UINT16_C(x) x
+
+# undef INT32_C
+# undef UINT32_C
+# define INT32_C(x) x
+# define UINT32_C(x) x ## U
+
+# undef INT64_C
+# undef UINT64_C
+# if LONG_MAX >> 31 >> 31 == 1
+# define INT64_C(x) x##L
+# elif defined _MSC_VER
+# define INT64_C(x) x##i64
+# elif @HAVE_LONG_LONG_INT@
+# define INT64_C(x) x##LL
+# endif
+# if ULONG_MAX >> 31 >> 31 >> 1 == 1
+# define UINT64_C(x) x##UL
+# elif defined _MSC_VER
+# define UINT64_C(x) x##ui64
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@
+# define UINT64_C(x) x##ULL
+# endif

/* 7.18.4.2. Macros for greatest-width integer constants */

-#ifndef INTMAX_C
-# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
-# define INTMAX_C(x) x##LL
-# elif defined GL_INT64_T
-# define INTMAX_C(x) INT64_C(x)
-# else
-# define INTMAX_C(x) x##L
+# ifndef INTMAX_C
+# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+# define INTMAX_C(x) x##LL
+# elif defined GL_INT64_T
+# define INTMAX_C(x) INT64_C(x)
+# else
+# define INTMAX_C(x) x##L
+# endif
# endif
-#endif

-#ifndef UINTMAX_C
-# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
-# define UINTMAX_C(x) x##ULL
-# elif defined GL_UINT64_T
-# define UINTMAX_C(x) UINT64_C(x)
-# else
-# define UINTMAX_C(x) x##UL
+# ifndef UINTMAX_C
+# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+# define UINTMAX_C(x) x##ULL
+# elif defined GL_UINT64_T
+# define UINTMAX_C(x) UINT64_C(x)
+# else
+# define UINTMAX_C(x) x##UL
+# endif
# endif
-#endif
+
+#endif /* !@HAVE_C99_STDINT_H@ */
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#if (!defined UINTMAX_WIDTH \
+ && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+# ifdef INT8_MAX
+# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
+# endif
+# ifdef UINT8_MAX
+# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
+# endif
+# ifdef INT16_MAX
+# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
+# endif
+# ifdef UINT16_MAX
+# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
+# endif
+# ifdef INT32_MAX
+# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
+# endif
+# ifdef UINT32_MAX
+# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
+# endif
+# ifdef INT64_MAX
+# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
+# endif
+# ifdef UINT64_MAX
+# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
+# endif
+# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
+# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
+# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
+# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
+# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
+# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
+# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
+# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
+# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
+# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
+# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
+# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
+# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
+# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
+# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
+# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
+# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
+# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
+# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
+# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
+# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
+# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
+# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
+# ifdef WINT_MAX
+# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
+# endif
+# ifdef SIG_ATOMIC_MAX
+# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
+# endif
+#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */

#endif /* ***@GUARD_PREFIX@_STDINT_H */
#endif /* !(defined __ANDROID__ && ...) */
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index 0b4b906..52f7814 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 44
+# stdint.m4 serial 45
dnl Copyright (C) 2001-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -11,6 +11,8 @@ AC_DEFUN_ONCE([gl_STDINT_H],
[
AC_PREREQ([2.59])dnl

+ AC_REQUIRE([gl_LIMITS_H])
+
dnl Check for long long int and unsigned long long int.
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
if test $ac_cv_type_long_long_int = yes; then
@@ -282,14 +284,20 @@ static const char *macro_values[] =
])
])
fi
+
+ HAVE_C99_STDINT_H=0
+ HAVE_SYS_BITYPES_H=0
+ HAVE_SYS_INTTYPES_H=0
+ STDINT_H=stdint.h
if test "$gl_cv_header_working_stdint_h" = yes; then
+ HAVE_C99_STDINT_H=1
dnl Now see whether the system <stdint.h> works without
dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
AC_CACHE_CHECK([whether stdint.h predates C++11],
[gl_cv_header_stdint_predates_cxx11_h],
[gl_cv_header_stdint_predates_cxx11_h=yes
AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([[
+ AC_LANG_PROGRAM([[
#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
#include <stdint.h>
]
@@ -306,27 +314,40 @@ int32_t i32 = INT32_C (0x7fffffff);
AC_DEFINE([__STDC_LIMIT_MACROS], [1],
[Define to 1 if the system <stdint.h> predates C++11.])
fi
- STDINT_H=
+ AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
+ [gl_cv_header_stdint_width],
+ [gl_cv_header_stdint_width=no
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ /* Work if build is not clean. */
+ #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
+ #include <stdint.h>
+ ]gl_STDINT_INCLUDES[
+ int iw = UINTMAX_WIDTH;
+ ]])],
+ [gl_cv_header_stdint_width=yes])])
+ if test "$gl_cv_header_stdint_width" = yes; then
+ STDINT_H=
+ fi
else
dnl Check for <sys/inttypes.h>, and for
dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
if test $ac_cv_header_sys_inttypes_h = yes; then
HAVE_SYS_INTTYPES_H=1
- else
- HAVE_SYS_INTTYPES_H=0
fi
- AC_SUBST([HAVE_SYS_INTTYPES_H])
if test $ac_cv_header_sys_bitypes_h = yes; then
HAVE_SYS_BITYPES_H=1
- else
- HAVE_SYS_BITYPES_H=0
fi
- AC_SUBST([HAVE_SYS_BITYPES_H])
-
gl_STDINT_TYPE_PROPERTIES
- STDINT_H=stdint.h
fi
+
+ # The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
+ test -z "$STDINT_H" || LIMITS_H=limits.h
+
+ AC_SUBST([HAVE_C99_STDINT_H])
+ AC_SUBST([HAVE_SYS_BITYPES_H])
+ AC_SUBST([HAVE_SYS_INTTYPES_H])
AC_SUBST([STDINT_H])
AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"])
])
@@ -504,8 +525,3 @@ dnl Remove this when we can assume autoconf >= 2.61.
m4_ifdef([AC_COMPUTE_INT], [], [
AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
])
-
-# Hey Emacs!
-# Local Variables:
-# indent-tabs-mode: nil
-# End:
diff --git a/modules/stdint b/modules/stdint
index 62a5797..a12c5df 100644
--- a/modules/stdint
+++ b/modules/stdint
@@ -1,5 +1,6 @@
Description:
-A <stdint.h> that nearly conforms to C99.
+A GNU-like <stdint.h>.
+It nearly conforms to C99 and to ISO/IEC TS 18661-1:2014.
Assumes typical host with 8-bit bytes, two's complement
representation, and no padding or trap representations, with int
widths equal to 8, 16, 32, and 64 bits. {uint,int}_fast{8,16,32,64}_t
@@ -13,6 +14,7 @@ m4/longlong.m4

Depends-on:
include_next
+limits-h
multiarch
sys_types

@@ -34,6 +36,7 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+ -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \
-e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
-e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
diff --git a/modules/stdint-tests b/modules/stdint-tests
index 5394060..c21bfa1 100644
--- a/modules/stdint-tests
+++ b/modules/stdint-tests
@@ -4,6 +4,7 @@ m4/wchar_t.m4
m4/wint_t.m4

Depends-on:
+extensions
verify
intprops
wchar
diff --git a/tests/test-stdint.c b/tests/test-stdint.c
index 7705fc7..c0e2f08 100644
--- a/tests/test-stdint.c
+++ b/tests/test-stdint.c
@@ -351,6 +351,64 @@ verify_same_types (INTMAX_C (17), (intmax_t)0 + 0);
verify (UINTMAX_C (17) == 17);
verify_same_types (UINTMAX_C (17), (uintmax_t)0 + 0);

+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#define verify_width(width, min, max) \
+ verify ((max) >> ((width) - 1 - ((min) < 0)) == 1)
+
+#ifdef INT8_MAX
+verify_width (INT8_WIDTH, INT8_MIN, INT8_MAX);
+#endif
+#ifdef UINT8_MAX
+verify_width (UINT8_WIDTH, 0, UINT8_MAX);
+#endif
+#ifdef INT16_MAX
+verify_width (INT16_WIDTH, INT16_MIN, INT16_MAX);
+#endif
+#ifdef UINT16_MAX
+verify_width (UINT16_WIDTH, 0, UINT16_MAX);
+#endif
+#ifdef INT32_MAX
+verify_width (INT32_WIDTH, INT32_MIN, INT32_MAX);
+#endif
+#ifdef UINT32_MAX
+verify_width (UINT32_WIDTH, 0, UINT32_MAX);
+#endif
+#ifdef INT64_MAX
+verify_width (INT64_WIDTH, INT64_MIN, INT64_MAX);
+#endif
+#ifdef UINT64_MAX
+verify_width (UINT64_WIDTH, 0, UINT64_MAX);
+#endif
+verify_width (INT_LEAST8_WIDTH, INT_LEAST8_MIN, INT_LEAST8_MAX);
+verify_width (UINT_LEAST8_WIDTH, 0, UINT_LEAST8_MAX);
+verify_width (INT_LEAST16_WIDTH, INT_LEAST16_MIN, INT_LEAST16_MAX);
+verify_width (UINT_LEAST16_WIDTH, 0, UINT_LEAST16_MAX);
+verify_width (INT_LEAST32_WIDTH, INT_LEAST32_MIN, INT_LEAST32_MAX);
+verify_width (UINT_LEAST32_WIDTH, 0, UINT_LEAST32_MAX);
+verify_width (INT_LEAST64_WIDTH, INT_LEAST64_MIN, INT_LEAST64_MAX);
+verify_width (UINT_LEAST64_WIDTH, 0, UINT_LEAST64_MAX);
+verify_width (INT_FAST8_WIDTH, INT_FAST8_MIN, INT_FAST8_MAX);
+verify_width (UINT_FAST8_WIDTH, 0, UINT_FAST8_MAX);
+verify_width (INT_FAST16_WIDTH, INT_FAST16_MIN, INT_FAST16_MAX);
+verify_width (UINT_FAST16_WIDTH, 0, UINT_FAST16_MAX);
+verify_width (INT_FAST32_WIDTH, INT_FAST32_MIN, INT_FAST32_MAX);
+verify_width (UINT_FAST32_WIDTH, 0, UINT_FAST32_MAX);
+verify_width (INT_FAST64_WIDTH, INT_FAST64_MIN, INT_FAST64_MAX);
+verify_width (UINT_FAST64_WIDTH, 0, UINT_FAST64_MAX);
+verify_width (INTPTR_WIDTH, INTPTR_MIN, INTPTR_MAX);
+verify_width (UINTPTR_WIDTH, 0, UINTPTR_MAX);
+verify_width (INTMAX_WIDTH, INTMAX_MIN, INTMAX_MAX);
+verify_width (UINTMAX_WIDTH, 0, UINTMAX_MAX);
+verify_width (PTRDIFF_WIDTH, PTRDIFF_MIN, PTRDIFF_MAX);
+verify_width (SIZE_WIDTH, 0, SIZE_MAX);
+verify_width (WCHAR_WIDTH, WCHAR_MIN, WCHAR_MAX);
+#ifdef WINT_MAX
+verify_width (WINT_WIDTH, WINT_MIN, WINT_MAX);
+#endif
+#ifdef SIG_ATOMIC_MAX
+verify_width (SIG_ATOMIC_WIDTH, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX);
+#endif

int
main (void)
--
2.7.4
Jim Meyering
2016-09-22 16:22:33 UTC
Permalink
Post by Paul Eggert
* doc/posix-headers/stdint.texi: Document this.
* lib/stdint.in.h: Add support for INTMAX_WIDTH. etc.
* m4/stdint.m4 (gl_STDINT_H): Require gl_LIMITS_H. Check for
support for INTMAX_WIDTH, etc. as well as for support for just C99.
* modules/stdint (Depends-on): Add limits-h.
(Makefile.am): Substitute HAVE_C99_STDINT_H.
* modules/stdint-tests (Depends-on): Add extensions, so that
INTMAX_MAX etc. are defined.
* tests/test-stdint.c: Verify the new macros.
---
ChangeLog | 11 +
doc/posix-headers/stdint.texi | 3 +
lib/stdint.in.h | 747 +++++++++++++++++++++++-------------------
m4/stdint.m4 | 48 ++-
modules/stdint | 5 +-
modules/stdint-tests | 1 +
tests/test-stdint.c | 58 ++++
7 files changed, 514 insertions(+), 359 deletions(-)
Nice change.
However, on a system like Fedora24 for which stdint.h is built, yet
not limits.h, there is a problem.
stdint.h uses _GL_INTEGER_WIDTH, and gnulib's limits.h defines it.
Hence, any time we use certain features of stdint.h, we must currently
also be sure to build gnulib-derived limits.h for that definition.
Otherwise, the following fails:

./gnulib-tool --create-testdir --dir=/tmp/x --with-tests --test stdint

with many errors like these:

In file included from ../../gltests/test-stdint.c:26:0:
../../gltests/test-stdint.c:357:48: error: expression in static
assertion is not constant
verify ((max) >> ((width) - 1 - ((min) < 0)) == 1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
../../gltests/../gllib/verify.h:251:31: note: in definition of macro ‘verify’
#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
^
../../gltests/test-stdint.c:360:1: note: in expansion of macro ‘verify_width’
verify_width (INT8_WIDTH, INT8_MIN, INT8_MAX);
^~~~~~~~~~~~
Paul Eggert
2016-09-22 17:55:05 UTC
Permalink
Post by Jim Meyering
./gnulib-tool --create-testdir --dir=/tmp/x --with-tests --test stdint
Odd, I'm not seeing those failures on x86-64 Fedora 24 (gcc 6.2.1
20160916 (Red Hat 6.2.1-2)).

Hmm, I think I see the problem. I guess you're using prerelease GCC 7?
Anyway, there is a typo in m4/stdint.m4. I installed the attached; does
it fix things for you?
Post by Jim Meyering
any time we use certain features of stdint.h, we must currently
also be sure to build gnulib-derived limits.h for that definition.
m4/stdint.m4 was supposed to do that, but the typo got in the way.
Jim Meyering
2016-09-22 18:08:52 UTC
Permalink
Post by Jim Meyering
./gnulib-tool --create-testdir --dir=/tmp/x --with-tests --test stdint
Odd, I'm not seeing those failures on x86-64 Fedora 24 (gcc 6.2.1 20160916
(Red Hat 6.2.1-2)).
Hmm, I think I see the problem. I guess you're using prerelease GCC 7?
Anyway, there is a typo in m4/stdint.m4. I installed the attached; does it
fix things for you?
Post by Jim Meyering
any time we use certain features of stdint.h, we must currently
also be sure to build gnulib-derived limits.h for that definition.
m4/stdint.m4 was supposed to do that, but the typo got in the way.
Oh, yes. This is with GCC 7.

Thanks for the quick patch. I applied it and reran that gnulib-tool
command, but it still fails (no limits.h is created), but have just
run out of time for them moment. Here's the log:
Paul Eggert
2016-09-22 18:48:59 UTC
Permalink
Post by Jim Meyering
it still fails (no limits.h is created)
Sorry about that. I managed to reproduce the problem with Fedora 24 GCC
6.2.1 by overriding its limits.h, and installed the attached further
patch which fixed it for me.
Jim Meyering
2016-09-22 18:59:51 UTC
Permalink
Post by Paul Eggert
Post by Jim Meyering
it still fails (no limits.h is created)
Sorry about that. I managed to reproduce the problem with Fedora 24 GCC
6.2.1 by overriding its limits.h, and installed the attached further patch
which fixed it for me.
Bingo. Confirmed that that test now passes for me, too. Thank you!
Loading...