1 /* Includes for memory limit warnings.
2 Copyright (C) 1990, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
4 This file is part of XEmacs.
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
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
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. */
21 /* Synched up with: FSF 19.30. */
23 /* #### This ancient code really sucks.
24 configure should check for:
25 HAVE_SYS_RESOURCE_H, HAVE_ULIMIT_H, HAVE_GETRLIMIT, HAVE_ULIMIT,
26 and select action based on those values.
27 getrlimit() should be preferred to ulimit().
28 On Linux, ulimit() is deprecated and always returns -1. */
30 #ifndef INCLUDED_mem_limits_h_
31 #define INCLUDED_mem_limits_h_
41 /* Some systems need this before <sys/resource.h>. */
42 #include <sys/types.h>
46 #include <sys/resource.h>
47 #define BSD4_2 /* Tell code below to use getrlimit. */
49 /* Old Linux startup code won't define __data_start. */
50 extern int etext, __data_start; weak_symbol (__data_start)
51 #define start_of_data() (&__data_start ?: &etext)
53 #else /* not GNU libc */
55 #if defined (__osf__) && (defined (__mips) || defined (mips) || defined (__alpha))
57 #include <sys/resource.h>
60 #if defined(__bsdi__) || defined(__NetBSD__) || defined(__linux__) || defined(__OpenBSD__)
68 #include <sys/vlimit.h>
69 #endif /* not CYGWIN */
70 #endif /* not WIN32_NATIVE */
74 #include <sys/resource.h>
78 /* The important properties of this type are that 1) it's a pointer, and
79 2) arithmetic on it should work as if the size of the object pointed
80 to has a size of 1. */
82 typedef void *POINTER;
84 typedef char *POINTER;
88 typedef unsigned long SIZE;
91 extern POINTER start_of_data (void);
92 #define EXCEEDS_LISP_PTR(ptr) 0
96 #define start_of_data() &etext
101 #define start_of_data() &etext
102 #endif /* not emacs */
104 #endif /* not _LIBC */
108 /* start of data space; can be changed by calling malloc_init */
109 static POINTER data_space_start;
111 /* Number of bytes of writable memory we can expect to be able to get */
112 extern unsigned long lim_data;
114 #if defined (HEAP_IN_DATA) && !defined(PDUMP)
115 extern unsigned long static_heap_size;
116 extern int initialized;
122 lim_data = (unsigned long) -1; /* static_heap_size; */
126 lim_data = (unsigned long) -1;
134 lim_data = (unsigned long) -1;
136 #else /* not NO_LIM_DATA */
138 #if defined(USG) && !defined(LINUX)
143 lim_data = (unsigned long) -1;
145 /* Use the ulimit call, if we seem to have it. */
146 #if !defined (ULIMIT_BREAK_VALUE)
147 lim_data = ulimit (3, 0);
150 /* If that didn't work, just use the macro's value. */
151 #ifdef ULIMIT_BREAK_VALUE
152 if (lim_data == (unsigned long) -1)
153 lim_data = ULIMIT_BREAK_VALUE;
156 lim_data -= (long) data_space_start;
160 #if defined( WIN32_NATIVE )
165 extern unsigned long data_region_size;
166 lim_data = data_region_size;
170 #if !defined (BSD4_2) && !defined (__osf__) && !defined(LINUX)
175 lim_data = vlimit (LIM_DATA, -1);
183 struct rlimit XXrlimit;
185 getrlimit (RLIMIT_DATA, &XXrlimit);
187 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
189 lim_data = XXrlimit.rlim_cur; /* soft limit */
193 #endif /* not WIN32_NATIVE */
195 #endif /* not NO_LIM_DATA */
196 #endif /* not HEAP_IN_DATA */
198 #endif /* INCLUDED_mem_limits_h_ */