diff options
| author | Paul Eggert | 2013-10-03 00:06:52 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-10-03 00:06:52 -0700 |
| commit | 0a858ebfc57a072ae8ab65f509d8a4901a2ec073 (patch) | |
| tree | dd81bcdf11f3d3efa32ffe00f7cdc90d3c1144d9 /lib/getdtablesize.c | |
| parent | b52f569dcfc5c2e1b764c89d27ea8699a44228e6 (diff) | |
| download | emacs-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
Diffstat (limited to 'lib/getdtablesize.c')
| -rw-r--r-- | lib/getdtablesize.c | 33 |
1 files changed, 27 insertions, 6 deletions
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 |
| 30 | static int | 30 | static 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. */ | ||
| 51 | static int dtablesize; | 52 | static int dtablesize; |
| 52 | 53 | ||
| 53 | int | 54 | int |
| @@ -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 | |||
| 92 | int | ||
| 93 | rpl_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 |