Re: [kvm-unit-tests PATCH] compiler.h: Make __always_inline match glibc definition, preventing redefine error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27/03/2023 14.22, Nicholas Piggin wrote:
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.

Signed-off-by: Nicholas Piggin <npiggin@xxxxxxxxx>
---
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(-)

diff --git a/lib/linux/compiler.h b/lib/linux/compiler.h
index 6f565e4..bf3313b 100644
--- a/lib/linux/compiler.h
+++ b/lib/linux/compiler.h
@@ -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__))

Thanks, applied.

 Thomas




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux