aboutsummaryrefslogtreecommitdiff
path: root/include/qemu
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2013-02-04 16:21:06 -0800
committerAnthony Liguori <aliguori@us.ibm.com>2013-02-06 08:29:21 -0600
commit91107fdf4443d2171e06840e87277bb7a047343b (patch)
tree389f64ce101a56c0fe6d5600211c1856bc9feb31 /include/qemu
parent5f876756c57c15f5e14d4136fc432b74f05f082b (diff)
bswap: Fix width of swap in leul_to_cpu
The misnamed HOST_LONG_BITS is really HOST_POINTER_BITS. Here we're explicitly using an unsigned long, rather than uintptr_t, so it is more correct to select the swap size via ULONG_MAX. Acked-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/bswap.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index e6d4798142..d3af35d1d9 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