Skip to contentSkip to conversation

arch_init: Fix AltiVec build on Darwin/ppc

PATCH In review Andreas Färber 3 participants 3 messages May 27, 2012 – May 28, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arch_init: Fix AltiVec build on Darwin/ppc

Commit f29a56147b66845914d0a645bf9b4c5bb9a6af57 (implement -no-user-config command-line option (v3)) introduced uses of bool in arch_init.c. Shortly before that usage is support code for AltiVec (conditional to __ALTIVEC__).

GCC's altivec.h may in a !__APPLE_ALTIVEC__ code path redefine bool, leading to type mismatches. altivec.h recommends to #undef for C++ compatibility, but doing so on C leads to bool remaining undefined.

Fix by redefining bool to _Bool as mandated for stdbool.h by POSIX.

Cc Eduardo Habkost <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Alexander Graf <[email protected]>
Cc qemu-ppc <[email protected]>
---
 arch_init.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch_init.c +4 -0
index 988adca..a9e8b74 100644
@@ -100,6 +100,10 @@ const uint32_t arch_type = QEMU_ARCH;
 #define VECTYPE        vector unsigned char
 #define SPLAT(p)       vec_splat(vec_ld(0, p), 0)
 #define ALL_EQ(v1, v2) vec_all_eq(v1, v2)
+/* altivec.h may redefine the bool macro as vector type.
+ * Reset it to POSIX semantics. */
+#undef bool
+#define bool _Bool
 #elif defined __SSE2__
 #include <emmintrin.h>
 #define VECTYPE        __m128i
Signature · 1 line
1.7.5.3
#1 lore raw

Am 27.05.2012 17:37, schrieb Andreas Färber:

Quoted 8 lines

Commit f29a56147b66845914d0a645bf9b4c5bb9a6af57 (implement -no-user-config command-line option (v3)) introduced uses of bool in arch_init.c. Shortly before that usage is support code for AltiVec (conditional to __ALTIVEC__).

GCC's altivec.h may in a !__APPLE_ALTIVEC__ code path redefine bool, leading to type mismatches. altivec.h recommends to #undef for C++ compatibility, but doing so on C leads to bool remaining undefined.

"in C" - please fix when applying.

Thanks,
Andreas

Quoted 7 lines

Fix by redefining bool to _Bool as mandated for stdbool.h by POSIX.

Cc Eduardo Habkost <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Alexander Graf <[email protected]>
Cc qemu-ppc <[email protected]>

P.S. No such errors with gcc (SUSE Linux) 4.6.3, even with --extra-cflags="-maltivec", so I'm guessing __bool differs.

Quoted 19 lines
---
 arch_init.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch_init.c +4 -0
index 988adca..a9e8b74 100644
@@ -100,6 +100,10 @@ const uint32_t arch_type = QEMU_ARCH;
 #define VECTYPE        vector unsigned char
 #define SPLAT(p)       vec_splat(vec_ld(0, p), 0)
 #define ALL_EQ(v1, v2) vec_all_eq(v1, v2)
+/* altivec.h may redefine the bool macro as vector type.
+ * Reset it to POSIX semantics. */
+#undef bool
+#define bool _Bool
 #elif defined __SSE2__
 #include <emmintrin.h>
 #define VECTYPE        __m128i
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Reviewed-by on v1 1/1
#2 lore raw
In reply to Andreas Färber

Il 27/05/2012 17:37, Andreas Färber ha scritto:

Quoted 3 lines

GCC's altivec.h may in a !__APPLE_ALTIVEC__ code path redefine bool, leading to type mismatches. altivec.h recommends to #undef for C++ compatibility, but doing so on C leads to bool remaining undefined.

Paolo