diff options
author | Richard M. Stallman <rms@gnu.org> | 2006-02-20 00:00:18 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2006-02-20 00:00:18 +0000 |
commit | 933f22f4f4d3528b1c02d574a685943f0ab9d7eb (patch) | |
tree | 3a627ba42cf48ef3f546802c715be663fec37be9 /src/vm-limit.c | |
parent | 8e6694f5e974d31a82f53eca8a036aebb427232e (diff) | |
download | emacs-933f22f4f4d3528b1c02d574a685943f0ab9d7eb.tar.gz emacs-933f22f4f4d3528b1c02d574a685943f0ab9d7eb.tar.bz2 emacs-933f22f4f4d3528b1c02d574a685943f0ab9d7eb.zip |
[HAVE_GETRLIMIT]: Include sys/resource.h.
(check_memory_limits) [HAVE_GETRLIMIT]: Use getrlimit.
Diffstat (limited to 'src/vm-limit.c')
-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; #include "mem-limits.h" +#ifdef HAVE_GETRLIMIT +#include <sys/resource.h> +#endif + /* Level number of warnings already issued. 0 -- no warnings issued. @@ -61,6 +65,19 @@ check_memory_limits () unsigned long five_percent; unsigned long data_size; +#ifdef HAVE_GETRLIMIT + struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; + } rlimit; + + getrlimit (RLIMIT_DATA, &rlimit); + + five_percent = rlimit.rlim_max / 20; + data_size = rlimit.rlim_cur; + +#else /* not HAVE_GETRLIMIT */ + if (lim_data == 0) get_lim_data (); five_percent = lim_data / 20; @@ -74,6 +91,8 @@ check_memory_limits () cp = (char *) (*__morecore) (0); data_size = (char *) cp - (char *) data_space_start; +#endif /* not HAVE_GETRLIMIT */ + if (warn_function) switch (warnlevel) { |