Mercurial > emacs
annotate src/vm-limit.c @ 1407:0f214040f708
* dispnew.c (scroll_frame_lines): All references to frame elements
`nruns' and 'face_list' removed. Handle new element `max_ascent'.
(free_frame_glyphs): Don't free nonexistent elements `nruns' and
`face_list'; do free `max_ascent' element.
(make_frame_glyphs): Don't allocate nonexistent elements `nruns'
and `face_list'; do allocate `max_ascent' element.
(update_frame): Replaced use of macro LINE_HEIGHT with element
frame element `pix_height'.
| author | Joseph Arceneaux <jla@gnu.org> |
|---|---|
| date | Wed, 14 Oct 1992 21:30:21 +0000 |
| parents | af08281c0cbe |
| children | 60bb5e719468 |
| rev | line source |
|---|---|
| 734 | 1 /* Functions for memory limit warnings. |
|
1398
70d0cd4c5bff
mem_limits.h is now called mem-limits.h.
Roland McGrath <roland@gnu.org>
parents:
1392
diff
changeset
|
2 Copyright (C) 1990, 1992 Free Software Foundation, Inc. |
| 734 | 3 |
| 4 This file is part of GNU Emacs. | |
| 5 | |
| 6 GNU Emacs is free software; you can redistribute it and/or modify | |
| 7 it under the terms of the GNU General Public License as published by | |
|
1398
70d0cd4c5bff
mem_limits.h is now called mem-limits.h.
Roland McGrath <roland@gnu.org>
parents:
1392
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
| 734 | 9 any later version. |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
| 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
| 19 | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
20 #ifdef emacs |
| 734 | 21 #include "config.h" |
| 22 #include "lisp.h" | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
23 #endif |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
24 |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
25 #ifndef emacs |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
26 #include <stddef.h> |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
27 typedef size_t SIZE; |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
28 typedef void *POINTER; |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
29 #define EXCEEDS_LISP_PTR(x) 0 |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
30 #endif |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
31 |
|
1398
70d0cd4c5bff
mem_limits.h is now called mem-limits.h.
Roland McGrath <roland@gnu.org>
parents:
1392
diff
changeset
|
32 #include "mem-limits.h" |
| 734 | 33 |
| 34 /* | |
| 35 Level number of warnings already issued. | |
| 36 0 -- no warnings issued. | |
| 37 1 -- 75% warning already issued. | |
| 38 2 -- 85% warning already issued. | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
39 3 -- 95% warning issued; keep warning frequently. |
| 734 | 40 */ |
| 41 static int warnlevel; | |
| 42 | |
| 43 /* Function to call to issue a warning; | |
| 44 0 means don't issue them. */ | |
|
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
45 static void (*warn_function) (); |
| 734 | 46 |
| 47 extern POINTER sbrk (); | |
| 48 | |
| 49 /* Get more memory space, complaining if we're near the end. */ | |
| 50 | |
| 51 static POINTER | |
| 52 morecore_with_warning (size) | |
| 53 register int size; | |
| 54 { | |
| 55 POINTER result; | |
| 56 register POINTER cp; | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
57 int five_percent; |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
58 int data_size; |
| 734 | 59 |
| 60 if (lim_data == 0) | |
| 61 get_lim_data (); | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
62 five_percent = lim_data / 20; |
| 734 | 63 |
| 64 /* Find current end of memory and issue warning if getting near max */ | |
| 65 cp = sbrk (0); | |
|
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
66 data_size = (char *) cp - (char *) data_space_start; |
| 734 | 67 |
|
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
68 if (warn_function) |
| 734 | 69 switch (warnlevel) |
| 70 { | |
| 71 case 0: | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
72 if (data_size > five_percent * 15) |
| 734 | 73 { |
| 74 warnlevel++; | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
75 (*warn_function) ("Warning: past 75% of memory limit"); |
| 734 | 76 } |
| 77 break; | |
| 78 | |
| 79 case 1: | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
80 if (data_size > five_percent * 17) |
| 734 | 81 { |
| 82 warnlevel++; | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
83 (*warn_function) ("Warning: past 85% of memory limit"); |
| 734 | 84 } |
| 85 break; | |
| 86 | |
| 87 case 2: | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
88 if (data_size > five_percent * 19) |
| 734 | 89 { |
| 90 warnlevel++; | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
91 (*warn_function) ("Warning: past 95% of memory limit"); |
| 734 | 92 } |
| 93 break; | |
| 94 | |
| 95 default: | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
96 (*warn_function) ("Warning: past acceptable memory limits"); |
| 734 | 97 break; |
| 98 } | |
| 99 | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
100 /* If we go down below 70% full, issue another 75% warning |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
101 when we go up again. */ |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
102 if (data_size < five_percent * 14) |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
103 warnlevel = 0; |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
104 /* If we go down below 80% full, issue another 85% warning |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
105 when we go up again. */ |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
106 else if (warnlevel > 1 && data_size < five_percent * 16) |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
107 warnlevel = 1; |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
108 /* If we go down below 90% full, issue another 95% warning |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
109 when we go up again. */ |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
110 else if (warnlevel > 2 && data_size < five_percent * 18) |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
111 warnlevel = 2; |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
112 |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
113 if (EXCEEDS_LISP_PTR (cp)) |
|
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
114 (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); |
| 734 | 115 |
| 116 result = sbrk (size); | |
| 117 if (result == (POINTER) -1) | |
| 118 return NULL; | |
| 119 return result; | |
| 120 } | |
| 121 | |
| 122 /* Cause reinitialization based on job parameters; | |
| 123 also declare where the end of pure storage is. */ | |
| 124 | |
| 125 void | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
126 memory_warnings (start, warnfun) |
| 734 | 127 POINTER start; |
| 128 void (*warnfun) (); | |
| 129 { | |
| 130 extern POINTER (* __morecore) (); /* From gmalloc.c */ | |
| 131 | |
| 132 if (start) | |
| 133 data_space_start = start; | |
|
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
134 else |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
135 data_space_start = start_of_data (); |
|
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
136 |
|
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
137 warn_function = warnfun; |
| 734 | 138 __morecore = &morecore_with_warning; |
| 139 } |
