diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-20 23:31:17 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-02-20 23:32:45 -0800 |
commit | 066b17df681fabb40108d719086669957aebbc51 (patch) | |
tree | 27f9362ed6a6e68ef6b61925932f84bb1afb37b8 /m4 | |
parent | 43fb42da8bd6851b5b22d2bbb5d2cd8ceede9c09 (diff) |
Merge from gnulib
* doc/misc/texinfo.tex: Update from gnulib.
* lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c:
* lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4:
Update from gnulib, incorporating:
2015-02-20 getdtablesize: port better for Android
2015-02-19 fcntl: Fix cross compiling
2015-02-18 dup2, fcntl: cross-compile better for Android
2015-02-18 getopt: don't crash on memory exhaustion
2015-02-17 tempname: allow compilation with C++ (trivial)
2015-02-17 dup2, fcntl: port to AIX
2015-02-16 getdtablesize, dup2, fcntl: port to Android
2015-02-11 getdtablesize, signal_h: Fix Android build
2015-02-11 maint: various whitespace cleanups in tempname
Diffstat (limited to 'm4')
-rw-r--r-- | m4/dup2.m4 | 76 | ||||
-rw-r--r-- | m4/fcntl.m4 | 52 | ||||
-rw-r--r-- | m4/getdtablesize.m4 | 6 |
3 files changed, 71 insertions, 63 deletions
diff --git a/m4/dup2.m4 b/m4/dup2.m4 index 0354c6ad47..9aa2ea85eb 100644 --- a/m4/dup2.m4 +++ b/m4/dup2.m4 @@ -1,4 +1,4 @@ -#serial 20 +#serial 22 dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,7 +8,6 @@ AC_DEFUN([gl_FUNC_DUP2], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CHECK_FUNCS_ONCE([getdtablesize]) m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [ AC_CHECK_FUNCS_ONCE([dup2]) if test $ac_cv_func_dup2 = no; then @@ -20,38 +19,44 @@ AC_DEFUN([gl_FUNC_DUP2], if test $HAVE_DUP2 = 1; then AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works], [AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[#include <unistd.h> -#include <fcntl.h> -#include <errno.h>]], - [int result = 0; -#ifdef HAVE_GETDTABLESIZE - int bad_fd = getdtablesize (); -#else - int bad_fd = 1000000; -#endif -#ifdef FD_CLOEXEC - if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1) - result |= 1; -#endif - if (dup2 (1, 1) == 0) - result |= 2; -#ifdef FD_CLOEXEC - if (fcntl (1, F_GETFD) != FD_CLOEXEC) - result |= 4; -#endif - close (0); - if (dup2 (0, 0) != -1) - result |= 8; - /* Many gnulib modules require POSIX conformance of EBADF. */ - if (dup2 (2, bad_fd) == -1 && errno != EBADF) - result |= 16; - /* Flush out some cygwin core dumps. */ - if (dup2 (2, -1) != -1 || errno != EBADF) - result |= 32; - dup2 (2, 255); - dup2 (2, 256); - return result; - ]) + AC_LANG_PROGRAM( + [[#include <errno.h> + #include <fcntl.h> + #include <limits.h> + #include <sys/resource.h> + #include <unistd.h> + ]], + [[int result = 0; + int bad_fd = INT_MAX; + struct rlimit rlim; + if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 + && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX + && rlim.rlim_cur != RLIM_INFINITY + && rlim.rlim_cur != RLIM_SAVED_MAX + && rlim.rlim_cur != RLIM_SAVED_CUR) + bad_fd = rlim.rlim_cur; + #ifdef FD_CLOEXEC + if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1) + result |= 1; + #endif + if (dup2 (1, 1) == 0) + result |= 2; + #ifdef FD_CLOEXEC + if (fcntl (1, F_GETFD) != FD_CLOEXEC) + result |= 4; + #endif + close (0); + if (dup2 (0, 0) != -1) + result |= 8; + /* Many gnulib modules require POSIX conformance of EBADF. */ + if (dup2 (2, bad_fd) == -1 && errno != EBADF) + result |= 16; + /* Flush out some cygwin core dumps. */ + if (dup2 (2, -1) != -1 || errno != EBADF) + result |= 32; + dup2 (2, 255); + dup2 (2, 256); + return result;]]) ], [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no], [case "$host_os" in @@ -59,9 +64,6 @@ AC_DEFUN([gl_FUNC_DUP2], gl_cv_func_dup2_works="guessing no" ;; cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 gl_cv_func_dup2_works="guessing no" ;; - linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a - # closed fd may yield -EBADF instead of -1 / errno=EBADF. - gl_cv_func_dup2_works="guessing no" ;; aix* | freebsd*) # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE, # not EBADF. diff --git a/m4/fcntl.m4 b/m4/fcntl.m4 index 733cd2d701..218e78628b 100644 --- a/m4/fcntl.m4 +++ b/m4/fcntl.m4 @@ -1,4 +1,4 @@ -# fcntl.m4 serial 5 +# fcntl.m4 serial 7 dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_FCNTL], AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CHECK_FUNCS_ONCE([fcntl getdtablesize]) + AC_CHECK_FUNCS_ONCE([fcntl]) if test $ac_cv_func_fcntl = no; then gl_REPLACE_FCNTL else @@ -27,30 +27,34 @@ AC_DEFUN([gl_FUNC_FCNTL], dnl haiku alpha 2 F_DUPFD has wrong errno AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly], [gl_cv_func_fcntl_f_dupfd_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_GETDTABLESIZE -# include <unistd.h> -#endif -#include <fcntl.h> -#include <errno.h> -]], [[int result = 0; -#ifdef HAVE_GETDTABLESIZE - int bad_fd = getdtablesize (); -#else - int bad_fd = 1000000; -#endif - if (fcntl (0, F_DUPFD, -1) != -1) result |= 1; - if (errno != EINVAL) result |= 2; - if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4; - if (errno != EINVAL) result |= 8; - return result; - ]])], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include <errno.h> + #include <fcntl.h> + #include <limits.h> + #include <sys/resource.h> + #include <unistd.h> + ]], + [[int result = 0; + int bad_fd = INT_MAX; + struct rlimit rlim; + if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 + && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX + && rlim.rlim_cur != RLIM_INFINITY + && rlim.rlim_cur != RLIM_SAVED_MAX + && rlim.rlim_cur != RLIM_SAVED_CUR) + bad_fd = rlim.rlim_cur; + if (fcntl (0, F_DUPFD, -1) != -1) result |= 1; + if (errno != EINVAL) result |= 2; + if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4; + if (errno != EINVAL) result |= 8; + return result;]])], [gl_cv_func_fcntl_f_dupfd_works=yes], [gl_cv_func_fcntl_f_dupfd_works=no], - [# Guess that it works on glibc systems - case $host_os in #(( - *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";; - *) gl_cv_func_fcntl_f_dupfd_works="guessing no";; + [case $host_os in + aix* | cygwin* | haiku*) + gl_cv_func_fcntl_f_dupfd_works="guessing no" ;; + *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;; esac])]) case $gl_cv_func_fcntl_f_dupfd_works in *yes) ;; diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4 index a6b6c1b6c5..25e9968947 100644 --- a/m4/getdtablesize.m4 +++ b/m4/getdtablesize.m4 @@ -1,4 +1,4 @@ -# getdtablesize.m4 serial 5 +# getdtablesize.m4 serial 6 dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,9 @@ AC_DEFUN([gl_FUNC_GETDTABLESIZE], AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_CHECK_FUNCS_ONCE([getdtablesize]) - if test $ac_cv_func_getdtablesize = yes; then + AC_CHECK_DECLS_ONCE([getdtablesize]) + if test $ac_cv_func_getdtablesize = yes && + test $ac_cv_have_decl_getdtablesize = yes; then # Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit # up to an unchangeable hard limit; all other platforms correctly # require setrlimit before getdtablesize() can report a larger value. |