From: Bruno Haible Date: Sat, 17 Dec 2016 17:46:30 +0000 (+0100) Subject: stdint: Fix WINT_MAX to match the gnulib provided wint_t on MSVC. X-Git-Tag: v1.0~6482 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=92cb6641a6f2127fda8a084444637c3d4e394f4c;p=gnulib.git stdint: Fix WINT_MAX to match the gnulib provided wint_t on MSVC. * m4/stdint.m4 (gl_STDINT_H): Define GNULIB_OVERRIDES_WINT_T. * modules/stdint (Makefile.am): Substitute GNULIB_OVERRIDES_WINT_T. * lib/stdint.in.h [GNULIB_OVERRIDES_WINT_T]: Redefine WINT_MIN and WINT_MAX. --- diff --git a/ChangeLog b/ChangeLog index e65df5895f..09c238ab67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-12-17 Bruno Haible + + stdint: Fix WINT_MAX to match the gnulib provided wint_t on MSVC. + * m4/stdint.m4 (gl_STDINT_H): Define GNULIB_OVERRIDES_WINT_T. + * modules/stdint (Makefile.am): Substitute GNULIB_OVERRIDES_WINT_T. + * lib/stdint.in.h [GNULIB_OVERRIDES_WINT_T]: Redefine WINT_MIN and + WINT_MAX. + 2016-12-17 Bruno Haible Avoid autoconf warning. @@ -22,7 +30,7 @@ getlogin: Port to newer mingw. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_GETLOGIN. * m4/getlogin.m4 (gl_FUNC_GETLOGIN): Set HAVE_DECL_GETLOGIN. - * modules/unistd (Makefile.am): Substibute HAVE_DECL_GETLOGIN, not + * modules/unistd (Makefile.am): Substitute HAVE_DECL_GETLOGIN, not HAVE_GETLOGIN. * lib/unistd.in.h (getlogin): Test HAVE_DECL_GETLOGIN, not HAVE_GETLOGIN. @@ -79211,7 +79219,7 @@ o Test only that noncanonical values do not cause crashes, not that (signbit): New macro. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize GNULIB_SIGNBIT and REPLACE_SIGNBIT. - * modules/math (Makefile.am): Substibute also GNULIB_SIGNBIT and + * modules/math (Makefile.am): Substitute also GNULIB_SIGNBIT and REPLACE_FREXPL into math.h. 2007-04-06 Bruno Haible @@ -79898,7 +79906,7 @@ o Test only that noncanonical values do not cause crashes, not that * lib/math_.h (frexpl): Define as a replacement macro if REPLACE_FREXPL is set. Don't provide a prototype if REPLACE_FREXPL is not set. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_FREXPL. - * modules/math (Makefile.am): Substibute also REPLACE_FREXPL into + * modules/math (Makefile.am): Substitute also REPLACE_FREXPL into math.h. 2007-03-25 Bruno Haible diff --git a/lib/stdint.in.h b/lib/stdint.in.h index f168e3e3f8..5060dab649 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -83,6 +83,15 @@ LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */ #include +/* Override WINT_MIN and WINT_MAX if gnulib's or overrides + wint_t. */ +#if @GNULIB_OVERRIDES_WINT_T@ +# undef WINT_MIN +# undef WINT_MAX +# define WINT_MIN 0x0U +# define WINT_MAX 0xffffffffU +#endif + #if ! @HAVE_C99_STDINT_H@ /* defines some of the stdint.h types as well, on glibc, diff --git a/m4/stdint.m4 b/m4/stdint.m4 index 05b6ab7846..b972ee4915 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -1,4 +1,4 @@ -# stdint.m4 serial 48 +# stdint.m4 serial 49 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, @@ -354,7 +354,33 @@ int32_t i32 = INT32_C (0x7fffffff); gl_STDINT_TYPE_PROPERTIES fi - # The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH. + dnl Determine whether gnulib's or would, if present, + dnl override 'wint_t'. + AC_CACHE_CHECK([whether wint_t is too small], + [gl_cv_type_wint_t_too_small], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +# include +# include +#endif +#include + int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1]; + ]])], + [gl_cv_type_wint_t_too_small=no], + [gl_cv_type_wint_t_too_small=yes])]) + if test $gl_cv_type_wint_t_too_small = yes; then + GNULIB_OVERRIDES_WINT_T=1 + else + GNULIB_OVERRIDES_WINT_T=0 + fi + + dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH. LIMITS_H=limits.h AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"]) @@ -362,6 +388,7 @@ int32_t i32 = INT32_C (0x7fffffff); AC_SUBST([HAVE_SYS_BITYPES_H]) AC_SUBST([HAVE_SYS_INTTYPES_H]) AC_SUBST([STDINT_H]) + AC_SUBST([GNULIB_OVERRIDES_WINT_T]) AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) ]) diff --git a/modules/stdint b/modules/stdint index a12c5dfc16..75ce257922 100644 --- a/modules/stdint +++ b/modules/stdint @@ -58,6 +58,7 @@ stdint.h: stdint.in.h $(top_builddir)/config.status -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ + -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \ < $(srcdir)/stdint.in.h; \ } > $@-t && \ mv $@-t $@