qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH] vmxnet: Don't use bswap_64 for c


From: Andreas Färber
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] vmxnet: Don't use bswap_64 for constants
Date: Thu, 28 Mar 2013 00:42:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

Am 27.03.2013 19:47, schrieb Richard Henderson:
> This macro is used in the context of defining enum values.
> We can't use a function call in that case.
> 
> Cc: address@hidden
> Signed-off-by: Richard Henderson <address@hidden>
> ---
>  hw/vmxnet3.h | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/vmxnet3.h b/hw/vmxnet3.h
> index 7db0c8f..cd9ac85 100644
> --- a/hw/vmxnet3.h
> +++ b/hw/vmxnet3.h
> @@ -37,7 +37,15 @@
>  #define __packed QEMU_PACKED
>  
>  #if defined(HOST_WORDS_BIGENDIAN)
> -#define const_cpu_to_le64(x) bswap_64(x)
> +#define const_cpu_to_le64(x) \
> +        (((x & 0x00000000000000ffULL) << 56) | \
> +         ((x & 0x000000000000ff00ULL) << 40) | \
> +         ((x & 0x0000000000ff0000ULL) << 24) | \
> +         ((x & 0x00000000ff000000ULL) <<  8) | \
> +         ((x & 0x000000ff00000000ULL) >>  8) | \
> +         ((x & 0x0000ff0000000000ULL) >> 24) | \
> +         ((x & 0x00ff000000000000ULL) >> 40) | \
> +         ((x & 0xff00000000000000ULL) >> 56))

Being a macro, shouldn't this better use (x) for operator precedence?

Andreas

>  #define __BIG_ENDIAN_BITFIELD
>  #else
>  #define const_cpu_to_le64(x) (x)
> 


-- 
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]