Merge pull request #11031 from poettering/gcc-attr-cleanup
various gcc attribute clean-ups
This commit is contained in:
+40
-13
@@ -8,27 +8,31 @@
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define _printf_(a, b) __attribute__ ((__format__(printf, a, b)))
|
||||
#define _printf_(a, b) __attribute__((__format__(printf, a, b)))
|
||||
#ifdef __clang__
|
||||
# define _alloc_(...)
|
||||
#else
|
||||
# define _alloc_(...) __attribute__ ((__alloc_size__(__VA_ARGS__)))
|
||||
# define _alloc_(...) __attribute__((__alloc_size__(__VA_ARGS__)))
|
||||
#endif
|
||||
#define _sentinel_ __attribute__ ((__sentinel__))
|
||||
#define _unused_ __attribute__ ((__unused__))
|
||||
#define _destructor_ __attribute__ ((__destructor__))
|
||||
#define _pure_ __attribute__ ((__pure__))
|
||||
#define _const_ __attribute__ ((__const__))
|
||||
#define _deprecated_ __attribute__ ((__deprecated__))
|
||||
#define _packed_ __attribute__ ((__packed__))
|
||||
#define _malloc_ __attribute__ ((__malloc__))
|
||||
#define _weak_ __attribute__ ((__weak__))
|
||||
#define _sentinel_ __attribute__((__sentinel__))
|
||||
#define _section_(x) __attribute__((__section__(x)))
|
||||
#define _used_ __attribute__((__used__))
|
||||
#define _unused_ __attribute__((__unused__))
|
||||
#define _destructor_ __attribute__((__destructor__))
|
||||
#define _pure_ __attribute__((__pure__))
|
||||
#define _const_ __attribute__((__const__))
|
||||
#define _deprecated_ __attribute__((__deprecated__))
|
||||
#define _packed_ __attribute__((__packed__))
|
||||
#define _malloc_ __attribute__((__malloc__))
|
||||
#define _weak_ __attribute__((__weak__))
|
||||
#define _likely_(x) (__builtin_expect(!!(x), 1))
|
||||
#define _unlikely_(x) (__builtin_expect(!!(x), 0))
|
||||
#define _public_ __attribute__ ((__visibility__("default")))
|
||||
#define _hidden_ __attribute__ ((__visibility__("hidden")))
|
||||
#define _public_ __attribute__((__visibility__("default")))
|
||||
#define _hidden_ __attribute__((__visibility__("hidden")))
|
||||
#define _weakref_(x) __attribute__((__weakref__(#x)))
|
||||
#define _align_(x) __attribute__((__aligned__(x)))
|
||||
#define _alignas_(x) __attribute__((__aligned__(__alignof(x))))
|
||||
#define _alignptr_ __attribute__((__aligned__(sizeof(void*))))
|
||||
#define _cleanup_(x) __attribute__((__cleanup__(x)))
|
||||
#if __GNUC__ >= 7
|
||||
#define _fallthrough_ __attribute__((__fallthrough__))
|
||||
@@ -56,6 +60,29 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
|
||||
# ifdef __SANITIZE_ADDRESS__
|
||||
# define HAS_FEATURE_ADDRESS_SANITIZER 1
|
||||
# elif defined(__has_feature)
|
||||
# if __has_feature(address_sanitizer)
|
||||
# define HAS_FEATURE_ADDRESS_SANITIZER 1
|
||||
# endif
|
||||
# endif
|
||||
# if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
|
||||
# define HAS_FEATURE_ADDRESS_SANITIZER 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Note: on GCC "no_sanitize_address" is a function attribute only, on llvm it may also be applied to global
|
||||
* variables. We define a specific macro which knows this. Note that on GCC we don't need this decorator so much, since
|
||||
* our primary usecase for this attribute is registration structures placed in named ELF sections which shall not be
|
||||
* padded, but GCC doesn't pad those anyway if AddressSanitizer is enabled. */
|
||||
#if HAS_FEATURE_ADDRESS_SANITIZER && defined(__clang__)
|
||||
#define _variable_no_sanitize_address_ __attribute__((__no_sanitize_address__))
|
||||
#else
|
||||
#define _variable_no_sanitize_address_
|
||||
#endif
|
||||
|
||||
/* Temporarily disable some warnings */
|
||||
#define DISABLE_WARNING_FORMAT_NONLITERAL \
|
||||
_Pragma("GCC diagnostic push"); \
|
||||
|
||||
Reference in New Issue
Block a user