Re: [PATCH] include/linux/compiler*.h: make compiler-*.h mutually exclusive

From: Joe Perches
Date: Thu Aug 23 2018 - 17:19:14 EST


On Thu, 2018-08-23 at 14:03 -0700, Nick Desaulniers wrote:
> One reply for a bunch of the various threads, to keep the number of emails down:
>
> On Wed, Aug 22, 2018 at 5:20 PM Joe Perches <joe@xxxxxxxxxxx> wrote:
> > On Wed, 2018-08-22 at 16:37 -0700, Nick Desaulniers wrote:
> > > +/* Compiler specific macros. */
> > > #ifdef __clang__
> > > #include <linux/compiler-clang.h>
> >
> > probably better as
> >
> > #if defined(__clang)
> >
> > to match the style of the #elif defined()s below it
>
> Hi Joe,
> Thanks for the feedback. I always appreciate it. If you have some
> cleanups, want to send them to me, and I'll bundle them up for a PR?
> I'm ok with that change.
>
> > > +#ifdef __GNUC_STDC_INLINE__
> > > +# define __gnu_inline __attribute__((gnu_inline))
> > > +#else
> > > +# define __gnu_inline
> > > +#endif
> >
> > Perhaps __gnu_inline should be in compiler-gcc and this
> > should use
> >
> > #ifndef __gnu_inline
> > #define __gnu_inline
> > #endif
>
> Not this case; it's how we get gnu89 semantics for `extern inline` is
> not compiler specific (therefor should not go in a compiler specific
> header).

It's not possible to know that compilers support what
__attribute__((<foo>)) and at what version that support
exists unless it is specified somewhere.

As far as I can tell, gnu_inline is not recognized by clang.

https://clang.llvm.org/docs/AttributeReference.html