From bb1dfdadd507bb4b77595c87875ef807c101ed7b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 4 Oct 2012 00:15:42 -0700 Subject: [PATCH] Merge from gnulib. --- ChangeLog | 9 +++++++++ lib/gnulib.mk | 1 + lib/pselect.c | 34 ++++++++++++++++++++++++++++++++++ lib/stdlib.in.h | 13 +++++++++++-- m4/manywarnings.m4 | 32 +++++++++++++++++++++++++------- m4/pselect.m4 | 40 +++++++++++++++++++++++++++++++++++++++- m4/stdlib_h.m4 | 1 + m4/sys_stat_h.m4 | 5 ++++- msdos/ChangeLog | 5 +++++ msdos/sedlibmk.inp | 1 + 10 files changed, 130 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 019913e27d..aa93dc4079 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2012-10-04 Paul Eggert + Merge from gnulib, incorporating: + 2012-10-02 pselect: reject invalid file descriptors + 2012-10-02 ptsname: reject invalid file descriptors + 2012-10-02 manywarnings: cater to more gcc infelicities + 2012-09-30 sockets, sys_stat: restore AC_C_INLINE + * lib/pselect.c, lib/stdlib.in.h, m4/manywarnings.m4, m4/pselect.m4: + * m4/stdlib_h.m4, m4/sys_stat_h.m4: Update from gnulib. + * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. + Port timers to OpenBSD, plus check for timer failures. OpenBSD problem reported by Han Boetes. * profiler.c (setup_cpu_timer): Check for failure of timer_settime diff --git a/lib/gnulib.mk b/lib/gnulib.mk index e79fe35622..23749331a8 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk @@ -857,6 +857,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ + -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ diff --git a/lib/pselect.c b/lib/pselect.c index d8ebc70f6c..1b6d099dcc 100644 --- a/lib/pselect.c +++ b/lib/pselect.c @@ -33,6 +33,8 @@ pointer parameter stands for no descriptors, an infinite timeout, or an unaffected signal mask. */ +#if !HAVE_PSELECT + int pselect (int nfds, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict xfds, @@ -74,3 +76,35 @@ pselect (int nfds, fd_set *restrict rfds, return select_result; } + +#else /* HAVE_PSELECT */ +# include +# undef pselect + +int +rpl_pselect (int nfds, fd_set *restrict rfds, + fd_set *restrict wfds, fd_set *restrict xfds, + struct timespec const *restrict timeout, + sigset_t const *restrict sigmask) +{ + int i; + + /* FreeBSD 8.2 has a bug: it does not always detect invalid fds. */ + if (nfds < 0 || nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + for (i = 0; i < nfds; i++) + { + if (((rfds && FD_ISSET (i, rfds)) + || (wfds && FD_ISSET (i, wfds)) + || (xfds && FD_ISSET (i, xfds))) + && dup2 (i, i) != i) + return -1; + } + + return pselect (nfds, rfds, wfds, xfds, timeout, sigmask); +} + +#endif diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 1d67ec64c6..8311a2893c 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -457,10 +457,19 @@ _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " #if @GNULIB_PTSNAME@ /* Return the pathname of the pseudo-terminal slave associated with the master FD is open on, or NULL on errors. */ -# if !@HAVE_PTSNAME@ +# if @REPLACE_PTSNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPCE) +# undef ptsname +# define ptsname rpl_ptsname +# endif +_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); +_GL_CXXALIAS_RPL (ptsname, char *, (int fd)); +# else +# if !@HAVE_PTSNAME@ _GL_FUNCDECL_SYS (ptsname, char *, (int fd)); -# endif +# endif _GL_CXXALIAS_SYS (ptsname, char *, (int fd)); +# endif _GL_CXXALIASWARN (ptsname); #elif defined GNULIB_POSIXCHECK # undef ptsname diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 2760efb3f2..f3cb23be1c 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -1,4 +1,4 @@ -# manywarnings.m4 serial 4 +# manywarnings.m4 serial 5 dnl Copyright (C) 2008-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -35,14 +35,12 @@ AC_DEFUN([gl_MANYWARN_COMPLEMENT], # make sure your gcc understands it. AC_DEFUN([gl_MANYWARN_ALL_GCC], [ - dnl First, check if -Wno-missing-field-initializers is needed. - dnl -Wmissing-field-initializers is implied by -W, but that issues - dnl warnings with GCC version before 4.7, for the common idiom - dnl of initializing types on the stack to zero, using { 0, } + dnl First, check for some issues that only occur when combining multiple + dnl gcc warning categories. AC_REQUIRE([AC_PROG_CC]) if test -n "$GCC"; then - dnl First, check -W -Werror -Wno-missing-field-initializers is supported + dnl Check if -W -Werror -Wno-missing-field-initializers is supported dnl with the current $CC $CFLAGS $CPPFLAGS. AC_MSG_CHECKING([whether -Wno-missing-field-initializers is supported]) AC_CACHE_VAL([gl_cv_cc_nomfi_supported], [ @@ -77,8 +75,24 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], ]) AC_MSG_RESULT([$gl_cv_cc_nomfi_needed]) fi + + dnl Next, check if -Werror -Wuninitialized is useful with the + dnl user's choice of $CFLAGS; some versions of gcc warn that it + dnl has no effect if -O is not also used + AC_MSG_CHECKING([whether -Wuninitialized is supported]) + AC_CACHE_VAL([gl_cv_cc_uninitialized_supported], [ + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror -Wuninitialized" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [gl_cv_cc_uninitialized_supported=yes], + [gl_cv_cc_uninitialized_supported=no]) + CFLAGS="$gl_save_CFLAGS"]) + AC_MSG_RESULT([$gl_cv_cc_uninitialized_supported]) + fi + # List all gcc warning categories. gl_manywarn_set= for gl_manywarn_item in \ -W \ @@ -197,10 +211,14 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item" done - # Disable the missing-field-initializers warning if needed + # Disable specific options as needed. if test "$gl_cv_cc_nomfi_needed" = yes; then gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers" fi + if test "$gl_cv_cc_uninitialized_supported" = no; then + gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized" + fi + $1=$gl_manywarn_set ]) diff --git a/m4/pselect.m4 b/m4/pselect.m4 index 97bf12cd2d..5edacd28f8 100644 --- a/m4/pselect.m4 +++ b/m4/pselect.m4 @@ -1,4 +1,4 @@ -# pselect.m4 +# pselect.m4 serial 2 dnl Copyright (C) 2011-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,6 +23,44 @@ AC_DEFUN([gl_FUNC_PSELECT], return !p;]])], [gl_cv_sig_pselect=yes], [gl_cv_sig_pselect=no])]) + + dnl On FreeBSD 8.2, pselect() doesn't always reject bad fds. + AC_CACHE_CHECK([whether pselect detects invalid fds], + [gl_cv_func_pselect_detects_ebadf], + [ + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#if HAVE_SYS_SELECT_H +# include +#endif +#include +#include +]],[[ + fd_set set; + dup2(0, 16); + FD_ZERO(&set); + FD_SET(16, &set); + close(16); + struct timespec timeout; + timeout.tv_sec = 0; + timeout.tv_nsec = 5000; + return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF; +]])], [gl_cv_func_pselect_detects_ebadf=yes], + [gl_cv_func_pselect_detects_ebadf=no], + [ + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_pselect_detects_ebadf="guessing no" ;; + esac + ]) + ]) + case $gl_cv_func_pselect_detects_ebadf in + *yes) ;; + *) REPLACE_PSELECT=1 ;; + esac fi if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index ab43728ace..9c69f2e4d1 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -102,6 +102,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) + REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index 8af3353ea5..f45dee1dc4 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 28 -*- Autoconf -*- +# sys_stat_h.m4 serial 27 -*- Autoconf -*- dnl Copyright (C) 2006-2012 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,9 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H], [ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + dnl For the mkdir substitute. + AC_REQUIRE([AC_C_INLINE]) + dnl Check for broken stat macros. AC_REQUIRE([AC_HEADER_STAT]) diff --git a/msdos/ChangeLog b/msdos/ChangeLog index 525868b2c7..d3d9bc657c 100644 --- a/msdos/ChangeLog +++ b/msdos/ChangeLog @@ -1,3 +1,8 @@ +2012-10-04 Paul Eggert + + Merge from gnulib. + * msdos/sedlibmk.inp (REPLACE_PTSNAME): Edit to appropriate value. + 2012-09-27 Paul Eggert Check more robustly for timer_settime. diff --git a/msdos/sedlibmk.inp b/msdos/sedlibmk.inp index 67719cffbd..9879947ca4 100644 --- a/msdos/sedlibmk.inp +++ b/msdos/sedlibmk.inp @@ -541,6 +541,7 @@ am__cd = cd /^REPLACE_PRINTF *=/s/@REPLACE_PRINTF@/0/ /^REPLACE_PTHREAD_SIGMASK *=/s/@REPLACE_PTHREAD_SIGMASK@/0/ /^REPLACE_PSELECT *=/s/@REPLACE_PSELECT@/0/ +/^REPLACE_PTSNAME *=/s/@REPLACE_PTSNAME@/0/ /^REPLACE_PTSNAME_R *=/s/@REPLACE_PTSNAME_R@/0/ /^REPLACE_PUTENV *=/s/@REPLACE_PUTENV@/0/ /^REPLACE_PWRITE *=/s/@REPLACE_PWRITE@/0/ -- 2.20.1