From: "Andreas Färber" <afaerber@suse.de>
To: Richard Henderson <rth@twiddle.net>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vmxnet: Don't use bswap_64 for constants
Date: Thu, 28 Mar 2013 00:42:26 +0100 [thread overview]
Message-ID: <515383E2.7010408@suse.de> (raw)
In-Reply-To: <1364410030-24008-1-git-send-email-rth@twiddle.net>
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: qemu-trivial@nongnu.org
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
> 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
next prev parent reply other threads:[~2013-03-27 23:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-27 18:47 [Qemu-devel] [PATCH] vmxnet: Don't use bswap_64 for constants Richard Henderson
2013-03-27 23:42 ` Andreas Färber [this message]
2013-03-28 0:52 ` Richard Henderson
2013-03-28 9:45 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=515383E2.7010408@suse.de \
--to=afaerber@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).