Skip to content

Commit b00d209

Browse files
committed
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
2 parents d50ffc5 + 24efee4 commit b00d209

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

include/linux/compiler_attributes.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@
44

55
/*
66
* 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: ...").
810
*
911
* Any other "attributes" (i.e. those that depend on a configuration option,
1012
* on a compiler, on an architecture, on plugins, on other attributes...)
1113
* 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).
1216
*
1317
* This file is meant to be sorted (by actual attribute name,
1418
* not by #define identifier). Use the __attribute__((__name__)) syntax
1519
* (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.
1721
*/
1822

1923
/*
20-
* To check for optional attributes, we use __has_attribute, which is supported
21-
* on gcc >= 5, clang >= 2.9 and icc >= 17. In the meantime, to support
22-
* 4.6 <= gcc < 5, we implement __has_attribute by hand.
24+
* __has_attribute is supported on gcc >= 5, clang >= 2.9 and icc >= 17.
25+
* In the meantime, to support 4.6 <= gcc < 5, we implement __has_attribute
26+
* by hand.
2327
*
2428
* sparse does not support __has_attribute (yet) and defines __GNUC_MINOR__
2529
* depending on the compiler used to build it; however, these attributes have

include/linux/compiler_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ struct ftrace_likely_data {
130130
# define randomized_struct_fields_end
131131
#endif
132132

133+
#ifndef asm_volatile_goto
134+
#define asm_volatile_goto(x...) asm goto(x)
135+
#endif
136+
133137
/* Are two types/vars the same type (ignoring qualifiers)? */
134138
#define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
135139

0 commit comments

Comments
 (0)