diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_post.h | 100 | ||||
| -rw-r--r-- | src/systhread.h | 12 |
2 files changed, 28 insertions, 84 deletions
diff --git a/src/conf_post.h b/src/conf_post.h index 8a6b32998d8..953b783ebea 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -30,13 +30,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | /* To help make dependencies clearer elsewhere, this file typically | 32 | /* To help make dependencies clearer elsewhere, this file typically |
| 33 | does not #include other files. The exceptions are first stdbool.h | 33 | does not #include other files. The exceptions are stdbool.h |
| 34 | because it is unlikely to interfere with configuration and bool is | 34 | because it is unlikely to interfere with configuration and bool is |
| 35 | such a core part of the C language, and second ms-w32.h (DOS_NT | 35 | such a core part of the C language, attribute.h because its |
| 36 | ATTRIBUTE_* macros are used here, and ms-w32.h (DOS_NT | ||
| 36 | only) because it historically was included here and changing that | 37 | only) because it historically was included here and changing that |
| 37 | would take some work. */ | 38 | would take some work. */ |
| 38 | 39 | ||
| 39 | #include <stdbool.h> | 40 | #include <stdbool.h> |
| 41 | #include <attribute.h> | ||
| 40 | 42 | ||
| 41 | #if defined WINDOWSNT && !defined DEFER_MS_W32_H | 43 | #if defined WINDOWSNT && !defined DEFER_MS_W32_H |
| 42 | # include <ms-w32.h> | 44 | # include <ms-w32.h> |
| @@ -65,31 +67,30 @@ typedef unsigned int bool_bf; | |||
| 65 | typedef bool bool_bf; | 67 | typedef bool bool_bf; |
| 66 | #endif | 68 | #endif |
| 67 | 69 | ||
| 68 | /* Simulate __has_attribute on compilers that lack it. It is used only | 70 | /* A substitute for __has_attribute on compilers that lack it. |
| 69 | on arguments like alloc_size that are handled in this simulation. | 71 | It is used only on arguments like cleanup that are handled here. |
| 70 | __has_attribute should be used only in #if expressions, as Oracle | 72 | This macro should be used only in #if expressions, as Oracle |
| 71 | Studio 12.5's __has_attribute does not work in plain code. */ | 73 | Studio 12.5's __has_attribute does not work in plain code. */ |
| 72 | #ifndef __has_attribute | 74 | #ifdef __has_attribute |
| 73 | # define __has_attribute(a) __has_attribute_##a | 75 | # define HAS_ATTRIBUTE(a) __has_attribute (__##a##__) |
| 74 | # define __has_attribute_alloc_size GNUC_PREREQ (4, 3, 0) | 76 | #else |
| 75 | # define __has_attribute_cleanup GNUC_PREREQ (3, 4, 0) | 77 | # define HAS_ATTRIBUTE(a) HAS_ATTR_##a |
| 76 | # define __has_attribute_cold GNUC_PREREQ (4, 3, 0) | 78 | # define HAS_ATTR_cleanup GNUC_PREREQ (3, 4, 0) |
| 77 | # define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0) | 79 | # define HAS_ATTR_no_address_safety_analysis false |
| 78 | # define __has_attribute_no_address_safety_analysis false | 80 | # define HAS_ATTR_no_sanitize_address GNUC_PREREQ (4, 8, 0) |
| 79 | # define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0) | 81 | # define HAS_ATTR_no_sanitize_undefined GNUC_PREREQ (4, 9, 0) |
| 80 | # define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0) | ||
| 81 | # define __has_attribute_returns_nonnull GNUC_PREREQ (4, 9, 0) | ||
| 82 | # define __has_attribute_warn_unused_result GNUC_PREREQ (3, 4, 0) | ||
| 83 | #endif | 82 | #endif |
| 84 | 83 | ||
| 85 | /* Simulate __has_feature on compilers that lack it. It is used only | 84 | /* A substitute for __has_feature on compilers that lack it. It is used only |
| 86 | to define ADDRESS_SANITIZER below. */ | 85 | to define ADDRESS_SANITIZER below. */ |
| 87 | #ifndef __has_feature | 86 | #ifdef __has_feature |
| 88 | # define __has_feature(a) false | 87 | # define HAS_FEATURE(a) __has_feature (a) |
| 88 | #else | ||
| 89 | # define HAS_FEATURE(a) false | ||
| 89 | #endif | 90 | #endif |
| 90 | 91 | ||
| 91 | /* True if addresses are being sanitized. */ | 92 | /* True if addresses are being sanitized. */ |
| 92 | #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer) | 93 | #if defined __SANITIZE_ADDRESS__ || HAS_FEATURE (address_sanitizer) |
| 93 | # define ADDRESS_SANITIZER true | 94 | # define ADDRESS_SANITIZER true |
| 94 | #else | 95 | #else |
| 95 | # define ADDRESS_SANITIZER false | 96 | # define ADDRESS_SANITIZER false |
| @@ -226,37 +227,8 @@ extern void _DebPrint (const char *fmt, ...); | |||
| 226 | extern char *emacs_getenv_TZ (void); | 227 | extern char *emacs_getenv_TZ (void); |
| 227 | extern int emacs_setenv_TZ (char const *); | 228 | extern int emacs_setenv_TZ (char const *); |
| 228 | 229 | ||
| 229 | /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at | 230 | #define NO_INLINE ATTRIBUTE_NOINLINE |
| 230 | <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. */ | 231 | #define EXTERNALLY_VISIBLE ATTRIBUTE_EXTERNALLY_VISIBLE |
| 231 | #if __has_attribute (cold) && !defined __MINGW32__ | ||
| 232 | # define ATTRIBUTE_COLD __attribute__ ((cold)) | ||
| 233 | #else | ||
| 234 | # define ATTRIBUTE_COLD | ||
| 235 | #endif | ||
| 236 | |||
| 237 | #if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ | ||
| 238 | #define NO_INLINE __attribute__((noinline)) | ||
| 239 | #else | ||
| 240 | #define NO_INLINE | ||
| 241 | #endif | ||
| 242 | |||
| 243 | #if __has_attribute (externally_visible) | ||
| 244 | #define EXTERNALLY_VISIBLE __attribute__((externally_visible)) | ||
| 245 | #else | ||
| 246 | #define EXTERNALLY_VISIBLE | ||
| 247 | #endif | ||
| 248 | |||
| 249 | #if GNUC_PREREQ (2, 7, 0) | ||
| 250 | # define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) | ||
| 251 | #else | ||
| 252 | # define ATTRIBUTE_FORMAT(spec) /* empty */ | ||
| 253 | #endif | ||
| 254 | |||
| 255 | #if GNUC_PREREQ (7, 0, 0) | ||
| 256 | # define FALLTHROUGH __attribute__ ((__fallthrough__)) | ||
| 257 | #else | ||
| 258 | # define FALLTHROUGH ((void) 0) | ||
| 259 | #endif | ||
| 260 | 232 | ||
| 261 | #if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__ | 233 | #if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__ |
| 262 | # define PRINTF_ARCHETYPE __gnu_printf__ | 234 | # define PRINTF_ARCHETYPE __gnu_printf__ |
| @@ -288,16 +260,8 @@ extern int emacs_setenv_TZ (char const *); | |||
| 288 | #define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \ | 260 | #define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \ |
| 289 | ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check)) | 261 | ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check)) |
| 290 | 262 | ||
| 291 | #define ARG_NONNULL _GL_ARG_NONNULL | 263 | #define ARG_NONNULL ATTRIBUTE_NONNULL |
| 292 | #define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST | 264 | #define ATTRIBUTE_UNUSED MAYBE_UNUSED |
| 293 | #define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE | ||
| 294 | #define ATTRIBUTE_UNUSED _GL_UNUSED | ||
| 295 | |||
| 296 | #if GNUC_PREREQ (3, 3, 0) && !defined __ICC | ||
| 297 | # define ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) | ||
| 298 | #else | ||
| 299 | # define ATTRIBUTE_MAY_ALIAS | ||
| 300 | #endif | ||
| 301 | 265 | ||
| 302 | /* Declare NAME to be a pointer to an object of type TYPE, initialized | 266 | /* Declare NAME to be a pointer to an object of type TYPE, initialized |
| 303 | to the address ADDR, which may be of a different type. Accesses | 267 | to the address ADDR, which may be of a different type. Accesses |
| @@ -308,27 +272,13 @@ extern int emacs_setenv_TZ (char const *); | |||
| 308 | type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr) | 272 | type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr) |
| 309 | 273 | ||
| 310 | #if 3 <= __GNUC__ | 274 | #if 3 <= __GNUC__ |
| 311 | # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) | ||
| 312 | # define ATTRIBUTE_SECTION(name) __attribute__((section (name))) | 275 | # define ATTRIBUTE_SECTION(name) __attribute__((section (name))) |
| 313 | #else | 276 | #else |
| 314 | # define ATTRIBUTE_MALLOC | ||
| 315 | #define ATTRIBUTE_SECTION(name) | 277 | #define ATTRIBUTE_SECTION(name) |
| 316 | #endif | 278 | #endif |
| 317 | 279 | ||
| 318 | #if __has_attribute (alloc_size) | ||
| 319 | # define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) | ||
| 320 | #else | ||
| 321 | # define ATTRIBUTE_ALLOC_SIZE(args) | ||
| 322 | #endif | ||
| 323 | |||
| 324 | #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args) | 280 | #define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args) |
| 325 | 281 | ||
| 326 | #if __has_attribute (returns_nonnull) | ||
| 327 | # define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((returns_nonnull)) | ||
| 328 | #else | ||
| 329 | # define ATTRIBUTE_RETURNS_NONNULL | ||
| 330 | #endif | ||
| 331 | |||
| 332 | /* Work around GCC bug 59600: when a function is inlined, the inlined | 282 | /* Work around GCC bug 59600: when a function is inlined, the inlined |
| 333 | code may have its addresses sanitized even if the function has the | 283 | code may have its addresses sanitized even if the function has the |
| 334 | no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and | 284 | no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and |
diff --git a/src/systhread.h b/src/systhread.h index 005388fd5a4..73c764a9401 100644 --- a/src/systhread.h +++ b/src/systhread.h | |||
| @@ -21,12 +21,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 21 | 21 | ||
| 22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
| 23 | 23 | ||
| 24 | #if __has_attribute (warn_unused_result) | ||
| 25 | # define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) | ||
| 26 | #else | ||
| 27 | # define ATTRIBUTE_WARN_UNUSED_RESULT | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #ifdef THREADS_ENABLED | 24 | #ifdef THREADS_ENABLED |
| 31 | 25 | ||
| 32 | #ifdef HAVE_PTHREAD | 26 | #ifdef HAVE_PTHREAD |
| @@ -108,13 +102,13 @@ extern void sys_cond_broadcast (sys_cond_t *); | |||
| 108 | extern void sys_cond_destroy (sys_cond_t *); | 102 | extern void sys_cond_destroy (sys_cond_t *); |
| 109 | 103 | ||
| 110 | extern sys_thread_t sys_thread_self (void) | 104 | extern sys_thread_t sys_thread_self (void) |
| 111 | ATTRIBUTE_WARN_UNUSED_RESULT; | 105 | NODISCARD; |
| 112 | extern bool sys_thread_equal (sys_thread_t, sys_thread_t) | 106 | extern bool sys_thread_equal (sys_thread_t, sys_thread_t) |
| 113 | ATTRIBUTE_WARN_UNUSED_RESULT; | 107 | NODISCARD; |
| 114 | 108 | ||
| 115 | extern bool sys_thread_create (sys_thread_t *, thread_creation_function *, | 109 | extern bool sys_thread_create (sys_thread_t *, thread_creation_function *, |
| 116 | void *) | 110 | void *) |
| 117 | ATTRIBUTE_WARN_UNUSED_RESULT; | 111 | NODISCARD; |
| 118 | 112 | ||
| 119 | extern void sys_thread_yield (void); | 113 | extern void sys_thread_yield (void); |
| 120 | extern void sys_thread_set_name (const char *); | 114 | extern void sys_thread_set_name (const char *); |