compiler.h: Make __always_inline match glibc definition, preventing redefine error
PATCH 1/1 compiler.h: Make __always_inline match glibc definition, preventing redefine error
This makes __always_inline match glibc's cdefs.h file, which prevents redefinition errors which can happen e.g., if glibc limits.h is included before kvm-unit-tests compiler.h.
---
I ran into this with some powerpc patches. I since changed include ordering in that series so it no longer depends on this change, but it might be good to have this to be less fragile.
Thanks,
Nick
lib/linux/compiler.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
lib/linux/compiler.h +8 -1
@@ -45,7 +45,14 @@#define barrier () asm volatile("" : : : "memory") -#define __always_inline inline __attribute__((always_inline)) +/* +* As glibc's sys/cdefs.h does, this undefines __always_inline because +* Linux's stddef.h kernel header also defines it in an incompatible +* way. +*/ +#undef __always_inline +#define __always_inline __inline __attribute__ ((__always_inline__)) +#define noinline __attribute__((noinline))#define __unused __attribute__((__unused__))
Signature · 1 line
2.37.2
Thomas Huth
AppliedQuoted 26 lines · Nicholas Piggin
This makes
__always_inlinematch glibc'scdefs.hfile, which prevents redefinition errors which can happen e.g., if glibclimits.his included before kvm-unit-testscompiler.h.Signed-off-by Nicholas Piggin <[email protected]>---
I ran into this with some powerpc patches. I since changed include ordering in that series so it no longer depends on this change, but it might be good to have this to be less fragile.Thanks,
Nicklib/linux/compiler.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)lib/linux/compiler.h +1
-1@@ -45,7 +45,14 @@#define barrier () asm volatile("" : : : "memory") -#define __always_inline inline __attribute__((always_inline)) +/*
lib/linux/compiler.h line 58
Quoted 10 lines
lib/linux/compiler.h +7
-0+* As glibc's sys/cdefs.h does, this undefines __always_inline because +* Linux's stddef.h kernel header also defines it in an incompatible +* way. +*/ +#undef __always_inline +#define __always_inline __inline __attribute__ ((__always_inline__)) +#define noinline __attribute__((noinline))#define __unused __attribute__((__unused__))
Thanks, applied.
Thomas