From 17ee0a04a943f893d2e3fda339c9a6daca2ca655 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Fri, 29 Jun 2007 05:38:36 +0200 Subject: [PATCH] Update gnulib files. --- build-aux/config.rpath | 58 ++++++++++--------- gl/.cvsignore | 2 + gl/Makefile.am | 70 ++++++++++++++--------- gl/float_.h | 6 +- gl/getdate.y | 10 ++++ gl/intprops.h | 78 ++++++++++++++++++++++++++ gl/m4/.cvsignore | 1 + gl/m4/absolute-header.m4 | 11 +++- gl/m4/float_h.m4 | 6 +- gl/m4/getaddrinfo.m4 | 31 ++++++++++- gl/m4/gnulib-comp.m4 | 3 + gl/m4/include_next.m4 | 85 ++++++++++++++++++++++++++++ gl/m4/netinet_in_h.m4 | 6 +- gl/m4/stdint.m4 | 16 ++---- gl/m4/stdio_h.m4 | 6 +- gl/m4/stdlib_h.m4 | 6 +- gl/m4/string_h.m4 | 4 +- gl/m4/sys_select_h.m4 | 7 +-- gl/m4/sys_socket_h.m4 | 7 +-- gl/m4/sys_stat_h.m4 | 6 +- gl/m4/sys_time_h.m4 | 6 +- gl/m4/time_h.m4 | 4 +- gl/m4/unistd_h.m4 | 9 +-- gl/m4/wchar.m4 | 6 +- gl/netinet_in_.h | 6 +- gl/printf-args.c | 6 +- gl/printf-parse.h | 8 +-- gl/stdint_.h | 12 ++-- gl/stdio_.h | 12 +--- gl/stdlib_.h | 12 +--- gl/string_.h | 6 +- gl/sys_select_.h | 6 +- gl/sys_socket_.h | 6 +- gl/sys_stat_.h | 6 +- gl/sys_time_.h | 6 +- gl/time_.h | 109 ++++++++++++++++-------------------- gl/unistd_.h | 34 +++++++++--- gl/verify.h | 141 +++++++++++++++++++++++++++++++++++++++++++++++ gl/wchar_.h | 6 +- gl/xreadlink.h | 10 ---- 40 files changed, 559 insertions(+), 271 deletions(-) create mode 100644 gl/intprops.h create mode 100644 gl/m4/include_next.m4 create mode 100644 gl/verify.h diff --git a/build-aux/config.rpath b/build-aux/config.rpath index e082db6b..c547c688 100755 --- a/build-aux/config.rpath +++ b/build-aux/config.rpath @@ -2,7 +2,7 @@ # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # -# Copyright 1996-2006 Free Software Foundation, Inc. +# Copyright 1996-2007 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # @@ -64,7 +64,7 @@ else ;; esac ;; - mingw* | pw32* | os2*) + mingw* | cygwin* | pw32* | os2*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' @@ -74,7 +74,7 @@ else ;; newsos6) ;; - linux*) + linux* | k*bsd*-gnu) case $cc_basename in icc* | ecc*) wl='-Wl,' @@ -100,7 +100,7 @@ else osf3* | osf4* | osf5*) wl='-Wl,' ;; - sco3.2v5*) + rdos*) ;; solaris*) wl='-Wl,' @@ -108,11 +108,14 @@ else sunos4*) wl='-Qoption ld ' ;; - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + sysv4 | sysv4.2uw2* | sysv4.3*) wl='-Wl,' ;; sysv4*MP*) ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; unicos*) wl='-Wl,' ;; @@ -189,11 +192,11 @@ if test "$with_gnu_ld" = yes; then ld_shlibs=no fi ;; - interix3*) + interix[3-9]*) hardcode_direct=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; - linux*) + gnu* | linux* | k*bsd*-gnu) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else @@ -280,7 +283,7 @@ else strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 - hardcode_direct=yes + : else # We have old collect2 hardcode_direct=unsupported @@ -359,7 +362,7 @@ else hardcode_direct=yes hardcode_minus_L=yes ;; - freebsd* | kfreebsd*-gnu | dragonfly*) + freebsd* | dragonfly*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; @@ -412,18 +415,22 @@ else hardcode_libdir_separator=: ;; openbsd*) - hardcode_direct=yes - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi else - case "$host_os" in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac + ld_shlibs=no fi ;; os2*) @@ -471,7 +478,7 @@ else ld_shlibs=yes fi ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) ;; sysv5* | sco3.2v5* | sco5v6*) hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' @@ -523,9 +530,6 @@ case "$host_os" in ;; freebsd1*) ;; - kfreebsd*-gnu) - library_names_spec='$libname$shrext' - ;; freebsd* | dragonfly*) case "$host_os" in freebsd[123]*) @@ -551,7 +555,7 @@ case "$host_os" in esac library_names_spec='$libname$shrext' ;; - interix3*) + interix[3-9]*) library_names_spec='$libname$shrext' ;; irix5* | irix6* | nonstopux*) @@ -572,7 +576,7 @@ case "$host_os" in ;; linux*oldld* | linux*aout* | linux*coff*) ;; - linux*) + linux* | k*bsd*-gnu) library_names_spec='$libname$shrext' ;; knetbsd*-gnu) @@ -598,6 +602,8 @@ case "$host_os" in osf3* | osf4* | osf5*) library_names_spec='$libname$shrext' ;; + rdos*) + ;; solaris*) library_names_spec='$libname$shrext' ;; diff --git a/gl/.cvsignore b/gl/.cvsignore index 43031bea..47e737a6 100644 --- a/gl/.cvsignore +++ b/gl/.cvsignore @@ -19,3 +19,5 @@ float+.h float_.h sys_socket_.h sys_stat_.h +intprops.h +verify.h diff --git a/gl/Makefile.am b/gl/Makefile.am index 3ae1caeb..0d696cb6 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -188,8 +188,8 @@ BUILT_SOURCES += $(FLOAT_H) float.h: float_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''ABSOLUTE_FLOAT_H''@|$(ABSOLUTE_FLOAT_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ < $(srcdir)/float_.h; \ } > $@-t mv $@-t $@ @@ -334,6 +334,13 @@ EXTRA_libgnu_la_SOURCES += inet_ntop.c ## end gnulib module inet_ntop +## begin gnulib module intprops + + +EXTRA_DIST += intprops.h + +## end gnulib module intprops + ## begin gnulib module link-warning LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h @@ -376,8 +383,8 @@ netinet/in.h: @MKDIR_P@ netinet rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''ABSOLUTE_NETINET_IN_H''@|$(ABSOLUTE_NETINET_IN_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ < $(srcdir)/netinet_in_.h; \ } > $@-t @@ -474,8 +481,8 @@ stdint.h: stdint_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ - -e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_STDINT_H''@|$(NEXT_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' \ @@ -513,8 +520,8 @@ BUILT_SOURCES += stdio.h stdio.h: stdio_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''ABSOLUTE_STDIO_H''@|$(ABSOLUTE_STDIO_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \ -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \ -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ @@ -565,8 +572,8 @@ BUILT_SOURCES += stdlib.h stdlib.h: stdlib_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''ABSOLUTE_STDLIB_H''@|$(ABSOLUTE_STDLIB_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ @@ -619,8 +626,8 @@ BUILT_SOURCES += string.h string.h: string_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''ABSOLUTE_STRING_H''@|$(ABSOLUTE_STRING_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \ -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \ -e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \ @@ -720,8 +727,8 @@ sys/select.h: @MKDIR_P@ sys rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''ABSOLUTE_SYS_SELECT_H''@|$(ABSOLUTE_SYS_SELECT_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \ -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \ < $(srcdir)/sys_select_.h; \ } > $@-t @@ -742,8 +749,8 @@ BUILT_SOURCES += $(SYS_SOCKET_H) sys/socket.h: sys_socket_.h @MKDIR_P@ sys { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''ABSOLUTE_SYS_SOCKET_H''@|$(ABSOLUTE_SYS_SOCKET_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ @@ -767,8 +774,8 @@ sys/stat.h: sys_stat_.h @MKDIR_P@ sys rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''ABSOLUTE_SYS_STAT_H''@|$(ABSOLUTE_SYS_STAT_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''HAVE_IO_H''@|$(HAVE_IO_H)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -e 's|@''HAVE_DECL_MKDIR''@|$(HAVE_DECL_MKDIR)|g' \ @@ -793,8 +800,8 @@ sys/time.h: sys_time_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ - -e 's|@''ABSOLUTE_SYS_TIME_H''@|$(ABSOLUTE_SYS_TIME_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ < $(srcdir)/sys_time_.h; \ @@ -815,8 +822,8 @@ BUILT_SOURCES += time.h time.h: time_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@ABSOLUTE_TIME_H''@|$(ABSOLUTE_TIME_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ -e 's|@REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ -e 's|@REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -e 's|@REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \ @@ -867,14 +874,15 @@ unistd.h: unistd_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ - -e 's|@''ABSOLUTE_UNISTD_H''@|$(ABSOLUTE_UNISTD_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ + -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ @@ -886,6 +894,7 @@ unistd.h: unistd_.h -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ + -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ < $(srcdir)/unistd_.h; \ } > $@-t @@ -914,6 +923,12 @@ EXTRA_libgnu_la_SOURCES += asprintf.c vasprintf.c ## end gnulib module vasprintf +## begin gnulib module verify + +libgnu_la_SOURCES += verify.h + +## end gnulib module verify + ## begin gnulib module wchar BUILT_SOURCES += $(WCHAR_H) @@ -923,8 +938,8 @@ BUILT_SOURCES += $(WCHAR_H) wchar.h: wchar_.h rm -f $@-t $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's|@''ABSOLUTE_WCHAR_H''@|$(ABSOLUTE_WCHAR_H)|g' \ - -e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ < $(srcdir)/wchar_.h; \ } > $@-t @@ -990,4 +1005,5 @@ mostlyclean-local: mostlyclean-generic if test -n "$$dir" && test -d $$dir; then \ echo "rmdir $$dir"; rmdir $$dir; \ fi; \ - done + done; \ + : diff --git a/gl/float_.h b/gl/float_.h index d898d85a..d61d630b 100644 --- a/gl/float_.h +++ b/gl/float_.h @@ -19,11 +19,7 @@ #ifndef _GL_FLOAT_H /* The include_next requires a split double-inclusion guard. */ -#if @HAVE_INCLUDE_NEXT@ -# include_next -#else -# include @ABSOLUTE_FLOAT_H@ -#endif +#@INCLUDE_NEXT@ @NEXT_FLOAT_H@ #ifndef _GL_FLOAT_H #define _GL_FLOAT_H diff --git a/gl/getdate.y b/gl/getdate.y index cbf3ca10..e34f4a94 100644 --- a/gl/getdate.y +++ b/gl/getdate.y @@ -35,7 +35,10 @@ #include #include "getdate.h" + +#include "intprops.h" #include "timespec.h" +#include "verify.h" /* There's no need to extend the stack, so there's no need to involve alloca. */ @@ -107,6 +110,13 @@ #define HOUR(x) ((x) * 60) +/* Lots of this code assumes time_t and time_t-like values fit into + long int. It also assumes that signed integer overflow silently + wraps around, but there's no portable way to check for that at + compile-time. */ +verify (TYPE_IS_INTEGER (time_t)); +verify (LONG_MIN <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= LONG_MAX); + /* An integer value, and the number of digits in its textual representation. */ typedef struct diff --git a/gl/intprops.h b/gl/intprops.h new file mode 100644 index 00000000..34f971cb --- /dev/null +++ b/gl/intprops.h @@ -0,0 +1,78 @@ +/* intprops.h -- properties of integer types + + Copyright (C) 2001, 2002, 2003, 2004, 2005 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 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert. */ + +#include + +/* The extra casts in the following macros work around compiler bugs, + e.g., in Cray C 5.0.3.0. */ + +/* True if the arithmetic type T is an integer type. bool counts as + an integer. */ +#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) + +/* True if negative values of the signed integer type T use two's + complement, ones' complement, or signed magnitude representation, + respectively. Much GNU code assumes two's complement, but some + people like to be portable to all possible C hosts. */ +#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) +#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) +#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) + +/* True if the arithmetic type T is signed. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + +/* The maximum and minimum values for the integer type T. These + macros have undefined behavior if T is signed and has padding bits. + If this is a problem for you, please let us know how to fix it for + your host. */ +#define TYPE_MINIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) 0 \ + : TYPE_SIGNED_MAGNITUDE (t) \ + ? ~ (t) 0 \ + : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) +#define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) + +/* Return zero if T can be determined to be an unsigned type. + Otherwise, return 1. + When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a + tighter bound. Otherwise, it overestimates the true bound by one byte + when applied to unsigned types of size 2, 4, 16, ... bytes. + The symbol signed_type_or_expr__ is private to this header file. */ +#if __GNUC__ >= 2 +# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) +#else +# define signed_type_or_expr__(t) 1 +#endif + +/* Bound on length of the string representing an integer type or expression T. + Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; + add 1 for integer division truncation; add 1 more for a minus sign + if needed. */ +#define INT_STRLEN_BOUND(t) \ + ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ + + signed_type_or_expr__ (t) + 1) + +/* Bound on buffer size needed to represent an integer type or expression T, + including the terminating null. */ +#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) diff --git a/gl/m4/.cvsignore b/gl/m4/.cvsignore index c08d7f70..fc0ce398 100644 --- a/gl/m4/.cvsignore +++ b/gl/m4/.cvsignore @@ -1,3 +1,4 @@ float_h.m4 fseeko.m4 malloca.m4 +include_next.m4 diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4 index c649df08..5b7a2fc3 100644 --- a/gl/m4/absolute-header.m4 +++ b/gl/m4/absolute-header.m4 @@ -1,5 +1,5 @@ -# absolute-header.m4 serial 6 -dnl Copyright (C) 2006 Free Software Foundation, Inc. +# absolute-header.m4 serial 7 +dnl Copyright (C) 2006, 2007 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. @@ -32,7 +32,12 @@ dnl eval is necessary to expand ac_cpp. dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell. AS_VAR_SET(gl_absolute_header, [`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | -sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#;s#^/[^/]#//&#;p;q;}'`]) +sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ + s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# + s#^/[^/]#//&# + p + q +}'`]) fi AS_VAR_POPDEF([ac_header_exists])dnl ])dnl diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4 index 36a07dcb..1b1ad103 100644 --- a/gl/m4/float_h.m4 +++ b/gl/m4/float_h.m4 @@ -1,4 +1,4 @@ -# float_h.m4 serial 1 +# float_h.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,9 +12,7 @@ AC_DEFUN([gl_FLOAT_H], case "$host_os" in beos*) FLOAT_H=float.h - gl_ABSOLUTE_HEADER([float.h]) - ABSOLUTE_FLOAT_H=\"$gl_cv_absolute_float_h\" - AC_SUBST([ABSOLUTE_FLOAT_H]) + gl_CHECK_NEXT_HEADERS([float.h]) ;; esac AC_SUBST([FLOAT_H]) diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4 index db285d94..4a1e09f7 100644 --- a/gl/m4/getaddrinfo.m4 +++ b/gl/m4/getaddrinfo.m4 @@ -1,11 +1,12 @@ -# getaddrinfo.m4 serial 11 -dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. +# getaddrinfo.m4 serial 12 +dnl Copyright (C) 2004, 2005, 2006, 2007 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. AC_DEFUN([gl_GETADDRINFO], [ + AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo]) AC_SEARCH_LIBS(getaddrinfo, [nsl socket]) @@ -28,12 +29,36 @@ AC_DEFUN([gl_GETADDRINFO], fi ]) - AC_REPLACE_FUNCS(gai_strerror) + # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an + # inline function declared in ws2tcpip.h, so we need to get that + # header included somehow. + AC_CHECK_HEADERS_ONCE(netdb.h) + AC_CACHE_CHECK([for gai_strerror (possibly via ws2tcpip.h)], + gl_cv_func_gai_strerror, [ + AC_TRY_LINK([ +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_WS2TCPIP_H +#include +#endif +], [gai_strerror (0);], + [gl_cv_func_gai_strerror=yes], + [gl_cv_func_gai_strerror=no])]) + if test $gl_cv_func_gai_strerror = no; then + AC_LIBOBJ(gai_strerror) + fi + gl_PREREQ_GETADDRINFO ]) # Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c. AC_DEFUN([gl_PREREQ_GETADDRINFO], [ + AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H AC_SEARCH_LIBS(gethostbyname, [inet nsl]) AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet]) AC_CHECK_FUNCS(gethostbyname,, [ diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 86810b96..5157fba3 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -239,6 +239,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/hmac.h lib/inet_ntop.c lib/inet_ntop.h + lib/intprops.h lib/lseek.c lib/malloca.c lib/malloca.h @@ -294,6 +295,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/vasnprintf.c lib/vasnprintf.h lib/vasprintf.c + lib/verify.h lib/wchar_.h lib/xalloc.h lib/xasprintf.c @@ -346,6 +348,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/gnulib-common.m4 m4/hmac-md5.m4 m4/hmac-sha1.m4 + m4/include_next.m4 m4/inet_ntop.m4 m4/inline.m4 m4/intmax_t.m4 diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4 new file mode 100644 index 00000000..4dc84c95 --- /dev/null +++ b/gl/m4/include_next.m4 @@ -0,0 +1,85 @@ +# include_next.m4 serial 3 +dnl Copyright (C) 2006, 2007 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 and Derek Price. + +AC_DEFUN([gl_INCLUDE_NEXT], +[ + AC_LANG_PREPROC_REQUIRE() + AC_CACHE_CHECK([whether the preprocessor supports include_next], + [gl_cv_have_include_next], + [AC_PREPROC_IFELSE([#include_next ], + [gl_cv_have_include_next=yes], + [gl_cv_have_include_next=no])]) + if test $gl_cv_have_include_next = yes; then + + dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it + dnl to use @INCLUDE_NEXT@ instead. + AC_DEFINE([HAVE_INCLUDE_NEXT], 1, + [Define if your compiler supports the #include_next directive.]) + + INCLUDE_NEXT=include_next + else + INCLUDE_NEXT=include + fi + AC_SUBST([INCLUDE_NEXT]) +]) + +# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) +# ------------------------------------------ +# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be +# ''; otherwise define it to be +# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. +# That way, a header file with the following line: +# #@INCLUDE_NEXT@ @NEXT_FOO_H@ +# behaves (after sed substitution) as if it contained +# #include_next +# even if the compiler does not support include_next. +# The three "///" are to pacify Sun C 5.8, which otherwise would say +# "warning: #include of /usr/include/... may be non-portable". +# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. +AC_DEFUN([gl_CHECK_NEXT_HEADERS], +[ + AC_REQUIRE([gl_INCLUDE_NEXT]) + AC_CHECK_HEADERS_ONCE([$1]) + + AC_FOREACH([gl_HEADER_NAME], [$1], + [AS_VAR_PUSHDEF([gl_next_header], + [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME]))) + if test $gl_cv_have_include_next = yes; then + AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) + else + AC_CACHE_CHECK( + [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>], + m4_quote(m4_defn([gl_next_header])), + [AS_VAR_PUSHDEF([gl_header_exists], + [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME]))) + if test AS_VAR_GET(gl_header_exists) = yes; then + AC_LANG_CONFTEST( + [AC_LANG_SOURCE( + [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] + )]) + dnl eval is necessary to expand ac_cpp. + dnl Ultrix and Pyramid sh refuse to redirect output of eval, + dnl so use subshell. + AS_VAR_SET([gl_next_header], + ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | + sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ + s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"']) + else + AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) + fi + AS_VAR_POPDEF([gl_header_exists])]) + fi + AC_SUBST( + AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))), + [AS_VAR_GET([gl_next_header])]) + AS_VAR_POPDEF([gl_next_header])]) +]) diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4 index 966bfe6a..096be740 100644 --- a/gl/m4/netinet_in_h.m4 +++ b/gl/m4/netinet_in_h.m4 @@ -1,4 +1,4 @@ -# netinet_in_h.m4 serial 2 +# netinet_in_h.m4 serial 3 dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,9 +18,7 @@ AC_DEFUN([gl_HEADER_NETINET_IN], else NETINET_IN_H='netinet/in.h' AC_CHECK_HEADERS([netinet/in.h]) - gl_ABSOLUTE_HEADER([netinet/in.h]) - ABSOLUTE_NETINET_IN_H=\"$gl_cv_absolute_netinet_in_h\" - AC_SUBST([ABSOLUTE_NETINET_IN_H]) + gl_CHECK_NEXT_HEADERS([netinet/in.h]) if test $ac_cv_header_netinet_in_h = yes; then HAVE_NETINET_IN_H=1 else diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4 index c12311d2..e8016bdd 100644 --- a/gl/m4/stdint.m4 +++ b/gl/m4/stdint.m4 @@ -1,4 +1,4 @@ -# stdint.m4 serial 26 +# stdint.m4 serial 27 dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -45,22 +45,15 @@ AC_DEFUN([gl_STDINT_H], fi AC_SUBST([HAVE_SYS_TYPES_H]) - dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_stdint_h. + gl_CHECK_NEXT_HEADERS([stdint.h]) if test $ac_cv_header_stdint_h = yes; then - gl_ABSOLUTE_HEADER([stdint.h]) - ABSOLUTE_STDINT_H=\"$gl_cv_absolute_stdint_h\" HAVE_STDINT_H=1 else - ABSOLUTE_STDINT_H=\"no/such/file/stdint.h\" HAVE_STDINT_H=0 fi - AC_SUBST([ABSOLUTE_STDINT_H]) AC_SUBST([HAVE_STDINT_H]) - dnl Now see whether we need a substitute . Use - dnl ABSOLUTE_STDINT_H, not , so that it also works during - dnl a "config.status --recheck" if a stdint.h has been - dnl created in the build directory. + dnl Now see whether we need a substitute . if test $ac_cv_header_stdint_h = yes; then AC_CACHE_CHECK([whether stdint.h conforms to C99], [gl_cv_header_working_stdint_h], @@ -70,7 +63,8 @@ AC_DEFUN([gl_STDINT_H], [ #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ #define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */ -#include ABSOLUTE_STDINT_H +#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ +#include #ifdef INT8_MAX int8_t a1 = INT8_MAX; int8_t a1min = INT8_MIN; diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4 index 955c9121..721c8262 100644 --- a/gl/m4/stdio_h.m4 +++ b/gl/m4/stdio_h.m4 @@ -1,4 +1,4 @@ -# stdio_h.m4 serial 6 +# stdio_h.m4 serial 7 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,9 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_STDIO_H], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - gl_ABSOLUTE_HEADER([stdio.h]) - ABSOLUTE_STDIO_H=\"$gl_cv_absolute_stdio_h\" - AC_SUBST([ABSOLUTE_STDIO_H]) + gl_CHECK_NEXT_HEADERS([stdio.h]) ]) AC_DEFUN([gl_STDIO_MODULE_INDICATOR], diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4 index d46a5f06..f13b4297 100644 --- a/gl/m4/stdlib_h.m4 +++ b/gl/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 1 +# stdlib_h.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,9 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_STDLIB_H], [ AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) - gl_ABSOLUTE_HEADER([stdlib.h]) - ABSOLUTE_STDLIB_H=\"$gl_cv_absolute_stdlib_h\" - AC_SUBST([ABSOLUTE_STDLIB_H]) + gl_CHECK_NEXT_HEADERS([stdlib.h]) ]) AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4 index ab5d7869..ec51e9a0 100644 --- a/gl/m4/string_h.m4 +++ b/gl/m4/string_h.m4 @@ -18,9 +18,7 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY], [ AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - gl_ABSOLUTE_HEADER([string.h]) - ABSOLUTE_STRING_H=\"$gl_cv_absolute_string_h\" - AC_SUBST([ABSOLUTE_STRING_H]) + gl_CHECK_NEXT_HEADERS([string.h]) ]) AC_DEFUN([gl_STRING_MODULE_INDICATOR], diff --git a/gl/m4/sys_select_h.m4 b/gl/m4/sys_select_h.m4 index 7fe67dff..1d48bcc9 100644 --- a/gl/m4/sys_select_h.m4 +++ b/gl/m4/sys_select_h.m4 @@ -1,4 +1,4 @@ -# sys_select_h.m4 serial 2 +# sys_select_h.m4 serial 3 dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -17,10 +17,7 @@ AC_DEFUN([gl_HEADER_SYS_SELECT], SYS_SELECT_H='' else SYS_SELECT_H='sys/select.h' - AC_CHECK_HEADERS([sys/select.h]) - gl_ABSOLUTE_HEADER([sys/select.h]) - ABSOLUTE_SYS_SELECT_H=\"$gl_cv_absolute_sys_select_h\" - AC_SUBST([ABSOLUTE_SYS_SELECT_H]) + gl_CHECK_NEXT_HEADERS([sys/select.h]) if test $ac_cv_header_sys_select_h = yes; then HAVE_SYS_SELECT_H=1 else diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4 index ce5acf6e..d9659c2d 100644 --- a/gl/m4/sys_socket_h.m4 +++ b/gl/m4/sys_socket_h.m4 @@ -1,4 +1,4 @@ -# sys_socket_h.m4 serial 3 +# sys_socket_h.m4 serial 4 dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -20,10 +20,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], else SYS_SOCKET_H='sys/socket.h' - AC_CHECK_HEADERS([sys/socket.h]) - gl_ABSOLUTE_HEADER([sys/socket.h]) - ABSOLUTE_SYS_SOCKET_H=\"$gl_cv_absolute_sys_socket_h\" - AC_SUBST([ABSOLUTE_SYS_SOCKET_H]) + gl_CHECK_NEXT_HEADERS([sys/socket.h]) if test $ac_cv_header_sys_socket_h = yes; then HAVE_SYS_SOCKET_H=1 HAVE_WINSOCK2_H=0 diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4 index 22831385..1bc08a17 100644 --- a/gl/m4/sys_stat_h.m4 +++ b/gl/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 5 -*- Autoconf -*- +# sys_stat_h.m4 serial 6 -*- Autoconf -*- dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -42,9 +42,7 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H], dnl Check for broken stat macros. AC_REQUIRE([AC_HEADER_STAT]) - gl_ABSOLUTE_HEADER([sys/stat.h]) - ABSOLUTE_SYS_STAT_H=\"$gl_cv_absolute_sys_stat_h\" - AC_SUBST([ABSOLUTE_SYS_STAT_H]) + gl_CHECK_NEXT_HEADERS([sys/stat.h]) SYS_STAT_H='sys/stat.h' AC_SUBST([SYS_STAT_H]) ]) # gl_HEADER_SYS_STAT_H diff --git a/gl/m4/sys_time_h.m4 b/gl/m4/sys_time_h.m4 index b38e1bc5..13ac5763 100644 --- a/gl/m4/sys_time_h.m4 +++ b/gl/m4/sys_time_h.m4 @@ -18,17 +18,13 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H], AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], [ AC_REQUIRE([AC_C_RESTRICT]) - AC_CHECK_HEADERS_ONCE([sys/time.h]) + gl_CHECK_NEXT_HEADERS([sys/time.h]) if test $ac_cv_header_sys_time_h = yes; then - gl_ABSOLUTE_HEADER([sys/time.h]) - ABSOLUTE_SYS_TIME_H=\"$gl_cv_absolute_sys_time_h\" HAVE_SYS_TIME_H=1 else - ABSOLUTE_SYS_TIME_H=\"no/such/file/sys/time.h\" HAVE_SYS_TIME_H=0 fi - AC_SUBST([ABSOLUTE_SYS_TIME_H]) AC_SUBST([HAVE_SYS_TIME_H]) AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4 index e90ed7ac..3f543a15 100644 --- a/gl/m4/time_h.m4 +++ b/gl/m4/time_h.m4 @@ -20,9 +20,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY], [ AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) - gl_ABSOLUTE_HEADER([time.h]) - ABSOLUTE_TIME_H=\"$gl_cv_absolute_time_h\" - AC_SUBST([ABSOLUTE_TIME_H]) + gl_CHECK_NEXT_HEADERS([time.h]) AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) ]) diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index 60dd7308..b12f84e8 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 7 +# unistd_h.m4 serial 9 dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,16 +12,15 @@ AC_DEFUN([gl_UNISTD_H], dnl once only, before all statements that occur in other macros. AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + gl_CHECK_NEXT_HEADERS([unistd.h]) + AC_CHECK_HEADERS_ONCE([unistd.h]) if test $ac_cv_header_unistd_h = yes; then HAVE_UNISTD_H=1 - gl_ABSOLUTE_HEADER([unistd.h]) - ABSOLUTE_UNISTD_H=\"$gl_cv_absolute_unistd_h\" else HAVE_UNISTD_H=0 fi AC_SUBST([HAVE_UNISTD_H]) - AC_SUBST([ABSOLUTE_UNISTD_H]) ]) AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], @@ -39,6 +38,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) + GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) @@ -51,5 +51,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) + REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) ]) diff --git a/gl/m4/wchar.m4 b/gl/m4/wchar.m4 index 30377ca1..bf32d283 100644 --- a/gl/m4/wchar.m4 +++ b/gl/m4/wchar.m4 @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Eric Blake. -# wchar.m4 serial 2 +# wchar.m4 serial 3 AC_DEFUN([gl_WCHAR_H], [ @@ -29,10 +29,8 @@ wchar_t w;]], HAVE_WCHAR_H=0 fi AC_SUBST([HAVE_WCHAR_H]) - gl_ABSOLUTE_HEADER([wchar.h]) - ABSOLUTE_WCHAR_H=\"$gl_cv_absolute_wchar_h\" + gl_CHECK_NEXT_HEADERS([wchar.h]) WCHAR_H=wchar.h fi - AC_SUBST([ABSOLUTE_WCHAR_H]) AC_SUBST([WCHAR_H]) ]) diff --git a/gl/netinet_in_.h b/gl/netinet_in_.h index 2585d33e..aa00e45c 100644 --- a/gl/netinet_in_.h +++ b/gl/netinet_in_.h @@ -24,11 +24,7 @@ # include /* The include_next requires a split double-inclusion guard. */ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_NETINET_IN_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_NETINET_IN_H@ #endif diff --git a/gl/printf-args.c b/gl/printf-args.c index 00b8c63b..49789146 100644 --- a/gl/printf-args.c +++ b/gl/printf-args.c @@ -150,7 +150,7 @@ PRINTF_FETCHARGS (va_list args, arguments *a) if (ap->a.a_u8_string == NULL) { static const uint8_t u8_null_string[] = - { '(', 'N', 'U', 'L', 'L', 0 }; + { '(', 'N', 'U', 'L', 'L', ')', 0 }; ap->a.a_u8_string = u8_null_string; } break; @@ -162,7 +162,7 @@ PRINTF_FETCHARGS (va_list args, arguments *a) if (ap->a.a_u16_string == NULL) { static const uint16_t u16_null_string[] = - { '(', 'N', 'U', 'L', 'L', 0 }; + { '(', 'N', 'U', 'L', 'L', ')', 0 }; ap->a.a_u16_string = u16_null_string; } break; @@ -174,7 +174,7 @@ PRINTF_FETCHARGS (va_list args, arguments *a) if (ap->a.a_u32_string == NULL) { static const uint32_t u32_null_string[] = - { '(', 'N', 'U', 'L', 'L', 0 }; + { '(', 'N', 'U', 'L', 'L', ')', 0 }; ap->a.a_u32_string = u32_null_string; } break; diff --git a/gl/printf-parse.h b/gl/printf-parse.h index 229693d2..de7fc49b 100644 --- a/gl/printf-parse.h +++ b/gl/printf-parse.h @@ -51,7 +51,7 @@ typedef struct const char* precision_start; const char* precision_end; size_t precision_arg_index; - char conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } char_directive; @@ -80,7 +80,7 @@ typedef struct const uint8_t* precision_start; const uint8_t* precision_end; size_t precision_arg_index; - uint8_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u8_directive; @@ -107,7 +107,7 @@ typedef struct const uint16_t* precision_start; const uint16_t* precision_end; size_t precision_arg_index; - uint16_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u16_directive; @@ -134,7 +134,7 @@ typedef struct const uint32_t* precision_start; const uint32_t* precision_end; size_t precision_arg_index; - uint32_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ + uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ size_t arg_index; } u32_directive; diff --git a/gl/stdint_.h b/gl/stdint_.h index d374535c..3299ac17 100644 --- a/gl/stdint_.h +++ b/gl/stdint_.h @@ -43,14 +43,10 @@ in would reinclude us, skipping our contents because _GL_STDINT_H is defined. The include_next requires a split double-inclusion guard. */ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_STDINT_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_STDINT_H@ #endif -#ifndef _GL_STDINT_H +#if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H #define _GL_STDINT_H /* defines some of the stdint.h types as well, on glibc, @@ -58,7 +54,7 @@ AIX 5.2 isn't needed and causes troubles. MacOS X 10.4.6 includes (which is us), but relies on the system definitions, so include - after @ABSOLUTE_STDINT_H@. */ + after @NEXT_STDINT_H@. */ #if @HAVE_SYS_TYPES_H@ && ! defined _AIX # include #endif @@ -509,4 +505,4 @@ #endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ #endif /* _GL_STDINT_H */ -#endif /* _GL_STDINT_H */ +#endif /* !defined _GL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ diff --git a/gl/stdio_.h b/gl/stdio_.h index 7afaedee..7d77c5e5 100644 --- a/gl/stdio_.h +++ b/gl/stdio_.h @@ -19,11 +19,7 @@ #if defined __need_FILE || defined __need___FILE /* Special invocation convention inside glibc header files. */ -#if @HAVE_INCLUDE_NEXT@ -# include_next -#else -# include @ABSOLUTE_STDIO_H@ -#endif +#@INCLUDE_NEXT@ @NEXT_STDIO_H@ #else /* Normal invocation convention. */ @@ -31,11 +27,7 @@ #ifndef _GL_STDIO_H /* The include_next requires a split double-inclusion guard. */ -#if @HAVE_INCLUDE_NEXT@ -# include_next -#else -# include @ABSOLUTE_STDIO_H@ -#endif +#@INCLUDE_NEXT@ @NEXT_STDIO_H@ #ifndef _GL_STDIO_H #define _GL_STDIO_H diff --git a/gl/stdlib_.h b/gl/stdlib_.h index 130f071a..d1e254ab 100644 --- a/gl/stdlib_.h +++ b/gl/stdlib_.h @@ -19,11 +19,7 @@ #if defined __need_malloc_and_calloc /* Special invocation convention inside glibc header files. */ -#if @HAVE_INCLUDE_NEXT@ -# include_next -#else -# include @ABSOLUTE_STDLIB_H@ -#endif +#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ #else /* Normal invocation convention. */ @@ -31,11 +27,7 @@ #ifndef _GL_STDLIB_H /* The include_next requires a split double-inclusion guard. */ -#if @HAVE_INCLUDE_NEXT@ -# include_next -#else -# include @ABSOLUTE_STDLIB_H@ -#endif +#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ #ifndef _GL_STDLIB_H #define _GL_STDLIB_H diff --git a/gl/string_.h b/gl/string_.h index 4dbe66cc..bfb22b0e 100644 --- a/gl/string_.h +++ b/gl/string_.h @@ -19,11 +19,7 @@ #ifndef _GL_STRING_H /* The include_next requires a split double-inclusion guard. */ -#if @HAVE_INCLUDE_NEXT@ -# include_next -#else -# include @ABSOLUTE_STRING_H@ -#endif +#@INCLUDE_NEXT@ @NEXT_STRING_H@ #ifndef _GL_STRING_H #define _GL_STRING_H diff --git a/gl/sys_select_.h b/gl/sys_select_.h index 0d575da9..05672026 100644 --- a/gl/sys_select_.h +++ b/gl/sys_select_.h @@ -24,11 +24,7 @@ # include /* The include_next requires a split double-inclusion guard. */ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_SYS_SELECT_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ #endif diff --git a/gl/sys_socket_.h b/gl/sys_socket_.h index c7eb6490..c25b6ab8 100644 --- a/gl/sys_socket_.h +++ b/gl/sys_socket_.h @@ -30,11 +30,7 @@ # include /* The include_next requires a split double-inclusion guard. */ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_SYS_SOCKET_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ #endif diff --git a/gl/sys_stat_.h b/gl/sys_stat_.h index 13333d33..2e411cd3 100644 --- a/gl/sys_stat_.h +++ b/gl/sys_stat_.h @@ -24,11 +24,7 @@ #ifndef _GL_SYS_STAT_H /* The include_next requires a split double-inclusion guard. */ -#if @HAVE_INCLUDE_NEXT@ -# include_next -#else -# include @ABSOLUTE_SYS_STAT_H@ -#endif +#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ #ifndef _GL_SYS_STAT_H #define _GL_SYS_STAT_H diff --git a/gl/sys_time_.h b/gl/sys_time_.h index 253316f7..08fac3c7 100644 --- a/gl/sys_time_.h +++ b/gl/sys_time_.h @@ -22,11 +22,7 @@ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_SYS_TIME_H@ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_SYS_TIME_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ #else # include #endif diff --git a/gl/time_.h b/gl/time_.h index 9a0507e6..4d5cab8d 100644 --- a/gl/time_.h +++ b/gl/time_.h @@ -18,108 +18,97 @@ /* Don't get in the way of glibc when it includes time.h merely to declare a few standard symbols, rather than to declare all the - symbols. */ -#if defined __need_time_t || defined __need_clock_t || defined __need_timespec + symbols. Also, Solaris 8 eventually includes itself + recursively; if that is happening, just include the system + without adding our own declarations. */ +#if (defined __need_time_t || defined __need_clock_t \ + || defined __need_timespec \ + || defined _GL_TIME_H) -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_TIME_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_TIME_H@ #else -/* Normal invocation convention. */ - -# if ! defined _GL_TIME_H -/* The include_next requires a split double-inclusion guard. */ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_TIME_H@ -# endif +# define _GL_TIME_H -# if ! defined _GL_TIME_H -# define _GL_TIME_H +# @INCLUDE_NEXT@ @NEXT_TIME_H@ -# ifdef __cplusplus +# ifdef __cplusplus extern "C" { -# endif +# endif /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). Or they define it with the wrong member names or define it in (e.g., FreeBSD circa 1997). */ -# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ -# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ -# include -# else -# undef timespec -# define timespec rpl_timespec +# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ +# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ +# include +# else +# undef timespec +# define timespec rpl_timespec struct timespec { time_t tv_sec; long int tv_nsec; }; -# endif -# endif +# endif +# endif /* Sleep for at least RQTP seconds unless interrupted, If interrupted, return -1 and store the remaining time into RMTP. See . */ -# if @REPLACE_NANOSLEEP@ -# define nanosleep rpl_nanosleep +# if @REPLACE_NANOSLEEP@ +# define nanosleep rpl_nanosleep int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp); -# endif +# endif /* Convert TIMER to RESULT, assuming local time and UTC respectively. See and . */ -# if @REPLACE_LOCALTIME_R@ -# undef localtime_r -# define localtime_r rpl_localtime_r -# undef gmtime_r -# define gmtime_r rpl_gmtime_r +# if @REPLACE_LOCALTIME_R@ +# undef localtime_r +# define localtime_r rpl_localtime_r +# undef gmtime_r +# define gmtime_r rpl_gmtime_r struct tm *localtime_r (time_t const *restrict __timer, struct tm *restrict __result); struct tm *gmtime_r (time_t const *restrict __timer, struct tm *restrict __result); -# endif +# endif /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store the resulting broken-down time into TM. See . */ -# if @REPLACE_STRPTIME@ -# undef strptime -# define strptime rpl_strptime +# if @REPLACE_STRPTIME@ +# undef strptime +# define strptime rpl_strptime char *strptime (char const *restrict __buf, char const *restrict __format, struct tm *restrict __tm); -# endif +# endif /* Convert TM to a time_t value, assuming UTC. */ -# if @REPLACE_TIMEGM@ -# undef timegm -# define timegm rpl_timegm +# if @REPLACE_TIMEGM@ +# undef timegm +# define timegm rpl_timegm time_t timegm (struct tm *__tm); -# endif +# endif /* Encourage applications to avoid unsafe functions that can overrun buffers when given outlandish struct tm values. Portable applications should use strftime (or even sprintf) instead. */ -# if GNULIB_PORTCHECK -# undef asctime -# define asctime eschew_asctime -# undef asctime_r -# define asctime_r eschew_asctime_r -# undef ctime -# define ctime eschew_ctime -# undef ctime_r -# define ctime_r eschew_ctime_r -# endif - -# ifdef __cplusplus +# if GNULIB_PORTCHECK +# undef asctime +# define asctime eschew_asctime +# undef asctime_r +# define asctime_r eschew_asctime_r +# undef ctime +# define ctime eschew_ctime +# undef ctime_r +# define ctime_r eschew_ctime_r +# endif + +# ifdef __cplusplus } -# endif +# endif -# endif /* _GL_TIME_H */ -# endif /* _GL_TIME_H */ #endif diff --git a/gl/unistd_.h b/gl/unistd_.h index f34bc66c..07c48778 100644 --- a/gl/unistd_.h +++ b/gl/unistd_.h @@ -19,11 +19,7 @@ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_UNISTD_H@ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_UNISTD_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ #endif #ifndef _GL_UNISTD_H @@ -49,13 +45,18 @@ extern "C" { #if @GNULIB_CHOWN@ # if @REPLACE_CHOWN@ +# ifndef REPLACE_CHOWN +# define REPLACE_CHOWN 1 +# endif +# if REPLACE_CHOWN /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE - to GID (if GID is not -1). + to GID (if GID is not -1). Follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2001 specification . */ -# define chown rpl_chown +# define chown rpl_chown extern int chown (const char *file, uid_t uid, gid_t gid); +# endif # endif #elif defined GNULIB_POSIXCHECK # undef chown @@ -179,6 +180,25 @@ extern int getlogin_r (char *name, size_t size); #endif +#if @GNULIB_LCHOWN@ +# if @REPLACE_LCHOWN@ +/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE + to GID (if GID is not -1). Do not follow symbolic links. + Return 0 if successful, otherwise -1 and errno set. + See the POSIX:2001 specification + . */ +# define lchown rpl_lchown +extern int lchown (char const *file, uid_t owner, gid_t group); +# endif +#elif defined GNULIB_POSIXCHECK +# undef lchown +# define lchown(f,u,g) \ + (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \ + "systems - use gnulib module lchown for portability"), \ + lchown (f, u, g)) +#endif + + #if @GNULIB_LSEEK@ # if @REPLACE_LSEEK@ /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. diff --git a/gl/verify.h b/gl/verify.h new file mode 100644 index 00000000..d603b173 --- /dev/null +++ b/gl/verify.h @@ -0,0 +1,141 @@ +/* Compile-time assert-like macros. + + Copyright (C) 2005, 2006 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 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ + +#ifndef VERIFY_H +# define VERIFY_H 1 + +/* Each of these macros verifies that its argument R is nonzero. To + be portable, R should be an integer constant expression. Unlike + assert (R), there is no run-time overhead. + + There are two macros, since no single macro can be used in all + contexts in C. verify_true (R) is for scalar contexts, including + integer constant expression contexts. verify (R) is for declaration + contexts, e.g., the top level. + + Symbols ending in "__" are private to this header. + + The code below uses several ideas. + + * The first step is ((R) ? 1 : -1). Given an expression R, of + integral or boolean or floating-point type, this yields an + expression of integral type, whose value is later verified to be + constant and nonnegative. + + * Next this expression W is wrapped in a type + struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }. + If W is negative, this yields a compile-time error. No compiler can + deal with a bit-field of negative size. + + One might think that an array size check would have the same + effect, that is, that the type struct { unsigned int dummy[W]; } + would work as well. However, inside a function, some compilers + (such as C++ compilers and GNU C) allow local parameters and + variables inside array size expressions. With these compilers, + an array size check would not properly diagnose this misuse of + the verify macro: + + void function (int n) { verify (n < 0); } + + * For the verify macro, the struct verify_type__ will need to + somehow be embedded into a declaration. To be portable, this + declaration must declare an object, a constant, a function, or a + typedef name. If the declared entity uses the type directly, + such as in + + struct dummy {...}; + typedef struct {...} dummy; + extern struct {...} *dummy; + extern void dummy (struct {...} *); + extern struct {...} *dummy (void); + + two uses of the verify macro would yield colliding declarations + if the entity names are not disambiguated. A workaround is to + attach the current line number to the entity name: + + #define GL_CONCAT0(x, y) x##y + #define GL_CONCAT(x, y) GL_CONCAT0 (x, y) + extern struct {...} * GL_CONCAT(dummy,__LINE__); + + But this has the problem that two invocations of verify from + within the same macro would collide, since the __LINE__ value + would be the same for both invocations. + + A solution is to use the sizeof operator. It yields a number, + getting rid of the identity of the type. Declarations like + + extern int dummy [sizeof (struct {...})]; + extern void dummy (int [sizeof (struct {...})]); + extern int (*dummy (void)) [sizeof (struct {...})]; + + can be repeated. + + * Should the implementation use a named struct or an unnamed struct? + Which of the following alternatives can be used? + + extern int dummy [sizeof (struct {...})]; + extern int dummy [sizeof (struct verify_type__ {...})]; + extern void dummy (int [sizeof (struct {...})]); + extern void dummy (int [sizeof (struct verify_type__ {...})]); + extern int (*dummy (void)) [sizeof (struct {...})]; + extern int (*dummy (void)) [sizeof (struct verify_type__ {...})]; + + In the second and sixth case, the struct type is exported to the + outer scope; two such declarations therefore collide. GCC warns + about the first, third, and fourth cases. So the only remaining + possibility is the fifth case: + + extern int (*dummy (void)) [sizeof (struct {...})]; + + * This implementation exploits the fact that GCC does not warn about + the last declaration mentioned above. If a future version of GCC + introduces a warning for this, the problem could be worked around + by using code specialized to GCC, e.g.,: + + #if 4 <= __GNUC__ + # define verify(R) \ + extern int (* verify_function__ (void)) \ + [__builtin_constant_p (R) && (R) ? 1 : -1] + #endif + + * In C++, any struct definition inside sizeof is invalid. + Use a template type to work around the problem. */ + + +/* Verify requirement R at compile-time, as an integer constant expression. + Return 1. */ + +# ifdef __cplusplus +template + struct verify_type__ { unsigned int verify_error_if_negative_size__: w; }; +# define verify_true(R) \ + (!!sizeof (verify_type__<(R) ? 1 : -1>)) +# else +# define verify_true(R) \ + (!!sizeof \ + (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; })) +# endif + +/* Verify requirement R at compile-time, as a declaration without a + trailing ';'. */ + +# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)] + +#endif diff --git a/gl/wchar_.h b/gl/wchar_.h index 6e04ccca..1d52b1dd 100644 --- a/gl/wchar_.h +++ b/gl/wchar_.h @@ -39,11 +39,7 @@ Some builds of uClibc lack it. */ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_WCHAR_H@ -# if @HAVE_INCLUDE_NEXT@ -# include_next -# else -# include @ABSOLUTE_WCHAR_H@ -# endif +# @INCLUDE_NEXT@ @NEXT_WCHAR_H@ #endif #ifndef _GL_WCHAR_H diff --git a/gl/xreadlink.h b/gl/xreadlink.h index 6d93fe6c..417e6e4d 100644 --- a/gl/xreadlink.h +++ b/gl/xreadlink.h @@ -21,14 +21,4 @@ #include -/* Call readlink to get the symbolic link value of FILENAME. - Return a pointer to that NUL-terminated string in malloc'd storage. - If readlink fails, return NULL and set errno. */ extern char *xreadlink (char const *filename); - -/* Call readlink to get the symbolic link value of FILENAME. - SIZE_HINT is a hint as to how long the link is expected to be; - typically it is taken from st_size. It need not be correct. - Return a pointer to that NUL-terminated string in malloc'd storage. - If readlink fails, return NULL and set errno. */ -extern char *xreadlink_with_size (char const *filename, size_t size_hint); -- 2.11.4.GIT