aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-11-08 07:06:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-11-08 07:06:58 -0500
commitb00d209241ff7ac336543f92ea764b9d6b03032a (patch)
tree838a937c4913dd54978929d66025db92ecf2359e
parentd50ffc585dbec04fb1d219d5e8523fe6055e706f (diff)
parent24efee412c75843755da0ddd7bbc2db2ce9129f5 (diff)
Merge tag 'compiler-attributes-for-linus-v4.20-rc2' of https://github.com/ojeda/linux
Pull compiler attribute fixlets from Miguel Ojeda: "Small improvements to Compiler Attributes: - Define asm_volatile_goto for non-gcc compilers (Nick Desaulniers) - Improve the explanation of compiler_attributes.h" * tag 'compiler-attributes-for-linus-v4.20-rc2' of https://github.com/ojeda/linux: Compiler Attributes: improve explanation of header include/linux/compiler*.h: define asm_volatile_goto
-rw-r--r--include/linux/compiler_attributes.h14
-rw-r--r--include/linux/compiler_types.h4
2 files changed, 13 insertions, 5 deletions
diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
index 6b28c1b7310c..f8c400ba1929 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -4,22 +4,26 @@
4 4
5/* 5/*
6 * The attributes in this file are unconditionally defined and they directly 6 * The attributes in this file are unconditionally defined and they directly
7 * map to compiler attribute(s) -- except those that are optional. 7 * map to compiler attribute(s), unless one of the compilers does not support
8 * the attribute. In that case, __has_attribute is used to check for support
9 * and the reason is stated in its comment ("Optional: ...").
8 * 10 *
9 * Any other "attributes" (i.e. those that depend on a configuration option, 11 * Any other "attributes" (i.e. those that depend on a configuration option,
10 * on a compiler, on an architecture, on plugins, on other attributes...) 12 * on a compiler, on an architecture, on plugins, on other attributes...)
11 * should be defined elsewhere (e.g. compiler_types.h or compiler-*.h). 13 * should be defined elsewhere (e.g. compiler_types.h or compiler-*.h).
14 * The intention is to keep this file as simple as possible, as well as
15 * compiler- and version-agnostic (e.g. avoiding GCC_VERSION checks).
12 * 16 *
13 * This file is meant to be sorted (by actual attribute name, 17 * This file is meant to be sorted (by actual attribute name,
14 * not by #define identifier). Use the __attribute__((__name__)) syntax 18 * not by #define identifier). Use the __attribute__((__name__)) syntax
15 * (i.e. with underscores) to avoid future collisions with other macros. 19 * (i.e. with underscores) to avoid future collisions with other macros.
16 * If an attribute is optional, state the reason in the comment. 20 * Provide links to the documentation of each supported compiler, if it exists.
17 */ 21 */
18 22
19/* 23/*
20 * To check for optional attributes, we use __has_attribute, which is supported 24 * __has_attribute is supported on gcc >= 5, clang >= 2.9 and icc >= 17.
21 * on gcc >= 5, clang >= 2.9 and icc >= 17. In the meantime, to support 25 * In the meantime, to support 4.6 <= gcc < 5, we implement __has_attribute
22 * 4.6 <= gcc < 5, we implement __has_attribute by hand. 26 * by hand.
23 * 27 *
24 * sparse does not support __has_attribute (yet) and defines __GNUC_MINOR__ 28 * sparse does not support __has_attribute (yet) and defines __GNUC_MINOR__
25 * depending on the compiler used to build it; however, these attributes have 29 * depending on the compiler used to build it; however, these attributes have
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 3439d7d0249a..4a3f9c09c92d 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -130,6 +130,10 @@ struct ftrace_likely_data {
130# define randomized_struct_fields_end 130# define randomized_struct_fields_end
131#endif 131#endif
132 132
133#ifndef asm_volatile_goto
134#define asm_volatile_goto(x...) asm goto(x)
135#endif
136
133/* Are two types/vars the same type (ignoring qualifiers)? */ 137/* Are two types/vars the same type (ignoring qualifiers)? */
134#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 138#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
135 139