]> git.eshelyaron.com Git - emacs.git/commitdiff
Merge from gnulib.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 4 Oct 2012 07:15:42 +0000 (00:15 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 4 Oct 2012 07:15:42 +0000 (00:15 -0700)
ChangeLog
lib/gnulib.mk
lib/pselect.c
lib/stdlib.in.h
m4/manywarnings.m4
m4/pselect.m4
m4/stdlib_h.m4
m4/sys_stat_h.m4
msdos/ChangeLog
msdos/sedlibmk.inp

index 019913e27d382e158a2cc4fbeb5531d96eba2912..aa93dc4079b796e33f01506464c736c823f59d55 100644 (file)
--- 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
index e79fe35622c9040901cb38c2f939737dada6a753..23749331a83035c0652e2336d17761e44f46dc63 100644 (file)
@@ -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' \
index d8ebc70f6c689cb9bff8d6aba2e5b4f746b16abe..1b6d099dccfad7b4e06cfdb0272611c36758e9c0 100644 (file)
@@ -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
index 1d67ec64c663517a86d3992ed6f29cc8d39881bd..8311a2893c8ac086c1db71eafd921c7d9c899676 100644 (file)
@@ -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
index 2760efb3f27863f2ed372b3c9648f8cd5f5bd0fa..f3cb23be1cdd4bfdffbe1fb2da71c2a1725e5729 100644 (file)
@@ -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
 ])
index 97bf12cd2d60aec5291c9958e4f0786479e399da..5edacd28f854ce6cfa178b17dea4743e8b72900c 100644 (file)
@@ -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
index ab43728ace41a4ce331571421396fbbe8ce867cb..9c69f2e4d15f0fcdef3c24f6797f4bcfa6def1ea 100644 (file)
@@ -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])
index 8af3353ea5108608e167f2b74e3feb362d15b8a5..f45dee1dc4dc35c88c5fdc900244d4f8343ddee2 100644 (file)
@@ -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])
 
index 525868b2c70363ecff54fc3207a31319820a4119..d3d9bc657ccbd9565273ca035aa4734ecd5c4000 100644 (file)
@@ -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.
index 67719cffbd4a4c8816e9992caf83ba59ea75af6a..9879947ca4587ebad73aabcdddb2f01242b3d968 100644 (file)
@@ -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/