Mercurial > emacs
changeset 1401:9689db083f88
(sbrk): Removed decl.
(real_morecore): New static variable.
(warnlevel, warn_function, check_memory_limits): Removed.
(obtain): Don't call check_memory_limits.
(obtain, relinquish, r_alloc_sbrk): Use (*real_morecore) in place of sbrk;
it returns 0 for errors, not -1.
(r_alloc_init): Set real_morecore to old value of __morecore.
Don't initialize lim_data or warnlevel, and don't call get_lim_data.
(memory_warnings): Function removed.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Mon, 12 Oct 1992 21:07:25 +0000 |
parents | af08281c0cbe |
children | 6a0dcfc81b4f |
files | src/ralloc.c |
diffstat | 1 files changed, 9 insertions(+), 98 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ralloc.c Mon Oct 12 19:59:52 1992 +0000 +++ b/src/ralloc.c Mon Oct 12 21:07:25 1992 +0000 @@ -59,8 +59,8 @@ /* Declarations for working with the malloc, ralloc, and system breaks. */ -/* System call to set the break value. */ -extern POINTER sbrk (); +/* Function to set the real break value. */ +static POINTER (*real_morecore) (); /* The break value, as seen by malloc (). */ static POINTER virtual_break_value; @@ -78,70 +78,6 @@ #define ROUNDUP(size) (((unsigned int) (size) + PAGE - 1) & ~(PAGE - 1)) #define ROUND_TO_PAGE(addr) (addr & (~(PAGE - 1))) -/* Managing "almost out of memory" warnings. */ - -/* Level of warnings issued. */ -static int warnlevel; - -/* Function to call to issue a warning; - 0 means don't issue them. */ -static void (*warn_function) (); - -static void -check_memory_limits (address) - POINTER address; -{ - SIZE data_size = address - data_space_start; - int five_percent = lim_data / 20; - - switch (warnlevel) - { - case 0: - if (data_size > five_percent * 15) - { - warnlevel++; - (*warn_function) ("Warning: past 75% of memory limit"); - } - break; - - case 1: - if (data_size > five_percent * 17) - { - warnlevel++; - (*warn_function) ("Warning: past 85% of memory limit"); - } - break; - - case 2: - if (data_size > five_percent * 19) - { - warnlevel++; - (*warn_function) ("Warning: past 95% of memory limit"); - } - break; - - default: - (*warn_function) ("Warning: past acceptable memory limits"); - break; - } - - /* If we go down below 70% full, issue another 75% warning - when we go up again. */ - if (data_size < five_percent * 14) - warnlevel = 0; - /* If we go down below 80% full, issue another 85% warning - when we go up again. */ - else if (warnlevel > 1 && data_size < five_percent * 16) - warnlevel = 1; - /* If we go down below 90% full, issue another 95% warning - when we go up again. */ - else if (warnlevel > 2 && data_size < five_percent * 18) - warnlevel = 2; - - if (EXCEEDS_LISP_PTR (address)) - memory_full (); -} - /* Functions to get and return memory from the system. */ /* Obtain SIZE bytes of space. If enough space is not presently available @@ -160,10 +96,7 @@ { SIZE get = ROUNDUP (size - already_available); - if (warn_function) - check_memory_limits (page_break_value); - - if (((int) sbrk (get)) < 0) + if ((*real_morecore) (get) == 0) return 0; page_break_value += get; @@ -202,8 +135,8 @@ if (new_page_break != page_break_value) { - if (((int) (sbrk ((char *) new_page_break - - (char *) page_break_value))) < 0) + if ((*real_morecore) ((char *) new_page_break + - (char *) page_break_value) == 0) abort (); page_break_value = new_page_break; @@ -373,7 +306,7 @@ POINTER ptr; if (! use_relocatable_buffers) - return sbrk (size); + return (*real_morecore) (size); if (size > 0) { @@ -499,38 +432,16 @@ return; r_alloc_initialized = 1; + real_morecore = __morecore; __morecore = r_alloc_sbrk; - virtual_break_value = break_value = sbrk (0); - if (break_value == (POINTER)NULL) + virtual_break_value = break_value = (*real_morecore) (0); + if (break_value == NULL) abort (); -#if 0 /* The following is unreasonable because warn_func may be 0. */ - (*warn_func)("memory initialization got 0 from sbrk(0)."); -#endif page_break_value = (POINTER) ROUNDUP (break_value); /* Clear the rest of the last page; this memory is in our address space even though it is after the sbrk value. */ bzero (break_value, (page_break_value - break_value)); use_relocatable_buffers = 1; - - lim_data = 0; - warnlevel = 0; - - get_lim_data (); } - -/* This is the name Emacs expects to call. */ - -void -memory_warnings (start, warn_func) - POINTER start; - void (*warn_func) (); -{ - if (start) - data_space_start = start; - else - data_space_start = start_of_data (); - - warn_function = warn_func; -}