static void check_memory_limits (void) { #ifndef REL_ALLOC void *(*real_morecore) (ptrdiff_t) = 0; #endif char *cp; size_t five_percent; size_t data_size; enum warnlevel new_warnlevel; if (lim_data == 0) get_lim_data (); five_percent = lim_data / 20; /* Find current end of memory and issue warning if getting near max */ cp = (real_morecore ? real_morecore : __morecore) (0); data_size = cp - data_space_start; if (!warn_function) return; /* What level of warning does current memory usage demand? */ new_warnlevel = (data_size > five_percent * 19) ? warned_95 : (data_size > five_percent * 17) ? warned_85 : (data_size > five_percent * 15) ? warned_75 : not_warned; /* If we have gone up a level, give the appropriate warning. */ if (new_warnlevel > warnlevel || new_warnlevel == warned_95) { warnlevel = new_warnlevel; static char const *const warn_diagnostic[] = { "Warning: past 75% of memory limit", "Warning: past 85% of memory limit", "Warning: past 95% of memory limit" }; warn_function (warn_diagnostic[warnlevel - 1]); } /* Handle going down in usage levels, with some hysteresis. */ else { /* If we go down below 70% full, issue another 75% warning when we go up again. */ if (data_size < five_percent * 14) warnlevel = not_warned; /* If we go down below 80% full, issue another 85% warning when we go up again. */ else if (warnlevel > warned_75 && data_size < five_percent * 16) warnlevel = warned_75; /* If we go down below 90% full, issue another 95% warning when we go up again. */ else if (warnlevel > warned_85 && data_size < five_percent * 18) warnlevel = warned_85; } }
static void check_memory_limits () { #ifdef REL_ALLOC extern POINTER (*real_morecore) (); #endif extern POINTER (*__morecore) (); register POINTER cp; unsigned long five_percent; unsigned long data_size; enum warnlevel new_warnlevel; if (lim_data == 0) get_lim_data (); five_percent = lim_data / 20; /* Find current end of memory and issue warning if getting near max */ #ifdef REL_ALLOC if (real_morecore) cp = (char *) (*real_morecore) (0); else #endif cp = (char *) (*__morecore) (0); data_size = (char *) cp - (char *) data_space_start; if (!warn_function) return; /* What level of warning does current memory usage demand? */ new_warnlevel = (data_size > five_percent * 19) ? warned_95 : (data_size > five_percent * 17) ? warned_85 : (data_size > five_percent * 15) ? warned_75 : not_warned; /* If we have gone up a level, give the appropriate warning. */ if (new_warnlevel > warnlevel || new_warnlevel == warned_95) { warnlevel = new_warnlevel; switch (warnlevel) { case warned_75: (*warn_function) ("Warning: past 75% of memory limit"); break; case warned_85: (*warn_function) ("Warning: past 85% of memory limit"); break; case warned_95: (*warn_function) ("Warning: past 95% of memory limit"); } } /* Handle going down in usage levels, with some hysteresis. */ else { /* If we go down below 70% full, issue another 75% warning when we go up again. */ if (data_size < five_percent * 14) warnlevel = not_warned; /* If we go down below 80% full, issue another 85% warning when we go up again. */ else if (warnlevel > warned_75 && data_size < five_percent * 16) warnlevel = warned_75; /* If we go down below 90% full, issue another 95% warning when we go up again. */ else if (warnlevel > warned_85 && data_size < five_percent * 18) warnlevel = warned_85; } if (EXCEEDS_LISP_PTR (cp)) (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); }
unsigned long ret_lim_data () { get_lim_data (); return lim_data; }
static void check_memory_limits (void) { extern POINTER (*__morecore) (ptrdiff_t size); POINTER cp; unsigned long five_percent; unsigned long data_size; void (*save_warn_fun) (const char *); if (lim_data == 0) get_lim_data (); five_percent = lim_data / 20; /* Find current end of memory and issue warning if getting near max */ cp = (char *) (*__morecore) (0); data_size = (char *) cp - (char *) data_space_start; if (warn_function) { /* temporarily reset the warn_function to 0 or we will get infinite looping. */ save_warn_fun = warn_function; warn_function = 0; switch (warnlevel) { case 0: if (data_size > five_percent * 15) { warnlevel++; (*save_warn_fun) ("Warning: past 75% of memory limit"); } break; case 1: if (data_size > five_percent * 17) { warnlevel++; (*save_warn_fun) ("Warning: past 85% of memory limit"); } break; case 2: if (data_size > five_percent * 19) { warnlevel++; (*save_warn_fun) ("Warning: past 95% of memory limit"); } break; default: (*save_warn_fun) ("Warning: past acceptable memory limits"); break; } warn_function = save_warn_fun; } /* 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 (cp)) { if (warn_function) { /* temporarily reset the warn_function to 0 or we will get infinite looping. */ save_warn_fun = warn_function; warn_function = 0; (*save_warn_fun) ("Warning: memory in use exceeds lisp pointer size"); warn_function = save_warn_fun; } } }