From: Andreas Schwab Date: Sun, 3 Aug 2008 09:27:34 +0000 (+0000) Subject: (get_lim_data) [HAVE_GETRLIMIT && RLIMIT_AS]: Define. X-Git-Tag: emacs-pretest-23.0.90~3675 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=517571872e4d1b48c16c357a82458910b4d538c7;p=emacs.git (get_lim_data) [HAVE_GETRLIMIT && RLIMIT_AS]: Define. (check_memory_limits): Don't handle HAVE_GETRLIMIT here. --- diff --git a/src/ChangeLog b/src/ChangeLog index 4f7354dd6aa..f19dcf8b12a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,7 @@ 2008-08-03 Andreas Schwab - * vm-limit.c (check_memory_limits) [HAVE_GETRLIMIT]: Fix - calculation of data_size. Use correct type for five_percent. + * vm-limit.c (get_lim_data) [HAVE_GETRLIMIT && RLIMIT_AS]: Define. + (check_memory_limits): Don't handle HAVE_GETRLIMIT here. 2008-08-02 Chong Yidong diff --git a/src/vm-limit.c b/src/vm-limit.c index 348fccbb827..f80e5c47604 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -65,6 +65,21 @@ get_lim_data () } #else /* not NO_LIM_DATA */ +#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS) +static void +get_lim_data () +{ + struct rlimit rlimit; + + getrlimit (RLIMIT_AS, &rlimit); + if (rlimit.rlim_cur == RLIM_INFINITY) + lim_data = -1; + else + lim_data = rlimit.rlim_cur; +} + +#else /* not HAVE_GETRLIMIT */ + #ifdef USG static void @@ -135,6 +150,7 @@ get_lim_data () #endif /* BSD4_2 */ #endif /* not WINDOWSNT */ #endif /* not USG */ +#endif /* not HAVE_GETRLIMIT */ #endif /* not NO_LIM_DATA */ /* Verify amount of memory available, complaining if we're near the end. */ @@ -148,34 +164,14 @@ check_memory_limits () extern POINTER (*__morecore) (); register POINTER cp; -#if defined (HAVE_GETRLIMIT) && ! defined (CYGWIN) - rlim_t five_percent; -#else unsigned long five_percent; -#endif unsigned long data_size; enum warnlevel new_warnlevel; - /* Cygwin has a faulty getrlimit implementation: - http://lists.gnu.org/archive/html/emacs-devel/2008-08/msg00125.html */ -#if defined (HAVE_GETRLIMIT) && ! defined (CYGWIN) - struct rlimit rlimit; - - getrlimit (RLIMIT_AS, &rlimit); - if (RLIM_INFINITY == rlimit.rlim_max - /* This is a nonsensical case, but it happens -- rms. */ - || rlimit.rlim_cur > rlimit.rlim_max) - return; - five_percent = rlimit.rlim_max / 20; - -#else /* not HAVE_GETRLIMIT */ - if (lim_data == 0) get_lim_data (); five_percent = lim_data / 20; -#endif /* not HAVE_GETRLIMIT */ - /* Find current end of memory and issue warning if getting near max */ #ifdef REL_ALLOC if (real_morecore) @@ -230,10 +226,8 @@ check_memory_limits () warnlevel = warned_85; } -#if ! defined (HAVE_GETRLIMIT) || defined (CYGWIN) if (EXCEEDS_LISP_PTR (cp)) (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); -#endif } /* Enable memory usage warnings.