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: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH] bswap: Don't rely on HOST_LONG_BITS
Date: Wed, 30 Jan 2013 23:03:02 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130105 Thunderbird/17.0.2

Am 30.01.2013 22:59, schrieb Richard Henderson:
> 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.

IIUC on w64 ULONG_MAX == UINT32_MAX but 64 is desired for pointer.
w64 is not C99-compliant.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

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