Commit | Line | Data |
---|---|---|
976411d6 GB |
1 | /* Common definitions. |
2 | ||
42a4f53d | 3 | Copyright (C) 1986-2019 Free Software Foundation, Inc. |
976411d6 GB |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program 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. | |
11 | ||
12 | This program 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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
1a5c2598 TT |
20 | #ifndef COMMON_COMMON_DEFS_H |
21 | #define COMMON_COMMON_DEFS_H | |
976411d6 GB |
22 | |
23 | #include "config.h" | |
d0ac1c44 SM |
24 | |
25 | #undef PACKAGE_NAME | |
26 | #undef PACKAGE_VERSION | |
27 | #undef PACKAGE_STRING | |
28 | #undef PACKAGE_TARNAME | |
29 | ||
976411d6 GB |
30 | #ifdef GDBSERVER |
31 | #include "build-gnulib-gdbserver/config.h" | |
32 | #else | |
73cc7272 | 33 | #include "../../gnulib/config.h" |
976411d6 GB |
34 | #endif |
35 | ||
d0ac1c44 SM |
36 | #undef PACKAGE_NAME |
37 | #undef PACKAGE_VERSION | |
38 | #undef PACKAGE_STRING | |
39 | #undef PACKAGE_TARNAME | |
40 | ||
28fe4f87 PA |
41 | /* From: |
42 | https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html | |
43 | ||
44 | "On some hosts that predate C++11, when using C++ one must define | |
45 | __STDC_CONSTANT_MACROS to make visible the definitions of constant | |
46 | macros such as INTMAX_C, and one must define __STDC_LIMIT_MACROS to | |
47 | make visible the definitions of limit macros such as INTMAX_MAX.". | |
48 | ||
b30f354a PA |
49 | And: |
50 | https://www.gnu.org/software/gnulib/manual/html_node/inttypes_002eh.html | |
51 | ||
52 | "On some hosts that predate C++11, when using C++ one must define | |
53 | __STDC_FORMAT_MACROS to make visible the declarations of format | |
54 | macros such as PRIdMAX." | |
55 | ||
56 | Must do this before including any system header, since other system | |
57 | headers may include stdint.h/inttypes.h. */ | |
28fe4f87 PA |
58 | #define __STDC_CONSTANT_MACROS 1 |
59 | #define __STDC_LIMIT_MACROS 1 | |
b30f354a | 60 | #define __STDC_FORMAT_MACROS 1 |
28fe4f87 | 61 | |
a97b53dd TT |
62 | /* Some distros enable _FORTIFY_SOURCE by default, which on occasion |
63 | has caused build failures with -Wunused-result when a patch is | |
64 | developed on a distro that does not enable _FORTIFY_SOURCE. We | |
65 | enable it here in order to try to catch these problems earlier; | |
66 | plus this seems like a reasonable safety measure. The check for | |
67 | optimization is required because _FORTIFY_SOURCE only works when | |
656efb5e SDJ |
68 | optimization is enabled. If _FORTIFY_SOURCE is already defined, |
69 | then we don't do anything. */ | |
a97b53dd | 70 | |
656efb5e | 71 | #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ > 0 |
a97b53dd TT |
72 | #define _FORTIFY_SOURCE 2 |
73 | #endif | |
74 | ||
353ea2d1 EZ |
75 | /* We don't support Windows versions before XP, so we define |
76 | _WIN32_WINNT correspondingly to ensure the Windows API headers | |
77 | expose the required symbols. */ | |
78 | #if defined (__MINGW32__) || defined (__CYGWIN__) | |
79 | # ifdef _WIN32_WINNT | |
80 | # if _WIN32_WINNT < 0x0501 | |
81 | # undef _WIN32_WINNT | |
82 | # define _WIN32_WINNT 0x0501 | |
83 | # endif | |
84 | # else | |
85 | # define _WIN32_WINNT 0x0501 | |
86 | # endif | |
87 | #endif /* __MINGW32__ || __CYGWIN__ */ | |
88 | ||
355e2102 | 89 | #include <stdarg.h> |
d02f550d | 90 | #include <stdio.h> |
d7096f71 | 91 | #include <stdlib.h> |
8ebb3f56 | 92 | #include <stddef.h> |
8cc73a39 | 93 | #include <stdint.h> |
6d3d12eb | 94 | #include <string.h> |
8ffc1bb1 EZ |
95 | #ifdef HAVE_STRINGS_H |
96 | #include <strings.h> /* for strcasecmp and strncasecmp */ | |
97 | #endif | |
bb974a24 | 98 | #include <errno.h> |
9c232dda | 99 | #include <alloca.h> |
91ee7171 | 100 | |
0e443c87 | 101 | #include "ansidecl.h" |
91ee7171 PA |
102 | /* This is defined by ansidecl.h, but we prefer gnulib's version. On |
103 | MinGW, gnulib might enable __USE_MINGW_ANSI_STDIO, which may or not | |
104 | require use of attribute gnu_printf instead of printf. gnulib | |
105 | checks that at configure time. Since _GL_ATTRIBUTE_FORMAT_PRINTF | |
106 | is compatible with ATTRIBUTE_PRINTF, simply use it. */ | |
107 | #undef ATTRIBUTE_PRINTF | |
108 | #define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF | |
109 | ||
18cb7c9f TT |
110 | #if GCC_VERSION >= 3004 |
111 | #define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) | |
112 | #else | |
113 | #define ATTRIBUTE_UNUSED_RESULT | |
114 | #endif | |
115 | ||
b9391142 | 116 | #include "libiberty.h" |
a5fceff8 | 117 | #include "pathmax.h" |
cb9f1a9b | 118 | #include "gdb/signals.h" |
3995eeee | 119 | #include "gdb_locale.h" |
4cb9c816 | 120 | #include "ptid.h" |
03aef70f | 121 | #include "common-types.h" |
e76df0d0 | 122 | #include "common-utils.h" |
dccbb609 | 123 | #include "gdb_assert.h" |
ef87c8bb | 124 | #include "errors.h" |
f6e94d78 | 125 | #include "print-utils.h" |
34abf635 | 126 | #include "common-debug.h" |
6f1947e8 | 127 | #include "cleanups.h" |
a442d071 | 128 | #include "common-exceptions.h" |
268a13a5 | 129 | #include "gdbsupport/poison.h" |
d02f550d | 130 | |
ddb6d633 PA |
131 | #define EXTERN_C extern "C" |
132 | #define EXTERN_C_PUSH extern "C" { | |
133 | #define EXTERN_C_POP } | |
56000a98 | 134 | |
5cc8c731 | 135 | /* Pull in gdb::unique_xmalloc_ptr. */ |
268a13a5 | 136 | #include "gdbsupport/gdb_unique_ptr.h" |
da804164 | 137 | |
b4987c95 SDJ |
138 | /* String containing the current directory (what getwd would return). */ |
139 | extern char *current_directory; | |
140 | ||
6242c6a6 SM |
141 | /* sbrk on macOS is not useful for our purposes, since sbrk(0) always |
142 | returns the same value. brk/sbrk on macOS is just an emulation | |
143 | that always returns a pointer to a 4MB section reserved for | |
144 | that. */ | |
145 | ||
146 | #if defined (HAVE_SBRK) && !__APPLE__ | |
147 | #define HAVE_USEFUL_SBRK 1 | |
148 | #endif | |
149 | ||
1a5c2598 | 150 | #endif /* COMMON_COMMON_DEFS_H */ |