annotate src/mem-limits.h @ 5927:b58b74274fa2 cygwin

changes from long ago, never committed...
author Henry Thompson <ht@markup.co.uk>
date Wed, 15 Dec 2021 19:02:33 +0000
parents 308d34e9f07d
children e2fae7783046
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Includes for memory limit warnings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1990, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 /* Synched up with: FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
21 /* Subsequently cleaned up and reorganised, made to use configure. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
23 #ifndef INCLUDED_mem_limits_h_
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
24 #define INCLUDED_mem_limits_h_
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #ifdef HAVE_ULIMIT_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include <ulimit.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
34 #ifdef HAVE_SYS_RESOURCE_H
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
35 /* Some systems need either sys/types.h or sys/time.h before <sys/resource.h>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include <sys/types.h>
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
37 #include <sys/time.h>
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
38 #include <sys/resource.h>
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
39 #endif
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
40
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
41 #ifdef HAVE_SYS_VLIMIT_H
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
42 #include <sys/vlimit.h>
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
43 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #ifdef _LIBC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 /* Old Linux startup code won't define __data_start. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 extern int etext, __data_start; weak_symbol (__data_start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #define start_of_data() (&__data_start ?: &etext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #else /* not GNU libc */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 #ifdef emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 typedef void *POINTER;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
56 #ifndef CYGWIN
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 typedef unsigned long SIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 extern POINTER start_of_data (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #define EXCEEDS_LISP_PTR(ptr) 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #ifdef BSD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 extern int etext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #define start_of_data() &etext
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 #else /* not emacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 extern char etext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 #define start_of_data() &etext
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 #endif /* not emacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 #endif /* not _LIBC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 /* start of data space; can be changed by calling malloc_init */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 static POINTER data_space_start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 /* Number of bytes of writable memory we can expect to be able to get */
2132
34ca43a57692 [xemacs-hg @ 2004-06-16 12:01:17 by malcolmp]
malcolmp
parents: 1632
diff changeset
81 extern unsigned long lim_data;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
83 /* The implementation of get_lim_data() is very machine dependent. */
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
84
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
85 #if defined (HEAP_IN_DATA) && !defined(PDUMP)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 extern unsigned long static_heap_size;
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1204
diff changeset
87 extern MODULE_API int initialized;
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
88
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 get_lim_data (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 if (!initialized)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 {
2132
34ca43a57692 [xemacs-hg @ 2004-06-16 12:01:17 by malcolmp]
malcolmp
parents: 1632
diff changeset
94 lim_data = (unsigned long) -1; /* static_heap_size; */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 {
2132
34ca43a57692 [xemacs-hg @ 2004-06-16 12:01:17 by malcolmp]
malcolmp
parents: 1632
diff changeset
98 lim_data = (unsigned long) -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 }
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
101
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
102 #elif defined(NO_LIM_DATA)
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
103
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 get_lim_data (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 {
2132
34ca43a57692 [xemacs-hg @ 2004-06-16 12:01:17 by malcolmp]
malcolmp
parents: 1632
diff changeset
107 lim_data = (unsigned long) -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 }
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
109
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
110 #elif defined(HAVE_GETRLIMIT)
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
111
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
112 static void
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
113 get_lim_data (void)
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
114 {
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
115 struct rlimit XXrlimit;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
117 getrlimit (RLIMIT_DATA, &XXrlimit);
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
118 #ifdef RLIM_INFINITY
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
119 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
120 #else
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
121 lim_data = XXrlimit.rlim_cur; /* soft limit */
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
122 #endif
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
123 }
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
124
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
125 #elif defined(HAVE_ULIMIT)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 get_lim_data (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 {
2132
34ca43a57692 [xemacs-hg @ 2004-06-16 12:01:17 by malcolmp]
malcolmp
parents: 1632
diff changeset
130 lim_data = (unsigned long) -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 /* Use the ulimit call, if we seem to have it. */
2132
34ca43a57692 [xemacs-hg @ 2004-06-16 12:01:17 by malcolmp]
malcolmp
parents: 1632
diff changeset
133 #if !defined (ULIMIT_BREAK_VALUE)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 lim_data = ulimit (3, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 /* If that didn't work, just use the macro's value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 #ifdef ULIMIT_BREAK_VALUE
2132
34ca43a57692 [xemacs-hg @ 2004-06-16 12:01:17 by malcolmp]
malcolmp
parents: 1632
diff changeset
139 if (lim_data == (unsigned long) -1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 lim_data = ULIMIT_BREAK_VALUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 lim_data -= (long) data_space_start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
146 #elif defined(WIN32_NATIVE)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 get_lim_data (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 extern unsigned long data_region_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 lim_data = data_region_size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
155 #elif defined(HAVE_VLIMIT)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 get_lim_data (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 lim_data = vlimit (LIM_DATA, -1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 #else
2263
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
164 #error Cannot determine an implementation of get_lim_data().
702b5727498a [xemacs-hg @ 2004-09-11 05:28:11 by malcolmp]
malcolmp
parents: 2132
diff changeset
165 #endif /* not HAVE_VLIMIT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
167 #endif /* INCLUDED_mem_limits_h_ */