Use 'header-line-highlight' face in proced and erc
[emacs.git] / src / conf_post.h
blobe1d6a9397d344058e82ca5f737a8106db64b4bf1
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 __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 #endif
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
74 simulation. */
75 #ifndef __has_builtin
76 # define __has_builtin(a) __has_builtin_##a
77 # define __has_builtin___builtin_assume_aligned GNUC_PREREQ (4, 7, 0)
78 #endif
80 /* Simulate __has_feature on compilers that lack it. It is used only
81 to define ADDRESS_SANITIZER below. */
82 #ifndef __has_feature
83 # define __has_feature(a) false
84 #endif
86 /* True if addresses are being sanitized. */
87 #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
88 # define ADDRESS_SANITIZER true
89 #else
90 # define ADDRESS_SANITIZER false
91 #endif
93 /* Yield PTR, which must be aligned to ALIGNMENT. */
94 #if ! __has_builtin (__builtin_assume_aligned)
95 # define __builtin_assume_aligned(ptr, ...) ((void *) (ptr))
96 #endif
98 #ifdef DARWIN_OS
99 #if defined emacs && !defined CANNOT_DUMP
100 #define malloc unexec_malloc
101 #define realloc unexec_realloc
102 #define free unexec_free
103 #endif
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
109 accomplish this. */
110 #ifdef HYBRID_MALLOC
111 #ifdef emacs
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
117 #endif
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. */
125 #ifdef HPUX
126 #undef srandom
127 #undef random
128 #undef HAVE_RANDOM
129 #undef HAVE_RINT
130 #endif /* HPUX */
132 #ifdef MSDOS
133 #ifndef __DJGPP__
134 You lose; /* Emacs for DOS must be compiled with DJGPP */
135 #endif
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
147 #else
148 # define lstat stat
149 /* DJGPP 2.03 and older don't have the next two. */
150 # define EOVERFLOW ERANGE
151 # define SIZE_MAX 4294967295U
152 #endif
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)
171 #else
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)
182 #endif
183 #endif /* MSDOS */
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. */
187 #ifdef HAVE_NS
188 #if defined NS_IMPL_GNUSTEP
189 # define SYSTEM_PURESIZE_EXTRA 30000
190 #elif defined DARWIN_OS
191 # define SYSTEM_PURESIZE_EXTRA 200000
192 #endif
193 #endif
195 #ifdef CYGWIN
196 #define SYSTEM_PURESIZE_EXTRA 50000
197 #endif
199 #if defined HAVE_NTGUI && !defined DebPrint
200 # ifdef EMACSDEBUG
201 extern void _DebPrint (const char *fmt, ...);
202 # define DebPrint(stuff) _DebPrint stuff
203 # else
204 # define DebPrint(stuff) ((void) 0)
205 # endif
206 #endif
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. */
212 #ifndef strnicmp
213 #define strnicmp strncasecmp
214 #endif
215 #endif
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)))
222 #endif
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))
233 #else
234 #define NO_INLINE
235 #endif
237 #if __has_attribute (externally_visible)
238 #define EXTERNALLY_VISIBLE __attribute__((externally_visible))
239 #else
240 #define EXTERNALLY_VISIBLE
241 #endif
243 #if GNUC_PREREQ (2, 7, 0)
244 # define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
245 #else
246 # define ATTRIBUTE_FORMAT(spec) /* empty */
247 #endif
249 #if GNUC_PREREQ (7, 0, 0)
250 # define FALLTHROUGH __attribute__ ((__fallthrough__))
251 #else
252 # define FALLTHROUGH ((void) 0)
253 #endif
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__
258 # define PRINTF_ARCHETYPE __ms_printf__
259 #else
260 # define PRINTF_ARCHETYPE __printf__
261 #endif
262 #define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
263 ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
265 #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
266 #define ATTRIBUTE_UNUSED _GL_UNUSED
268 #if GNUC_PREREQ (3, 3, 0) && !defined __ICC
269 # define ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
270 #else
271 # define ATTRIBUTE_MAY_ALIAS
272 #endif
274 /* Declare NAME to be a pointer to an object of type TYPE, initialized
275 to the address ADDR, which may be of a different type. Accesses
276 via NAME may alias with other accesses with the traditional
277 behavior, even if options like gcc -fstrict-aliasing are used. */
279 #define DECLARE_POINTER_ALIAS(name, type, addr) \
280 type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr)
282 #if 3 <= __GNUC__
283 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
284 #else
285 # define ATTRIBUTE_MALLOC
286 #endif
288 #if __has_attribute (alloc_size)
289 # define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
290 #else
291 # define ATTRIBUTE_ALLOC_SIZE(args)
292 #endif
294 #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args)
296 /* Work around GCC bug 59600: when a function is inlined, the inlined
297 code may have its addresses sanitized even if the function has the
298 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and
299 clang 3.4. */
300 #if (! ADDRESS_SANITIZER \
301 || (GNUC_PREREQ (4, 9, 0) \
302 || 3 < __clang_major__ + (4 <= __clang_minor__)))
303 # define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */
304 #else
305 # define ADDRESS_SANITIZER_WORKAROUND NO_INLINE
306 #endif
308 /* Attribute of functions whose code should not have addresses
309 sanitized. */
311 #if __has_attribute (no_sanitize_address)
312 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
313 __attribute__ ((no_sanitize_address)) ADDRESS_SANITIZER_WORKAROUND
314 #elif __has_attribute (no_address_safety_analysis)
315 # define ATTRIBUTE_NO_SANITIZE_ADDRESS \
316 __attribute__ ((no_address_safety_analysis)) ADDRESS_SANITIZER_WORKAROUND
317 #else
318 # define ATTRIBUTE_NO_SANITIZE_ADDRESS
319 #endif
321 /* gcc -fsanitize=address does not work with vfork in Fedora 25 x86-64.
322 For now, assume that this problem occurs on all platforms. */
323 #if ADDRESS_SANITIZER && !defined vfork
324 # define vfork fork
325 #endif
327 /* Some versions of GNU/Linux define noinline in their headers. */
328 #ifdef noinline
329 #undef noinline
330 #endif
332 /* Use Gnulib's extern-inline module for extern inline functions.
333 An include file foo.h should prepend FOO_INLINE to function
334 definitions, with the following overall pattern:
336 [#include any other .h files first.]
338 INLINE_HEADER_BEGIN
340 INLINE int
341 incr (int i)
343 return i + 1;
346 INLINE_HEADER_END
348 For every executable, exactly one file that includes the header
349 should do this:
351 #define INLINE EXTERN_INLINE
353 before including config.h or any other .h file.
354 Other .c files should not define INLINE.
355 For Emacs, this is done by having emacs.c first '#define INLINE
356 EXTERN_INLINE' and then include every .h file that uses INLINE.
358 The INLINE_HEADER_BEGIN and INLINE_HEADER_END suppress bogus
359 warnings in some GCC versions; see ../m4/extern-inline.m4.
361 C99 compilers compile functions like 'incr' as C99-style extern
362 inline functions. Buggy GCC implementations do something similar with
363 GNU-specific keywords. Buggy non-GCC compilers use static
364 functions, which bloats the code but is good enough. */
366 #ifndef INLINE
367 # define INLINE _GL_INLINE
368 #endif
369 #define EXTERN_INLINE _GL_EXTERN_INLINE
370 #define INLINE_HEADER_BEGIN _GL_INLINE_HEADER_BEGIN
371 #define INLINE_HEADER_END _GL_INLINE_HEADER_END
373 /* 'int x UNINIT;' is equivalent to 'int x;', except it cajoles GCC
374 into not warning incorrectly about use of an uninitialized variable. */
375 #if defined GCC_LINT || defined lint
376 # define UNINIT = {0,}
377 #else
378 # define UNINIT /* empty */
379 #endif