Sync usage with man page.
[netbsd-mini2440.git] / gnu / lib / libmalloc / mem-limits.h
blob074831292de087bc8929b9b641c6a6ae03ef6e7d
1 /* Includes for memory limit warnings.
2 Copyright (C) 1990, 1993 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If
19 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
20 Cambridge, MA 02139, USA. */
22 #if defined(__osf__) && (defined(__mips) || defined(mips))
23 #include <sys/time.h>
24 #include <sys/resource.h>
25 #endif
27 #if defined(__bsdi__) || defined(__NetBSD__)
28 #define BSD4_2
29 #endif
31 #ifndef BSD4_2
32 #ifndef USG
33 #include <sys/vlimit.h>
34 #endif /* not USG */
35 #else /* if BSD4_2 */
36 #include <sys/time.h>
37 #include <sys/resource.h>
38 #endif /* BSD4_2 */
40 #ifdef emacs
41 /* The important properties of this type are that 1) it's a pointer, and
42 2) arithmetic on it should work as if the size of the object pointed
43 to has a size of 1. */
44 #ifdef __STDC__
45 typedef void *POINTER;
46 #else
47 typedef char *POINTER;
48 #endif
50 typedef unsigned long SIZE;
52 #ifdef NULL
53 #undef NULL
54 #endif
55 #define NULL ((POINTER) 0)
57 extern POINTER start_of_data ();
58 #ifdef DATA_SEG_BITS
59 #define EXCEEDS_LISP_PTR(ptr) \
60 (((unsigned int) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
61 #else
62 #define EXCEEDS_LISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS)
63 #endif
65 #ifdef BSD
66 #ifndef DATA_SEG_BITS
67 extern char etext;
68 #define start_of_data() &etext
69 #endif
70 #endif
72 #else /* Not emacs */
73 extern char etext;
74 #define start_of_data() &etext
75 #endif /* Not emacs */
79 /* start of data space; can be changed by calling malloc_init */
80 static POINTER data_space_start;
82 /* Number of bytes of writable memory we can expect to be able to get */
83 static unsigned int lim_data;
85 #ifdef USG
87 static void
88 get_lim_data ()
90 extern long ulimit ();
92 lim_data = -1;
94 /* Use the ulimit call, if we seem to have it. */
95 #if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX)
96 lim_data = ulimit (3, 0);
97 #endif
99 /* If that didn't work, just use the macro's value. */
100 #ifdef ULIMIT_BREAK_VALUE
101 if (lim_data == -1)
102 lim_data = ULIMIT_BREAK_VALUE;
103 #endif
105 lim_data -= (long) data_space_start;
108 #else /* not USG */
109 #if !defined(BSD4_2) && !defined(__osf__)
111 static void
112 get_lim_data ()
114 lim_data = vlimit (LIM_DATA, -1);
117 #else /* BSD4_2 */
119 static void
120 get_lim_data ()
122 struct rlimit XXrlimit;
124 getrlimit (RLIMIT_DATA, &XXrlimit);
125 #ifdef RLIM_INFINITY
126 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
127 #else
128 lim_data = XXrlimit.rlim_cur; /* soft limit */
129 #endif
131 #endif /* BSD4_2 */
132 #endif /* not USG */