Mercurial > hg > xemacs-beta
annotate src/mem-limits.h @ 5475:248176c74e6b
Merge with trunk.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Sat, 23 Apr 2011 23:47:13 +0200 |
parents | 308d34e9f07d |
children | e2fae7783046 |
rev | line source |
---|---|
428 | 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 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
6 XEmacs is free software: you can redistribute it and/or modify it |
428 | 7 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
8 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
9 option) any later version. |
428 | 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 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
2263
diff
changeset
|
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 18 |
19 /* Synched up with: FSF 19.30. */ | |
20 | |
2263 | 21 /* Subsequently cleaned up and reorganised, made to use configure. */ |
428 | 22 |
440 | 23 #ifndef INCLUDED_mem_limits_h_ |
24 #define INCLUDED_mem_limits_h_ | |
428 | 25 |
26 #ifdef HAVE_CONFIG_H | |
27 #include <config.h> | |
28 #endif | |
29 | |
30 #ifdef HAVE_ULIMIT_H | |
31 #include <ulimit.h> | |
32 #endif | |
33 | |
2263 | 34 #ifdef HAVE_SYS_RESOURCE_H |
35 /* Some systems need either sys/types.h or sys/time.h before <sys/resource.h>. */ | |
428 | 36 #include <sys/types.h> |
2263 | 37 #include <sys/time.h> |
38 #include <sys/resource.h> | |
39 #endif | |
40 | |
41 #ifdef HAVE_SYS_VLIMIT_H | |
42 #include <sys/vlimit.h> | |
43 #endif | |
428 | 44 |
45 #ifdef _LIBC | |
46 | |
47 /* Old Linux startup code won't define __data_start. */ | |
48 extern int etext, __data_start; weak_symbol (__data_start) | |
49 #define start_of_data() (&__data_start ?: &etext) | |
50 | |
51 #else /* not GNU libc */ | |
52 | |
53 #ifdef emacs | |
54 typedef void *POINTER; | |
55 | |
442 | 56 #ifndef CYGWIN |
428 | 57 typedef unsigned long SIZE; |
58 #endif | |
59 | |
60 extern POINTER start_of_data (void); | |
61 #define EXCEEDS_LISP_PTR(ptr) 0 | |
62 | |
63 #ifdef BSD | |
64 extern int etext; | |
65 #define start_of_data() &etext | |
66 #endif | |
67 | |
68 #else /* not emacs */ | |
69 extern char etext; | |
70 #define start_of_data() &etext | |
71 #endif /* not emacs */ | |
72 | |
73 #endif /* not _LIBC */ | |
74 | |
75 | |
76 | |
77 /* start of data space; can be changed by calling malloc_init */ | |
78 static POINTER data_space_start; | |
79 | |
80 /* Number of bytes of writable memory we can expect to be able to get */ | |
2132 | 81 extern unsigned long lim_data; |
428 | 82 |
2263 | 83 /* The implementation of get_lim_data() is very machine dependent. */ |
84 | |
442 | 85 #if defined (HEAP_IN_DATA) && !defined(PDUMP) |
428 | 86 extern unsigned long static_heap_size; |
1632 | 87 extern MODULE_API int initialized; |
2263 | 88 |
428 | 89 static void |
90 get_lim_data (void) | |
91 { | |
92 if (!initialized) | |
93 { | |
2132 | 94 lim_data = (unsigned long) -1; /* static_heap_size; */ |
428 | 95 } |
96 else | |
97 { | |
2132 | 98 lim_data = (unsigned long) -1; |
428 | 99 } |
100 } | |
2263 | 101 |
102 #elif defined(NO_LIM_DATA) | |
103 | |
428 | 104 static void |
105 get_lim_data (void) | |
106 { | |
2132 | 107 lim_data = (unsigned long) -1; |
428 | 108 } |
2263 | 109 |
110 #elif defined(HAVE_GETRLIMIT) | |
111 | |
112 static void | |
113 get_lim_data (void) | |
114 { | |
115 struct rlimit XXrlimit; | |
428 | 116 |
2263 | 117 getrlimit (RLIMIT_DATA, &XXrlimit); |
118 #ifdef RLIM_INFINITY | |
119 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ | |
120 #else | |
121 lim_data = XXrlimit.rlim_cur; /* soft limit */ | |
122 #endif | |
123 } | |
124 | |
125 #elif defined(HAVE_ULIMIT) | |
428 | 126 |
127 static void | |
128 get_lim_data (void) | |
129 { | |
2132 | 130 lim_data = (unsigned long) -1; |
428 | 131 |
132 /* Use the ulimit call, if we seem to have it. */ | |
2132 | 133 #if !defined (ULIMIT_BREAK_VALUE) |
428 | 134 lim_data = ulimit (3, 0); |
135 #endif | |
136 | |
137 /* If that didn't work, just use the macro's value. */ | |
138 #ifdef ULIMIT_BREAK_VALUE | |
2132 | 139 if (lim_data == (unsigned long) -1) |
428 | 140 lim_data = ULIMIT_BREAK_VALUE; |
141 #endif | |
142 | |
143 lim_data -= (long) data_space_start; | |
144 } | |
145 | |
2263 | 146 #elif defined(WIN32_NATIVE) |
428 | 147 |
148 static void | |
149 get_lim_data (void) | |
150 { | |
151 extern unsigned long data_region_size; | |
152 lim_data = data_region_size; | |
153 } | |
154 | |
2263 | 155 #elif defined(HAVE_VLIMIT) |
428 | 156 |
157 static void | |
158 get_lim_data (void) | |
159 { | |
160 lim_data = vlimit (LIM_DATA, -1); | |
161 } | |
162 | |
163 #else | |
2263 | 164 #error Cannot determine an implementation of get_lim_data(). |
165 #endif /* not HAVE_VLIMIT */ | |
428 | 166 |
440 | 167 #endif /* INCLUDED_mem_limits_h_ */ |