summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-10-03 00:06:52 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-10-03 00:06:52 -0700
commit0a858ebfc57a072ae8ab65f509d8a4901a2ec073 (patch)
treedd81bcdf11f3d3efa32ffe00f7cdc90d3c1144d9
parentb52f569dcfc5c2e1b764c89d27ea8699a44228e6 (diff)
downloademacs-0a858ebfc57a072ae8ab65f509d8a4901a2ec073.tar.gz
Merge from gnulib.
* src/conf_post.h (__has_builtin, assume): Remove; gnulib now does these. * src/lisp.h: Include <verify.h>, for 'assume'. This also incorpoprates: 2013-10-02 verify: new macro 'assume' 2013-09-26 dup2, dup3: work around another cygwin crasher 2013-09-26 getdtablesize: work around cygwin issue
-rw-r--r--ChangeLog7
-rw-r--r--lib/dup2.c4
-rw-r--r--lib/getdtablesize.c33
-rw-r--r--lib/gnulib.mk1
-rw-r--r--lib/unistd.in.h13
-rw-r--r--lib/verify.h24
-rw-r--r--m4/dup2.m47
-rw-r--r--m4/getdtablesize.m431
-rw-r--r--m4/gnulib-comp.m42
-rw-r--r--m4/unistd_h.m43
-rw-r--r--src/ChangeLog4
-rw-r--r--src/conf_post.h17
-rw-r--r--src/lisp.h5
13 files changed, 118 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index f8a219d6a15..44e83d25737 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-10-03 Paul Eggert <eggert@cs.ucla.edu>
+
+ Merge from gnulib, incorporating:
+ 2013-10-02 verify: new macro 'assume'
+ 2013-09-26 dup2, dup3: work around another cygwin crasher
+ 2013-09-26 getdtablesize: work around cygwin issue
+
2013-09-25 Paul Eggert <eggert@cs.ucla.edu>
Merge from gnulib, incorporating:
diff --git a/lib/dup2.c b/lib/dup2.c
index 9219eb38238..f128e7a63cd 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -96,7 +96,11 @@ rpl_dup2 (int fd, int desired_fd)
/* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
On Cygwin 1.5.x, dup2 (1, 1) returns 0.
On Cygwin 1.7.17, dup2 (1, -1) dumps core.
+ On Cygwin 1.7.25, dup2 (1, 256) can dump core.
On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */
+# if HAVE_SETDTABLESIZE
+ setdtablesize (desired_fd + 1);
+# endif
if (desired_fd < 0)
fd = desired_fd;
if (fd == desired_fd)
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index 9947405af61..355c17e3b9e 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -22,11 +22,11 @@
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-#include <stdio.h>
+# include <stdio.h>
-#include "msvc-inval.h"
+# include "msvc-inval.h"
-#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
_setmaxstdio_nothrow (int newmax)
{
@@ -44,10 +44,11 @@ _setmaxstdio_nothrow (int newmax)
return result;
}
-# define _setmaxstdio _setmaxstdio_nothrow
-#endif
+# define _setmaxstdio _setmaxstdio_nothrow
+# endif
-/* Cache for the previous getdtablesize () result. */
+/* Cache for the previous getdtablesize () result. Safe to cache because
+ Windows also lacks setrlimit. */
static int dtablesize;
int
@@ -83,4 +84,24 @@ getdtablesize (void)
return dtablesize;
}
+#elif HAVE_GETDTABLESIZE
+
+# include <sys/resource.h>
+# undef getdtablesize
+
+int
+rpl_getdtablesize(void)
+{
+ /* To date, this replacement is only compiled for Cygwin 1.7.25,
+ which auto-increased the RLIMIT_NOFILE soft limit until it
+ hits the compile-time constant hard limit of 3200. Although
+ that version of cygwin supported a child process inheriting
+ a smaller soft limit, the smaller limit is not enforced, so
+ we might as well just report the hard limit. */
+ struct rlimit lim;
+ if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_max != RLIM_INFINITY)
+ return lim.rlim_max;
+ return getdtablesize ();
+}
+
#endif
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 32255181fb4..14d45e798e5 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -1707,6 +1707,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
+ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
-e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
-e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 874c628a63b..0e510d679c6 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -654,10 +654,19 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
#if @GNULIB_GETDTABLESIZE@
/* Return the maximum number of file descriptors in the current process.
In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
-# if !@HAVE_GETDTABLESIZE@
+# if @REPLACE_GETDTABLESIZE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getdtablesize
+# define getdtablesize rpl_getdtablesize
+# endif
+_GL_FUNCDECL_RPL (getdtablesize, int, (void));
+_GL_CXXALIAS_RPL (getdtablesize, int, (void));
+# else
+# if !@HAVE_GETDTABLESIZE@
_GL_FUNCDECL_SYS (getdtablesize, int, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (getdtablesize, int, (void));
+# endif
_GL_CXXALIASWARN (getdtablesize);
#elif defined GNULIB_POSIXCHECK
# undef getdtablesize
diff --git a/lib/verify.h b/lib/verify.h
index d42d0750ee1..bf40b028c92 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -250,6 +250,30 @@ template <int w>
#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+/* Assume that R always holds. This lets the compiler optimize
+ accordingly. R should not have side-effects; it may or may not be
+ evaluated. Behavior is undefined if R is false. */
+
+#if (__has_builtin (__builtin_unreachable) \
+ || 4 < __GNUC__ + (5 <= __GNUC_MINOR__))
+# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
+#elif 1200 <= _MSC_VER
+# define assume(R) __assume (R)
+#elif (defined lint \
+ && (__has_builtin (__builtin_trap) \
+ || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))))
+ /* Doing it this way helps various packages when configured with
+ --enable-gcc-warnings, which compiles with -Dlint. It's nicer
+ when 'assume' silences warnings even with older GCCs. */
+# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
+#else
+# define assume(R) ((void) (0 && (R)))
+#endif
+
/* @assert.h omit end@ */
#endif
diff --git a/m4/dup2.m4 b/m4/dup2.m4
index 269cfdc1123..dc3070c0d9a 100644
--- a/m4/dup2.m4
+++ b/m4/dup2.m4
@@ -1,4 +1,4 @@
-#serial 19
+#serial 20
dnl Copyright (C) 2002, 2005, 2007, 2009-2013 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -39,9 +39,11 @@ AC_DEFUN([gl_FUNC_DUP2],
/* Many gnulib modules require POSIX conformance of EBADF. */
if (dup2 (2, 1000000) == -1 && errno != EBADF)
result |= 16;
- /* Flush out a cygwin core dump. */
+ /* Flush out some cygwin core dumps. */
if (dup2 (2, -1) != -1 || errno != EBADF)
result |= 32;
+ dup2 (2, 255);
+ dup2 (2, 256);
return result;
])
],
@@ -65,6 +67,7 @@ AC_DEFUN([gl_FUNC_DUP2],
*yes) ;;
*)
REPLACE_DUP2=1
+ AC_CHECK_FUNCS([setdtablesize])
;;
esac
fi
diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4
index 8f04b3b8c2a..b3fa1af6a5a 100644
--- a/m4/getdtablesize.m4
+++ b/m4/getdtablesize.m4
@@ -1,4 +1,4 @@
-# getdtablesize.m4 serial 4
+# getdtablesize.m4 serial 5
dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,8 +7,35 @@ dnl with or without modifications, as long as this notice is preserved.
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
+ if test $ac_cv_func_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.
+ AC_CACHE_CHECK([whether getdtablesize works],
+ [gl_cv_func_getdtablesize_works],
+ [AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([[#include <unistd.h>]],
+ [int size = getdtablesize();
+ if (dup2 (0, getdtablesize()) != -1)
+ return 1;
+ if (size != getdtablesize())
+ return 2;
+ ])],
+ [gl_cv_func_getdtablesize_works=yes],
+ [gl_cv_func_getdtablesize_works=no],
+ [case "$host_os" in
+ cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
+ gl_cv_func_getdtablesize_works="guessing no" ;;
+ *) gl_cv_func_getdtablesize_works="guessing yes" ;;
+ esac])
+ ])
+ case "$gl_cv_func_getdtablesize_works" in
+ *yes) ;;
+ *) REPLACE_GETDTABLESIZE=1 ;;
+ esac
+ else
HAVE_GETDTABLESIZE=0
fi
])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 7c5f22861b5..2e5a9cf97d1 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -433,7 +433,7 @@ AC_DEFUN([gl_INIT],
{
if ! $gl_gnulib_enabled_getdtablesize; then
gl_FUNC_GETDTABLESIZE
- if test $HAVE_GETDTABLESIZE = 0; then
+ if test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1; then
AC_LIBOBJ([getdtablesize])
gl_PREREQ_GETDTABLESIZE
fi
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 32dcfa58204..4231578cf24 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 66
+# unistd_h.m4 serial 67
dnl Copyright (C) 2006-2013 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -160,6 +160,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
+ REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
diff --git a/src/ChangeLog b/src/ChangeLog
index 8a0d8863548..8713d493dca 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2013-10-03 Paul Eggert <eggert@cs.ucla.edu>
+ Adjust to merge from gnulib.
+ * conf_post.h (__has_builtin, assume): Remove; gnulib now does these.
+ * lisp.h: Include <verify.h>, for 'assume'.
+
* eval.c (clobbered_eassert): New macro.
(internal_catch, internal_condition_case)
(internal_condition_case_1, internal_condition_case_2)
diff --git a/src/conf_post.h b/src/conf_post.h
index 0786bdfeb33..786105864f2 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -248,23 +248,6 @@ extern void _DebPrint (const char *fmt, ...);
# define FLEXIBLE_ARRAY_MEMBER 1
#endif
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
-/* Tell the compiler (and lint) that COND will always hold, and that
- it should optimize (or check) accordingly. */
-#if (__has_builtin (__builtin_unreachable) \
- || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4)
-# define assume(cond) ((cond) ? (void) 0 : __builtin_unreachable ())
-#elif defined _MSC_VER
-# define assume(cond) __assume (cond)
-#elif defined lint
-# define assume(cond) ((cond) ? (void) 0 : abort ())
-#else
-# define assume(cond) ((void) (0 && (cond)))
-#endif
-
/* Use this to suppress gcc's `...may be used before initialized' warnings. */
#ifdef lint
/* Use CODE only if lint checking is in effect. */
diff --git a/src/lisp.h b/src/lisp.h
index 688c89c1eee..ee83e227db0 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -31,6 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <limits.h>
#include <intprops.h>
+#include <verify.h>
INLINE_HEADER_BEGIN
@@ -1145,9 +1146,9 @@ struct Lisp_Vector
/* ...but sometimes there is also a pointer internally used in
vector allocation code. Usually you don't want to touch this. */
struct Lisp_Vector *next;
-
+
/* We can't use FLEXIBLE_ARRAY_MEMBER here. */
- Lisp_Object contents[1];
+ Lisp_Object contents[1];
} u;
};