* [Qemu-devel] [PATCH] vmxnet: Don't use bswap_64 for constants
@ 2013-03-27 18:47 Richard Henderson
2013-03-27 23:42 ` Andreas Färber
0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2013-03-27 18:47 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
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))
#define __BIG_ENDIAN_BITFIELD
#else
#define const_cpu_to_le64(x) (x)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] vmxnet: Don't use bswap_64 for constants
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
2013-03-28 0:52 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Färber @ 2013-03-27 23:42 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-trivial, qemu-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] vmxnet: Don't use bswap_64 for constants
2013-03-27 23:42 ` Andreas Färber
@ 2013-03-28 0:52 ` Richard Henderson
2013-03-28 9:45 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2013-03-28 0:52 UTC (permalink / raw)
To: Andreas Färber; +Cc: qemu-trivial, qemu-devel
On 2013-03-27 16:42, Andreas Färber wrote:
> 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?
It doesn't matter for this usage.
Nor, according to other threads that appeared on the list today, is this
the right fix, since the bswap itself turns out to be bogus.
Myself, I never tested the driver code, just fixed the compile error.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] vmxnet: Don't use bswap_64 for constants
2013-03-28 0:52 ` Richard Henderson
@ 2013-03-28 9:45 ` Stefan Hajnoczi
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2013-03-28 9:45 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-trivial, Andreas Färber, qemu-devel
On Wed, Mar 27, 2013 at 05:52:56PM -0700, Richard Henderson wrote:
> On 2013-03-27 16:42, Andreas Färber wrote:
> >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?
>
> It doesn't matter for this usage.
>
> Nor, according to other threads that appeared on the list today, is this
> the right fix, since the bswap itself turns out to be bogus.
Dmitry said he's sending a fix, will wait for that.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-28 9:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2013-03-28 0:52 ` Richard Henderson
2013-03-28 9:45 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
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).