* [Qemu-devel] [PATCH v2] bswap: Fix width of swap in leul_to_cpu
@ 2013-02-01 22:26 Richard Henderson
2013-02-02 16:35 ` Andreas Färber
0 siblings, 1 reply; 2+ messages in thread
From: Richard Henderson @ 2013-02-01 22:26 UTC (permalink / raw)
To: qemu-devel; +Cc: blauwirbel, afaerber
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.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
include/qemu/bswap.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
This is the patch from
http://lists.gnu.org/archive/html/qemu-devel/2013-01/msg05868.html
with the commit message re-worded as per Andreas Färber feedback.
r~
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
--
1.7.11.7
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] bswap: Fix width of swap in leul_to_cpu
2013-02-01 22:26 [Qemu-devel] [PATCH v2] bswap: Fix width of swap in leul_to_cpu Richard Henderson
@ 2013-02-02 16:35 ` Andreas Färber
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Färber @ 2013-02-02 16:35 UTC (permalink / raw)
To: Richard Henderson; +Cc: blauwirbel, qemu-devel
Am 01.02.2013 23:26, schrieb Richard Henderson:
> 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.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
Acked-by: Andreas Färber <afaerber@suse.de>
Fixes a warning when including qemu/bswap.h from tests/tmp105-test.c.
Thanks,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-02 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-01 22:26 [Qemu-devel] [PATCH v2] bswap: Fix width of swap in leul_to_cpu Richard Henderson
2013-02-02 16:35 ` Andreas Färber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).