From 0f9bb261439c3e76eccb43b3f2c3c1d09a561171 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 7 Sep 2023 09:48:34 -0400 Subject: [PATCH] MT#55283 unify __attribute__() test macros Change-Id: Ia2ef8e995c78a2dd1fe33e37f78eed6e58191ac7 --- lib/auxlib.h | 2 +- lib/compat.h | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/auxlib.h b/lib/auxlib.h index 7610fac9f..e03439236 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -448,7 +448,7 @@ INLINE pid_t gettid(void) { /*** TAINT FUNCTIONS ***/ -#if __has_attribute(__error__) +#if HAS_ATTR(__error__) /* This is not supported in clang, and on gcc it might become inert if the * symbol gets remapped to a builtin or stack protected function, but it * otherwise gives better diagnostics. */ diff --git a/lib/compat.h b/lib/compat.h index 6bcd61e1a..d39078f32 100644 --- a/lib/compat.h +++ b/lib/compat.h @@ -7,12 +7,16 @@ # define INLINE static inline __attribute__((always_inline)) #endif -#define ACCESS(...) #if defined __has_attribute -# if __has_attribute(access) -# undef ACCESS -# define ACCESS(...) __attribute__((access(__VA_ARGS__))) -# endif +# define HAS_ATTR(x) __has_attribute(x) +#else +# define HAS_ATTR(x) 0 +#endif + +#if HAS_ATTR(access) +# define ACCESS(...) __attribute__((access(__VA_ARGS__))) +#else +# define ACCESS(...) #endif