summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-10-04 00:15:42 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-10-04 00:15:42 -0700
commitbb1dfdadd507bb4b77595c87875ef807c101ed7b (patch)
treeeb92a2335896c34e76a9e19362049396b8d0483f
parent88d69b7ddca305bb96d6e671300f6724e4f147dd (diff)
downloademacs-bb1dfdadd507bb4b77595c87875ef807c101ed7b.tar.gz
Merge from gnulib.
-rw-r--r--ChangeLog9
-rw-r--r--lib/gnulib.mk1
-rw-r--r--lib/pselect.c34
-rw-r--r--lib/stdlib.in.h13
-rw-r--r--m4/manywarnings.m432
-rw-r--r--m4/pselect.m440
-rw-r--r--m4/stdlib_h.m41
-rw-r--r--m4/sys_stat_h.m45
-rw-r--r--msdos/ChangeLog5
-rw-r--r--msdos/sedlibmk.inp1
10 files changed, 130 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 019913e27d3..aa93dc4079b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2012-10-04 Paul Eggert <eggert@cs.ucla.edu>
+ 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 e79fe35622c..23749331a83 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 d8ebc70f6c6..1b6d099dccf 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 <unistd.h>
+# 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 1d67ec64c66..8311a2893c8 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 2760efb3f27..f3cb23be1cd 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 97bf12cd2d6..5edacd28f85 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 <sys/types.h>
+#include <sys/time.h>
+#if HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+#include <unistd.h>
+#include <errno.h>
+]],[[
+ 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 ab43728ace4..9c69f2e4d15 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 8af3353ea51..f45dee1dc4d 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 525868b2c70..d3d9bc657cc 100644
--- a/msdos/ChangeLog
+++ b/msdos/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-04 Paul Eggert <eggert@cs.ucla.edu>
+
+ Merge from gnulib.
+ * msdos/sedlibmk.inp (REPLACE_PTSNAME): Edit to appropriate value.
+
2012-09-27 Paul Eggert <eggert@cs.ucla.edu>
Check more robustly for timer_settime.
diff --git a/msdos/sedlibmk.inp b/msdos/sedlibmk.inp
index 67719cffbd4..9879947ca45 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/