486
|
1 /* Includes for memory limit warnings.
|
|
2 Copyright (C) 1990 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of GNU Emacs.
|
|
5
|
|
6 GNU Emacs is free software; you can redistribute it and/or modify
|
|
7 it under the terms of the GNU General Public License as published by
|
|
8 the Free Software Foundation; either version 1, or (at your option)
|
|
9 any later version.
|
|
10
|
|
11 GNU Emacs is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 GNU General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with GNU Emacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
19
|
|
20 #ifndef BSD4_2
|
|
21 #ifndef USG
|
|
22 #include <sys/vlimit.h>
|
|
23 #endif /* not USG */
|
|
24 #else /* if BSD4_2 */
|
|
25 #include <sys/time.h>
|
|
26 #include <sys/resource.h>
|
|
27 #endif /* BSD4_2 */
|
|
28
|
|
29 #ifdef __STDC__
|
|
30 typedef void *POINTER;
|
|
31 #else
|
|
32 typedef char *POINTER;
|
|
33 #endif
|
|
34
|
|
35 typedef unsigned long SIZE;
|
|
36
|
|
37 #ifdef NULL
|
|
38 #undef NULL
|
|
39 #endif
|
|
40 #define NULL ((POINTER) 0)
|
|
41
|
|
42 #ifdef emacs
|
|
43 extern POINTER start_of_data ();
|
|
44
|
|
45 #ifdef BSD
|
|
46 #ifndef DATA_SEG_BITS
|
|
47 #define start_of_data() &etext
|
|
48 #endif
|
|
49 #endif
|
|
50
|
|
51 #else /* Not emacs */
|
|
52 #define start_of_data() &etext
|
|
53 #endif /* Not emacs */
|
|
54
|
|
55
|
|
56
|
|
57 /* start of data space; can be changed by calling malloc_init */
|
|
58 static POINTER data_space_start;
|
|
59
|
|
60 /* Number of bytes of writable memory we can expect to be able to get */
|
|
61 static unsigned int lim_data;
|
|
62
|
|
63
|
|
64
|
|
65 #ifdef USG
|
|
66
|
|
67 get_lim_data ()
|
|
68 {
|
|
69 extern long ulimit ();
|
|
70
|
|
71 #ifdef ULIMIT_BREAK_VALUE
|
|
72 lim_data = ULIMIT_BREAK_VALUE;
|
|
73 #else
|
|
74 lim_data = ulimit (3, 0);
|
|
75 #endif
|
|
76
|
|
77 lim_data -= (long) data_space_start;
|
|
78 }
|
|
79
|
|
80 #else /* not USG */
|
|
81 #ifndef BSD4_2
|
|
82
|
|
83 get_lim_data ()
|
|
84 {
|
|
85 lim_data = vlimit (LIM_DATA, -1);
|
|
86 }
|
|
87
|
|
88 #else /* BSD4_2 */
|
|
89
|
|
90 get_lim_data ()
|
|
91 {
|
|
92 struct rlimit XXrlimit;
|
|
93
|
|
94 getrlimit (RLIMIT_DATA, &XXrlimit);
|
|
95 #ifdef RLIM_INFINITY
|
|
96 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
|
|
97 #else
|
|
98 lim_data = XXrlimit.rlim_cur; /* soft limit */
|
|
99 #endif
|
|
100 }
|
|
101 #endif /* BSD4_2 */
|
|
102 #endif /* not USG */
|