diff options
author | Roland McGrath <roland@gnu.org> | 1992-10-12 21:07:25 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1992-10-12 21:07:25 +0000 |
commit | 93f93d09970dbf2c4a6579635989cbe4d02d04d7 (patch) | |
tree | 2816263d6cd5ef70324fb3eb596bd94ed0c40fdf | |
parent | eb7d800de01e9ef736e94d91037397a720583643 (diff) | |
download | emacs-93f93d09970dbf2c4a6579635989cbe4d02d04d7.tar.gz |
(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.
-rw-r--r-- | src/ralloc.c | 107 |
1 files changed, 9 insertions, 98 deletions
diff --git a/src/ralloc.c b/src/ralloc.c index 5131402bdf2..f2d0ecf14fa 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -59,8 +59,8 @@ static void r_alloc_init (); /* 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 @@ static POINTER page_break_value; #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 @@ obtain (size) { 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 @@ relinquish (size) 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 @@ r_alloc_sbrk (size) POINTER ptr; if (! use_relocatable_buffers) - return sbrk (size); + return (*real_morecore) (size); if (size > 0) { @@ -499,38 +432,16 @@ r_alloc_init () 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; } |