Commit bb1dfdad authored by Paul Eggert's avatar Paul Eggert

Merge from gnulib.

parent 88d69b7d
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
......
......@@ -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' \
......
......@@ -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
......@@ -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
......
# 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
])
# 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
......
......@@ -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])
......
# 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])
......
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.
......
......@@ -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/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment