[PATCH v4 1/3] compiler-gcc.h: add gnu_inline to all inline declarations

H. Peter Anvin
Tue, 12 Jun 2018 21:31:08 -0000

On 06/12/18 13:19, Nick Desaulniers wrote:
>
> Oh, by [0] __GCC_STDC_INLINE__ is indeed actually the correct symbol
> to check for.  Clang does support that, so nothing to fix there.
>
>> By the way, you should check clang against gcc's predefined macros
by doing:
>>
>> gcc [options] -x c -Wp,-dM -E /dev/null | sort
>>
>> Options can change the predefined macros substantially, especially the,
-std=, arch and -O options. -x c can be replaced with e.g. -x c++, objective-c,
assembler-with-cpp etc.
>
> Neat, I'll have to bookmark that incantation.  I can s/gcc/clang/ to
> get a similar list (which is how I know it supports
> __GCC_STDC_INLINE__).>

I bet that if you add -fgnu89-inlines then it *does* define
__GNUC_GNU_INLINE__.

>
> Patch now becomes something like:
>
> #ifdef __GNUC_GNU_INLINE__
> #define __gnu_inline __attribute__((gnu_inline))
> #else
> #define __gnu_inline
> #endif
>
> #define inline inline __attribute__((always_inline, unused)) notrace
> __gnu_inline
> ...
>
> Issues with that approach?
>

s/__GNUC_GNU_INLINE__/__GNUC_STDC_INLINE__/

	-hpa