提交 91107fdf 编写于 作者: R Richard Henderson 提交者: Anthony Liguori

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: NAndreas Färber <afaerber@suse.de>
Signed-off-by: NRichard Henderson <rth@twiddle.net>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 5f876756
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册