qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] Fix circular dependency for HOST_LONG_BITS qemu-com


From: David Gibson
Subject: [Qemu-devel] [PATCH] Fix circular dependency for HOST_LONG_BITS qemu-common.h <-> bswap.h
Date: Tue, 22 Jan 2013 16:33:26 +1100

Commit c732a52d3e3b7ed42d7daa94ba40a83408cd6f22 from Richard Henderson
changed leul_to_cpu() in bswap.h from a macro to an inline function.  Both
versions use HOST_LONG_BITS, but as an inline, HOST_LONG_BITS now needs to
be evaluated at the point of definition rather than only when the macro is
invoked.

HOST_LONG_BITS is defined in qemu-common.h... which in turn includes
bswap.h leading to a circular dependency.  This doesn't show up on little
endian hosts like x86, because the macros used within leul_to_cpu() end
up removing the reference to HOST_LONG_BITS.  This problem, however, breaks
build on all big endian hosts such as powerpc.

This patch fixes the problem by moving the basic HOST_LONG_BITS definition
to osdep.h, which is already included before bswap.h.

Cc: Richard Henderson <address@hidden>

Signed-off-by: David Gibson <address@hidden>
---
 include/qemu-common.h |    9 ---------
 include/qemu/osdep.h  |   10 ++++++++++
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index ca464bb..ca7f8dc 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -72,15 +72,6 @@
 #define TIME_MAX LONG_MAX
 #endif
 
-/* HOST_LONG_BITS is the size of a native pointer in bits. */
-#if UINTPTR_MAX == UINT32_MAX
-# define HOST_LONG_BITS 32
-#elif UINTPTR_MAX == UINT64_MAX
-# define HOST_LONG_BITS 64
-#else
-# error Unknown pointer size
-#endif
-
 #ifndef CONFIG_IOVEC
 #define CONFIG_IOVEC
 struct iovec {
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 87d3b9c..ebac074 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -3,6 +3,7 @@
 
 #include <stdarg.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <stdbool.h>
 #ifdef __OpenBSD__
 #include <sys/types.h>
@@ -18,6 +19,15 @@ typedef unsigned int            uint_fast16_t;
 typedef signed int              int_fast16_t;
 #endif
 
+/* HOST_LONG_BITS is the size of a native pointer in bits. */
+#if UINTPTR_MAX == UINT32_MAX
+# define HOST_LONG_BITS 32
+#elif UINTPTR_MAX == UINT64_MAX
+# define HOST_LONG_BITS 64
+#else
+# error Unknown pointer size
+#endif
+
 #ifndef glue
 #define xglue(x, y) x ## y
 #define glue(x, y) xglue(x, y)
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]