feature/igc3 07b35c82b7d: Move 'read_commit_limit' to sysdep.c
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: feature/igc3 commit 07b35c82b7dfc9d0c044dc54dcc65675f49de87e Author: Eli Zaretskii <[email protected]> Commit: Eli Zaretskii <[email protected]> Move 'read_commit_limit' to sysdep.c * src/igc.c (read_commit_limit): Move from here... * src/sysdep.c (read_commit_limit): ...to here. Make non-static. Relax compile-time conditions for using 'sysconf' and 'getrlimit' to systems other than GNU/Linux which have 'sysconf' and/or 'getrlimit'. Add implementation for WINDOWSNT. * src/lisp.h (read_commit_limit): Add prototype. --- src/igc.c | 25 ------------------------- src/lisp.h | 1 + src/sysdep.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/igc.c b/src/igc.c index ab09e708e73..437f65ef494 100644 --- a/src/igc.c +++ b/src/igc.c @@ -100,11 +100,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ # include "xwidget.h" #endif -#ifdef GNU_LINUX -#include <sys/resource.h> -#include <errno.h> -#endif - #if !USE_LSB_TAG # error "USE_LSB_TAG required" #endif @@ -5914,26 +5909,6 @@ read_arena_size (size_t *size) return ok; } -static bool -read_commit_limit (size_t *size_o) -{ - size_t limit = SIZE_MAX; -#ifdef GNU_LINUX - { - errno = 0; - long phys_limit = sysconf (_SC_PHYS_PAGES); - if (phys_limit != -1 && errno == 0) - limit = min (limit, (size_t) phys_limit * getpagesize ()); - - struct rlimit data_limit; - if (getrlimit (RLIMIT_DATA, &data_limit) == 0) - limit = min (limit, data_limit.rlim_cur); - } -#endif - *size_o = limit; - return limit != SIZE_MAX; -} - static void make_arena (struct igc *gc) { diff --git a/src/lisp.h b/src/lisp.h index d90faacf429..141c0ecf871 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -5928,6 +5928,7 @@ extern int renameat_noreplace (int, char const *, int, char const *); #endif extern int str_collate (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object); extern void syms_of_sysdep (void); +extern bool read_commit_limit (size_t *); /* Defined in filelock.c. */ extern void unlock_all_files (void); diff --git a/src/sysdep.c b/src/sysdep.c index 069e052d3ab..817f41e7721 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -4707,6 +4707,41 @@ str_collate (Lisp_Object s1, Lisp_Object s2, } #endif /* WINDOWSNT */ + +#ifdef HAVE_MPS +/* Commit limit for MPS. */ + + +bool +read_commit_limit (size_t *size_o) +{ + size_t limit = SIZE_MAX; + +#ifdef _SC_PHYS_PAGES + errno = 0; + long phys_limit = sysconf (_SC_PHYS_PAGES); + if (phys_limit != -1 && errno == 0) + limit = min (limit, (size_t) phys_limit * getpagesize ()); +#endif + +#if defined HAVE_GETRLIMIT && defined RLIMIT_DATA + struct rlimit data_limit; + if (getrlimit (RLIMIT_DATA, &data_limit) == 0) + limit = min (limit, data_limit.rlim_cur); +#endif + +#ifdef WINDOWSNT + unsigned long long phys_limit, commit_limit; + unsigned long long ignored1, ignored2; + if (w32_memory_info (&phys_limit, &ignored1, &commit_limit, &ignored2) == 0) + limit = min (min (limit, phys_limit), commit_limit); +#endif + + *size_o = limit; + return limit != SIZE_MAX; +} + +#endif /* HAVE_MPS */ void syms_of_sysdep (void) {