Mercurial > emacs
comparison src/vm-limit.c @ 1416:60bb5e719468
(morecore_with_warning): Removed.
(check_memory_limits): New fn; most code from morecore_with_warning, but
only checks limits, doesn't do any work.
(memory_warnings): Set __after_morecore_hook to check_memory_limits;
don't set __morecore.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Thu, 15 Oct 1992 23:29:28 +0000 |
parents | af08281c0cbe |
children | 3a1576d52874 |
comparison
equal
deleted
inserted
replaced
1415:1b82f79c4eb4 | 1416:60bb5e719468 |
---|---|
42 | 42 |
43 /* Function to call to issue a warning; | 43 /* Function to call to issue a warning; |
44 0 means don't issue them. */ | 44 0 means don't issue them. */ |
45 static void (*warn_function) (); | 45 static void (*warn_function) (); |
46 | 46 |
47 extern POINTER sbrk (); | |
48 | |
49 /* Get more memory space, complaining if we're near the end. */ | 47 /* Get more memory space, complaining if we're near the end. */ |
50 | 48 |
51 static POINTER | 49 static void |
52 morecore_with_warning (size) | 50 check_memory_limits () |
53 register int size; | |
54 { | 51 { |
55 POINTER result; | 52 POINTER result; |
56 register POINTER cp; | 53 register POINTER cp; |
57 int five_percent; | 54 int five_percent; |
58 int data_size; | 55 int data_size; |
60 if (lim_data == 0) | 57 if (lim_data == 0) |
61 get_lim_data (); | 58 get_lim_data (); |
62 five_percent = lim_data / 20; | 59 five_percent = lim_data / 20; |
63 | 60 |
64 /* Find current end of memory and issue warning if getting near max */ | 61 /* Find current end of memory and issue warning if getting near max */ |
65 cp = sbrk (0); | 62 cp = (char *) (*__morecore) (0); |
66 data_size = (char *) cp - (char *) data_space_start; | 63 data_size = (char *) cp - (char *) data_space_start; |
67 | 64 |
68 if (warn_function) | 65 if (warn_function) |
69 switch (warnlevel) | 66 switch (warnlevel) |
70 { | 67 { |
110 else if (warnlevel > 2 && data_size < five_percent * 18) | 107 else if (warnlevel > 2 && data_size < five_percent * 18) |
111 warnlevel = 2; | 108 warnlevel = 2; |
112 | 109 |
113 if (EXCEEDS_LISP_PTR (cp)) | 110 if (EXCEEDS_LISP_PTR (cp)) |
114 (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); | 111 (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); |
115 | |
116 result = sbrk (size); | |
117 if (result == (POINTER) -1) | |
118 return NULL; | |
119 return result; | |
120 } | 112 } |
121 | 113 |
122 /* Cause reinitialization based on job parameters; | 114 /* Cause reinitialization based on job parameters; |
123 also declare where the end of pure storage is. */ | 115 also declare where the end of pure storage is. */ |
124 | 116 |
125 void | 117 void |
126 memory_warnings (start, warnfun) | 118 memory_warnings (start, warnfun) |
127 POINTER start; | 119 POINTER start; |
128 void (*warnfun) (); | 120 void (*warnfun) (); |
129 { | 121 { |
130 extern POINTER (* __morecore) (); /* From gmalloc.c */ | 122 extern void (* __after_morecore_hook) (); /* From gmalloc.c */ |
131 | 123 |
132 if (start) | 124 if (start) |
133 data_space_start = start; | 125 data_space_start = start; |
134 else | 126 else |
135 data_space_start = start_of_data (); | 127 data_space_start = start_of_data (); |
136 | 128 |
137 warn_function = warnfun; | 129 warn_function = warnfun; |
138 __morecore = &morecore_with_warning; | 130 __after_morecore_hook = check_memory_limits; |
139 } | 131 } |