path: root/init
diff options
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2019-09-13 00:19:25 +0200
committerMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>2019-09-15 20:14:15 +0200
commiteb111869301e15b737315a46c913ae82bd19eb9d (patch)
tree318b0dbee699f3c007fc0a3c6fce072a103f45d1 /init
parentc30724e9a061135f8c7b925c0fcdf742510a3bc5 (diff)
compiler-types.h: add asm_inline definition
This adds an asm_inline macro which expands to "asm inline" [1] when the compiler supports it. This is currently gcc 9.1+, gcc 8.3 and (once released) gcc 7.5 [2]. It expands to just "asm" for other compilers. Using asm inline("foo") instead of asm("foo") overrules gcc's heuristic estimate of the size of the code represented by the asm() statement, and makes gcc use the minimum possible size instead. That can in turn affect gcc's inlining decisions. I wasn't sure whether to make this a function-like macro or not - this way, it can be combined with volatile as asm_inline volatile() but perhaps we'd prefer to spell that asm_inline_volatile() anyway. The Kconfig logic is taken from an RFC patch by Masahiro Yamada [3]. [1] Technically, asm __inline, since both inline and __inline__ are macros that attach various attributes, making gcc barf if one literally does "asm inline()". However, the third spelling __inline is available for referring to the bare keyword. [2] https://lore.kernel.org/lkml/20190907001411.GG9749@gate.crashing.org/ [3] https://lore.kernel.org/lkml/1544695154-15250-1-git-send-email-yamada.masahiro@socionext.com/ Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Diffstat (limited to 'init')
1 files changed, 3 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig
index bd7d650d4a99..7fee5978dd73 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -30,6 +30,9 @@ config CC_CAN_LINK
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
+ def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null)
def_bool $(cc-option,-Wmaybe-uninitialized)

Privacy Policy