Merge chages made in Gnus trunk.
[emacs.git] / src / puresize.h
blob593eb3d717f1a3327c66b316ac395d6b073cba30
1 /* How much read-only Lisp storage a dumped Emacs needs.
2 Copyright (C) 1993, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs 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
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 /* Define PURESIZE, the number of bytes of pure Lisp code to leave space for.
22 At one point, this was defined in config.h, meaning that changing
23 PURESIZE would make Make recompile all of Emacs. But only a few
24 files actually use PURESIZE, so we split it out to its own .h file.
26 Make sure to include this file after config.h, since that tells us
27 whether we are running X windows, which tells us how much pure
28 storage to allocate. */
30 /* First define a measure of the amount of data we have. */
32 /* A system configuration file may set this to request a certain extra
33 amount of storage. This is a lot more update-robust that defining
34 BASE_PURESIZE or even PURESIZE directly. */
35 #ifndef SYSTEM_PURESIZE_EXTRA
36 #define SYSTEM_PURESIZE_EXTRA 0
37 #endif
39 #ifndef SITELOAD_PURESIZE_EXTRA
40 #define SITELOAD_PURESIZE_EXTRA 0
41 #endif
43 #ifndef BASE_PURESIZE
44 #define BASE_PURESIZE (1620000 + SYSTEM_PURESIZE_EXTRA + SITELOAD_PURESIZE_EXTRA)
45 #endif
47 /* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */
48 #ifndef PURESIZE_RATIO
49 #if BITS_PER_EMACS_INT > 32
50 #define PURESIZE_RATIO 10/6 /* Don't surround with `()'. */
51 #else
52 #define PURESIZE_RATIO 1
53 #endif
54 #endif
56 #ifdef ENABLE_CHECKING
57 /* ENABLE_CHECKING somehow increases the purespace used, probably because
58 it tends to cause some macro arguments to be evaluated twice. This is
59 a bug, but it's difficult to track it down. */
60 #define PURESIZE_CHECKING_RATIO 12/10 /* Don't surround with `()'. */
61 #else
62 #define PURESIZE_CHECKING_RATIO 1
63 #endif
65 /* This is the actual size in bytes to allocate. */
66 #ifndef PURESIZE
67 #define PURESIZE (BASE_PURESIZE * PURESIZE_RATIO * PURESIZE_CHECKING_RATIO)
68 #endif
70 /* Signal an error if OBJ is pure. */
71 #define CHECK_IMPURE(obj) \
72 { if (PURE_P (obj)) \
73 pure_write_error (); }
75 extern void pure_write_error (void) NO_RETURN;
77 /* Define PURE_P. */
79 #ifdef VIRT_ADDR_VARIES
80 /* For machines where text and data can go anywhere
81 in virtual memory. */
83 extern EMACS_INT pure[];
85 #define PURE_P(obj) \
86 ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE) \
87 && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure)
89 #else /* not VIRT_ADDR_VARIES */
90 /* When PNTR_COMPARISON_TYPE is not the default (unsigned int). */
92 extern char my_edata[];
94 #define PURE_P(obj) \
95 ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) my_edata)
97 #endif /* VIRT_ADDRESS_VARIES */