Am 30.01.2013 22:04, schrieb Stefan Weil:
Am 30.01.2013 21:55, schrieb Richard Henderson:
This is not always defined in all places qemu/bswap.h is used.
If we include qemu-common.h to get it, we create an include loop.
This resolves a build problem on any big-endian host like ppc64.
Signed-off-by: Richard Henderson<[email protected]>
---
include/qemu/bswap.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index e6d4798..d3af35d 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -2,8 +2,8 @@
#define BSWAP_H
#include "config-host.h"
-
#include<inttypes.h>
+#include<limits.h>
#include "fpu/softfloat.h"
#ifdef CONFIG_MACHINE_BSWAP_H
@@ -458,7 +458,15 @@ static inline void cpu_to_32wu(uint32_t *p,
uint32_t v)
static inline unsigned long leul_to_cpu(unsigned long v)
{
- return le_bswap(v, HOST_LONG_BITS);
+ /* In order to break an include loop between here and
+ qemu-common.h, don't rely on HOST_LONG_BITS. */
+#if ULONG_MAX == UINT32_MAX
+ return le_bswap(v, 32);
+#elif ULONG_MAX == UINT64_MAX
+ return le_bswap(v, 64);
+#else
+# error Unknown sizeof long
+#endif
}
#undef le_bswap
That would be wrong for 64 bit MinGW-w64 because
HOST_LONG_BITS is _not_ the bit size of a long value.
See qemu-common.h for the correct definition.
Regards
Stefan W.
Could you please try whether this patch fixes the build problems:
From 4dd39af7a3e493669977ec6f50e91bf649b5727f Mon Sep 17 00:00:00 2001
From: Stefan Weil <[email protected]>
Date: Wed, 30 Jan 2013 22:52:12 +0100
Subject: [PATCH] Fix build problems for big endian hosts
Make sure that HOST_LONG_BITS is always defined when qemu/bswap.h
is included.
Signed-off-by: Stefan Weil <[email protected]>
---
fsdev/virtio-9p-marshal.c | 12 +-----------
hw/spapr_nvram.c | 2 ++
include/qemu/bswap.h | 4 ++++
3 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c
index 20f308b..4e634df 100644
--- a/fsdev/virtio-9p-marshal.c
+++ b/fsdev/virtio-9p-marshal.c
@@ -11,20 +11,10 @@
*
*/
-#include <glib.h>
#include <glib/gprintf.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/time.h>
-#include <utime.h>
-#include <sys/uio.h>
-#include <string.h>
-#include <stdint.h>
-#include <errno.h>
-#include "qemu/compiler.h"
+#include "qemu-common.h"
#include "virtio-9p-marshal.h"
-#include "qemu/bswap.h"
void v9fs_string_free(V9fsString *str)
{
diff --git a/hw/spapr_nvram.c b/hw/spapr_nvram.c
index 680cdba..2960b15 100644
--- a/hw/spapr_nvram.c
+++ b/hw/spapr_nvram.c
@@ -22,6 +22,8 @@
* THE SOFTWARE.
*/
+#include "qemu-common.h"
+
#include <libfdt.h>
#include "sysemu/device_tree.h"
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index e6d4798..07dadc2 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -13,6 +13,10 @@
#elif defined(CONFIG_BYTESWAP_H)
# include <byteswap.h>
+#if !defined(HOST_LONG_BITS)
+# error needs HOST_LONG_BITS
+#endif
+
static inline uint16_t bswap16(uint16_t x)
{
return bswap_16(x);
--
1.7.10.4