]> git.baikalelectronics.ru Git - kernel.git/commit
Compiler Attributes: use feature checks instead of version checks
authorMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Thu, 30 Aug 2018 18:36:59 +0000 (20:36 +0200)
committerMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Sun, 30 Sep 2018 18:14:03 +0000 (20:14 +0200)
commit3f1d2a94c41a72a5a6a0051a8641e8559e6a419e
tree8855bb09c0335640b625080fe266e668d9225c16
parent6d30b9ad30a5b8575235b0981be3d94634703c90
Compiler Attributes: use feature checks instead of version checks

Instead of using version checks per-compiler to define (or not)
each attribute, use __has_attribute to test for them, following
the cleanup started with commit 573db898fb28
("include/linux/compiler*.h: make compiler-*.h mutually exclusive"),
which is supported on gcc >= 5, clang >= 2.9 and icc >= 17.
In the meantime, to support 4.6 <= gcc < 5, we implement
__has_attribute by hand.

All the attributes that can be unconditionally defined and directly
map to compiler attribute(s) (even if optional) have been moved
to a new file include/linux/compiler_attributes.h

In an effort to make the file as regular as possible, comments
stating the purpose of attributes have been removed. Instead,
links to the compiler docs have been added (i.e. to gcc and,
if available, to clang as well). In addition, they have been sorted.

Finally, if an attribute is optional (i.e. if it is guarded
by __has_attribute), the reason has been stated for future reference.

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>
include/linux/compiler-clang.h
include/linux/compiler-gcc.h
include/linux/compiler-intel.h
include/linux/compiler_attributes.h [new file with mode: 0644]
include/linux/compiler_types.h