Fix leul_to_cpu on big endian hosts
PATCH 1/1 Fix leul_to_cpu on big endian hosts
Commit 213acd2e introduced leul_to_cpu with a special code path for big endian hosts. Unfortunately that code used preprocessor magic that didn't work.
This patch replaces the explicit ##s by glue() which is proven to work reliably, enabling me to compile qemu on ppc again.
--- bswap.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
bswap.h +1 -1
@@ -205,7 +205,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)#ifdef HOST_WORDS_BIGENDIAN #define cpu_to_32wu cpu_to_be32wu -#define leul_to_cpu (v) le ## HOST_LONG_BITS ## _to_cpu(v) +#define leul_to_cpu (v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)#else #define cpu_to_32wu cpu_to_le32wu#define leul_to_cpu (v) (v)
Signature · 1 line
1.6.0.2
Quoted 16 lines · Alexander Graf
Commit
213acd2eintroducedleul_to_cpuwith a special code path for big endian hosts. Unfortunately that code used preprocessor magic that didn't work.This patch replaces the explicit ##s by
glue()which is proven to work reliably, enabling me to compile qemu on ppc again.Signed-off-by Alexander Graf <[email protected]>--- bswap.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)bswap.h +0
-0
bswap.h static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) · line 211
Quoted 8 lines
bswap.h +1
-1@@ -205,7 +205,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)#ifdef HOST_WORDS_BIGENDIAN #define cpu_to_32wu cpu_to_be32wu -#define leul_to_cpu (v) le ## HOST_LONG_BITS ## _to_cpu(v) +#define leul_to_cpu (v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)#else #define cpu_to_32wu cpu_to_le32wu#define leul_to_cpu (v) (v)
While the patch looks correct, I am not able to reproduce the issue. Do you have more details about it?
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 19 lines · Aurelien Jarno
Quoted 17 lines · Alexander Graf
Commit
213acd2eintroducedleul_to_cpuwith a special code path for big endian hosts. Unfortunately that code used preprocessor magic that didn't work.This patch replaces the explicit ##s by
glue()which is proven to work reliably, enabling me to compile qemu on ppc again.Signed-off-by Alexander Graf <[email protected]>--- bswap.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)bswap.h +0
-0@@ -205,7 +205,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
Quoted 12 lines
bswap.h static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) · line 211
Quoted 8 lines
bswap.h +1
-1#ifdef HOST_WORDS_BIGENDIAN #define cpu_to_32wu cpu_to_be32wu -#define leul_to_cpu (v) le ## HOST_LONG_BITS ## _to_cpu(v) +#define leul_to_cpu (v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)#else #define cpu_to_32wu cpu_to_le32wu#define leul_to_cpu (v) (v)While the patch looks correct, I am not able to reproduce the issue. Do you have more details about it?
When building on a KVM capable PPC host (or S390 for that matter), I get the following:
cc1: warnings being treated as errors /home/agraf/release/qemu/kvm-all.c: In function ‘kvm_get_dirty_pages_log_range’:/home/agraf/release/qemu/kvm-all.c:305: error: implicit declaration of function ‘leHOST_LONG_BITS_to_cpu’
make[1]: *** [kvm-all.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [subdir-ppc64-softmmu] Error 2
Alex
Quoted 36 lines · Alexander Graf
Quoted 19 lines · Aurelien Jarno
Quoted 17 lines · Alexander Graf
Commit
213acd2eintroducedleul_to_cpuwith a special code path for big endian hosts. Unfortunately that code used preprocessor magic that didn't work.This patch replaces the explicit ##s by
glue()which is proven to work reliably, enabling me to compile qemu on ppc again.Signed-off-by Alexander Graf <[email protected]>--- bswap.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)bswap.h +0
-0@@ -205,7 +205,7 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)Quoted 12 lines
bswap.h static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) · line 211
Quoted 8 lines
bswap.h +1
-1#ifdef HOST_WORDS_BIGENDIAN #define cpu_to_32wu cpu_to_be32wu -#define leul_to_cpu (v) le ## HOST_LONG_BITS ## _to_cpu(v) +#define leul_to_cpu (v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v)#else #define cpu_to_32wu cpu_to_le32wu#define leul_to_cpu (v) (v)While the patch looks correct, I am not able to reproduce the issue. Do you have more details about it?
When building on a KVM capable PPC host (or S390 for that matter), I get the following:
Quoted 9 lines
cc1: warnings being treated as errors
/home/agraf/release/qemu/kvm-all.c: In function ‘kvm_get_dirty_pages_log_range’:/home/agraf/release/qemu/kvm-all.c:305: error: implicit declaration of function ‘leHOST_LONG_BITS_to_cpu’
make[1]: *** [kvm-all.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [subdir-ppc64-softmmu] Error 2
Ok, that make sense now. I have tried to build on a big endian host, but KVM was not enabled. Strangely this function is also used at other places, so I was expecting the build to fail.
Applied now.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 6 lines · Alexander Graf
Commit
213acd2eintroducedleul_to_cpuwith a special code path for big endian hosts. Unfortunately that code used preprocessor magic that didn't work.This patch replaces the explicit ##s by
glue()which is proven to work reliably, enabling me to compile qemu on ppc again.
Ping?
Alex