aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2013-10-03 00:06:52 -0700
committerPaul Eggert2013-10-03 00:06:52 -0700
commit0a858ebfc57a072ae8ab65f509d8a4901a2ec073 (patch)
treedd81bcdf11f3d3efa32ffe00f7cdc90d3c1144d9
parentb52f569dcfc5c2e1b764c89d27ea8699a44228e6 (diff)
downloademacs-0a858ebfc57a072ae8ab65f509d8a4901a2ec073.tar.gz
emacs-0a858ebfc57a072ae8ab65f509d8a4901a2ec073.zip
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 @@
12013-10-03 Paul Eggert <eggert@cs.ucla.edu>
2
3 Merge from gnulib, incorporating:
4 2013-10-02 verify: new macro 'assume'
5 2013-09-26 dup2, dup3: work around another cygwin crasher
6 2013-09-26 getdtablesize: work around cygwin issue
7
12013-09-25 Paul Eggert <eggert@cs.ucla.edu> 82013-09-25 Paul Eggert <eggert@cs.ucla.edu>
2 9
3 Merge from gnulib, incorporating: 10 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)
96 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF. 96 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
97 On Cygwin 1.5.x, dup2 (1, 1) returns 0. 97 On Cygwin 1.5.x, dup2 (1, 1) returns 0.
98 On Cygwin 1.7.17, dup2 (1, -1) dumps core. 98 On Cygwin 1.7.17, dup2 (1, -1) dumps core.
99 On Cygwin 1.7.25, dup2 (1, 256) can dump core.
99 On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */ 100 On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */
101# if HAVE_SETDTABLESIZE
102 setdtablesize (desired_fd + 1);
103# endif
100 if (desired_fd < 0) 104 if (desired_fd < 0)
101 fd = desired_fd; 105 fd = desired_fd;
102 if (fd == desired_fd) 106 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 @@
22 22
23#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 23#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
24 24
25#include <stdio.h> 25# include <stdio.h>
26 26
27#include "msvc-inval.h" 27# include "msvc-inval.h"
28 28
29#if HAVE_MSVC_INVALID_PARAMETER_HANDLER 29# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
30static int 30static int
31_setmaxstdio_nothrow (int newmax) 31_setmaxstdio_nothrow (int newmax)
32{ 32{
@@ -44,10 +44,11 @@ _setmaxstdio_nothrow (int newmax)
44 44
45 return result; 45 return result;
46} 46}
47# define _setmaxstdio _setmaxstdio_nothrow 47# define _setmaxstdio _setmaxstdio_nothrow
48#endif 48# endif
49 49
50/* Cache for the previous getdtablesize () result. */ 50/* Cache for the previous getdtablesize () result. Safe to cache because
51 Windows also lacks setrlimit. */
51static int dtablesize; 52static int dtablesize;
52 53
53int 54int
@@ -83,4 +84,24 @@ getdtablesize (void)
83 return dtablesize; 84 return dtablesize;
84} 85}
85 86
87#elif HAVE_GETDTABLESIZE
88
89# include <sys/resource.h>
90# undef getdtablesize
91
92int
93rpl_getdtablesize(void)
94{
95 /* To date, this replacement is only compiled for Cygwin 1.7.25,
96 which auto-increased the RLIMIT_NOFILE soft limit until it
97 hits the compile-time constant hard limit of 3200. Although
98 that version of cygwin supported a child process inheriting
99 a smaller soft limit, the smaller limit is not enforced, so
100 we might as well just report the hard limit. */
101 struct rlimit lim;
102 if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_max != RLIM_INFINITY)
103 return lim.rlim_max;
104 return getdtablesize ();
105}
106
86#endif 107#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
1707 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ 1707 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
1708 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ 1708 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
1709 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ 1709 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
1710 -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
1710 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ 1711 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
1711 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ 1712 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
1712 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ 1713 -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 - "
654#if @GNULIB_GETDTABLESIZE@ 654#if @GNULIB_GETDTABLESIZE@
655/* Return the maximum number of file descriptors in the current process. 655/* Return the maximum number of file descriptors in the current process.
656 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ 656 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
657# if !@HAVE_GETDTABLESIZE@ 657# if @REPLACE_GETDTABLESIZE@
658# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
659# undef getdtablesize
660# define getdtablesize rpl_getdtablesize
661# endif
662_GL_FUNCDECL_RPL (getdtablesize, int, (void));
663_GL_CXXALIAS_RPL (getdtablesize, int, (void));
664# else
665# if !@HAVE_GETDTABLESIZE@
658_GL_FUNCDECL_SYS (getdtablesize, int, (void)); 666_GL_FUNCDECL_SYS (getdtablesize, int, (void));
659# endif 667# endif
660_GL_CXXALIAS_SYS (getdtablesize, int, (void)); 668_GL_CXXALIAS_SYS (getdtablesize, int, (void));
669# endif
661_GL_CXXALIASWARN (getdtablesize); 670_GL_CXXALIASWARN (getdtablesize);
662#elif defined GNULIB_POSIXCHECK 671#elif defined GNULIB_POSIXCHECK
663# undef getdtablesize 672# 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>
250 250
251#define verify(R) _GL_VERIFY (R, "verify (" #R ")") 251#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
252 252
253#ifndef __has_builtin
254# define __has_builtin(x) 0
255#endif
256
257/* Assume that R always holds. This lets the compiler optimize
258 accordingly. R should not have side-effects; it may or may not be
259 evaluated. Behavior is undefined if R is false. */
260
261#if (__has_builtin (__builtin_unreachable) \
262 || 4 < __GNUC__ + (5 <= __GNUC_MINOR__))
263# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
264#elif 1200 <= _MSC_VER
265# define assume(R) __assume (R)
266#elif (defined lint \
267 && (__has_builtin (__builtin_trap) \
268 || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))))
269 /* Doing it this way helps various packages when configured with
270 --enable-gcc-warnings, which compiles with -Dlint. It's nicer
271 when 'assume' silences warnings even with older GCCs. */
272# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
273#else
274# define assume(R) ((void) (0 && (R)))
275#endif
276
253/* @assert.h omit end@ */ 277/* @assert.h omit end@ */
254 278
255#endif 279#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 @@
1#serial 19 1#serial 20
2dnl Copyright (C) 2002, 2005, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2005, 2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -39,9 +39,11 @@ AC_DEFUN([gl_FUNC_DUP2],
39 /* Many gnulib modules require POSIX conformance of EBADF. */ 39 /* Many gnulib modules require POSIX conformance of EBADF. */
40 if (dup2 (2, 1000000) == -1 && errno != EBADF) 40 if (dup2 (2, 1000000) == -1 && errno != EBADF)
41 result |= 16; 41 result |= 16;
42 /* Flush out a cygwin core dump. */ 42 /* Flush out some cygwin core dumps. */
43 if (dup2 (2, -1) != -1 || errno != EBADF) 43 if (dup2 (2, -1) != -1 || errno != EBADF)
44 result |= 32; 44 result |= 32;
45 dup2 (2, 255);
46 dup2 (2, 256);
45 return result; 47 return result;
46 ]) 48 ])
47 ], 49 ],
@@ -65,6 +67,7 @@ AC_DEFUN([gl_FUNC_DUP2],
65 *yes) ;; 67 *yes) ;;
66 *) 68 *)
67 REPLACE_DUP2=1 69 REPLACE_DUP2=1
70 AC_CHECK_FUNCS([setdtablesize])
68 ;; 71 ;;
69 esac 72 esac
70 fi 73 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 @@
1# getdtablesize.m4 serial 4 1# getdtablesize.m4 serial 5
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl 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.
7AC_DEFUN([gl_FUNC_GETDTABLESIZE], 7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[ 8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_CHECK_FUNCS_ONCE([getdtablesize]) 11 AC_CHECK_FUNCS_ONCE([getdtablesize])
11 if test $ac_cv_func_getdtablesize != yes; then 12 if test $ac_cv_func_getdtablesize = yes; then
13 # Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit
14 # up to an unchangeable hard limit; all other platforms correctly
15 # require setrlimit before getdtablesize() can report a larger value.
16 AC_CACHE_CHECK([whether getdtablesize works],
17 [gl_cv_func_getdtablesize_works],
18 [AC_RUN_IFELSE([
19 AC_LANG_PROGRAM([[#include <unistd.h>]],
20 [int size = getdtablesize();
21 if (dup2 (0, getdtablesize()) != -1)
22 return 1;
23 if (size != getdtablesize())
24 return 2;
25 ])],
26 [gl_cv_func_getdtablesize_works=yes],
27 [gl_cv_func_getdtablesize_works=no],
28 [case "$host_os" in
29 cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
30 gl_cv_func_getdtablesize_works="guessing no" ;;
31 *) gl_cv_func_getdtablesize_works="guessing yes" ;;
32 esac])
33 ])
34 case "$gl_cv_func_getdtablesize_works" in
35 *yes) ;;
36 *) REPLACE_GETDTABLESIZE=1 ;;
37 esac
38 else
12 HAVE_GETDTABLESIZE=0 39 HAVE_GETDTABLESIZE=0
13 fi 40 fi
14]) 41])
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],
433 { 433 {
434 if ! $gl_gnulib_enabled_getdtablesize; then 434 if ! $gl_gnulib_enabled_getdtablesize; then
435 gl_FUNC_GETDTABLESIZE 435 gl_FUNC_GETDTABLESIZE
436 if test $HAVE_GETDTABLESIZE = 0; then 436 if test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1; then
437 AC_LIBOBJ([getdtablesize]) 437 AC_LIBOBJ([getdtablesize])
438 gl_PREREQ_GETDTABLESIZE 438 gl_PREREQ_GETDTABLESIZE
439 fi 439 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 @@
1# unistd_h.m4 serial 66 1# unistd_h.m4 serial 67
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -160,6 +160,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
160 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) 160 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
161 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) 161 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
162 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) 162 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
163 REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
163 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) 164 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
164 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) 165 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
165 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) 166 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 @@
12013-10-03 Paul Eggert <eggert@cs.ucla.edu> 12013-10-03 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Adjust to merge from gnulib.
4 * conf_post.h (__has_builtin, assume): Remove; gnulib now does these.
5 * lisp.h: Include <verify.h>, for 'assume'.
6
3 * eval.c (clobbered_eassert): New macro. 7 * eval.c (clobbered_eassert): New macro.
4 (internal_catch, internal_condition_case) 8 (internal_catch, internal_condition_case)
5 (internal_condition_case_1, internal_condition_case_2) 9 (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, ...);
248# define FLEXIBLE_ARRAY_MEMBER 1 248# define FLEXIBLE_ARRAY_MEMBER 1
249#endif 249#endif
250 250
251#ifndef __has_builtin
252# define __has_builtin(x) 0
253#endif
254
255/* Tell the compiler (and lint) that COND will always hold, and that
256 it should optimize (or check) accordingly. */
257#if (__has_builtin (__builtin_unreachable) \
258 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4)
259# define assume(cond) ((cond) ? (void) 0 : __builtin_unreachable ())
260#elif defined _MSC_VER
261# define assume(cond) __assume (cond)
262#elif defined lint
263# define assume(cond) ((cond) ? (void) 0 : abort ())
264#else
265# define assume(cond) ((void) (0 && (cond)))
266#endif
267
268/* Use this to suppress gcc's `...may be used before initialized' warnings. */ 251/* Use this to suppress gcc's `...may be used before initialized' warnings. */
269#ifdef lint 252#ifdef lint
270/* Use CODE only if lint checking is in effect. */ 253/* 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/>. */
31#include <limits.h> 31#include <limits.h>
32 32
33#include <intprops.h> 33#include <intprops.h>
34#include <verify.h>
34 35
35INLINE_HEADER_BEGIN 36INLINE_HEADER_BEGIN
36 37
@@ -1145,9 +1146,9 @@ struct Lisp_Vector
1145 /* ...but sometimes there is also a pointer internally used in 1146 /* ...but sometimes there is also a pointer internally used in
1146 vector allocation code. Usually you don't want to touch this. */ 1147 vector allocation code. Usually you don't want to touch this. */
1147 struct Lisp_Vector *next; 1148 struct Lisp_Vector *next;
1148 1149
1149 /* We can't use FLEXIBLE_ARRAY_MEMBER here. */ 1150 /* We can't use FLEXIBLE_ARRAY_MEMBER here. */
1150 Lisp_Object contents[1]; 1151 Lisp_Object contents[1];
1151 } u; 1152 } u;
1152 }; 1153 };
1153 1154