comparison src/mem-limits.h @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
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
26 #ifdef MSDOS
27 #include <dpmi.h>
28 #endif
29
30 /* Some systems need this before <sys/resource.h>. */
31 #include <sys/types.h>
32
33 #ifdef _LIBC
34
35 #include <sys/resource.h>
36 #define BSD4_2 /* Tell code below to use getrlimit. */
37
38 /* Old Linux startup code won't define __data_start. */
39 extern int etext, __data_start; weak_symbol (__data_start)
40 #define start_of_data() (&__data_start ?: &etext)
41
42 #else /* not _LIBC */
43
44 #if defined (__osf__) && (defined (__mips) || defined (mips) || defined (__alpha))
45 #include <sys/time.h>
46 #include <sys/resource.h>
47 #endif
48
49 #if defined(__bsdi__) || defined(__NetBSD__)
50 #define BSD4_2
51 #endif
52
53 #ifndef BSD4_2
54 #ifndef USG
55 #ifndef MSDOS
56 #ifndef WINDOWSNT
57 #include <sys/vlimit.h>
58 #endif /* not WINDOWSNT */
59 #endif /* not MSDOS */
60 #endif /* not USG */
61 #else /* if BSD4_2 */
62 #include <sys/time.h>
63 #include <sys/resource.h>
64 #endif /* BSD4_2 */
65
66 #ifdef emacs
67 /* The important properties of this type are that 1) it's a pointer, and
68 2) arithmetic on it should work as if the size of the object pointed
69 to has a size of 1. */
70 #ifdef __STDC__
71 typedef void *POINTER;
72 #else
73 typedef char *POINTER;
74 #endif
75
76 typedef unsigned long SIZE;
77
78 #ifdef NULL
79 #undef NULL
80 #endif
81 #define NULL ((POINTER) 0)
82
83 extern POINTER start_of_data ();
84 #ifdef DATA_SEG_BITS
85 #define EXCEEDS_LISP_PTR(ptr) \
86 (((EMACS_UINT) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
87 #else
88 #define EXCEEDS_LISP_PTR(ptr) ((EMACS_UINT) (ptr) >> VALBITS)
89 #endif
90
91 #ifdef BSD
92 #ifndef DATA_SEG_BITS
93 extern int etext;
94 #define start_of_data() &etext
95 #endif
96 #endif
97
98 #else /* not emacs */
99 extern char etext;
100 #define start_of_data() &etext
101 #endif /* not emacs */
102
103 #endif /* not _LIBC */
104
105
106
107 /* start of data space; can be changed by calling malloc_init */
108 static POINTER data_space_start;
109
110 /* Number of bytes of writable memory we can expect to be able to get */
111 extern unsigned int lim_data;
112
113 #ifdef NO_LIM_DATA
114 static void
115 get_lim_data ()
116 {
117 lim_data = -1;
118 }
119 #else /* not NO_LIM_DATA */
120
121 #ifdef USG
122
123 static void
124 get_lim_data ()
125 {
126 extern long ulimit ();
127
128 lim_data = -1;
129
130 /* Use the ulimit call, if we seem to have it. */
131 #if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX)
132 lim_data = ulimit (3, 0);
133 #endif
134
135 /* If that didn't work, just use the macro's value. */
136 #ifdef ULIMIT_BREAK_VALUE
137 if (lim_data == -1)
138 lim_data = ULIMIT_BREAK_VALUE;
139 #endif
140
141 lim_data -= (long) data_space_start;
142 }
143
144 #else /* not USG */
145 #ifdef WINDOWSNT
146
147 static void
148 get_lim_data ()
149 {
150 extern unsigned long data_region_size;
151 lim_data = data_region_size;
152 }
153
154 #else
155 #if !defined (BSD4_2) && !defined (__osf__)
156
157 #ifdef MSDOS
158 void
159 get_lim_data ()
160 {
161 _go32_dpmi_meminfo info;
162
163 _go32_dpmi_get_free_memory_information (&info);
164 lim_data = info.available_memory;
165 }
166 #else /* not MSDOS */
167 static void
168 get_lim_data ()
169 {
170 lim_data = vlimit (LIM_DATA, -1);
171 }
172 #endif /* not MSDOS */
173
174 #else /* BSD4_2 */
175
176 static void
177 get_lim_data ()
178 {
179 struct rlimit XXrlimit;
180
181 getrlimit (RLIMIT_DATA, &XXrlimit);
182 #ifdef RLIM_INFINITY
183 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
184 #else
185 lim_data = XXrlimit.rlim_cur; /* soft limit */
186 #endif
187 }
188 #endif /* BSD4_2 */
189 #endif /* not WINDOWSNT */
190 #endif /* not USG */
191 #endif /* not NO_LIM_DATA */
192
193 #endif /* _XEMACS_MEM_LIMITS_H_ */