提交 5c67a52f 编写于 作者: M Miguel Ojeda

Compiler Attributes: always use the extra-underscores syntax

The attribute syntax optionally allows to surround attribute names
with "__" in order to avoid collisions with macros of the same name
(see https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html).

This homogenizes all attributes to use the syntax with underscores.
While there are currently only a handful of cases of some TUs defining
macros like "error" which may collide with the attributes,
this should prevent futures surprises.

This has been done only for "standard" attributes supported by
the major compilers. In other words, those of third-party tools
(e.g. sparse, plugins...) have not been changed for the moment.

Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # on top of v4.19-rc5, clang 7
Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
Reviewed-by: NLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: NMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
上级 29efbc6a
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define __SANITIZE_ADDRESS__ #define __SANITIZE_ADDRESS__
#endif #endif
#define __no_sanitize_address __attribute__((no_sanitize("address"))) #define __no_sanitize_address __attribute__((__no_sanitize__("address")))
/* /*
* Not all versions of clang implement the the type-generic versions * Not all versions of clang implement the the type-generic versions
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
#endif #endif
#ifdef RETPOLINE #ifdef RETPOLINE
#define __noretpoline __attribute__((indirect_branch("keep"))) #define __noretpoline __attribute__((__indirect_branch__("keep")))
#endif #endif
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
#define __compiletime_object_size(obj) __builtin_object_size(obj, 0) #define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
#ifndef __CHECKER__ #ifndef __CHECKER__
#define __compiletime_warning(message) __attribute__((warning(message))) #define __compiletime_warning(message) __attribute__((__warning__(message)))
#define __compiletime_error(message) __attribute__((error(message))) #define __compiletime_error(message) __attribute__((__error__(message)))
#ifdef LATENT_ENTROPY_PLUGIN #ifdef LATENT_ENTROPY_PLUGIN
#define __latent_entropy __attribute__((latent_entropy)) #define __latent_entropy __attribute__((latent_entropy))
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
* optimizer that something else uses this function or variable, thus preventing * optimizer that something else uses this function or variable, thus preventing
* this. * this.
*/ */
#define __visible __attribute__((externally_visible)) #define __visible __attribute__((__externally_visible__))
/* gcc version specific checks */ /* gcc version specific checks */
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
* should not be applied to that function. * should not be applied to that function.
* Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
*/ */
#define __no_sanitize_address __attribute__((no_sanitize_address)) #define __no_sanitize_address __attribute__((__no_sanitize_address__))
#endif #endif
#if GCC_VERSION >= 50100 #if GCC_VERSION >= 50100
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
* Mark structures as requiring designated initializers. * Mark structures as requiring designated initializers.
* https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
*/ */
#define __designated_init __attribute__((designated_init)) #define __designated_init __attribute__((__designated_init__))
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
#endif #endif
......
...@@ -42,4 +42,4 @@ ...@@ -42,4 +42,4 @@
* and may be redefined here because they should not be shared with other * and may be redefined here because they should not be shared with other
* compilers, like clang. * compilers, like clang.
*/ */
#define __visible __attribute__((externally_visible)) #define __visible __attribute__((__externally_visible__))
...@@ -24,7 +24,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, ...@@ -24,7 +24,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
long ______r; \ long ______r; \
static struct ftrace_likely_data \ static struct ftrace_likely_data \
__attribute__((__aligned__(4))) \ __attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_annotated_branch"))) \ __attribute__((__section__("_ftrace_annotated_branch"))) \
______f = { \ ______f = { \
.data.func = __func__, \ .data.func = __func__, \
.data.file = __FILE__, \ .data.file = __FILE__, \
...@@ -60,7 +60,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, ...@@ -60,7 +60,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
int ______r; \ int ______r; \
static struct ftrace_branch_data \ static struct ftrace_branch_data \
__attribute__((__aligned__(4))) \ __attribute__((__aligned__(4))) \
__attribute__((section("_ftrace_branch"))) \ __attribute__((__section__("_ftrace_branch"))) \
______f = { \ ______f = { \
.func = __func__, \ .func = __func__, \
.file = __FILE__, \ .file = __FILE__, \
...@@ -146,7 +146,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, ...@@ -146,7 +146,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
extern typeof(sym) sym; \ extern typeof(sym) sym; \
static const unsigned long __kentry_##sym \ static const unsigned long __kentry_##sym \
__used \ __used \
__attribute__((section("___kentry" "+" #sym ), used)) \ __attribute__((__section__("___kentry" "+" #sym ), used)) \
= (unsigned long)&sym; = (unsigned long)&sym;
#endif #endif
...@@ -287,7 +287,7 @@ unsigned long read_word_at_a_time(const void *addr) ...@@ -287,7 +287,7 @@ unsigned long read_word_at_a_time(const void *addr)
* visible to the compiler. * visible to the compiler.
*/ */
#define __ADDRESSABLE(sym) \ #define __ADDRESSABLE(sym) \
static void * __attribute__((section(".discard.addressable"), used)) \ static void * __attribute__((__section__(".discard.addressable"), used)) \
__PASTE(__addressable_##sym, __LINE__) = (void *)&sym; __PASTE(__addressable_##sym, __LINE__) = (void *)&sym;
/** /**
......
...@@ -195,26 +195,26 @@ struct ftrace_likely_data { ...@@ -195,26 +195,26 @@ struct ftrace_likely_data {
* would be. * would be.
* [...] * [...]
*/ */
#define __pure __attribute__((pure)) #define __pure __attribute__((__pure__))
#define __aligned(x) __attribute__((aligned(x))) #define __aligned(x) __attribute__((__aligned__(x)))
#define __aligned_largest __attribute__((aligned)) #define __aligned_largest __attribute__((__aligned__))
#define __printf(a, b) __attribute__((format(printf, a, b))) #define __printf(a, b) __attribute__((__format__(printf, a, b)))
#define __scanf(a, b) __attribute__((format(scanf, a, b))) #define __scanf(a, b) __attribute__((__format__(scanf, a, b)))
#define __maybe_unused __attribute__((unused)) #define __maybe_unused __attribute__((__unused__))
#define __always_unused __attribute__((unused)) #define __always_unused __attribute__((__unused__))
#define __mode(x) __attribute__((mode(x))) #define __mode(x) __attribute__((__mode__(x)))
#define __malloc __attribute__((__malloc__)) #define __malloc __attribute__((__malloc__))
#define __used __attribute__((__used__)) #define __used __attribute__((__used__))
#define __noreturn __attribute__((noreturn)) #define __noreturn __attribute__((__noreturn__))
#define __packed __attribute__((packed)) #define __packed __attribute__((__packed__))
#define __weak __attribute__((weak)) #define __weak __attribute__((__weak__))
#define __alias(symbol) __attribute__((alias(#symbol))) #define __alias(symbol) __attribute__((__alias__(#symbol)))
#define __cold __attribute__((cold)) #define __cold __attribute__((__cold__))
#define __section(S) __attribute__((__section__(#S))) #define __section(S) __attribute__((__section__(#S)))
#ifdef CONFIG_ENABLE_MUST_CHECK #ifdef CONFIG_ENABLE_MUST_CHECK
#define __must_check __attribute__((warn_unused_result)) #define __must_check __attribute__((__warn_unused_result__))
#else #else
#define __must_check #define __must_check
#endif #endif
...@@ -222,7 +222,7 @@ struct ftrace_likely_data { ...@@ -222,7 +222,7 @@ struct ftrace_likely_data {
#if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__) #if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__)
#define notrace __attribute__((hotpatch(0, 0))) #define notrace __attribute__((hotpatch(0, 0)))
#else #else
#define notrace __attribute__((no_instrument_function)) #define notrace __attribute__((__no_instrument_function__))
#endif #endif
/* /*
...@@ -231,7 +231,7 @@ struct ftrace_likely_data { ...@@ -231,7 +231,7 @@ struct ftrace_likely_data {
* stack and frame pointer being set up and there is no chance to * stack and frame pointer being set up and there is no chance to
* restore the lr register to the value before mcount was called. * restore the lr register to the value before mcount was called.
*/ */
#define __naked __attribute__((naked)) notrace #define __naked __attribute__((__naked__)) notrace
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b) #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
...@@ -242,7 +242,7 @@ struct ftrace_likely_data { ...@@ -242,7 +242,7 @@ struct ftrace_likely_data {
* defined so the gnu89 semantics are the default. * defined so the gnu89 semantics are the default.
*/ */
#ifdef __GNUC_STDC_INLINE__ #ifdef __GNUC_STDC_INLINE__
# define __gnu_inline __attribute__((gnu_inline)) # define __gnu_inline __attribute__((__gnu_inline__))
#else #else
# define __gnu_inline # define __gnu_inline
#endif #endif
...@@ -262,17 +262,17 @@ struct ftrace_likely_data { ...@@ -262,17 +262,17 @@ struct ftrace_likely_data {
#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
!defined(CONFIG_OPTIMIZE_INLINING) !defined(CONFIG_OPTIMIZE_INLINING)
#define inline \ #define inline \
inline __attribute__((always_inline, unused)) notrace __gnu_inline inline __attribute__((__always_inline__, __unused__)) notrace __gnu_inline
#else #else
#define inline inline __attribute__((unused)) notrace __gnu_inline #define inline inline __attribute__((__unused__)) notrace __gnu_inline
#endif #endif
#define __inline__ inline #define __inline__ inline
#define __inline inline #define __inline inline
#define noinline __attribute__((noinline)) #define noinline __attribute__((__noinline__))
#ifndef __always_inline #ifndef __always_inline
#define __always_inline inline __attribute__((always_inline)) #define __always_inline inline __attribute__((__always_inline__))
#endif #endif
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册