Mercurial > emacs
annotate src/vm-limit.c @ 69395:973779d570da
(ispell-find-aspell-dictionaries): Add aliases before merging elements from the
standard ispell-dictionary-alist.
(ispell-aspell-add-aliases): Add aliases to the passed dictionary alist, and
return the new alist.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 11 Mar 2006 15:36:15 +0000 |
parents | 7e58bc915ffe |
children | 4c6bb2c4dbcf |
rev | line source |
---|---|
734 | 1 /* Functions for memory limit warnings. |
64770
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
2 Copyright (C) 1990, 1992, 2002, 2003, 2004, |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64770
diff
changeset
|
3 2005, 2006 Free Software Foundation, Inc. |
734 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 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
|
9 the Free Software Foundation; either version 2, or (at your option) |
734 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. */ | |
734 | 21 |
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
22 #ifdef emacs |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
3935
diff
changeset
|
23 #include <config.h> |
734 | 24 #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
|
25 #endif |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
26 |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
27 #ifndef emacs |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
28 #include <stddef.h> |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
29 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
|
30 typedef void *POINTER; |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
31 #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
|
32 #endif |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
33 |
1398
70d0cd4c5bff
mem_limits.h is now called mem-limits.h.
Roland McGrath <roland@gnu.org>
parents:
1392
diff
changeset
|
34 #include "mem-limits.h" |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
35 #include <sys/resource.h> |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
36 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
37 #define HAVE_GETRLIMIT |
734 | 38 |
69019
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
39 #ifdef HAVE_GETRLIMIT |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
40 #include <sys/resource.h> |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
41 #endif |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
42 |
734 | 43 /* |
44 Level number of warnings already issued. | |
45 0 -- no warnings issued. | |
46 1 -- 75% warning already issued. | |
47 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
|
48 3 -- 95% warning issued; keep warning frequently. |
734 | 49 */ |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
50 enum warnlevel { not_warned, warned_75, warned_85, warned_95 }; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
51 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
52 static enum warnlevel warnlevel; |
734 | 53 |
54 /* Function to call to issue a warning; | |
55 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
|
56 static void (*warn_function) (); |
734 | 57 |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
58 /* Start of data space; can be changed by calling malloc_init. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
59 static POINTER data_space_start; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
60 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
61 /* Number of bytes of writable memory we can expect to be able to get. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
62 static unsigned long lim_data; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
63 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
64 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
65 #ifdef NO_LIM_DATA |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
66 static void |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
67 get_lim_data () |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
68 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
69 lim_data = -1; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
70 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
71 #else /* not NO_LIM_DATA */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
72 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
73 #ifdef USG |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
74 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
75 static void |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
76 get_lim_data () |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
77 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
78 extern long ulimit (); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
79 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
80 lim_data = -1; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
81 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
82 /* Use the ulimit call, if we seem to have it. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
83 #if !defined (ULIMIT_BREAK_VALUE) || defined (GNU_LINUX) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
84 lim_data = ulimit (3, 0); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
85 #endif |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
86 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
87 /* If that didn't work, just use the macro's value. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
88 #ifdef ULIMIT_BREAK_VALUE |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
89 if (lim_data == -1) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
90 lim_data = ULIMIT_BREAK_VALUE; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
91 #endif |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
92 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
93 lim_data -= (long) data_space_start; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
94 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
95 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
96 #else /* not USG */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
97 #ifdef WINDOWSNT |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
98 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
99 static void |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
100 get_lim_data () |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
101 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
102 extern unsigned long reserved_heap_size; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
103 lim_data = reserved_heap_size; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
104 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
105 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
106 #else |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
107 #if !defined (BSD4_2) && !defined (__osf__) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
108 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
109 #ifdef MSDOS |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
110 void |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
111 get_lim_data () |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
112 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
113 _go32_dpmi_meminfo info; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
114 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
115 _go32_dpmi_get_free_memory_information (&info); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
116 lim_data = info.available_memory; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
117 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
118 #else /* not MSDOS */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
119 static void |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
120 get_lim_data () |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
121 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
122 lim_data = vlimit (LIM_DATA, -1); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
123 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
124 #endif /* not MSDOS */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
125 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
126 #else /* BSD4_2 */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
127 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
128 static void |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
129 get_lim_data () |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
130 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
131 struct rlimit XXrlimit; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
132 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
133 getrlimit (RLIMIT_DATA, &XXrlimit); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
134 #ifdef RLIM_INFINITY |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
135 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
136 #else |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
137 lim_data = XXrlimit.rlim_cur; /* soft limit */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
138 #endif |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
139 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
140 #endif /* BSD4_2 */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
141 #endif /* not WINDOWSNT */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
142 #endif /* not USG */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
143 #endif /* not NO_LIM_DATA */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
144 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
145 /* Verify amount of memory available, complaining if we're near the end. */ |
734 | 146 |
1416
60bb5e719468
(morecore_with_warning): Removed.
Roland McGrath <roland@gnu.org>
parents:
1400
diff
changeset
|
147 static void |
60bb5e719468
(morecore_with_warning): Removed.
Roland McGrath <roland@gnu.org>
parents:
1400
diff
changeset
|
148 check_memory_limits () |
734 | 149 { |
30062
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
150 #ifdef REL_ALLOC |
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
151 extern POINTER (*real_morecore) (); |
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
152 #endif |
1417
3a1576d52874
(check_memory_limits): Declare __morecore.
Roland McGrath <roland@gnu.org>
parents:
1416
diff
changeset
|
153 extern POINTER (*__morecore) (); |
3a1576d52874
(check_memory_limits): Declare __morecore.
Roland McGrath <roland@gnu.org>
parents:
1416
diff
changeset
|
154 |
30062
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
155 |
734 | 156 register POINTER cp; |
3935
cecc2b59e875
(check_memory_limits): Use unsigned long to hold memory size values.
Richard M. Stallman <rms@gnu.org>
parents:
1417
diff
changeset
|
157 unsigned long five_percent; |
cecc2b59e875
(check_memory_limits): Use unsigned long to hold memory size values.
Richard M. Stallman <rms@gnu.org>
parents:
1417
diff
changeset
|
158 unsigned long data_size; |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
159 enum warnlevel new_warnlevel; |
734 | 160 |
69019
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
161 #ifdef HAVE_GETRLIMIT |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
162 struct rlimit rlimit; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
163 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
164 getrlimit (RLIMIT_AS, &rlimit); |
69019
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
165 |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
166 if (RLIM_INFINITY == rlimit.rlim_max) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
167 return; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
168 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
169 /* This is a nonsensical case, but it happens -- rms. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
170 if (rlimit.rlim_cur > rlimit.rlim_max) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
171 return; |
69019
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
172 |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
173 five_percent = rlimit.rlim_max / 20; |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
174 data_size = rlimit.rlim_cur; |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
175 |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
176 #else /* not HAVE_GETRLIMIT */ |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
177 |
734 | 178 if (lim_data == 0) |
179 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
|
180 five_percent = lim_data / 20; |
734 | 181 |
182 /* Find current end of memory and issue warning if getting near max */ | |
30062
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
183 #ifdef REL_ALLOC |
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
184 if (real_morecore) |
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
185 cp = (char *) (*real_morecore) (0); |
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
186 else |
9a026d470bc9
(check_memory_limits) [REL_ALLOC]: Use real_morecore
Andrew Innes <andrewi@gnu.org>
parents:
24366
diff
changeset
|
187 #endif |
1416
60bb5e719468
(morecore_with_warning): Removed.
Roland McGrath <roland@gnu.org>
parents:
1400
diff
changeset
|
188 cp = (char *) (*__morecore) (0); |
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
189 data_size = (char *) cp - (char *) data_space_start; |
734 | 190 |
69019
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
191 #endif /* not HAVE_GETRLIMIT */ |
01f2a79bee28
[HAVE_GETRLIMIT]: Include sys/resource.h.
Richard M. Stallman <rms@gnu.org>
parents:
68651
diff
changeset
|
192 |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
193 if (!warn_function) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
194 return; |
734 | 195 |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
196 /* What level of warning does current memory usage demand? */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
197 if (data_size > five_percent * 19) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
198 new_warnlevel = warned_95; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
199 else if (data_size > five_percent * 17) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
200 new_warnlevel = warned_85; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
201 else if (data_size > five_percent * 15) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
202 new_warnlevel = warned_75; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
203 else |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
204 new_warnlevel = not_warned; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
205 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
206 /* If we have gone up a level, give the appropriate warning. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
207 if (new_warnlevel > warnlevel || new_warnlevel == warned_95) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
208 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
209 warnlevel = new_warnlevel; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
210 switch (warnlevel) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
211 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
212 case warned_75: |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
213 (*warn_function) ("Warning: past 75% of memory limit"); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
214 break; |
734 | 215 |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
216 case warned_85: |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
217 (*warn_function) ("Warning: past 85% of memory limit"); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
218 break; |
734 | 219 |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
220 case warned_95: |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
221 (*warn_function) ("Warning: past 95% of memory limit"); |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
222 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
223 } |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
224 /* Handle going down in usage levels, with some hysteresis. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
225 else |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
226 { |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
227 /* If we go down below 70% full, issue another 75% warning |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
228 when we go up again. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
229 if (data_size < five_percent * 14) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
230 warnlevel = not_warned; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
231 /* If we go down below 80% full, issue another 85% warning |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
232 when we go up again. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
233 else if (warnlevel > warned_75 && data_size < five_percent * 16) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
234 warnlevel = warned_75; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
235 /* If we go down below 90% full, issue another 95% warning |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
236 when we go up again. */ |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
237 else if (warnlevel > warned_85 && data_size < five_percent * 18) |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
238 warnlevel = warned_85; |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
239 } |
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
240 |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
241 if (EXCEEDS_LISP_PTR (cp)) |
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
242 (*warn_function) ("Warning: memory in use exceeds lisp pointer size"); |
734 | 243 } |
69390
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
244 |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
245 /* Enable memory usage warnings. |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
246 START says where the end of pure storage is. |
7e58bc915ffe
(get_lim_data, lim_data, data_space_start): Moved from mem-limits.h.
Richard M. Stallman <rms@gnu.org>
parents:
69019
diff
changeset
|
247 WARNFUN specifies the function to call to issue a warning. */ |
734 | 248 |
249 void | |
1392
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
250 memory_warnings (start, warnfun) |
734 | 251 POINTER start; |
252 void (*warnfun) (); | |
253 { | |
1416
60bb5e719468
(morecore_with_warning): Removed.
Roland McGrath <roland@gnu.org>
parents:
1400
diff
changeset
|
254 extern void (* __after_morecore_hook) (); /* From gmalloc.c */ |
734 | 255 |
256 if (start) | |
257 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
|
258 else |
ad64a94cd81c
(morecore_with_warning): Reduce warnlevel when usage drops far enough.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
259 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
|
260 |
1400
af08281c0cbe
(warnfunction): Renamed to warn_function (was used inconsistently).
Roland McGrath <roland@gnu.org>
parents:
1398
diff
changeset
|
261 warn_function = warnfun; |
1416
60bb5e719468
(morecore_with_warning): Removed.
Roland McGrath <roland@gnu.org>
parents:
1400
diff
changeset
|
262 __after_morecore_hook = check_memory_limits; |
24366
274b79aeb3b7
(memory_warnings) [WINDOWSNT]: Reset lim_data on each
Andrew Innes <andrewi@gnu.org>
parents:
14186
diff
changeset
|
263 |
274b79aeb3b7
(memory_warnings) [WINDOWSNT]: Reset lim_data on each
Andrew Innes <andrewi@gnu.org>
parents:
14186
diff
changeset
|
264 /* Force data limit to be recalculated on each run. */ |
274b79aeb3b7
(memory_warnings) [WINDOWSNT]: Reset lim_data on each
Andrew Innes <andrewi@gnu.org>
parents:
14186
diff
changeset
|
265 lim_data = 0; |
734 | 266 } |
52401 | 267 |
268 /* arch-tag: eab04eda-1f69-447a-8d9f-95f0a3983ca5 | |
269 (do not change this comment) */ |