qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] bswap: Don't rely on HOST_LONG_BITS


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH] bswap: Don't rely on HOST_LONG_BITS
Date: Wed, 30 Jan 2013 13:59:33 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 01/30/2013 01:04 PM, Stefan Weil wrote:
  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.

I beg your pardon, but it *is* right. HOST_LONG_BITS is set to the size of a host pointer, not a host long. Which suggests that my patch is the *only* correct way to do this, at least for now.


r~



reply via email to

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