diff options
| author | Chong Yidong | 2008-08-03 14:07:10 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-08-03 14:07:10 +0000 |
| commit | 5ced3ad912eed8acc19d5208606e28f8cb798627 (patch) | |
| tree | 446dfeaf06806395b7646a15139217a4778a9c82 /src | |
| parent | 880c60ca7ecbe9af72e612897141e808182b5ff5 (diff) | |
| download | emacs-5ced3ad912eed8acc19d5208606e28f8cb798627.tar.gz emacs-5ced3ad912eed8acc19d5208606e28f8cb798627.zip | |
(get_lim_data) [HAVE_GETRLIMIT && RLIMIT_AS]: Define.
(check_memory_limits): Don't handle HAVE_GETRLIMIT here.
Diffstat (limited to 'src')
| -rw-r--r-- | src/vm-limit.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/vm-limit.c b/src/vm-limit.c index 7b954e12e8b..8581bba26da 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c | |||
| @@ -67,6 +67,21 @@ get_lim_data () | |||
| 67 | } | 67 | } |
| 68 | #else /* not NO_LIM_DATA */ | 68 | #else /* not NO_LIM_DATA */ |
| 69 | 69 | ||
| 70 | #if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS) | ||
| 71 | static void | ||
| 72 | get_lim_data () | ||
| 73 | { | ||
| 74 | struct rlimit rlimit; | ||
| 75 | |||
| 76 | getrlimit (RLIMIT_AS, &rlimit); | ||
| 77 | if (rlimit.rlim_cur == RLIM_INFINITY) | ||
| 78 | lim_data = -1; | ||
| 79 | else | ||
| 80 | lim_data = rlimit.rlim_cur; | ||
| 81 | } | ||
| 82 | |||
| 83 | #else /* not HAVE_GETRLIMIT */ | ||
| 84 | |||
| 70 | #ifdef USG | 85 | #ifdef USG |
| 71 | 86 | ||
| 72 | static void | 87 | static void |
| @@ -137,6 +152,7 @@ get_lim_data () | |||
| 137 | #endif /* BSD4_2 */ | 152 | #endif /* BSD4_2 */ |
| 138 | #endif /* not WINDOWSNT */ | 153 | #endif /* not WINDOWSNT */ |
| 139 | #endif /* not USG */ | 154 | #endif /* not USG */ |
| 155 | #endif /* not HAVE_GETRLIMIT */ | ||
| 140 | #endif /* not NO_LIM_DATA */ | 156 | #endif /* not NO_LIM_DATA */ |
| 141 | 157 | ||
| 142 | /* Verify amount of memory available, complaining if we're near the end. */ | 158 | /* Verify amount of memory available, complaining if we're near the end. */ |
| @@ -154,21 +170,6 @@ check_memory_limits () | |||
| 154 | unsigned long data_size; | 170 | unsigned long data_size; |
| 155 | enum warnlevel new_warnlevel; | 171 | enum warnlevel new_warnlevel; |
| 156 | 172 | ||
| 157 | /* Cygwin has a faulty getrlimit implementation: | ||
| 158 | http://lists.gnu.org/archive/html/emacs-devel/2008-08/msg00125.html */ | ||
| 159 | #if defined (HAVE_GETRLIMIT) && ! defined (CYGWIN) | ||
| 160 | struct rlimit rlimit; | ||
| 161 | |||
| 162 | getrlimit (RLIMIT_AS, &rlimit); | ||
| 163 | if (RLIM_INFINITY == rlimit.rlim_max | ||
| 164 | /* This is a nonsensical case, but it happens -- rms. */ | ||
| 165 | || rlimit.rlim_cur > rlimit.rlim_max) | ||
| 166 | return; | ||
| 167 | five_percent = rlimit.rlim_max / 20; | ||
| 168 | data_size = rlimit.rlim_cur; | ||
| 169 | |||
| 170 | #else /* not HAVE_GETRLIMIT */ | ||
| 171 | |||
| 172 | if (lim_data == 0) | 173 | if (lim_data == 0) |
| 173 | get_lim_data (); | 174 | get_lim_data (); |
| 174 | five_percent = lim_data / 20; | 175 | five_percent = lim_data / 20; |
| @@ -182,8 +183,6 @@ check_memory_limits () | |||
| 182 | cp = (char *) (*__morecore) (0); | 183 | cp = (char *) (*__morecore) (0); |
| 183 | data_size = (char *) cp - (char *) data_space_start; | 184 | data_size = (char *) cp - (char *) data_space_start; |
| 184 | 185 | ||
| 185 | #endif /* not HAVE_GETRLIMIT */ | ||
| 186 | |||
| 187 | if (!warn_function) | 186 | if (!warn_function) |
| 188 | return; | 187 | return; |
| 189 | 188 | ||
| @@ -229,10 +228,8 @@ check_memory_limits () | |||
| 229 | warnlevel = warned_85; | 228 | warnlevel = warned_85; |
| 230 | } | 229 | } |
| 231 | 230 | ||
| 232 | #if ! defined (HAVE_GETRLIMIT) || defined (CYGWIN) | ||
| 233 | if (EXCEEDS_LISP_PTR (cp)) | 231 | if (EXCEEDS_LISP_PTR (cp)) |
| 234 | (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); | 232 | (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); |
| 235 | #endif | ||
| 236 | } | 233 | } |
| 237 | 234 | ||
| 238 | /* Enable memory usage warnings. | 235 | /* Enable memory usage warnings. |