qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] bswap: improve gluing
@ 2013-01-13 16:35 Blue Swirl
  2013-01-14 15:15 ` Richard Henderson
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Blue Swirl @ 2013-01-13 16:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, rth

OpenBSD system compiler (gcc 4.2.1) has problems with concatenation
of macro arguments in macro functions:
  CC    aes.o
In file included from /src/qemu/include/qemu-common.h:126,
                 from /src/qemu/aes.c:30:
/src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu':
/src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS'
/src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS'

Function leul_to_cpu() is only used in kvm-all.c, so the warnings
are not fatal on OpenBSD without -Werror.

Fix by applying glue(). Also add do {} while(0) wrapping and fix
semicolon use while at it.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 include/qemu/bswap.h |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index be9b035..e6d4798 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -72,45 +72,45 @@ static inline void bswap64s(uint64_t *s)
 
 #if defined(HOST_WORDS_BIGENDIAN)
 #define be_bswap(v, size) (v)
-#define le_bswap(v, size) bswap ## size(v)
+#define le_bswap(v, size) glue(bswap, size)(v)
 #define be_bswaps(v, size)
-#define le_bswaps(p, size) *p = bswap ## size(*p);
+#define le_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0)
 #else
 #define le_bswap(v, size) (v)
-#define be_bswap(v, size) bswap ## size(v)
+#define be_bswap(v, size) glue(bswap, size)(v)
 #define le_bswaps(v, size)
-#define be_bswaps(p, size) *p = bswap ## size(*p);
+#define be_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0)
 #endif
 
 #define CPU_CONVERT(endian, size, type)\
 static inline type endian ## size ## _to_cpu(type v)\
 {\
-    return endian ## _bswap(v, size);\
+    return glue(endian, _bswap)(v, size);\
 }\
 \
 static inline type cpu_to_ ## endian ## size(type v)\
 {\
-    return endian ## _bswap(v, size);\
+    return glue(endian, _bswap)(v, size);\
 }\
 \
 static inline void endian ## size ## _to_cpus(type *p)\
 {\
-    endian ## _bswaps(p, size)\
+    glue(endian, _bswaps)(p, size);\
 }\
 \
 static inline void cpu_to_ ## endian ## size ## s(type *p)\
 {\
-    endian ## _bswaps(p, size)\
+    glue(endian, _bswaps)(p, size);\
 }\
 \
 static inline type endian ## size ## _to_cpup(const type *p)\
 {\
-    return endian ## size ## _to_cpu(*p);\
+    return glue(glue(endian, size), _to_cpu)(*p);\
 }\
 \
 static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\
 {\
-     *p = cpu_to_ ## endian ## size(v);\
+    *p = glue(glue(cpu_to_, endian), size)(v);\
 }
 
 CPU_CONVERT(be, 16, uint16_t)
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] bswap: improve gluing
  2013-01-13 16:35 [Qemu-devel] [PATCH] bswap: improve gluing Blue Swirl
@ 2013-01-14 15:15 ` Richard Henderson
  2013-01-15  4:25 ` Andreas Färber
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2013-01-14 15:15 UTC (permalink / raw)
  To: Blue Swirl; +Cc: qemu-devel

On 2013-01-13 08:35, Blue Swirl wrote:
> Fix by applying glue(). Also add do {} while(0) wrapping and fix
> semicolon use while at it.
>
> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
> ---
>   include/qemu/bswap.h |   20 ++++++++++----------
>   1 files changed, 10 insertions(+), 10 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] bswap: improve gluing
  2013-01-13 16:35 [Qemu-devel] [PATCH] bswap: improve gluing Blue Swirl
  2013-01-14 15:15 ` Richard Henderson
@ 2013-01-15  4:25 ` Andreas Färber
  2013-01-17  1:11 ` David Gibson
  2013-01-20 20:53 ` Anthony Liguori
  3 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2013-01-15  4:25 UTC (permalink / raw)
  To: Blue Swirl; +Cc: Alexander Graf, qemu-devel, rth

Am 13.01.2013 17:35, schrieb Blue Swirl:
> OpenBSD system compiler (gcc 4.2.1) has problems with concatenation
> of macro arguments in macro functions:
>   CC    aes.o
> In file included from /src/qemu/include/qemu-common.h:126,
>                  from /src/qemu/aes.c:30:
> /src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu':
> /src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS'
> /src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS'
> 
> Function leul_to_cpu() is only used in kvm-all.c, so the warnings
> are not fatal on OpenBSD without -Werror.
> 
> Fix by applying glue(). Also add do {} while(0) wrapping and fix
> semicolon use while at it.
> 
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

Tested-by: Andreas Färber <afaerber@suse.de>

This unbreaks the build on openSUSE 12.2 ppc64:
gcc (SUSE Linux) 4.7.1 20120723 [gcc-4_7-branch revision 189773]

Andreas

-- 
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] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] bswap: improve gluing
  2013-01-13 16:35 [Qemu-devel] [PATCH] bswap: improve gluing Blue Swirl
  2013-01-14 15:15 ` Richard Henderson
  2013-01-15  4:25 ` Andreas Färber
@ 2013-01-17  1:11 ` David Gibson
  2013-01-17  7:50   ` Markus Armbruster
  2013-01-20 20:53 ` Anthony Liguori
  3 siblings, 1 reply; 8+ messages in thread
From: David Gibson @ 2013-01-17  1:11 UTC (permalink / raw)
  To: Blue Swirl; +Cc: qemu-devel, rth

[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]

On Sun, Jan 13, 2013 at 04:35:41PM +0000, Blue Swirl wrote:
> OpenBSD system compiler (gcc 4.2.1) has problems with concatenation
> of macro arguments in macro functions:
>   CC    aes.o
> In file included from /src/qemu/include/qemu-common.h:126,
>                  from /src/qemu/aes.c:30:
> /src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu':
> /src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS'
> /src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS'
> 
> Function leul_to_cpu() is only used in kvm-all.c, so the warnings
> are not fatal on OpenBSD without -Werror.
> 
> Fix by applying glue(). Also add do {} while(0) wrapping and fix
> semicolon use while at it.
> 
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

In fact, this is not merely an improvement, and not OpenBSD specific.
This is a vital bugfix for all big-endian hosts.

Please apply.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] bswap: improve gluing
  2013-01-17  1:11 ` David Gibson
@ 2013-01-17  7:50   ` Markus Armbruster
  2013-01-18 16:31     ` Alexander Graf
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Armbruster @ 2013-01-17  7:50 UTC (permalink / raw)
  To: David Gibson; +Cc: Blue Swirl, qemu-devel, rth

David Gibson <david@gibson.dropbear.id.au> writes:

> On Sun, Jan 13, 2013 at 04:35:41PM +0000, Blue Swirl wrote:
>> OpenBSD system compiler (gcc 4.2.1) has problems with concatenation
>> of macro arguments in macro functions:
>>   CC    aes.o
>> In file included from /src/qemu/include/qemu-common.h:126,
>>                  from /src/qemu/aes.c:30:
>> /src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu':
>> /src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS'
>> /src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS'
>> 
>> Function leul_to_cpu() is only used in kvm-all.c, so the warnings
>> are not fatal on OpenBSD without -Werror.
>> 
>> Fix by applying glue(). Also add do {} while(0) wrapping and fix
>> semicolon use while at it.
>> 
>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
> In fact, this is not merely an improvement, and not OpenBSD specific.
> This is a vital bugfix for all big-endian hosts.
>
> Please apply.

Suggest to reword the commit message accordingly then.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] bswap: improve gluing
  2013-01-17  7:50   ` Markus Armbruster
@ 2013-01-18 16:31     ` Alexander Graf
  2013-01-18 17:03       ` Markus Armbruster
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander Graf @ 2013-01-18 16:31 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Blue Swirl, rth, qemu-devel, David Gibson


On 17.01.2013, at 08:50, Markus Armbruster wrote:

> David Gibson <david@gibson.dropbear.id.au> writes:
> 
>> On Sun, Jan 13, 2013 at 04:35:41PM +0000, Blue Swirl wrote:
>>> OpenBSD system compiler (gcc 4.2.1) has problems with concatenation
>>> of macro arguments in macro functions:
>>>  CC    aes.o
>>> In file included from /src/qemu/include/qemu-common.h:126,
>>>                 from /src/qemu/aes.c:30:
>>> /src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu':
>>> /src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS'
>>> /src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS'
>>> 
>>> Function leul_to_cpu() is only used in kvm-all.c, so the warnings
>>> are not fatal on OpenBSD without -Werror.
>>> 
>>> Fix by applying glue(). Also add do {} while(0) wrapping and fix
>>> semicolon use while at it.
>>> 
>>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>> 
>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>> 
>> In fact, this is not merely an improvement, and not OpenBSD specific.
>> This is a vital bugfix for all big-endian hosts.
>> 
>> Please apply.
> 
> Suggest to reword the commit message accordingly then.

I don't care about the commit message, just get this patch in ASAP please. The current tree is broken on s390 and ppc.


Alex

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] bswap: improve gluing
  2013-01-18 16:31     ` Alexander Graf
@ 2013-01-18 17:03       ` Markus Armbruster
  0 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2013-01-18 17:03 UTC (permalink / raw)
  To: Alexander Graf; +Cc: Blue Swirl, rth, qemu-devel, David Gibson

Alexander Graf <agraf@suse.de> writes:

> On 17.01.2013, at 08:50, Markus Armbruster wrote:
>
>> David Gibson <david@gibson.dropbear.id.au> writes:
>> 
>>> On Sun, Jan 13, 2013 at 04:35:41PM +0000, Blue Swirl wrote:
>>>> OpenBSD system compiler (gcc 4.2.1) has problems with concatenation
>>>> of macro arguments in macro functions:
>>>>  CC    aes.o
>>>> In file included from /src/qemu/include/qemu-common.h:126,
>>>>                 from /src/qemu/aes.c:30:
>>>> /src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu':
>>>> /src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS'
>>>> /src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS'
>>>> 
>>>> Function leul_to_cpu() is only used in kvm-all.c, so the warnings
>>>> are not fatal on OpenBSD without -Werror.
>>>> 
>>>> Fix by applying glue(). Also add do {} while(0) wrapping and fix
>>>> semicolon use while at it.
>>>> 
>>>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>>> 
>>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>>> 
>>> In fact, this is not merely an improvement, and not OpenBSD specific.
>>> This is a vital bugfix for all big-endian hosts.
>>> 
>>> Please apply.
>> 
>> Suggest to reword the commit message accordingly then.
>
> I don't care about the commit message, just get this patch in ASAP
> please. The current tree is broken on s390 and ppc.

I think Blue's perfectly capable to amend this commit message without
noticeable loss in commit speed.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH] bswap: improve gluing
  2013-01-13 16:35 [Qemu-devel] [PATCH] bswap: improve gluing Blue Swirl
                   ` (2 preceding siblings ...)
  2013-01-17  1:11 ` David Gibson
@ 2013-01-20 20:53 ` Anthony Liguori
  3 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2013-01-20 20:53 UTC (permalink / raw)
  To: Blue Swirl, qemu-devel; +Cc: rth

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-01-20 20:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-13 16:35 [Qemu-devel] [PATCH] bswap: improve gluing Blue Swirl
2013-01-14 15:15 ` Richard Henderson
2013-01-15  4:25 ` Andreas Färber
2013-01-17  1:11 ` David Gibson
2013-01-17  7:50   ` Markus Armbruster
2013-01-18 16:31     ` Alexander Graf
2013-01-18 17:03       ` Markus Armbruster
2013-01-20 20:53 ` Anthony Liguori

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).