0
|
1 /* Includes for memory limit warnings.
|
|
2 Copyright (C) 1990, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: FSF 19.30. */
|
|
22
|
|
23 #ifndef _XEMACS_MEM_LIMITS_H_
|
|
24 #define _XEMACS_MEM_LIMITS_H_
|
|
25
|
169
|
26 #ifdef HAVE_CONFIG_H
|
|
27 #include <config.h>
|
|
28 #endif
|
|
29
|
|
30 #ifdef HAVE_ULIMIT_H
|
|
31 #include <ulimit.h>
|
|
32 #endif
|
|
33
|
0
|
34 #ifdef MSDOS
|
|
35 #include <dpmi.h>
|
|
36 #endif
|
|
37
|
|
38 /* Some systems need this before <sys/resource.h>. */
|
|
39 #include <sys/types.h>
|
|
40
|
|
41 #ifdef _LIBC
|
|
42
|
|
43 #include <sys/resource.h>
|
|
44 #define BSD4_2 /* Tell code below to use getrlimit. */
|
|
45
|
|
46 /* Old Linux startup code won't define __data_start. */
|
|
47 extern int etext, __data_start; weak_symbol (__data_start)
|
|
48 #define start_of_data() (&__data_start ?: &etext)
|
|
49
|
|
50 #else /* not _LIBC */
|
|
51
|
|
52 #if defined (__osf__) && (defined (__mips) || defined (mips) || defined (__alpha))
|
|
53 #include <sys/time.h>
|
|
54 #include <sys/resource.h>
|
|
55 #endif
|
|
56
|
|
57 #if defined(__bsdi__) || defined(__NetBSD__)
|
|
58 #define BSD4_2
|
|
59 #endif
|
|
60
|
|
61 #ifndef BSD4_2
|
|
62 #ifndef USG
|
|
63 #ifndef MSDOS
|
|
64 #ifndef WINDOWSNT
|
|
65 #include <sys/vlimit.h>
|
|
66 #endif /* not WINDOWSNT */
|
|
67 #endif /* not MSDOS */
|
|
68 #endif /* not USG */
|
|
69 #else /* if BSD4_2 */
|
|
70 #include <sys/time.h>
|
|
71 #include <sys/resource.h>
|
|
72 #endif /* BSD4_2 */
|
|
73
|
|
74 #ifdef emacs
|
|
75 /* The important properties of this type are that 1) it's a pointer, and
|
|
76 2) arithmetic on it should work as if the size of the object pointed
|
|
77 to has a size of 1. */
|
|
78 #ifdef __STDC__
|
|
79 typedef void *POINTER;
|
|
80 #else
|
|
81 typedef char *POINTER;
|
|
82 #endif
|
|
83
|
|
84 typedef unsigned long SIZE;
|
|
85
|
|
86 #ifdef NULL
|
|
87 #undef NULL
|
|
88 #endif
|
|
89 #define NULL ((POINTER) 0)
|
|
90
|
|
91 extern POINTER start_of_data ();
|
|
92 #ifdef DATA_SEG_BITS
|
|
93 #define EXCEEDS_LISP_PTR(ptr) \
|
|
94 (((EMACS_UINT) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
|
|
95 #else
|
|
96 #define EXCEEDS_LISP_PTR(ptr) ((EMACS_UINT) (ptr) >> VALBITS)
|
|
97 #endif
|
|
98
|
|
99 #ifdef BSD
|
|
100 #ifndef DATA_SEG_BITS
|
|
101 extern int etext;
|
|
102 #define start_of_data() &etext
|
|
103 #endif
|
|
104 #endif
|
|
105
|
|
106 #else /* not emacs */
|
|
107 extern char etext;
|
|
108 #define start_of_data() &etext
|
|
109 #endif /* not emacs */
|
|
110
|
|
111 #endif /* not _LIBC */
|
|
112
|
|
113
|
|
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 */
|
|
119 extern unsigned int lim_data;
|
|
120
|
|
121 #ifdef NO_LIM_DATA
|
|
122 static void
|
74
|
123 get_lim_data (void)
|
0
|
124 {
|
|
125 lim_data = -1;
|
|
126 }
|
|
127 #else /* not NO_LIM_DATA */
|
|
128
|
|
129 #ifdef USG
|
|
130
|
|
131 static void
|
74
|
132 get_lim_data (void)
|
0
|
133 {
|
|
134 lim_data = -1;
|
|
135
|
|
136 /* Use the ulimit call, if we seem to have it. */
|
|
137 #if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX)
|
|
138 lim_data = ulimit (3, 0);
|
|
139 #endif
|
|
140
|
|
141 /* If that didn't work, just use the macro's value. */
|
|
142 #ifdef ULIMIT_BREAK_VALUE
|
|
143 if (lim_data == -1)
|
|
144 lim_data = ULIMIT_BREAK_VALUE;
|
|
145 #endif
|
|
146
|
|
147 lim_data -= (long) data_space_start;
|
|
148 }
|
|
149
|
|
150 #else /* not USG */
|
|
151 #ifdef WINDOWSNT
|
|
152
|
|
153 static void
|
74
|
154 get_lim_data (void)
|
0
|
155 {
|
|
156 extern unsigned long data_region_size;
|
|
157 lim_data = data_region_size;
|
|
158 }
|
|
159
|
|
160 #else
|
|
161 #if !defined (BSD4_2) && !defined (__osf__)
|
|
162
|
|
163 #ifdef MSDOS
|
|
164 void
|
74
|
165 get_lim_data (void)
|
0
|
166 {
|
|
167 _go32_dpmi_meminfo info;
|
|
168
|
|
169 _go32_dpmi_get_free_memory_information (&info);
|
|
170 lim_data = info.available_memory;
|
|
171 }
|
|
172 #else /* not MSDOS */
|
|
173 static void
|
74
|
174 get_lim_data (void)
|
0
|
175 {
|
|
176 lim_data = vlimit (LIM_DATA, -1);
|
|
177 }
|
|
178 #endif /* not MSDOS */
|
|
179
|
|
180 #else /* BSD4_2 */
|
|
181
|
|
182 static void
|
74
|
183 get_lim_data (void)
|
0
|
184 {
|
|
185 struct rlimit XXrlimit;
|
|
186
|
|
187 getrlimit (RLIMIT_DATA, &XXrlimit);
|
|
188 #ifdef RLIM_INFINITY
|
|
189 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
|
|
190 #else
|
|
191 lim_data = XXrlimit.rlim_cur; /* soft limit */
|
|
192 #endif
|
|
193 }
|
|
194 #endif /* BSD4_2 */
|
|
195 #endif /* not WINDOWSNT */
|
|
196 #endif /* not USG */
|
|
197 #endif /* not NO_LIM_DATA */
|
|
198
|
|
199 #endif /* _XEMACS_MEM_LIMITS_H_ */
|