[MSDOS]: Use text mode for all files but ".elc" files.
[bpt/emacs.git] / src / mem-limits.h
CommitLineData
9889c728 1/* Includes for memory limit warnings.
c6c5df7f 2 Copyright (C) 1990, 1993 Free Software Foundation, Inc.
9889c728
JB
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
cd1168e1 8the Free Software Foundation; either version 2, or (at your option)
9889c728
JB
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
b1814de2
RM
20#ifdef _LIBC
21
22#include <sys/resource.h>
ab8fb193 23#define BSD4_2 /* Tell code below to use getrlimit. */
b1814de2
RM
24
25#else
26
c027d070
JB
27#if defined(__osf__) && (defined(__mips) || defined(mips))
28#include <sys/time.h>
29#include <sys/resource.h>
30#endif
31
cd1168e1
RS
32#ifdef __bsdi__
33#define BSD4_2
34#endif
35
9889c728
JB
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
b1814de2
RM
45#endif /* _LIBC */
46
6fb48933 47#ifdef emacs
5399ec5d
JB
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. */
9889c728
JB
51#ifdef __STDC__
52typedef void *POINTER;
53#else
54typedef char *POINTER;
55#endif
56
57typedef unsigned long SIZE;
58
59#ifdef NULL
60#undef NULL
61#endif
62#define NULL ((POINTER) 0)
63
9889c728 64extern POINTER start_of_data ();
27050994
JB
65#ifdef DATA_SEG_BITS
66#define EXCEEDS_LISP_PTR(ptr) \
67 (((unsigned int) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
68#else
6fb48933 69#define EXCEEDS_LISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS)
27050994 70#endif
9889c728
JB
71
72#ifdef BSD
73#ifndef DATA_SEG_BITS
94d7c01a 74extern char etext;
9889c728
JB
75#define start_of_data() &etext
76#endif
77#endif
78
79#else /* Not emacs */
94d7c01a 80extern char etext;
9889c728
JB
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 */
87static POINTER data_space_start;
88
89/* Number of bytes of writable memory we can expect to be able to get */
90static unsigned int lim_data;
91
9889c728
JB
92#ifdef USG
93
c52713b1 94static void
9889c728
JB
95get_lim_data ()
96{
97 extern long ulimit ();
161aa2f8
JB
98
99 lim_data = -1;
100
101 /* Use the ulimit call, if we seem to have it. */
102#if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX)
9889c728
JB
103 lim_data = ulimit (3, 0);
104#endif
105
161aa2f8
JB
106 /* If that didn't work, just use the macro's value. */
107#ifdef ULIMIT_BREAK_VALUE
108 if (lim_data == -1)
109 lim_data = ULIMIT_BREAK_VALUE;
110#endif
111
9889c728
JB
112 lim_data -= (long) data_space_start;
113}
114
115#else /* not USG */
c027d070 116#if !defined(BSD4_2) && !defined(__osf__)
9889c728 117
c52713b1 118static void
9889c728
JB
119get_lim_data ()
120{
121 lim_data = vlimit (LIM_DATA, -1);
122}
123
124#else /* BSD4_2 */
125
c52713b1 126static void
9889c728
JB
127get_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 */