diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-01 21:34:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-01 21:34:46 -0400 |
commit | e468f5c06b5ebef3f6f3c187e51aa6daab667e57 (patch) | |
tree | be59927a66ffdf5dec86154a2ccb4ea51602450e /include/linux/compiler.h | |
parent | baa888d25ea64d0c59344d474284ca99cfdd449a (diff) | |
parent | 1ff2fea5e30ca15752777441ecb64a169fe22e9e (diff) |
Merge tag 'compiler-attributes-for-linus-4.20-rc1' of https://github.com/ojeda/linux
Pull compiler attribute updates from Miguel Ojeda:
"This is an effort to disentangle the include/linux/compiler*.h headers
and bring them up to date.
The main idea behind the series is to use feature checking macros
(i.e. __has_attribute) instead of compiler version checks (e.g.
GCC_VERSION), which are compiler-agnostic (so they can be shared,
reducing the size of compiler-specific headers) and version-agnostic.
Other related improvements have been performed in the headers as well,
which on top of the use of __has_attribute it has amounted to a
significant simplification of these headers (e.g. GCC_VERSION is now
only guarding a few non-attribute macros).
This series should also help the efforts to support compiling the
kernel with clang and icc. A fair amount of documentation and comments
have also been added, clarified or removed; and the headers are now
more readable, which should help kernel developers in general.
The series was triggered due to the move to gcc >= 4.6. In turn, this
series has also triggered Sparse to gain the ability to recognize
__has_attribute on its own.
Finally, the __nonstring variable attribute series has been also
applied on top; plus two related patches from Nick Desaulniers for
unreachable() that came a bit afterwards"
* tag 'compiler-attributes-for-linus-4.20-rc1' of https://github.com/ojeda/linux:
compiler-gcc: remove comment about gcc 4.5 from unreachable()
compiler.h: update definition of unreachable()
Compiler Attributes: ext4: remove local __nonstring definition
Compiler Attributes: auxdisplay: panel: use __nonstring
Compiler Attributes: enable -Wstringop-truncation on W=1 (gcc >= 8)
Compiler Attributes: add support for __nonstring (gcc >= 8)
Compiler Attributes: add MAINTAINERS entry
Compiler Attributes: add Doc/process/programming-language.rst
Compiler Attributes: remove uses of __attribute__ from compiler.h
Compiler Attributes: KENTRY used twice the "used" attribute
Compiler Attributes: use feature checks instead of version checks
Compiler Attributes: add missing SPDX ID in compiler_types.h
Compiler Attributes: remove unneeded sparse (__CHECKER__) tests
Compiler Attributes: homogenize __must_be_array
Compiler Attributes: remove unneeded tests
Compiler Attributes: always use the extra-underscores syntax
Compiler Attributes: remove unused attributes
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r-- | include/linux/compiler.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 4170fcee5adb..18c80cfa4fc4 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -23,8 +23,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, | |||
23 | #define __branch_check__(x, expect, is_constant) ({ \ | 23 | #define __branch_check__(x, expect, is_constant) ({ \ |
24 | long ______r; \ | 24 | long ______r; \ |
25 | static struct ftrace_likely_data \ | 25 | static struct ftrace_likely_data \ |
26 | __attribute__((__aligned__(4))) \ | 26 | __aligned(4) \ |
27 | __attribute__((section("_ftrace_annotated_branch"))) \ | 27 | __section("_ftrace_annotated_branch") \ |
28 | ______f = { \ | 28 | ______f = { \ |
29 | .data.func = __func__, \ | 29 | .data.func = __func__, \ |
30 | .data.file = __FILE__, \ | 30 | .data.file = __FILE__, \ |
@@ -59,8 +59,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, | |||
59 | ({ \ | 59 | ({ \ |
60 | int ______r; \ | 60 | int ______r; \ |
61 | static struct ftrace_branch_data \ | 61 | static struct ftrace_branch_data \ |
62 | __attribute__((__aligned__(4))) \ | 62 | __aligned(4) \ |
63 | __attribute__((section("_ftrace_branch"))) \ | 63 | __section("_ftrace_branch") \ |
64 | ______f = { \ | 64 | ______f = { \ |
65 | .func = __func__, \ | 65 | .func = __func__, \ |
66 | .file = __FILE__, \ | 66 | .file = __FILE__, \ |
@@ -115,7 +115,10 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, | |||
115 | # define ASM_UNREACHABLE | 115 | # define ASM_UNREACHABLE |
116 | #endif | 116 | #endif |
117 | #ifndef unreachable | 117 | #ifndef unreachable |
118 | # define unreachable() do { annotate_reachable(); do { } while (1); } while (0) | 118 | # define unreachable() do { \ |
119 | annotate_unreachable(); \ | ||
120 | __builtin_unreachable(); \ | ||
121 | } while (0) | ||
119 | #endif | 122 | #endif |
120 | 123 | ||
121 | /* | 124 | /* |
@@ -137,7 +140,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, | |||
137 | extern typeof(sym) sym; \ | 140 | extern typeof(sym) sym; \ |
138 | static const unsigned long __kentry_##sym \ | 141 | static const unsigned long __kentry_##sym \ |
139 | __used \ | 142 | __used \ |
140 | __attribute__((section("___kentry" "+" #sym ), used)) \ | 143 | __section("___kentry" "+" #sym ) \ |
141 | = (unsigned long)&sym; | 144 | = (unsigned long)&sym; |
142 | #endif | 145 | #endif |
143 | 146 | ||
@@ -278,7 +281,7 @@ unsigned long read_word_at_a_time(const void *addr) | |||
278 | * visible to the compiler. | 281 | * visible to the compiler. |
279 | */ | 282 | */ |
280 | #define __ADDRESSABLE(sym) \ | 283 | #define __ADDRESSABLE(sym) \ |
281 | static void * __attribute__((section(".discard.addressable"), used)) \ | 284 | static void * __section(".discard.addressable") __used \ |
282 | __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; | 285 | __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; |
283 | 286 | ||
284 | /** | 287 | /** |
@@ -331,10 +334,6 @@ static inline void *offset_to_ptr(const int *off) | |||
331 | #endif /* __KERNEL__ */ | 334 | #endif /* __KERNEL__ */ |
332 | #endif /* __ASSEMBLY__ */ | 335 | #endif /* __ASSEMBLY__ */ |
333 | 336 | ||
334 | #ifndef __optimize | ||
335 | # define __optimize(level) | ||
336 | #endif | ||
337 | |||
338 | /* Compile time object size, -1 for unknown */ | 337 | /* Compile time object size, -1 for unknown */ |
339 | #ifndef __compiletime_object_size | 338 | #ifndef __compiletime_object_size |
340 | # define __compiletime_object_size(obj) -1 | 339 | # define __compiletime_object_size(obj) -1 |
@@ -376,4 +375,7 @@ static inline void *offset_to_ptr(const int *off) | |||
376 | compiletime_assert(__native_word(t), \ | 375 | compiletime_assert(__native_word(t), \ |
377 | "Need native word sized stores/loads for atomicity.") | 376 | "Need native word sized stores/loads for atomicity.") |
378 | 377 | ||
378 | /* &a[0] degrades to a pointer: a different type from an array */ | ||
379 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) | ||
380 | |||
379 | #endif /* __LINUX_COMPILER_H */ | 381 | #endif /* __LINUX_COMPILER_H */ |