Re: [PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations
From: Sedat Dilek
Date: Fri Jun 08 2018 - 10:35:00 EST
On Wed, Jun 6, 2018 at 6:39 PM, <hpa@xxxxxxxxx> wrote:
...
>>Beyond this, a general question: Can someone explain why all these
>>inline defines are in compiler-gcc.h (as there exists compiler.h and
>>compiler-clang.h)?
>>
>>Thanks.
>>
>>Regards,
>>- Sedat -
>
> Because gcc itself also supports both GNU89-style and C99-style inlines, but the kernel was built with the former, and it is not necessarily a trivial modification, except for "static inline" which is the same for both.
>
> The other option is to pass -fgnu89-inline on the command line, which is supported by both gcc and clang. The two methods are fully equivalent.
>
We have...
$ ls include/linux/compiler*
include/linux/compiler-clang.h include/linux/compiler-gcc.h
include/linux/compiler.h include/linux/compiler-intel.h
include/linux/compiler_types.h
include/linux/compiler_types.h says...
#ifdef __GNUC__
#include <linux/compiler-gcc.h>
#endif
...
/* Intel compiler defines __GNUC__. So we will overwrite implementations
* coming from above header files here
*/
#ifdef __INTEL_COMPILER
# include <linux/compiler-intel.h>
#endif
/* Clang compiler defines __GNUC__. So we will overwrite implementations
* coming from above header files here
*/
#ifdef __clang__
#include <linux/compiler-clang.h>
#endif
/*
* Generic compiler-dependent macros required for kernel
* build go below this comment. Actual compiler/compiler version
* specific implementations come from the above header files
*/
...
include/linux/compiler-clang.h says...
#ifndef __LINUX_COMPILER_TYPES_H
#error "Please don't include <linux/compiler-clang.h> directly,
include <linux/compiler.h> instead."
#endif
So, compiler-clang.h uses defines etc. from compiler-gcc.h but might
overwrite it.
Correct?
I would have expected inline defines in compiler.h as I thought there
is the place for generic stuff.
Maybe you can clarify on the roles of especially compiler.h and
compiler_types.h.
Thanks.
- sed@ -