diff options
| author | Paul Eggert | 2012-12-07 22:56:26 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-12-07 22:56:26 -0800 |
| commit | 7be78020e3baaa73d047af75675ea6c92c1c1fda (patch) | |
| tree | 8b08777c7980d162178d2cdfdc683f9f14c337f4 /src | |
| parent | d983a10b9a070fd8f6d4f48ec44e5514b62feaa6 (diff) | |
| download | emacs-7be78020e3baaa73d047af75675ea6c92c1c1fda.tar.gz emacs-7be78020e3baaa73d047af75675ea6c92c1c1fda.zip | |
Simplify get_lim_data.
* admin/CPP-DEFINES (ULIMIT_BREAK_VALUE): Remove.
* configure.ac (ULIMIT_BREAK_VALUE): Remove.
* src/vm-limit.c (get_lim_data): Combine RLIMIT_AS and RLIMIT_DATA methods.
Remove USG and vlimit methods; no longer used these days.
Add #error catchall just in case.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/vm-limit.c | 75 |
2 files changed, 20 insertions, 60 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 2b283a609e3..218dd425a2d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2012-12-08 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-12-08 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Simplify get_lim_data. | ||
| 4 | * vm-limit.c (get_lim_data): Combine RLIMIT_AS and RLIMIT_DATA methods. | ||
| 5 | Remove USG and vlimit methods; no longer used these days. | ||
| 6 | Add #error catchall just in case. | ||
| 7 | |||
| 3 | Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026). | 8 | Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026). |
| 4 | Exceptions: do not assume SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, | 9 | Exceptions: do not assume SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, |
| 5 | SIGTTOU, SIGUSR1, SIGUSR2, as Microsoft platforms lack these. | 10 | SIGTTOU, SIGUSR1, SIGUSR2, as Microsoft platforms lack these. |
diff --git a/src/vm-limit.c b/src/vm-limit.c index 2a71e88695a..befc01d400f 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c | |||
| @@ -44,46 +44,26 @@ static POINTER data_space_start; | |||
| 44 | static size_t lim_data; | 44 | static size_t lim_data; |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | #if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS) | 47 | #ifdef HAVE_GETRLIMIT |
| 48 | static void | ||
| 49 | get_lim_data (void) | ||
| 50 | { | ||
| 51 | struct rlimit rlimit; | ||
| 52 | |||
| 53 | getrlimit (RLIMIT_AS, &rlimit); | ||
| 54 | if (rlimit.rlim_cur == RLIM_INFINITY) | ||
| 55 | lim_data = -1; | ||
| 56 | else | ||
| 57 | lim_data = rlimit.rlim_cur; | ||
| 58 | } | ||
| 59 | 48 | ||
| 60 | #else /* not HAVE_GETRLIMIT */ | 49 | # ifndef RLIMIT_AS |
| 61 | 50 | # define RLIMIT_AS RLIMIT_DATA | |
| 62 | #ifdef USG | 51 | # endif |
| 63 | 52 | ||
| 64 | static void | 53 | static void |
| 65 | get_lim_data (void) | 54 | get_lim_data (void) |
| 66 | { | 55 | { |
| 67 | extern long ulimit (); | 56 | /* Set LIM_DATA to the minimum of the maximum object size and the |
| 68 | 57 | maximum address space. Don't bother to check for values like | |
| 69 | lim_data = -1; | 58 | RLIM_INFINITY since in practice they are not much less than SIZE_MAX. */ |
| 70 | 59 | struct rlimit rlimit; | |
| 71 | /* Use the ulimit call, if we seem to have it. */ | 60 | lim_data |
| 72 | #if !defined (ULIMIT_BREAK_VALUE) || defined (GNU_LINUX) | 61 | = (getrlimit (RLIMIT_AS, &rlimit) == 0 && rlimit.rlim_cur <= SIZE_MAX |
| 73 | lim_data = ulimit (3, 0); | 62 | ? rlimit.rlim_cur |
| 74 | #endif | 63 | : SIZE_MAX); |
| 75 | |||
| 76 | /* If that didn't work, just use the macro's value. */ | ||
| 77 | #ifdef ULIMIT_BREAK_VALUE | ||
| 78 | if (lim_data == -1) | ||
| 79 | lim_data = ULIMIT_BREAK_VALUE; | ||
| 80 | #endif | ||
| 81 | |||
| 82 | lim_data -= (long) data_space_start; | ||
| 83 | } | 64 | } |
| 84 | 65 | ||
| 85 | #else /* not USG */ | 66 | #elif defined WINDOWSNT |
| 86 | #ifdef WINDOWSNT | ||
| 87 | 67 | ||
| 88 | #include "w32heap.h" | 68 | #include "w32heap.h" |
| 89 | 69 | ||
| @@ -94,10 +74,8 @@ get_lim_data (void) | |||
| 94 | lim_data = reserved_heap_size; | 74 | lim_data = reserved_heap_size; |
| 95 | } | 75 | } |
| 96 | 76 | ||
| 97 | #else | 77 | #elif defined MSDOS |
| 98 | #if !defined (BSD4_2) && !defined (CYGWIN) | ||
| 99 | 78 | ||
| 100 | #ifdef MSDOS | ||
| 101 | void | 79 | void |
| 102 | get_lim_data (void) | 80 | get_lim_data (void) |
| 103 | { | 81 | { |
| @@ -135,32 +113,9 @@ ret_lim_data (void) | |||
| 135 | get_lim_data (); | 113 | get_lim_data (); |
| 136 | return lim_data; | 114 | return lim_data; |
| 137 | } | 115 | } |
| 138 | #else /* not MSDOS */ | ||
| 139 | static void | ||
| 140 | get_lim_data (void) | ||
| 141 | { | ||
| 142 | lim_data = vlimit (LIM_DATA, -1); | ||
| 143 | } | ||
| 144 | #endif /* not MSDOS */ | ||
| 145 | |||
| 146 | #else /* BSD4_2 || CYGWIN */ | ||
| 147 | |||
| 148 | static void | ||
| 149 | get_lim_data (void) | ||
| 150 | { | ||
| 151 | struct rlimit XXrlimit; | ||
| 152 | |||
| 153 | getrlimit (RLIMIT_DATA, &XXrlimit); | ||
| 154 | #ifdef RLIM_INFINITY | ||
| 155 | lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ | ||
| 156 | #else | 116 | #else |
| 157 | lim_data = XXrlimit.rlim_cur; /* soft limit */ | 117 | # error "get_lim_data not implemented on this machine" |
| 158 | #endif | 118 | #endif |
| 159 | } | ||
| 160 | #endif /* BSD4_2 */ | ||
| 161 | #endif /* not WINDOWSNT */ | ||
| 162 | #endif /* not USG */ | ||
| 163 | #endif /* not HAVE_GETRLIMIT */ | ||
| 164 | 119 | ||
| 165 | /* Verify amount of memory available, complaining if we're near the end. */ | 120 | /* Verify amount of memory available, complaining if we're near the end. */ |
| 166 | 121 | ||