; Add entry to MAINTAINERS
[emacs.git] / src / puresize.h
blobfb9d934cad58a23431232e22b500986271d2b292
1 /* How much read-only Lisp storage a dumped Emacs needs.
2 Copyright (C) 1993, 2001-2016 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
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 3 of the License, or (at
9 your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef EMACS_PURESIZE_H
20 #define EMACS_PURESIZE_H
22 #include "lisp.h"
24 INLINE_HEADER_BEGIN
26 /* Define PURESIZE, the number of bytes of pure Lisp code to leave space for.
28 At one point, this was defined in config.h, meaning that changing
29 PURESIZE would make Make recompile all of Emacs. But only a few
30 files actually use PURESIZE, so we split it out to its own .h file.
32 Make sure to include this file after config.h, since that tells us
33 whether we are running X windows, which tells us how much pure
34 storage to allocate. */
36 /* First define a measure of the amount of data we have. */
38 /* A system configuration file may set this to request a certain extra
39 amount of storage. This is a lot more update-robust that defining
40 BASE_PURESIZE or even PURESIZE directly. */
41 #ifndef SYSTEM_PURESIZE_EXTRA
42 #define SYSTEM_PURESIZE_EXTRA 0
43 #endif
45 #ifndef SITELOAD_PURESIZE_EXTRA
46 #define SITELOAD_PURESIZE_EXTRA 0
47 #endif
49 #ifndef BASE_PURESIZE
50 #define BASE_PURESIZE (1800000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA)
51 #endif
53 /* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */
54 #ifndef PURESIZE_RATIO
55 #if EMACS_INT_MAX >> 31 != 0
56 #if PTRDIFF_MAX >> 31 != 0
57 #define PURESIZE_RATIO 10 / 6 /* Don't surround with `()'. */
58 #else
59 #define PURESIZE_RATIO 8 / 6 /* Don't surround with `()'. */
60 #endif
61 #else
62 #define PURESIZE_RATIO 1
63 #endif
64 #endif
66 #ifdef ENABLE_CHECKING
67 /* ENABLE_CHECKING somehow increases the purespace used, probably because
68 it tends to cause some macro arguments to be evaluated twice. This is
69 a bug, but it's difficult to track it down. */
70 #define PURESIZE_CHECKING_RATIO 12 / 10 /* Don't surround with `()'. */
71 #else
72 #define PURESIZE_CHECKING_RATIO 1
73 #endif
75 /* This is the actual size in bytes to allocate. */
76 #ifndef PURESIZE
77 #define PURESIZE (BASE_PURESIZE * PURESIZE_RATIO * PURESIZE_CHECKING_RATIO)
78 #endif
80 extern _Noreturn void pure_write_error (Lisp_Object);
82 extern EMACS_INT pure[];
84 /* The puresize_h_* macros are private to this include file. */
86 /* True if PTR is pure. */
88 #define puresize_h_PURE_P(ptr) \
89 ((uintptr_t) (ptr) - (uintptr_t) pure <= PURESIZE)
91 INLINE bool
92 PURE_P (void *ptr)
94 return puresize_h_PURE_P (ptr);
97 /* Signal an error if OBJ is pure. PTR is OBJ untagged. */
99 #define puresize_h_CHECK_IMPURE(obj, ptr) \
100 (PURE_P (ptr) ? pure_write_error (obj) : (void) 0)
102 INLINE void
103 CHECK_IMPURE (Lisp_Object obj, void *ptr)
105 puresize_h_CHECK_IMPURE (obj, ptr);
108 #if DEFINE_KEY_OPS_AS_MACROS
109 # define PURE_P(ptr) puresize_h_PURE_P (ptr)
110 # define CHECK_IMPURE(obj, ptr) puresize_h_CHECK_IMPURE (obj, ptr)
111 #endif
113 INLINE_HEADER_END
115 #endif /* EMACS_PURESIZE_H */