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
|
231
|
65 #ifndef __CYGWIN32__
|
0
|
66 #include <sys/vlimit.h>
|
231
|
67 #endif /* not __CYGWIN32__ */
|
0
|
68 #endif /* not WINDOWSNT */
|
|
69 #endif /* not MSDOS */
|
|
70 #endif /* not USG */
|
|
71 #else /* if BSD4_2 */
|
|
72 #include <sys/time.h>
|
|
73 #include <sys/resource.h>
|
|
74 #endif /* BSD4_2 */
|
|
75
|
|
76 #ifdef emacs
|
|
77 /* The important properties of this type are that 1) it's a pointer, and
|
|
78 2) arithmetic on it should work as if the size of the object pointed
|
|
79 to has a size of 1. */
|
|
80 #ifdef __STDC__
|
|
81 typedef void *POINTER;
|
|
82 #else
|
|
83 typedef char *POINTER;
|
|
84 #endif
|
|
85
|
231
|
86 #ifndef __CYGWIN32__
|
0
|
87 typedef unsigned long SIZE;
|
231
|
88 #endif
|
0
|
89
|
|
90 #ifdef NULL
|
|
91 #undef NULL
|
|
92 #endif
|
|
93 #define NULL ((POINTER) 0)
|
|
94
|
|
95 extern POINTER start_of_data ();
|
|
96 #ifdef DATA_SEG_BITS
|
|
97 #define EXCEEDS_LISP_PTR(ptr) \
|
|
98 (((EMACS_UINT) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
|
|
99 #else
|
|
100 #define EXCEEDS_LISP_PTR(ptr) ((EMACS_UINT) (ptr) >> VALBITS)
|
|
101 #endif
|
|
102
|
|
103 #ifdef BSD
|
|
104 #ifndef DATA_SEG_BITS
|
|
105 extern int etext;
|
|
106 #define start_of_data() &etext
|
|
107 #endif
|
|
108 #endif
|
|
109
|
|
110 #else /* not emacs */
|
|
111 extern char etext;
|
|
112 #define start_of_data() &etext
|
|
113 #endif /* not emacs */
|
|
114
|
|
115 #endif /* not _LIBC */
|
|
116
|
|
117
|
|
118
|
|
119 /* start of data space; can be changed by calling malloc_init */
|
|
120 static POINTER data_space_start;
|
|
121
|
|
122 /* Number of bytes of writable memory we can expect to be able to get */
|
|
123 extern unsigned int lim_data;
|
|
124
|
|
125 #ifdef NO_LIM_DATA
|
|
126 static void
|
74
|
127 get_lim_data (void)
|
0
|
128 {
|
|
129 lim_data = -1;
|
|
130 }
|
|
131 #else /* not NO_LIM_DATA */
|
|
132
|
|
133 #ifdef USG
|
|
134
|
|
135 static void
|
74
|
136 get_lim_data (void)
|
0
|
137 {
|
|
138 lim_data = -1;
|
|
139
|
|
140 /* Use the ulimit call, if we seem to have it. */
|
|
141 #if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX)
|
|
142 lim_data = ulimit (3, 0);
|
|
143 #endif
|
|
144
|
|
145 /* If that didn't work, just use the macro's value. */
|
|
146 #ifdef ULIMIT_BREAK_VALUE
|
|
147 if (lim_data == -1)
|
|
148 lim_data = ULIMIT_BREAK_VALUE;
|
|
149 #endif
|
|
150
|
|
151 lim_data -= (long) data_space_start;
|
|
152 }
|
|
153
|
|
154 #else /* not USG */
|
231
|
155 #if defined( WINDOWSNT ) || defined (__CYGWIN32__)
|
0
|
156
|
|
157 static void
|
74
|
158 get_lim_data (void)
|
0
|
159 {
|
|
160 extern unsigned long data_region_size;
|
|
161 lim_data = data_region_size;
|
|
162 }
|
|
163
|
|
164 #else
|
|
165 #if !defined (BSD4_2) && !defined (__osf__)
|
|
166
|
|
167 #ifdef MSDOS
|
|
168 void
|
74
|
169 get_lim_data (void)
|
0
|
170 {
|
|
171 _go32_dpmi_meminfo info;
|
|
172
|
|
173 _go32_dpmi_get_free_memory_information (&info);
|
|
174 lim_data = info.available_memory;
|
|
175 }
|
|
176 #else /* not MSDOS */
|
|
177 static void
|
74
|
178 get_lim_data (void)
|
0
|
179 {
|
|
180 lim_data = vlimit (LIM_DATA, -1);
|
|
181 }
|
|
182 #endif /* not MSDOS */
|
|
183
|
|
184 #else /* BSD4_2 */
|
|
185
|
|
186 static void
|
74
|
187 get_lim_data (void)
|
0
|
188 {
|
|
189 struct rlimit XXrlimit;
|
|
190
|
|
191 getrlimit (RLIMIT_DATA, &XXrlimit);
|
|
192 #ifdef RLIM_INFINITY
|
|
193 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
|
|
194 #else
|
|
195 lim_data = XXrlimit.rlim_cur; /* soft limit */
|
|
196 #endif
|
|
197 }
|
|
198 #endif /* BSD4_2 */
|
|
199 #endif /* not WINDOWSNT */
|
|
200 #endif /* not USG */
|
|
201 #endif /* not NO_LIM_DATA */
|
|
202
|
|
203 #endif /* _XEMACS_MEM_LIMITS_H_ */
|