aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>2018-08-30 13:13:37 -0400
committerMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>2018-09-30 14:14:03 -0400
commit5c67a52f3da0f0d22764f2daec417702695a8112 (patch)
tree2d3921c950b927a3bdf1a54265fd76409804e0ed
parent29efbc6aea9d9bd9aa9870a9afc1882046303cf9 (diff)
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: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
-rw-r--r--include/linux/compiler-clang.h2
-rw-r--r--include/linux/compiler-gcc.h12
-rw-r--r--include/linux/compiler-intel.h2
-rw-r--r--include/linux/compiler.h8
-rw-r--r--include/linux/compiler_types.h42
5 files changed, 33 insertions, 33 deletions
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index b1ce500fe8b3..d11cad61ba5c 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -21,7 +21,7 @@
21#define __SANITIZE_ADDRESS__ 21#define __SANITIZE_ADDRESS__
22#endif 22#endif
23 23
24#define __no_sanitize_address __attribute__((no_sanitize("address"))) 24#define __no_sanitize_address __attribute__((__no_sanitize__("address")))
25 25
26/* 26/*
27 * Not all versions of clang implement the the type-generic versions 27 * Not all versions of clang implement the the type-generic versions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 1302b425e625..7a1de7683df5 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -76,7 +76,7 @@
76#endif 76#endif
77 77
78#ifdef RETPOLINE 78#ifdef RETPOLINE
79#define __noretpoline __attribute__((indirect_branch("keep"))) 79#define __noretpoline __attribute__((__indirect_branch__("keep")))
80#endif 80#endif
81 81
82#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) 82#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
@@ -84,8 +84,8 @@
84#define __compiletime_object_size(obj) __builtin_object_size(obj, 0) 84#define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
85 85
86#ifndef __CHECKER__ 86#ifndef __CHECKER__
87#define __compiletime_warning(message) __attribute__((warning(message))) 87#define __compiletime_warning(message) __attribute__((__warning__(message)))
88#define __compiletime_error(message) __attribute__((error(message))) 88#define __compiletime_error(message) __attribute__((__error__(message)))
89 89
90#ifdef LATENT_ENTROPY_PLUGIN 90#ifdef LATENT_ENTROPY_PLUGIN
91#define __latent_entropy __attribute__((latent_entropy)) 91#define __latent_entropy __attribute__((latent_entropy))
@@ -134,7 +134,7 @@
134 * optimizer that something else uses this function or variable, thus preventing 134 * optimizer that something else uses this function or variable, thus preventing
135 * this. 135 * this.
136 */ 136 */
137#define __visible __attribute__((externally_visible)) 137#define __visible __attribute__((__externally_visible__))
138 138
139/* gcc version specific checks */ 139/* gcc version specific checks */
140 140
@@ -191,7 +191,7 @@
191 * should not be applied to that function. 191 * should not be applied to that function.
192 * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 192 * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
193 */ 193 */
194#define __no_sanitize_address __attribute__((no_sanitize_address)) 194#define __no_sanitize_address __attribute__((__no_sanitize_address__))
195#endif 195#endif
196 196
197#if GCC_VERSION >= 50100 197#if GCC_VERSION >= 50100
@@ -199,7 +199,7 @@
199 * Mark structures as requiring designated initializers. 199 * Mark structures as requiring designated initializers.
200 * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html 200 * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
201 */ 201 */
202#define __designated_init __attribute__((designated_init)) 202#define __designated_init __attribute__((__designated_init__))
203#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 203#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
204#endif 204#endif
205 205
diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h
index 4c7f9befa9f6..fef8bb3e53ef 100644
--- a/include/linux/compiler-intel.h
+++ b/include/linux/compiler-intel.h
@@ -42,4 +42,4 @@
42 * and may be redefined here because they should not be shared with other 42 * and may be redefined here because they should not be shared with other
43 * compilers, like clang. 43 * compilers, like clang.
44 */ 44 */
45#define __visible __attribute__((externally_visible)) 45#define __visible __attribute__((__externally_visible__))
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 7c0157d50964..ec4a28bad2c6 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -24,7 +24,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
24 long ______r; \ 24 long ______r; \
25 static struct ftrace_likely_data \ 25 static struct ftrace_likely_data \
26 __attribute__((__aligned__(4))) \ 26 __attribute__((__aligned__(4))) \
27 __attribute__((section("_ftrace_annotated_branch"))) \ 27 __attribute__((__section__("_ftrace_annotated_branch"))) \
28 ______f = { \ 28 ______f = { \
29 .data.func = __func__, \ 29 .data.func = __func__, \
30 .data.file = __FILE__, \ 30 .data.file = __FILE__, \
@@ -60,7 +60,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
60 int ______r; \ 60 int ______r; \
61 static struct ftrace_branch_data \ 61 static struct ftrace_branch_data \
62 __attribute__((__aligned__(4))) \ 62 __attribute__((__aligned__(4))) \
63 __attribute__((section("_ftrace_branch"))) \ 63 __attribute__((__section__("_ftrace_branch"))) \
64 ______f = { \ 64 ______f = { \
65 .func = __func__, \ 65 .func = __func__, \
66 .file = __FILE__, \ 66 .file = __FILE__, \
@@ -146,7 +146,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
146 extern typeof(sym) sym; \ 146 extern typeof(sym) sym; \
147 static const unsigned long __kentry_##sym \ 147 static const unsigned long __kentry_##sym \
148 __used \ 148 __used \
149 __attribute__((section("___kentry" "+" #sym ), used)) \ 149 __attribute__((__section__("___kentry" "+" #sym ), used)) \
150 = (unsigned long)&sym; 150 = (unsigned long)&sym;
151#endif 151#endif
152 152
@@ -287,7 +287,7 @@ unsigned long read_word_at_a_time(const void *addr)
287 * visible to the compiler. 287 * visible to the compiler.
288 */ 288 */
289#define __ADDRESSABLE(sym) \ 289#define __ADDRESSABLE(sym) \
290 static void * __attribute__((section(".discard.addressable"), used)) \ 290 static void * __attribute__((__section__(".discard.addressable"), used)) \
291 __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; 291 __PASTE(__addressable_##sym, __LINE__) = (void *)&sym;
292 292
293/** 293/**
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index a19562cb047c..8fbdd47dd3d0 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -195,26 +195,26 @@ struct ftrace_likely_data {
195 * would be. 195 * would be.
196 * [...] 196 * [...]
197 */ 197 */
198#define __pure __attribute__((pure)) 198#define __pure __attribute__((__pure__))
199#define __aligned(x) __attribute__((aligned(x))) 199#define __aligned(x) __attribute__((__aligned__(x)))
200#define __aligned_largest __attribute__((aligned)) 200#define __aligned_largest __attribute__((__aligned__))
201#define __printf(a, b) __attribute__((format(printf, a, b))) 201#define __printf(a, b) __attribute__((__format__(printf, a, b)))
202#define __scanf(a, b) __attribute__((format(scanf, a, b))) 202#define __scanf(a, b) __attribute__((__format__(scanf, a, b)))
203#define __maybe_unused __attribute__((unused)) 203#define __maybe_unused __attribute__((__unused__))
204#define __always_unused __attribute__((unused)) 204#define __always_unused __attribute__((__unused__))
205#define __mode(x) __attribute__((mode(x))) 205#define __mode(x) __attribute__((__mode__(x)))
206#define __malloc __attribute__((__malloc__)) 206#define __malloc __attribute__((__malloc__))
207#define __used __attribute__((__used__)) 207#define __used __attribute__((__used__))
208#define __noreturn __attribute__((noreturn)) 208#define __noreturn __attribute__((__noreturn__))
209#define __packed __attribute__((packed)) 209#define __packed __attribute__((__packed__))
210#define __weak __attribute__((weak)) 210#define __weak __attribute__((__weak__))
211#define __alias(symbol) __attribute__((alias(#symbol))) 211#define __alias(symbol) __attribute__((__alias__(#symbol)))
212#define __cold __attribute__((cold)) 212#define __cold __attribute__((__cold__))
213#define __section(S) __attribute__((__section__(#S))) 213#define __section(S) __attribute__((__section__(#S)))
214 214
215 215
216#ifdef CONFIG_ENABLE_MUST_CHECK 216#ifdef CONFIG_ENABLE_MUST_CHECK
217#define __must_check __attribute__((warn_unused_result)) 217#define __must_check __attribute__((__warn_unused_result__))
218#else 218#else
219#define __must_check 219#define __must_check
220#endif 220#endif
@@ -222,7 +222,7 @@ struct ftrace_likely_data {
222#if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__) 222#if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__)
223#define notrace __attribute__((hotpatch(0, 0))) 223#define notrace __attribute__((hotpatch(0, 0)))
224#else 224#else
225#define notrace __attribute__((no_instrument_function)) 225#define notrace __attribute__((__no_instrument_function__))
226#endif 226#endif
227 227
228/* 228/*
@@ -231,7 +231,7 @@ struct ftrace_likely_data {
231 * stack and frame pointer being set up and there is no chance to 231 * stack and frame pointer being set up and there is no chance to
232 * restore the lr register to the value before mcount was called. 232 * restore the lr register to the value before mcount was called.
233 */ 233 */
234#define __naked __attribute__((naked)) notrace 234#define __naked __attribute__((__naked__)) notrace
235 235
236#define __compiler_offsetof(a, b) __builtin_offsetof(a, b) 236#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
237 237
@@ -242,7 +242,7 @@ struct ftrace_likely_data {
242 * defined so the gnu89 semantics are the default. 242 * defined so the gnu89 semantics are the default.
243 */ 243 */
244#ifdef __GNUC_STDC_INLINE__ 244#ifdef __GNUC_STDC_INLINE__
245# define __gnu_inline __attribute__((gnu_inline)) 245# define __gnu_inline __attribute__((__gnu_inline__))
246#else 246#else
247# define __gnu_inline 247# define __gnu_inline
248#endif 248#endif
@@ -262,17 +262,17 @@ struct ftrace_likely_data {
262#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ 262#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
263 !defined(CONFIG_OPTIMIZE_INLINING) 263 !defined(CONFIG_OPTIMIZE_INLINING)
264#define inline \ 264#define inline \
265 inline __attribute__((always_inline, unused)) notrace __gnu_inline 265 inline __attribute__((__always_inline__, __unused__)) notrace __gnu_inline
266#else 266#else
267#define inline inline __attribute__((unused)) notrace __gnu_inline 267#define inline inline __attribute__((__unused__)) notrace __gnu_inline
268#endif 268#endif
269 269
270#define __inline__ inline 270#define __inline__ inline
271#define __inline inline 271#define __inline inline
272#define noinline __attribute__((noinline)) 272#define noinline __attribute__((__noinline__))
273 273
274#ifndef __always_inline 274#ifndef __always_inline
275#define __always_inline inline __attribute__((always_inline)) 275#define __always_inline inline __attribute__((__always_inline__))
276#endif 276#endif
277 277
278/* 278/*