diff options
| author | Richard M. Stallman | 2006-02-20 00:00:18 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-02-20 00:00:18 +0000 |
| commit | 933f22f4f4d3528b1c02d574a685943f0ab9d7eb (patch) | |
| tree | 3a627ba42cf48ef3f546802c715be663fec37be9 /src | |
| parent | 8e6694f5e974d31a82f53eca8a036aebb427232e (diff) | |
| download | emacs-933f22f4f4d3528b1c02d574a685943f0ab9d7eb.tar.gz emacs-933f22f4f4d3528b1c02d574a685943f0ab9d7eb.zip | |
[HAVE_GETRLIMIT]: Include sys/resource.h.
(check_memory_limits) [HAVE_GETRLIMIT]: Use getrlimit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/vm-limit.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/vm-limit.c b/src/vm-limit.c index fb127b27b74..48d13c323ae 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c | |||
| @@ -33,6 +33,10 @@ typedef void *POINTER; | |||
| 33 | 33 | ||
| 34 | #include "mem-limits.h" | 34 | #include "mem-limits.h" |
| 35 | 35 | ||
| 36 | #ifdef HAVE_GETRLIMIT | ||
| 37 | #include <sys/resource.h> | ||
| 38 | #endif | ||
| 39 | |||
| 36 | /* | 40 | /* |
| 37 | Level number of warnings already issued. | 41 | Level number of warnings already issued. |
| 38 | 0 -- no warnings issued. | 42 | 0 -- no warnings issued. |
| @@ -61,6 +65,19 @@ check_memory_limits () | |||
| 61 | unsigned long five_percent; | 65 | unsigned long five_percent; |
| 62 | unsigned long data_size; | 66 | unsigned long data_size; |
| 63 | 67 | ||
| 68 | #ifdef HAVE_GETRLIMIT | ||
| 69 | struct rlimit { | ||
| 70 | rlim_t rlim_cur; | ||
| 71 | rlim_t rlim_max; | ||
| 72 | } rlimit; | ||
| 73 | |||
| 74 | getrlimit (RLIMIT_DATA, &rlimit); | ||
| 75 | |||
| 76 | five_percent = rlimit.rlim_max / 20; | ||
| 77 | data_size = rlimit.rlim_cur; | ||
| 78 | |||
| 79 | #else /* not HAVE_GETRLIMIT */ | ||
| 80 | |||
| 64 | if (lim_data == 0) | 81 | if (lim_data == 0) |
| 65 | get_lim_data (); | 82 | get_lim_data (); |
| 66 | five_percent = lim_data / 20; | 83 | five_percent = lim_data / 20; |
| @@ -74,6 +91,8 @@ check_memory_limits () | |||
| 74 | cp = (char *) (*__morecore) (0); | 91 | cp = (char *) (*__morecore) (0); |
| 75 | data_size = (char *) cp - (char *) data_space_start; | 92 | data_size = (char *) cp - (char *) data_space_start; |
| 76 | 93 | ||
| 94 | #endif /* not HAVE_GETRLIMIT */ | ||
| 95 | |||
| 77 | if (warn_function) | 96 | if (warn_function) |
| 78 | switch (warnlevel) | 97 | switch (warnlevel) |
| 79 | { | 98 | { |