1 /* conf_post.h --- configure.ac includes this via AH_BOTTOM
3 Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2018 Free Software
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 <https://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. */
34 #if defined WINDOWSNT && !defined DEFER_MS_W32_H
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))
46 # define GNUC_PREREQ(v, w, x) \
47 ((v) < __GNUC__ + ((w) < __GNUC_MINOR__ + ((x) <= __GNUC_PATCHLEVEL__)))
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. */
54 typedef unsigned int bool_bf
;
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 __has_attribute should be used only in #if expressions, as Oracle
62 Studio 12.5's __has_attribute does not work in plain code. */
63 #ifndef __has_attribute
64 # define __has_attribute(a) __has_attribute_##a
65 # define __has_attribute_alloc_size GNUC_PREREQ (4, 3, 0)
66 # define __has_attribute_cleanup GNUC_PREREQ (3, 4, 0)
67 # define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0)
68 # define __has_attribute_no_address_safety_analysis false
69 # define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0)
70 # define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0)
73 /* Simulate __has_feature on compilers that lack it. It is used only
74 to define ADDRESS_SANITIZER below. */
76 # define __has_feature(a) false
79 /* True if addresses are being sanitized. */
80 #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
81 # define ADDRESS_SANITIZER true
83 # define ADDRESS_SANITIZER false
87 #if defined emacs && !defined CANNOT_DUMP
88 #define malloc unexec_malloc
89 #define realloc unexec_realloc
90 #define free unexec_free
92 #endif /* DARWIN_OS */
94 /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use
95 gmalloc before dumping and the system malloc after dumping.
96 hybrid_malloc and friends, defined in gmalloc.c, are wrappers that
100 #define malloc hybrid_malloc
101 #define realloc hybrid_realloc
102 #define aligned_alloc hybrid_aligned_alloc
103 #define calloc hybrid_calloc
104 #define free hybrid_free
106 #endif /* HYBRID_MALLOC */
108 /* We have to go this route, rather than the old hpux9 approach of
109 renaming the functions via macros. The system's stdlib.h has fully
110 prototyped declarations, which yields a conflicting definition of
111 srand48; it tries to redeclare what was once srandom to be srand48.
112 So we go with HAVE_LRAND48 being defined. */
122 You lose
; /* Emacs for DOS must be compiled with DJGPP */
124 #define _NAIVE_DOS_REGS
126 /* Start of gnulib-related stuff */
128 /* lib/ftoastr.c wants strtold, but DJGPP only has _strtold. DJGPP >
129 2.03 has it, but it also has _strtold as a stub that jumps to
130 strtold, so use _strtold in all versions. */
131 #define strtold _strtold
133 #if __DJGPP__ > 2 || __DJGPP_MINOR__ > 3
134 # define HAVE_LSTAT 1
137 /* DJGPP 2.03 and older don't have the next two. */
138 # define EOVERFLOW ERANGE
139 # define SIZE_MAX 4294967295U
142 /* We must intercept 'opendir' calls to stash away the directory name,
143 so we could reuse it in readlinkat; see msdos.c. */
144 #define opendir sys_opendir
146 /* End of gnulib-related stuff. */
148 #define emacs_raise(sig) msdos_fatal_signal (sig)
150 /* DATA_START is needed by vm-limit.c and unexcoff.c. */
151 #define DATA_START (&etext + 1)
153 /* Define one of these for easier conditionals. */
154 #ifdef HAVE_X_WINDOWS
155 /* We need a little extra space, see ../../lisp/loadup.el and the
156 commentary below, in the non-X branch. The 140KB number was
157 measured on GNU/Linux and on MS-Windows. */
158 #define SYSTEM_PURESIZE_EXTRA (-170000+140000)
160 /* We need a little extra space, see ../../lisp/loadup.el.
161 As of 20091024, DOS-specific files use up 62KB of pure space. But
162 overall, we end up wasting 130KB of pure space, because
163 BASE_PURESIZE starts at 1.47MB, while we need only 1.3MB (including
164 non-DOS specific files and load history; the latter is about 55K,
165 but depends on the depth of the top-level Emacs directory in the
166 directory tree). Given the unknown policy of different DPMI
167 hosts regarding loading of untouched pages, I'm not going to risk
168 enlarging Emacs footprint by another 100+ KBytes. */
169 #define SYSTEM_PURESIZE_EXTRA (-170000+90000)
173 /* macOS / GNUstep need a bit more pure memory. Of the existing knobs,
174 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */
176 #if defined NS_IMPL_GNUSTEP
177 # define SYSTEM_PURESIZE_EXTRA 30000
178 #elif defined DARWIN_OS
179 # define SYSTEM_PURESIZE_EXTRA 200000
184 #define SYSTEM_PURESIZE_EXTRA 50000
187 #if defined HAVE_NTGUI && !defined DebPrint
189 extern void _DebPrint (const char *fmt
, ...);
190 # define DebPrint(stuff) _DebPrint stuff
192 # define DebPrint(stuff) ((void) 0)
196 #if defined CYGWIN && defined HAVE_NTGUI
197 # define NTGUI_UNICODE /* Cygwin runs only on UNICODE-supporting systems */
198 # define _WIN32_WINNT 0x500 /* Win2k */
199 /* The following was in /usr/include/string.h prior to Cygwin 1.7.33. */
201 #define strnicmp strncasecmp
205 #ifdef emacs /* Don't do this for lib-src. */
206 /* Tell regex.c to use a type compatible with Emacs. */
207 #define RE_TRANSLATE_TYPE Lisp_Object
208 #define RE_TRANSLATE(TBL, C) char_table_translate (TBL, C)
209 #define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
212 /* Tell time_rz.c to use Emacs's getter and setter for TZ.
213 Only Emacs uses time_rz so this is OK. */
214 #define getenv_TZ emacs_getenv_TZ
215 #define setenv_TZ emacs_setenv_TZ
216 extern char *emacs_getenv_TZ (void);
217 extern int emacs_setenv_TZ (char const *);
219 #if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */
220 #define NO_INLINE __attribute__((noinline))
225 #if __has_attribute (externally_visible)
226 #define EXTERNALLY_VISIBLE __attribute__((externally_visible))
228 #define EXTERNALLY_VISIBLE
231 #if GNUC_PREREQ (2, 7, 0)
232 # define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
234 # define ATTRIBUTE_FORMAT(spec) /* empty */
237 #if GNUC_PREREQ (7, 0, 0)
238 # define FALLTHROUGH __attribute__ ((__fallthrough__))
240 # define FALLTHROUGH ((void) 0)
243 #if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
244 # define PRINTF_ARCHETYPE __gnu_printf__
245 #elif GNUC_PREREQ (4, 4, 0) && defined __MINGW32__
247 /* When __USE_MINGW_ANSI_STDIO is non-zero (as set by config.h),
248 MinGW64 replaces printf* with its own versions that are
249 __gnu_printf__ compatible, and emits warnings for MS native %I64d
251 # if __USE_MINGW_ANSI_STDIO
252 # define PRINTF_ARCHETYPE __gnu_printf__
254 # define PRINTF_ARCHETYPE __ms_printf__
256 # else /* mingw.org's MinGW */
257 /* Starting from runtime v5.0.0, mingw.org's MinGW with GCC 6 and
258 later turns on __USE_MINGW_ANSI_STDIO by default, replaces printf*
259 with its own __mingw_printf__ version, which still recognizes
261 # if GNUC_PREREQ (6, 0, 0) && __MINGW32_MAJOR_VERSION >= 5
262 # define PRINTF_ARCHETYPE __mingw_printf__
263 # else /* __MINGW32_MAJOR_VERSION < 5 */
264 # define PRINTF_ARCHETYPE __ms_printf__
265 # endif /* __MINGW32_MAJOR_VERSION < 5 */
268 # define PRINTF_ARCHETYPE __printf__
270 #define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
271 ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
273 #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
274 #define ATTRIBUTE_UNUSED _GL_UNUSED
276 #if GNUC_PREREQ (3, 3, 0) && !defined __ICC
277 # define ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
279 # define ATTRIBUTE_MAY_ALIAS
282 /* Declare NAME to be a pointer to an object of type TYPE, initialized
283 to the address ADDR, which may be of a different type. Accesses
284 via NAME may alias with other accesses with the traditional
285 behavior, even if options like gcc -fstrict-aliasing are used. */
287 #define DECLARE_POINTER_ALIAS(name, type, addr) \
288 type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr)
291 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
293 # define ATTRIBUTE_MALLOC
296 #if __has_attribute (alloc_size)
297 # define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
299 # define ATTRIBUTE_ALLOC_SIZE(args)
302 #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args)
304 /* Work around GCC bug 59600: when a function is inlined, the inlined
305 code may have its addresses sanitized even if the function has the
306 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and
308 #if (! ADDRESS_SANITIZER \
309 || (GNUC_PREREQ (4, 9, 0) \
310 || 3 < __clang_major__ + (4 <= __clang_minor__)))
311 # define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */
313 # define ADDRESS_SANITIZER_WORKAROUND NO_INLINE
316 /* Attribute of functions whose code should not have addresses
319 #if __has_attribute (no_sanitize_address)
320 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
321 __attribute__ ((no_sanitize_address)) ADDRESS_SANITIZER_WORKAROUND
322 #elif __has_attribute (no_address_safety_analysis)
323 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
324 __attribute__ ((no_address_safety_analysis)) ADDRESS_SANITIZER_WORKAROUND
326 # define ATTRIBUTE_NO_SANITIZE_ADDRESS
329 /* Attribute of functions whose undefined behavior should not be sanitized. */
331 #if __has_attribute (no_sanitize_undefined)
332 # define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined))
333 #elif __has_attribute (no_sanitize)
334 # define ATTRIBUTE_NO_SANITIZE_UNDEFINED \
335 __attribute__ ((no_sanitize ("undefined")))
337 # define ATTRIBUTE_NO_SANITIZE_UNDEFINED
340 /* gcc -fsanitize=address does not work with vfork in Fedora 28 x86-64. See:
341 https://lists.gnu.org/r/emacs-devel/2017-05/msg00464.html
342 For now, assume that this problem occurs on all platforms. */
343 #if ADDRESS_SANITIZER && !defined vfork
347 #if ! (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)
351 /* Some versions of GNU/Linux define noinline in their headers. */
356 /* Use Gnulib's extern-inline module for extern inline functions.
357 An include file foo.h should prepend FOO_INLINE to function
358 definitions, with the following overall pattern:
360 [#include any other .h files first.]
372 For every executable, exactly one file that includes the header
375 #define INLINE EXTERN_INLINE
377 before including config.h or any other .h file.
378 Other .c files should not define INLINE.
379 For Emacs, this is done by having emacs.c first '#define INLINE
380 EXTERN_INLINE' and then include every .h file that uses INLINE.
382 The INLINE_HEADER_BEGIN and INLINE_HEADER_END suppress bogus
383 warnings in some GCC versions; see ../m4/extern-inline.m4.
385 C99 compilers compile functions like 'incr' as C99-style extern
386 inline functions. Buggy GCC implementations do something similar with
387 GNU-specific keywords. Buggy non-GCC compilers use static
388 functions, which bloats the code but is good enough. */
391 # define INLINE _GL_INLINE
393 #define EXTERN_INLINE _GL_EXTERN_INLINE
394 #define INLINE_HEADER_BEGIN _GL_INLINE_HEADER_BEGIN
395 #define INLINE_HEADER_END _GL_INLINE_HEADER_END
397 /* 'int x UNINIT;' is equivalent to 'int x;', except it cajoles GCC
398 into not warning incorrectly about use of an uninitialized variable. */
399 #if defined GCC_LINT || defined lint
400 # define UNINIT = {0,}
402 # define UNINIT /* empty */