qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] bswap: Fix width of swap in leul_to_cpu


From: Jay Foad
Subject: Re: [Qemu-devel] [PATCH v2] bswap: Fix width of swap in leul_to_cpu
Date: Tue, 12 Feb 2013 12:33:43 +0000

> @@ -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.  */

The comment's wrong, isn't it? The reason we're not using
HOST_LONG_BITS is because it's the wrong thing, not because of any
include loops.

> +#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

Is there any reason this can't be simplified to something like:

    return le_bswap(v, 8 * sizeof v);

?

Jay.



reply via email to

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