* [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host
@ 2012-05-27 16:42 Andreas Färber
2012-05-27 22:10 ` Peter Maydell
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Färber @ 2012-05-27 16:42 UTC (permalink / raw)
To: qemu-devel; +Cc: Jan Kiszka, Andreas Färber
Darwin has HTON*/NTOH* macros that on BE simply return the argument.
This is incompatible with SLIRP's use of these macros as a statement.
Special-case Darwin in the HOST_WORDS_BIGENDIAN code path to redefine
these macros as no-op statement to avoid tons of compiler warnings.
Also adapt the fallback definitions.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
slirp/ip.h | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/slirp/ip.h b/slirp/ip.h
index 88c903f..ddf9e9e 100644
--- a/slirp/ip.h
+++ b/slirp/ip.h
@@ -34,17 +34,28 @@
#define _IP_H_
#ifdef HOST_WORDS_BIGENDIAN
-# ifndef NTOHL
-# define NTOHL(d)
-# endif
-# ifndef NTOHS
-# define NTOHS(d)
-# endif
-# ifndef HTONL
-# define HTONL(d)
-# endif
-# ifndef HTONS
-# define HTONS(d)
+# if defined(__APPLE__)
+# undef NTOHL
+# undef NTOHS
+# undef HTONL
+# undef HTONS
+# define NTOHL(d) do { } while (0)
+# define NTOHS(d) do { } while (0)
+# define HTONL(d) do { } while (0)
+# define HTONS(d) do { } while (0)
+# else
+# ifndef NTOHL
+# define NTOHL(d) do { } while (0)
+# endif
+# ifndef NTOHS
+# define NTOHS(d) do { } while (0)
+# endif
+# ifndef HTONL
+# define HTONL(d) do { } while (0)
+# endif
+# ifndef HTONS
+# define HTONS(d) do { } while (0)
+# endif
# endif
#else
# ifndef NTOHL
--
1.7.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host
2012-05-27 16:42 [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host Andreas Färber
@ 2012-05-27 22:10 ` Peter Maydell
2012-05-28 11:47 ` Jan Kiszka
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2012-05-27 22:10 UTC (permalink / raw)
To: Andreas Färber; +Cc: Jan Kiszka, qemu-devel
On 27 May 2012 17:42, Andreas Färber <andreas.faerber@web.de> wrote:
> +# if defined(__APPLE__)
> +# undef NTOHL
> +# undef NTOHS
> +# undef HTONL
> +# undef HTONS
> +# define NTOHL(d) do { } while (0)
> +# define NTOHS(d) do { } while (0)
> +# define HTONL(d) do { } while (0)
> +# define HTONS(d) do { } while (0)
> +# else
We could just use this for everything, not just if __APPLE__,
right? For big-endian the semantics we want are always "do
nothing" so it's always OK to undef and redefine...
That would save having a special case.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host
2012-05-27 22:10 ` Peter Maydell
@ 2012-05-28 11:47 ` Jan Kiszka
2012-05-28 12:00 ` Peter Maydell
2012-05-28 15:18 ` Andreas Färber
0 siblings, 2 replies; 6+ messages in thread
From: Jan Kiszka @ 2012-05-28 11:47 UTC (permalink / raw)
To: Peter Maydell; +Cc: Andreas Färber, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 656 bytes --]
On 2012-05-28 00:10, Peter Maydell wrote:
> On 27 May 2012 17:42, Andreas Färber <andreas.faerber@web.de> wrote:
>> +# if defined(__APPLE__)
>> +# undef NTOHL
>> +# undef NTOHS
>> +# undef HTONL
>> +# undef HTONS
>> +# define NTOHL(d) do { } while (0)
>> +# define NTOHS(d) do { } while (0)
>> +# define HTONL(d) do { } while (0)
>> +# define HTONS(d) do { } while (0)
>> +# else
>
> We could just use this for everything, not just if __APPLE__,
> right? For big-endian the semantics we want are always "do
> nothing" so it's always OK to undef and redefine...
> That would save having a special case.
Yes, please.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host
2012-05-28 11:47 ` Jan Kiszka
@ 2012-05-28 12:00 ` Peter Maydell
2012-05-28 14:06 ` Andreas Färber
2012-05-28 15:18 ` Andreas Färber
1 sibling, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2012-05-28 12:00 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Andreas Färber, qemu-devel
On 28 May 2012 12:47, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2012-05-28 00:10, Peter Maydell wrote:
>> On 27 May 2012 17:42, Andreas Färber <andreas.faerber@web.de> wrote:
>>> +# if defined(__APPLE__)
>>> +# undef NTOHL
>>> +# undef NTOHS
>>> +# undef HTONL
>>> +# undef HTONS
>>> +# define NTOHL(d) do { } while (0)
>>> +# define NTOHS(d) do { } while (0)
>>> +# define HTONL(d) do { } while (0)
>>> +# define HTONS(d) do { } while (0)
>>> +# else
>>
>> We could just use this for everything, not just if __APPLE__,
>> right? For big-endian the semantics we want are always "do
>> nothing" so it's always OK to undef and redefine...
>> That would save having a special case.
>
> Yes, please.
It occurred to me that you could also have the unconditional
#undefs outside the #ifdef HOST_WORDS_BIGENDIAN, but that
is starting to stray outside of the "simple fix for 1.1"
territory.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host
2012-05-28 12:00 ` Peter Maydell
@ 2012-05-28 14:06 ` Andreas Färber
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2012-05-28 14:06 UTC (permalink / raw)
To: Peter Maydell; +Cc: Jan Kiszka, qemu-devel
Am 28.05.2012 14:00, schrieb Peter Maydell:
> On 28 May 2012 12:47, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2012-05-28 00:10, Peter Maydell wrote:
>>> On 27 May 2012 17:42, Andreas Färber <andreas.faerber@web.de> wrote:
>>>> +# if defined(__APPLE__)
>>>> +# undef NTOHL
>>>> +# undef NTOHS
>>>> +# undef HTONL
>>>> +# undef HTONS
>>>> +# define NTOHL(d) do { } while (0)
>>>> +# define NTOHS(d) do { } while (0)
>>>> +# define HTONL(d) do { } while (0)
>>>> +# define HTONS(d) do { } while (0)
>>>> +# else
>>>
>>> We could just use this for everything, not just if __APPLE__,
>>> right? For big-endian the semantics we want are always "do
>>> nothing" so it's always OK to undef and redefine...
>>> That would save having a special case.
>>
>> Yes, please.
>
> It occurred to me that you could also have the unconditional
> #undefs outside the #ifdef HOST_WORDS_BIGENDIAN, but that
> is starting to stray outside of the "simple fix for 1.1"
> territory.
For 1.2 I would suggest to go even further and drop these SLIRP-specific
macros in favor of QEMU-wide available ones. static inline functions
would've avoided the problem in the first place.
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] 6+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host
2012-05-28 11:47 ` Jan Kiszka
2012-05-28 12:00 ` Peter Maydell
@ 2012-05-28 15:18 ` Andreas Färber
1 sibling, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2012-05-28 15:18 UTC (permalink / raw)
To: Jan Kiszka, Peter Maydell; +Cc: qemu-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 28.05.2012 13:47, schrieb Jan Kiszka:
> On 2012-05-28 00:10, Peter Maydell wrote:
>> On 27 May 2012 17:42, Andreas Färber <andreas.faerber@web.de>
>> wrote:
>>> +# if defined(__APPLE__) +# undef NTOHL +# undef NTOHS +#
>>> undef HTONL +# undef HTONS +# define NTOHL(d) do { } while
>>> (0) +# define NTOHS(d) do { } while (0) +# define HTONL(d) do
>>> { } while (0) +# define HTONS(d) do { } while (0) +# else
>>
>> We could just use this for everything, not just if __APPLE__,
>> right? For big-endian the semantics we want are always "do
>> nothing" so it's always OK to undef and redefine... That would
>> save having a special case.
>
> Yes, please.
On second thoughts my v2 was totally unnecessary and the solution
flawed: The HTONS(x); warning is stemming from Apple's
#define HTONS(d) (d)
not from our
#define HTONS(d)
so we can just unconditionally #undef the existing definitions.
That'll lead to unnecessary semicolons but not to warnings.
Andreas
- --
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
iQIcBAEBAgAGBQJPw5dgAAoJEPou0S0+fgE/wIkP/iu4ZQMR22nukCvtXANu2G7b
QfnsM7w28zRS2y+RkpoQ4pdldD5o2PMVowUA8uGtscvO4o5wVn7/h+1z768NFMht
KeOAic2h1cDUMQZp5DIhuMwXNHtzrYKejxyJSWzVFdpT+Za8tecQ4ge+iDXObdL0
u2a5RAfZU5oPSLZYdUWHkQhf6GayXRvkr/o6rBHKi0Y6S/Du9vlNUpMcANg1O85E
LtraZbfikfKAtWxX+3+yTaNmpfylbYTnUQqHGEXcwMSr7TIDstoyf1kmQcrOacQa
KwOGfW0psRsLQHSb9c3msezo4bFM/S+hyLj3Qg/Cr6Va/jENiyHUNALSymRCvlNw
nVTZOPoNfYOYHnu7yR7xTjpIxngCL7vtdjw4RhJASVKZXQo1TzeAgi9Wx/LFGuFa
Kifqr1wQwSUm+BESMAtJMKixobMscm1rkcwsITuAxTR+l6Cp6X3FcOG9xuHWbT52
IBToxsapwkRNdrb5HZxRIufOvTUq6j/zRfpODqiYe5IoHhF25w4Cvx5+eJ8X7Up6
2RrWRwtj6lmkBhezp2yiBZ/nIUVDcD8jywllla3PS52rjwJoFvRfAU9551yZPMkP
sVhSdID9f9KzwzzUE8YfcCGaVFnOriJG5LikxqcRztp7nlKSPFQNA0DvTK3xTuez
TzrCEwLr6wtBcdvG+6CK
=0bsI
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-05-28 15:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-27 16:42 [Qemu-devel] [PATCH for-1.1? v2] slirp: Avoid statements without effect on Big Endian host Andreas Färber
2012-05-27 22:10 ` Peter Maydell
2012-05-28 11:47 ` Jan Kiszka
2012-05-28 12:00 ` Peter Maydell
2012-05-28 14:06 ` Andreas Färber
2012-05-28 15:18 ` Andreas Färber
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).