Mercurial > emacs
annotate src/mem-limits.h @ 5020:94de08fd8a7c
(Fnext_single_property_change): Fix missing \n\.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 15 Nov 1993 06:41:45 +0000 |
| parents | 99e7b0227413 |
| children | 525a2027ec95 |
| rev | line source |
|---|---|
| 486 | 1 /* Includes for memory limit warnings. |
| 2961 | 2 Copyright (C) 1990, 1993 Free Software Foundation, Inc. |
| 486 | 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 | |
|
3370
2df248d76c58
[__bsdi__]: Define BSD4_2.
Richard M. Stallman <rms@gnu.org>
parents:
3055
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
| 486 | 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 | |
|
4229
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
20 #ifdef _LIBC |
|
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
21 |
|
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
22 #include <sys/resource.h> |
| 4254 | 23 #define BSD4_2 /* Tell code below to use getrlimit. */ |
|
4229
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
24 |
|
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
25 #else |
|
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
26 |
| 3055 | 27 #if defined(__osf__) && (defined(__mips) || defined(mips)) |
| 28 #include <sys/time.h> | |
| 29 #include <sys/resource.h> | |
| 30 #endif | |
| 31 | |
|
3370
2df248d76c58
[__bsdi__]: Define BSD4_2.
Richard M. Stallman <rms@gnu.org>
parents:
3055
diff
changeset
|
32 #ifdef __bsdi__ |
|
2df248d76c58
[__bsdi__]: Define BSD4_2.
Richard M. Stallman <rms@gnu.org>
parents:
3055
diff
changeset
|
33 #define BSD4_2 |
|
2df248d76c58
[__bsdi__]: Define BSD4_2.
Richard M. Stallman <rms@gnu.org>
parents:
3055
diff
changeset
|
34 #endif |
|
2df248d76c58
[__bsdi__]: Define BSD4_2.
Richard M. Stallman <rms@gnu.org>
parents:
3055
diff
changeset
|
35 |
| 486 | 36 #ifndef BSD4_2 |
| 37 #ifndef USG | |
| 38 #include <sys/vlimit.h> | |
| 39 #endif /* not USG */ | |
| 40 #else /* if BSD4_2 */ | |
| 41 #include <sys/time.h> | |
| 42 #include <sys/resource.h> | |
| 43 #endif /* BSD4_2 */ | |
| 44 | |
|
4229
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
45 #endif /* _LIBC */ |
|
edf8c9e14e02
[_LIBC]: Just include <sys/resource.h>, and skip hairy #ifdef mess.
Roland McGrath <roland@gnu.org>
parents:
3370
diff
changeset
|
46 |
|
1393
d2ae5897e43c
[!emacs]: Don't define POINTER, SIZE or NULL.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
47 #ifdef emacs |
| 575 | 48 /* The important properties of this type are that 1) it's a pointer, and |
| 49 2) arithmetic on it should work as if the size of the object pointed | |
| 50 to has a size of 1. */ | |
| 486 | 51 #ifdef __STDC__ |
| 52 typedef void *POINTER; | |
| 53 #else | |
| 54 typedef char *POINTER; | |
| 55 #endif | |
| 56 | |
| 57 typedef unsigned long SIZE; | |
| 58 | |
| 59 #ifdef NULL | |
| 60 #undef NULL | |
| 61 #endif | |
| 62 #define NULL ((POINTER) 0) | |
| 63 | |
| 64 extern POINTER start_of_data (); | |
|
1592
613783a3f00c
* mem-limits.h [DATA_SEG_BITS] (EXCEEDS_LISP_PTR): Remember to
Jim Blandy <jimb@redhat.com>
parents:
1450
diff
changeset
|
65 #ifdef DATA_SEG_BITS |
|
613783a3f00c
* mem-limits.h [DATA_SEG_BITS] (EXCEEDS_LISP_PTR): Remember to
Jim Blandy <jimb@redhat.com>
parents:
1450
diff
changeset
|
66 #define EXCEEDS_LISP_PTR(ptr) \ |
|
613783a3f00c
* mem-limits.h [DATA_SEG_BITS] (EXCEEDS_LISP_PTR): Remember to
Jim Blandy <jimb@redhat.com>
parents:
1450
diff
changeset
|
67 (((unsigned int) (ptr) & ~DATA_SEG_BITS) >> VALBITS) |
|
613783a3f00c
* mem-limits.h [DATA_SEG_BITS] (EXCEEDS_LISP_PTR): Remember to
Jim Blandy <jimb@redhat.com>
parents:
1450
diff
changeset
|
68 #else |
|
1393
d2ae5897e43c
[!emacs]: Don't define POINTER, SIZE or NULL.
Richard M. Stallman <rms@gnu.org>
parents:
734
diff
changeset
|
69 #define EXCEEDS_LISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS) |
|
1592
613783a3f00c
* mem-limits.h [DATA_SEG_BITS] (EXCEEDS_LISP_PTR): Remember to
Jim Blandy <jimb@redhat.com>
parents:
1450
diff
changeset
|
70 #endif |
| 486 | 71 |
| 72 #ifdef BSD | |
| 73 #ifndef DATA_SEG_BITS | |
| 734 | 74 extern char etext; |
| 486 | 75 #define start_of_data() &etext |
| 76 #endif | |
| 77 #endif | |
| 78 | |
| 79 #else /* Not emacs */ | |
| 734 | 80 extern char etext; |
| 486 | 81 #define start_of_data() &etext |
| 82 #endif /* Not emacs */ | |
| 83 | |
| 84 | |
| 85 | |
| 86 /* start of data space; can be changed by calling malloc_init */ | |
| 87 static POINTER data_space_start; | |
| 88 | |
| 89 /* Number of bytes of writable memory we can expect to be able to get */ | |
| 90 static unsigned int lim_data; | |
| 91 | |
| 92 #ifdef USG | |
| 93 | |
|
1450
a321ed0fa3ae
(get_lim_data): Make it static.
Richard M. Stallman <rms@gnu.org>
parents:
1399
diff
changeset
|
94 static void |
| 486 | 95 get_lim_data () |
| 96 { | |
| 97 extern long ulimit (); | |
|
2917
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
98 |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
99 lim_data = -1; |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
100 |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
101 /* Use the ulimit call, if we seem to have it. */ |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
102 #if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX) |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
103 lim_data = ulimit (3, 0); |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
104 #endif |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
105 |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
106 /* If that didn't work, just use the macro's value. */ |
| 486 | 107 #ifdef ULIMIT_BREAK_VALUE |
|
2917
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
108 if (lim_data == -1) |
|
725698689fbd
Some more changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
1592
diff
changeset
|
109 lim_data = ULIMIT_BREAK_VALUE; |
| 486 | 110 #endif |
| 111 | |
| 112 lim_data -= (long) data_space_start; | |
| 113 } | |
| 114 | |
| 115 #else /* not USG */ | |
| 3055 | 116 #if !defined(BSD4_2) && !defined(__osf__) |
| 486 | 117 |
|
1450
a321ed0fa3ae
(get_lim_data): Make it static.
Richard M. Stallman <rms@gnu.org>
parents:
1399
diff
changeset
|
118 static void |
| 486 | 119 get_lim_data () |
| 120 { | |
| 121 lim_data = vlimit (LIM_DATA, -1); | |
| 122 } | |
| 123 | |
| 124 #else /* BSD4_2 */ | |
| 125 | |
|
1450
a321ed0fa3ae
(get_lim_data): Make it static.
Richard M. Stallman <rms@gnu.org>
parents:
1399
diff
changeset
|
126 static void |
| 486 | 127 get_lim_data () |
| 128 { | |
| 129 struct rlimit XXrlimit; | |
| 130 | |
| 131 getrlimit (RLIMIT_DATA, &XXrlimit); | |
| 132 #ifdef RLIM_INFINITY | |
| 133 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */ | |
| 134 #else | |
| 135 lim_data = XXrlimit.rlim_cur; /* soft limit */ | |
| 136 #endif | |
| 137 } | |
| 138 #endif /* BSD4_2 */ | |
| 139 #endif /* not USG */ |
