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)
72 /* Simulate __has_builtin on compilers that lack it. It is used only
73 on arguments like __builtin_assume_aligned that are handled in this
76 # define __has_builtin(a) __has_builtin_##a
77 # define __has_builtin___builtin_assume_aligned GNUC_PREREQ (4, 7, 0)
80 /* Simulate __has_feature on compilers that lack it. It is used only
81 to define ADDRESS_SANITIZER below. */
83 # define __has_feature(a) false
86 /* True if addresses are being sanitized. */
87 #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
88 # define ADDRESS_SANITIZER true
90 # define ADDRESS_SANITIZER false
93 /* Yield PTR, which must be aligned to ALIGNMENT. */
94 #if ! __has_builtin (__builtin_assume_aligned)
95 # define __builtin_assume_aligned(ptr, ...) ((void *) (ptr))
99 #if defined emacs && !defined CANNOT_DUMP
100 #define malloc unexec_malloc
101 #define realloc unexec_realloc
102 #define free unexec_free
104 #endif /* DARWIN_OS */
106 /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use
107 gmalloc before dumping and the system malloc after dumping.
108 hybrid_malloc and friends, defined in gmalloc.c, are wrappers that
112 #define malloc hybrid_malloc
113 #define realloc hybrid_realloc
114 #define aligned_alloc hybrid_aligned_alloc
115 #define calloc hybrid_calloc
116 #define free hybrid_free
118 #endif /* HYBRID_MALLOC */
120 /* We have to go this route, rather than the old hpux9 approach of
121 renaming the functions via macros. The system's stdlib.h has fully
122 prototyped declarations, which yields a conflicting definition of
123 srand48; it tries to redeclare what was once srandom to be srand48.
124 So we go with HAVE_LRAND48 being defined. */
134 You lose
; /* Emacs for DOS must be compiled with DJGPP */
136 #define _NAIVE_DOS_REGS
138 /* Start of gnulib-related stuff */
140 /* lib/ftoastr.c wants strtold, but DJGPP only has _strtold. DJGPP >
141 2.03 has it, but it also has _strtold as a stub that jumps to
142 strtold, so use _strtold in all versions. */
143 #define strtold _strtold
145 #if __DJGPP__ > 2 || __DJGPP_MINOR__ > 3
146 # define HAVE_LSTAT 1
149 /* DJGPP 2.03 and older don't have the next two. */
150 # define EOVERFLOW ERANGE
151 # define SIZE_MAX 4294967295U
154 /* We must intercept 'opendir' calls to stash away the directory name,
155 so we could reuse it in readlinkat; see msdos.c. */
156 #define opendir sys_opendir
158 /* End of gnulib-related stuff. */
160 #define emacs_raise(sig) msdos_fatal_signal (sig)
162 /* DATA_START is needed by vm-limit.c and unexcoff.c. */
163 #define DATA_START (&etext + 1)
165 /* Define one of these for easier conditionals. */
166 #ifdef HAVE_X_WINDOWS
167 /* We need a little extra space, see ../../lisp/loadup.el and the
168 commentary below, in the non-X branch. The 140KB number was
169 measured on GNU/Linux and on MS-Windows. */
170 #define SYSTEM_PURESIZE_EXTRA (-170000+140000)
172 /* We need a little extra space, see ../../lisp/loadup.el.
173 As of 20091024, DOS-specific files use up 62KB of pure space. But
174 overall, we end up wasting 130KB of pure space, because
175 BASE_PURESIZE starts at 1.47MB, while we need only 1.3MB (including
176 non-DOS specific files and load history; the latter is about 55K,
177 but depends on the depth of the top-level Emacs directory in the
178 directory tree). Given the unknown policy of different DPMI
179 hosts regarding loading of untouched pages, I'm not going to risk
180 enlarging Emacs footprint by another 100+ KBytes. */
181 #define SYSTEM_PURESIZE_EXTRA (-170000+90000)
185 /* macOS / GNUstep need a bit more pure memory. Of the existing knobs,
186 SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems. */
188 #if defined NS_IMPL_GNUSTEP
189 # define SYSTEM_PURESIZE_EXTRA 30000
190 #elif defined DARWIN_OS
191 # define SYSTEM_PURESIZE_EXTRA 200000
196 #define SYSTEM_PURESIZE_EXTRA 50000
199 #if defined HAVE_NTGUI && !defined DebPrint
201 extern void _DebPrint (const char *fmt
, ...);
202 # define DebPrint(stuff) _DebPrint stuff
204 # define DebPrint(stuff) ((void) 0)
208 #if defined CYGWIN && defined HAVE_NTGUI
209 # define NTGUI_UNICODE /* Cygwin runs only on UNICODE-supporting systems */
210 # define _WIN32_WINNT 0x500 /* Win2k */
211 /* The following was in /usr/include/string.h prior to Cygwin 1.7.33. */
213 #define strnicmp strncasecmp
217 #ifdef emacs /* Don't do this for lib-src. */
218 /* Tell regex.c to use a type compatible with Emacs. */
219 #define RE_TRANSLATE_TYPE Lisp_Object
220 #define RE_TRANSLATE(TBL, C) char_table_translate (TBL, C)
221 #define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
224 /* Tell time_rz.c to use Emacs's getter and setter for TZ.
225 Only Emacs uses time_rz so this is OK. */
226 #define getenv_TZ emacs_getenv_TZ
227 #define setenv_TZ emacs_setenv_TZ
228 extern char *emacs_getenv_TZ (void);
229 extern int emacs_setenv_TZ (char const *);
231 #if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */
232 #define NO_INLINE __attribute__((noinline))
237 #if __has_attribute (externally_visible)
238 #define EXTERNALLY_VISIBLE __attribute__((externally_visible))
240 #define EXTERNALLY_VISIBLE
243 #if GNUC_PREREQ (2, 7, 0)
244 # define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
246 # define ATTRIBUTE_FORMAT(spec) /* empty */
249 #if GNUC_PREREQ (7, 0, 0)
250 # define FALLTHROUGH __attribute__ ((__fallthrough__))
252 # define FALLTHROUGH ((void) 0)
255 #if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
256 # define PRINTF_ARCHETYPE __gnu_printf__
257 #elif GNUC_PREREQ (4, 4, 0) && defined __MINGW32__
259 /* When __USE_MINGW_ANSI_STDIO is non-zero (as set by config.h),
260 MinGW64 replaces printf* with its own versions that are
261 __gnu_printf__ compatible, and emits warnings for MS native %I64d
263 # if __USE_MINGW_ANSI_STDIO
264 # define PRINTF_ARCHETYPE __gnu_printf__
266 # define PRINTF_ARCHETYPE __ms_printf__
268 # else /* mingw.org's MinGW */
269 /* Starting from runtime v5.0.0, mingw.org's MinGW with GCC 6 and
270 later turns on __USE_MINGW_ANSI_STDIO by default, replaces printf*
271 with its own __mingw_printf__ version, which still recognizes
273 # if GNUC_PREREQ (6, 0, 0) && __MINGW32_MAJOR_VERSION >= 5
274 # define PRINTF_ARCHETYPE __mingw_printf__
275 # else /* __MINGW32_MAJOR_VERSION < 5 */
276 # define PRINTF_ARCHETYPE __ms_printf__
277 # endif /* __MINGW32_MAJOR_VERSION < 5 */
280 # define PRINTF_ARCHETYPE __printf__
282 #define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
283 ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
285 #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
286 #define ATTRIBUTE_UNUSED _GL_UNUSED
288 #if GNUC_PREREQ (3, 3, 0) && !defined __ICC
289 # define ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
291 # define ATTRIBUTE_MAY_ALIAS
294 /* Declare NAME to be a pointer to an object of type TYPE, initialized
295 to the address ADDR, which may be of a different type. Accesses
296 via NAME may alias with other accesses with the traditional
297 behavior, even if options like gcc -fstrict-aliasing are used. */
299 #define DECLARE_POINTER_ALIAS(name, type, addr) \
300 type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr)
303 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
305 # define ATTRIBUTE_MALLOC
308 #if __has_attribute (alloc_size)
309 # define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
311 # define ATTRIBUTE_ALLOC_SIZE(args)
314 #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args)
316 /* Work around GCC bug 59600: when a function is inlined, the inlined
317 code may have its addresses sanitized even if the function has the
318 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and
320 #if (! ADDRESS_SANITIZER \
321 || (GNUC_PREREQ (4, 9, 0) \
322 || 3 < __clang_major__ + (4 <= __clang_minor__)))
323 # define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */
325 # define ADDRESS_SANITIZER_WORKAROUND NO_INLINE
328 /* Attribute of functions whose code should not have addresses
331 #if __has_attribute (no_sanitize_address)
332 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
333 __attribute__ ((no_sanitize_address)) ADDRESS_SANITIZER_WORKAROUND
334 #elif __has_attribute (no_address_safety_analysis)
335 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
336 __attribute__ ((no_address_safety_analysis)) ADDRESS_SANITIZER_WORKAROUND
338 # define ATTRIBUTE_NO_SANITIZE_ADDRESS
341 /* gcc -fsanitize=address does not work with vfork in Fedora 25 x86-64.
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 */