Subject: Restore correct Gnus newsgroup name after sending message
[emacs.git] / src / conf_post.h
blobe146b9bbe8a6f4d209fa41a364009d9526ef0e44
1 /* conf_post.h --- configure.ac includes this via AH_BOTTOM
3 Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2017 Free Software
4 Foundation, Inc.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or (at
11 your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 /* Put the code here rather than in configure.ac using AH_BOTTOM.
22 This way, the code does not get processed by autoheader. For
23 example, undefs here are not commented out.
25 To help make dependencies clearer elsewhere, this file typically
26 does not #include other files. The exceptions are first stdbool.h
27 because it is unlikely to interfere with configuration and bool is
28 such a core part of the C language, and second ms-w32.h (DOS_NT
29 only) because it historically was included here and changing that
30 would take some work. */
32 #include <stdbool.h>
34 #if defined DOS_NT && !defined DEFER_MS_W32_H
35 # include <ms-w32.h>
36 #endif
38 /* GNUC_PREREQ (V, W, X) is true if this is GNU C version V.W.X or later.
39 It can be used in a preprocessor expression. */
40 #ifndef __GNUC_MINOR__
41 # define GNUC_PREREQ(v, w, x) false
42 #elif ! defined __GNUC_PATCHLEVEL__
43 # define GNUC_PREREQ(v, w, x) \
44 ((v) < __GNUC__ + ((w) < __GNUC_MINOR__ + ((x) == 0))
45 #else
46 # define GNUC_PREREQ(v, w, x) \
47 ((v) < __GNUC__ + ((w) < __GNUC_MINOR__ + ((x) <= __GNUC_PATCHLEVEL__)))
48 #endif
50 /* The type of bool bitfields. Needed to compile Objective-C with
51 standard GCC. It was also needed to port to pre-C99 compilers,
52 although we don't care about that any more. */
53 #if NS_IMPL_GNUSTEP
54 typedef unsigned int bool_bf;
55 #else
56 typedef bool bool_bf;
57 #endif
59 /* Simulate __has_attribute on compilers that lack it. It is used only
60 on arguments like alloc_size that are handled in this simulation. */
61 #ifndef __has_attribute
62 # define __has_attribute(a) __has_attribute_##a
63 # define __has_attribute_alloc_size GNUC_PREREQ (4, 3, 0)
64 # define __has_attribute_cleanup GNUC_PREREQ (3, 4, 0)
65 # define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0)
66 # define __has_attribute_no_address_safety_analysis false
67 # define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0)
68 #endif
70 /* Simulate __has_builtin on compilers that lack it. It is used only
71 on arguments like __builtin_assume_aligned that are handled in this
72 simulation. */
73 #ifndef __has_builtin
74 # define __has_builtin(a) __has_builtin_##a
75 # define __has_builtin___builtin_assume_aligned GNUC_PREREQ (4, 7, 0)
76 #endif
78 /* Simulate __has_feature on compilers that lack it. It is used only
79 to define ADDRESS_SANITIZER below. */
80 #ifndef __has_feature
81 # define __has_feature(a) false
82 #endif
84 /* True if addresses are being sanitized. */
85 #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
86 # define ADDRESS_SANITIZER true
87 #else
88 # define ADDRESS_SANITIZER false
89 #endif
91 /* Yield PTR, which must be aligned to ALIGNMENT. */
92 #if ! __has_builtin (__builtin_assume_aligned)
93 # define __builtin_assume_aligned(ptr, ...) ((void *) (ptr))
94 #endif
96 #ifdef DARWIN_OS
97 #ifdef emacs
98 #define malloc unexec_malloc
99 #define realloc unexec_realloc
100 #define free unexec_free
101 #endif
102 /* The following solves the problem that Emacs hangs when evaluating
103 (make-comint "test0" "/nodir/nofile" nil "") when /nodir/nofile
104 does not exist. Also, setsid is not allowed in the vfork child's
105 context as of Darwin 9/Mac OS X 10.5. */
106 #undef HAVE_WORKING_VFORK
107 #define vfork fork
108 #endif /* DARWIN_OS */
110 /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use
111 gmalloc before dumping and the system malloc after dumping.
112 hybrid_malloc and friends, defined in gmalloc.c, are wrappers that
113 accomplish this. */
114 #ifdef HYBRID_MALLOC
115 #ifdef emacs
116 #define malloc hybrid_malloc
117 #define realloc hybrid_realloc
118 #define aligned_alloc hybrid_aligned_alloc
119 #define calloc hybrid_calloc
120 #define free hybrid_free
121 #endif
122 #endif /* HYBRID_MALLOC */
124 /* We have to go this route, rather than the old hpux9 approach of
125 renaming the functions via macros. The system's stdlib.h has fully
126 prototyped declarations, which yields a conflicting definition of
127 srand48; it tries to redeclare what was once srandom to be srand48.
128 So we go with HAVE_LRAND48 being defined. */
129 #ifdef HPUX
130 #undef srandom
131 #undef random
132 #undef HAVE_RANDOM
133 #undef HAVE_RINT
134 #endif /* HPUX */
136 #ifdef MSDOS
137 #ifndef __DJGPP__
138 You lose; /* Emacs for DOS must be compiled with DJGPP */
139 #endif
140 #define _NAIVE_DOS_REGS
142 /* Start of gnulib-related stuff */
144 /* lib/ftoastr.c wants strtold, but DJGPP only has _strtold. DJGPP >
145 2.03 has it, but it also has _strtold as a stub that jumps to
146 strtold, so use _strtold in all versions. */
147 #define strtold _strtold
149 #if __DJGPP__ > 2 || __DJGPP_MINOR__ > 3
150 # define HAVE_LSTAT 1
151 #else
152 # define lstat stat
153 /* DJGPP 2.03 and older don't have the next two. */
154 # define EOVERFLOW ERANGE
155 # define SIZE_MAX 4294967295U
156 #endif
158 /* We must intercept 'opendir' calls to stash away the directory name,
159 so we could reuse it in readlinkat; see msdos.c. */
160 #define opendir sys_opendir
162 /* End of gnulib-related stuff. */
164 #define emacs_raise(sig) msdos_fatal_signal (sig)
166 /* DATA_START is needed by vm-limit.c and unexcoff.c. */
167 #define DATA_START (&etext + 1)
169 /* Define one of these for easier conditionals. */
170 #ifdef HAVE_X_WINDOWS
171 /* We need a little extra space, see ../../lisp/loadup.el and the
172 commentary below, in the non-X branch. The 140KB number was
173 measured on GNU/Linux and on MS-Windows. */
174 #define SYSTEM_PURESIZE_EXTRA (-170000+140000)
175 #else
176 /* We need a little extra space, see ../../lisp/loadup.el.
177 As of 20091024, DOS-specific files use up 62KB of pure space. But
178 overall, we end up wasting 130KB of pure space, because
179 BASE_PURESIZE starts at 1.47MB, while we need only 1.3MB (including
180 non-DOS specific files and load history; the latter is about 55K,
181 but depends on the depth of the top-level Emacs directory in the
182 directory tree). Given the unknown policy of different DPMI
183 hosts regarding loading of untouched pages, I'm not going to risk
184 enlarging Emacs footprint by another 100+ KBytes. */
185 #define SYSTEM_PURESIZE_EXTRA (-170000+90000)
186 #endif
187 #endif /* MSDOS */
189 /* macOS / GNUstep need a bit more pure memory. Of the existing knobs,
190 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */
191 #ifdef HAVE_NS
192 #if defined NS_IMPL_GNUSTEP
193 # define SYSTEM_PURESIZE_EXTRA 30000
194 #elif defined DARWIN_OS
195 # define SYSTEM_PURESIZE_EXTRA 200000
196 #endif
197 #endif
199 #ifdef CYGWIN
200 #define SYSTEM_PURESIZE_EXTRA 50000
201 #endif
203 #if defined HAVE_NTGUI && !defined DebPrint
204 # ifdef EMACSDEBUG
205 extern void _DebPrint (const char *fmt, ...);
206 # define DebPrint(stuff) _DebPrint stuff
207 # else
208 # define DebPrint(stuff) ((void) 0)
209 # endif
210 #endif
212 #if defined CYGWIN && defined HAVE_NTGUI
213 # define NTGUI_UNICODE /* Cygwin runs only on UNICODE-supporting systems */
214 # define _WIN32_WINNT 0x500 /* Win2k */
215 /* The following was in /usr/include/string.h prior to Cygwin 1.7.33. */
216 #ifndef strnicmp
217 #define strnicmp strncasecmp
218 #endif
219 #endif
221 #ifdef emacs /* Don't do this for lib-src. */
222 /* Tell regex.c to use a type compatible with Emacs. */
223 #define RE_TRANSLATE_TYPE Lisp_Object
224 #define RE_TRANSLATE(TBL, C) char_table_translate (TBL, C)
225 #define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
226 #endif
228 /* Tell time_rz.c to use Emacs's getter and setter for TZ.
229 Only Emacs uses time_rz so this is OK. */
230 #define getenv_TZ emacs_getenv_TZ
231 #define setenv_TZ emacs_setenv_TZ
232 extern char *emacs_getenv_TZ (void);
233 extern int emacs_setenv_TZ (char const *);
235 #if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */
236 #define NO_INLINE __attribute__((noinline))
237 #else
238 #define NO_INLINE
239 #endif
241 #if __has_attribute (externally_visible)
242 #define EXTERNALLY_VISIBLE __attribute__((externally_visible))
243 #else
244 #define EXTERNALLY_VISIBLE
245 #endif
247 #if GNUC_PREREQ (2, 7, 0)
248 # define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
249 #else
250 # define ATTRIBUTE_FORMAT(spec) /* empty */
251 #endif
253 #if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
254 # define PRINTF_ARCHETYPE __gnu_printf__
255 #elif GNUC_PREREQ (4, 4, 0) && defined __MINGW32__
256 # define PRINTF_ARCHETYPE __ms_printf__
257 #else
258 # define PRINTF_ARCHETYPE __printf__
259 #endif
260 #define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
261 ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
263 #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
264 #define ATTRIBUTE_UNUSED _GL_UNUSED
266 #if 3 <= __GNUC__
267 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
268 #else
269 # define ATTRIBUTE_MALLOC
270 #endif
272 #if __has_attribute (alloc_size)
273 # define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
274 #else
275 # define ATTRIBUTE_ALLOC_SIZE(args)
276 #endif
278 #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args)
280 /* Work around GCC bug 59600: when a function is inlined, the inlined
281 code may have its addresses sanitized even if the function has the
282 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and
283 clang 3.4. */
284 #if (! ADDRESS_SANITIZER \
285 || (GNUC_PREREQ (4, 9, 0) \
286 || 3 < __clang_major__ + (4 <= __clang_minor__)))
287 # define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */
288 #else
289 # define ADDRESS_SANITIZER_WORKAROUND NO_INLINE
290 #endif
292 /* Attribute of functions whose code should not have addresses
293 sanitized. */
295 #if __has_attribute (no_sanitize_address)
296 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
297 __attribute__ ((no_sanitize_address)) ADDRESS_SANITIZER_WORKAROUND
298 #elif __has_attribute (no_address_safety_analysis)
299 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
300 __attribute__ ((no_address_safety_analysis)) ADDRESS_SANITIZER_WORKAROUND
301 #else
302 # define ATTRIBUTE_NO_SANITIZE_ADDRESS
303 #endif
305 /* Some versions of GNU/Linux define noinline in their headers. */
306 #ifdef noinline
307 #undef noinline
308 #endif
310 /* Use Gnulib's extern-inline module for extern inline functions.
311 An include file foo.h should prepend FOO_INLINE to function
312 definitions, with the following overall pattern:
314 [#include any other .h files first.]
316 INLINE_HEADER_BEGIN
318 INLINE int
319 incr (int i)
321 return i + 1;
324 INLINE_HEADER_END
326 For every executable, exactly one file that includes the header
327 should do this:
329 #define INLINE EXTERN_INLINE
331 before including config.h or any other .h file.
332 Other .c files should not define INLINE.
333 For Emacs, this is done by having emacs.c first '#define INLINE
334 EXTERN_INLINE' and then include every .h file that uses INLINE.
336 The INLINE_HEADER_BEGIN and INLINE_HEADER_END suppress bogus
337 warnings in some GCC versions; see ../m4/extern-inline.m4.
339 C99 compilers compile functions like 'incr' as C99-style extern
340 inline functions. Buggy GCC implementations do something similar with
341 GNU-specific keywords. Buggy non-GCC compilers use static
342 functions, which bloats the code but is good enough. */
344 #ifndef INLINE
345 # define INLINE _GL_INLINE
346 #endif
347 #define EXTERN_INLINE _GL_EXTERN_INLINE
348 #define INLINE_HEADER_BEGIN _GL_INLINE_HEADER_BEGIN
349 #define INLINE_HEADER_END _GL_INLINE_HEADER_END
351 /* 'int x UNINIT;' is equivalent to 'int x;', except it cajoles GCC
352 into not warning incorrectly about use of an uninitialized variable. */
353 #if defined GCC_LINT || defined lint
354 # define UNINIT = {0,}
355 #else
356 # define UNINIT /* empty */
357 #endif