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 . */
#endif
/* To help make dependencies clearer elsewhere, this file typically
- does not #include other files. The exceptions are first stdbool.h
+ does not #include other files. The exceptions are stdbool.h
because it is unlikely to interfere with configuration and bool is
- such a core part of the C language, and second ms-w32.h (DOS_NT
+ such a core part of the C language, attribute.h because its
+ ATTRIBUTE_* macros are used here, and ms-w32.h (DOS_NT
only) because it historically was included here and changing that
would take some work. */
#include
+#include
#if defined WINDOWSNT && !defined DEFER_MS_W32_H
# include
@@ -65,31 +67,30 @@ typedef unsigned int bool_bf;
typedef bool bool_bf;
#endif
-/* Simulate __has_attribute on compilers that lack it. It is used only
- on arguments like alloc_size that are handled in this simulation.
- __has_attribute should be used only in #if expressions, as Oracle
+/* A substitute for __has_attribute on compilers that lack it.
+ It is used only on arguments like cleanup that are handled here.
+ This macro should be used only in #if expressions, as Oracle
Studio 12.5's __has_attribute does not work in plain code. */
-#ifndef __has_attribute
-# define __has_attribute(a) __has_attribute_##a
-# define __has_attribute_alloc_size GNUC_PREREQ (4, 3, 0)
-# define __has_attribute_cleanup GNUC_PREREQ (3, 4, 0)
-# define __has_attribute_cold GNUC_PREREQ (4, 3, 0)
-# define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0)
-# define __has_attribute_no_address_safety_analysis false
-# define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0)
-# define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0)
-# define __has_attribute_returns_nonnull GNUC_PREREQ (4, 9, 0)
-# define __has_attribute_warn_unused_result GNUC_PREREQ (3, 4, 0)
+#ifdef __has_attribute
+# define HAS_ATTRIBUTE(a) __has_attribute (__##a##__)
+#else
+# define HAS_ATTRIBUTE(a) HAS_ATTR_##a
+# define HAS_ATTR_cleanup GNUC_PREREQ (3, 4, 0)
+# define HAS_ATTR_no_address_safety_analysis false
+# define HAS_ATTR_no_sanitize_address GNUC_PREREQ (4, 8, 0)
+# define HAS_ATTR_no_sanitize_undefined GNUC_PREREQ (4, 9, 0)
#endif
-/* Simulate __has_feature on compilers that lack it. It is used only
+/* A substitute for __has_feature on compilers that lack it. It is used only
to define ADDRESS_SANITIZER below. */
-#ifndef __has_feature
-# define __has_feature(a) false
+#ifdef __has_feature
+# define HAS_FEATURE(a) __has_feature (a)
+#else
+# define HAS_FEATURE(a) false
#endif
/* True if addresses are being sanitized. */
-#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
+#if defined __SANITIZE_ADDRESS__ || HAS_FEATURE (address_sanitizer)
# define ADDRESS_SANITIZER true
#else
# define ADDRESS_SANITIZER false
@@ -226,37 +227,8 @@ extern void _DebPrint (const char *fmt, ...);
extern char *emacs_getenv_TZ (void);
extern int emacs_setenv_TZ (char const *);
-/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
- . */
-#if __has_attribute (cold) && !defined __MINGW32__
-# define ATTRIBUTE_COLD __attribute__ ((cold))
-#else
-# define ATTRIBUTE_COLD
-#endif
-
-#if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */
-#define NO_INLINE __attribute__((noinline))
-#else
-#define NO_INLINE
-#endif
-
-#if __has_attribute (externally_visible)
-#define EXTERNALLY_VISIBLE __attribute__((externally_visible))
-#else
-#define EXTERNALLY_VISIBLE
-#endif
-
-#if GNUC_PREREQ (2, 7, 0)
-# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
-#else
-# define ATTRIBUTE_FORMAT(spec) /* empty */
-#endif
-
-#if GNUC_PREREQ (7, 0, 0)
-# define FALLTHROUGH __attribute__ ((__fallthrough__))
-#else
-# define FALLTHROUGH ((void) 0)
-#endif
+#define NO_INLINE ATTRIBUTE_NOINLINE
+#define EXTERNALLY_VISIBLE ATTRIBUTE_EXTERNALLY_VISIBLE
#if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
# define PRINTF_ARCHETYPE __gnu_printf__
@@ -288,16 +260,8 @@ extern int emacs_setenv_TZ (char const *);
#define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
-#define ARG_NONNULL _GL_ARG_NONNULL
-#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
-#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
-#define ATTRIBUTE_UNUSED _GL_UNUSED
-
-#if GNUC_PREREQ (3, 3, 0) && !defined __ICC
-# define ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
-#else
-# define ATTRIBUTE_MAY_ALIAS
-#endif
+#define ARG_NONNULL ATTRIBUTE_NONNULL
+#define ATTRIBUTE_UNUSED MAYBE_UNUSED
/* Declare NAME to be a pointer to an object of type TYPE, initialized
to the address ADDR, which may be of a different type. Accesses
@@ -308,27 +272,13 @@ extern int emacs_setenv_TZ (char const *);
type ATTRIBUTE_MAY_ALIAS *name = (type *) (addr)
#if 3 <= __GNUC__
-# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
# define ATTRIBUTE_SECTION(name) __attribute__((section (name)))
#else
-# define ATTRIBUTE_MALLOC
#define ATTRIBUTE_SECTION(name)
#endif
-#if __has_attribute (alloc_size)
-# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
-#else
-# define ATTRIBUTE_ALLOC_SIZE(args)
-#endif
-
#define ATTRIBUTE_MALLOC_SIZE(args) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE (args)
-#if __has_attribute (returns_nonnull)
-# define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((returns_nonnull))
-#else
-# define ATTRIBUTE_RETURNS_NONNULL
-#endif
-
/* Work around GCC bug 59600: when a function is inlined, the inlined
code may have its addresses sanitized even if the function has the
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 . */
#include
-#if __has_attribute (warn_unused_result)
-# define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
-#else
-# define ATTRIBUTE_WARN_UNUSED_RESULT
-#endif
-
#ifdef THREADS_ENABLED
#ifdef HAVE_PTHREAD
@@ -108,13 +102,13 @@ extern void sys_cond_broadcast (sys_cond_t *);
extern void sys_cond_destroy (sys_cond_t *);
extern sys_thread_t sys_thread_self (void)
- ATTRIBUTE_WARN_UNUSED_RESULT;
+ NODISCARD;
extern bool sys_thread_equal (sys_thread_t, sys_thread_t)
- ATTRIBUTE_WARN_UNUSED_RESULT;
+ NODISCARD;
extern bool sys_thread_create (sys_thread_t *, thread_creation_function *,
void *)
- ATTRIBUTE_WARN_UNUSED_RESULT;
+ NODISCARD;
extern void sys_thread_yield (void);
extern void sys_thread_set_name (const char *);