486
|
1 /* Includes for memory limit warnings.
|
64770
|
2 Copyright (C) 1990, 1993, 1994, 1995, 1996, 2002, 2003, 2004,
|
|
3 2005 Free Software Foundation, Inc.
|
486
|
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
|
3370
|
9 the Free Software Foundation; either version 2, or (at your option)
|
486
|
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. */
|
486
|
21
|
5497
|
22 #ifdef MSDOS
|
|
23 #include <dpmi.h>
|
46950
|
24 extern int etext;
|
5497
|
25 #endif
|
|
26
|
5547
|
27 /* Some systems need this before <sys/resource.h>. */
|
|
28 #include <sys/types.h>
|
|
29
|
4229
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
diff
changeset
|
30 #ifdef _LIBC
|
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
diff
changeset
|
31
|
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
diff
changeset
|
32 #include <sys/resource.h>
|
4254
|
33 #define BSD4_2 /* Tell code below to use getrlimit. */
|
4229
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
diff
changeset
|
34
|
13563
c011026c071d
[_LIBC] (start_of_data): Use weak ref to __data_start; use &etext if not
Roland McGrath <roland@gnu.org>
diff
changeset
|
35 /* Old Linux startup code won't define __data_start. */
|
15634
08bcd5d2c8ab
[_LIBC]: Use weak_extern instead of weak_symbol for __data_start.
Roland McGrath <roland@gnu.org>
diff
changeset
|
36 extern int etext, __data_start; weak_extern (__data_start)
|
13563
c011026c071d
[_LIBC] (start_of_data): Use weak ref to __data_start; use &etext if not
Roland McGrath <roland@gnu.org>
diff
changeset
|
37 #define start_of_data() (&__data_start ?: &etext)
|
12197
|
38
|
12216
|
39 #else /* not _LIBC */
|
4229
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
diff
changeset
|
40
|
51399
|
41 #ifdef HAVE_SYS_RESOURCE_H
|
|
42 # include <sys/time.h>
|
|
43 # include <sys/resource.h>
|
|
44 #else
|
|
45 # if HAVE_SYS_VLIMIT_H
|
|
46 # include <sys/vlimit.h> /* Obsolete, says glibc */
|
|
47 # endif
|
3055
|
48 #endif
|
|
49
|
3370
|
50 #ifdef __bsdi__
|
|
51 #define BSD4_2
|
|
52 #endif
|
|
53
|
49549
|
54 #ifdef CYGWIN
|
|
55 #define BSD4_2
|
|
56 #endif
|
|
57
|
486
|
58 #ifndef BSD4_2
|
|
59 #ifndef USG
|
5497
|
60 #ifndef MSDOS
|
9791
|
61 #ifndef WINDOWSNT
|
486
|
62 #include <sys/vlimit.h>
|
9791
|
63 #endif /* not WINDOWSNT */
|
5497
|
64 #endif /* not MSDOS */
|
486
|
65 #endif /* not USG */
|
|
66 #else /* if BSD4_2 */
|
|
67 #include <sys/time.h>
|
|
68 #include <sys/resource.h>
|
|
69 #endif /* BSD4_2 */
|
|
70
|
1393
|
71 #ifdef emacs
|
575
|
72 /* The important properties of this type are that 1) it's a pointer, and
|
|
73 2) arithmetic on it should work as if the size of the object pointed
|
|
74 to has a size of 1. */
|
28055
|
75 typedef POINTER_TYPE *POINTER;
|
486
|
76
|
|
77 typedef unsigned long SIZE;
|
|
78
|
|
79 #ifdef NULL
|
|
80 #undef NULL
|
|
81 #endif
|
|
82 #define NULL ((POINTER) 0)
|
|
83
|
|
84 extern POINTER start_of_data ();
|
55875
|
85 #if defined USE_LSB_TAG
|
|
86 #define EXCEEDS_LISP_PTR(ptr) 0
|
|
87 #elif defined DATA_SEG_BITS
|
1592
|
88 #define EXCEEDS_LISP_PTR(ptr) \
|
8830
|
89 (((EMACS_UINT) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
|
1592
|
90 #else
|
8830
|
91 #define EXCEEDS_LISP_PTR(ptr) ((EMACS_UINT) (ptr) >> VALBITS)
|
1592
|
92 #endif
|
486
|
93
|
46652
|
94 #ifdef DATA_START
|
|
95 #define start_of_data() ((char *)DATA_START)
|
|
96 #endif
|
|
97
|
16220
|
98 #ifdef BSD_SYSTEM
|
486
|
99 #ifndef DATA_SEG_BITS
|
46652
|
100 #ifndef DATA_START
|
734
|
101 extern char etext;
|
486
|
102 #define start_of_data() &etext
|
|
103 #endif
|
|
104 #endif
|
46652
|
105 #endif
|
486
|
106
|
13563
c011026c071d
[_LIBC] (start_of_data): Use weak ref to __data_start; use &etext if not
Roland McGrath <roland@gnu.org>
diff
changeset
|
107 #else /* not emacs */
|
734
|
108 extern char etext;
|
486
|
109 #define start_of_data() &etext
|
12216
|
110 #endif /* not emacs */
|
486
|
111
|
12216
|
112 #endif /* not _LIBC */
|
12197
|
113
|
486
|
114
|
|
115 /* start of data space; can be changed by calling malloc_init */
|
|
116 static POINTER data_space_start;
|
|
117
|
|
118 /* Number of bytes of writable memory we can expect to be able to get */
|
15643
|
119 static unsigned long lim_data;
|
486
|
120
|
7010
|
121 #ifdef NO_LIM_DATA
|
|
122 static void
|
|
123 get_lim_data ()
|
|
124 {
|
|
125 lim_data = -1;
|
|
126 }
|
|
127 #else /* not NO_LIM_DATA */
|
|
128
|
486
|
129 #ifdef USG
|
|
130
|
1450
|
131 static void
|
486
|
132 get_lim_data ()
|
|
133 {
|
|
134 extern long ulimit ();
|
2917
|
135
|
|
136 lim_data = -1;
|
|
137
|
|
138 /* Use the ulimit call, if we seem to have it. */
|
41969
|
139 #if !defined (ULIMIT_BREAK_VALUE) || defined (GNU_LINUX)
|
2917
|
140 lim_data = ulimit (3, 0);
|
|
141 #endif
|
|
142
|
|
143 /* If that didn't work, just use the macro's value. */
|
486
|
144 #ifdef ULIMIT_BREAK_VALUE
|
2917
|
145 if (lim_data == -1)
|
|
146 lim_data = ULIMIT_BREAK_VALUE;
|
486
|
147 #endif
|
|
148
|
|
149 lim_data -= (long) data_space_start;
|
|
150 }
|
|
151
|
|
152 #else /* not USG */
|
9791
|
153 #ifdef WINDOWSNT
|
|
154
|
|
155 static void
|
|
156 get_lim_data ()
|
|
157 {
|
24101
|
158 extern unsigned long reserved_heap_size;
|
|
159 lim_data = reserved_heap_size;
|
9791
|
160 }
|
|
161
|
|
162 #else
|
5497
|
163 #if !defined (BSD4_2) && !defined (__osf__)
|
486
|
164
|
5497
|
165 #ifdef MSDOS
|
|
166 void
|
|
167 get_lim_data ()
|
|
168 {
|
|
169 _go32_dpmi_meminfo info;
|
|
170
|
|
171 _go32_dpmi_get_free_memory_information (&info);
|
|
172 lim_data = info.available_memory;
|
|
173 }
|
|
174 #else /* not MSDOS */
|
1450
|
175 static void
|
486
|
176 get_lim_data ()
|
|
177 {
|
|
178 lim_data = vlimit (LIM_DATA, -1);
|
|
179 }
|
5497
|
180 #endif /* not MSDOS */
|
486
|
181
|
|
182 #else /* BSD4_2 */
|
|
183
|
1450
|
184 static void
|
486
|
185 get_lim_data ()
|
|
186 {
|
|
187 struct rlimit XXrlimit;
|
|
188
|
|
189 getrlimit (RLIMIT_DATA, &XXrlimit);
|
|
190 #ifdef RLIM_INFINITY
|
|
191 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
|
|
192 #else
|
|
193 lim_data = XXrlimit.rlim_cur; /* soft limit */
|
|
194 #endif
|
|
195 }
|
|
196 #endif /* BSD4_2 */
|
9791
|
197 #endif /* not WINDOWSNT */
|
486
|
198 #endif /* not USG */
|
7010
|
199 #endif /* not NO_LIM_DATA */
|
52401
|
200
|
|
201 /* arch-tag: fe39244e-e54f-4208-b7aa-02556f7841c5
|
|
202 (do not change this comment) */
|