annotate src/mem-limits.h @ 169:15872534500d r20-3b11

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