On 05/09/2019 02.18, Nick Desaulniers wrote: > On Fri, Aug 30, 2019 at 4:15 PM Rasmus Villemoes > <li...@rasmusvillemoes.dk> wrote: >> >> This adds an asm_inline macro which expands to "asm inline" [1] when gcc >> is new enough (>= 9.1), and just asm for older gccs and other >> compilers. >> >> Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> >> --- >> include/linux/compiler-gcc.h | 4 ++++ >> include/linux/compiler_types.h | 4 ++++ >> 2 files changed, 8 insertions(+) >> >> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h >> index d7ee4c6bad48..544b87b41b58 100644 >> --- a/include/linux/compiler-gcc.h >> +++ b/include/linux/compiler-gcc.h >> @@ -172,3 +172,7 @@ >> #endif >> >> #define __no_fgcse __attribute__((optimize("-fno-gcse"))) >> + >> +#if GCC_VERSION >= 90100 > > Is it too late to ask for a feature test macro? Maybe one already > exists?
No, not as far as I know. Perhaps something like below, though that won't affect the already released gcc 9.1 and 9.2, of course. gcc maintainers, WDYT? Can we add a feature test macro for asm inline()? For context, I'm trying to add an asm_inline macro to the kernel source that will fall back to asm when "asm inline" is not supported - see https://lore.kernel.org/lkml/20190830231527.22304-1-li...@rasmusvillemoes.dk/ for the whole thread. From: Rasmus Villemoes <r...@rasmusvillemoes.dk> Subject: [PATCH] add feature test macro for "asm inline" Allow users to check availability of "asm inline()" via a feature test macro. If and when clang implements support for "asm inline()", it's easier for users if they can just test __HAVE_ASM_INLINE rather than juggling different version checks for different compilers. Changelog: gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Add pre-define for __HAVE_ASM_INLINE. gcc/ * doc/cpp.texi: Document predefine __HAVE_ASM_INLINE. --- gcc/c-family/c-cppbuiltin.c | 3 +++ gcc/doc/cpp.texi | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index fc68bc4d0c4..163f3058741 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -1383,6 +1383,9 @@ c_cpp_builtins (cpp_reader *pfile) if (targetm.have_speculation_safe_value (false)) cpp_define (pfile, "__HAVE_SPECULATION_SAFE_VALUE"); + /* Show the availability of "asm inline()". */ + cpp_define (pfile, "__HAVE_ASM_INLINE"); + #ifdef DWARF2_UNWIND_INFO if (dwarf2out_do_cfi_asm ()) cpp_define (pfile, "__GCC_HAVE_DWARF2_CFI_ASM"); diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index e271f5180d8..98f6d625857 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -2386,6 +2386,11 @@ and swap operations on operands 1, 2, 4, 8 or 16 bytes in length, respectively. This macro is defined with the value 1 to show that this version of GCC supports @code{__builtin_speculation_safe_value}. +@item __HAVE_ASM_INLINE +This macro is defined with the value 1 to show that this version of GCC +supports @code{asm inline()}. @xref{Size of an asm,,, gcc, Using +the GNU Compiler Collection (GCC)}. + @item __GCC_HAVE_DWARF2_CFI_ASM This macro is defined when the compiler is emitting DWARF CFI directives to the assembler. When this is defined, it is possible to emit those same