Skip to contentSkip to conversation

slirp: Avoid statements without effect on Big Endian host

PATCH Superseded Andreas Färber 2 participants 2 messages May 27, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 slirp: Avoid statements without effect on Big Endian host

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.

---
 slirp/ip.h |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)
slirp/ip.h +22 -11
index 88c903f..6e98b1d 100644
@@ -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)
+#  endif
+#  ifndef NTOHS
+#   define NTOHS(d)
+#  endif
+#  ifndef HTONL
+#   define HTONL(d)
+#  endif
+#  ifndef HTONS
+#   define HTONS(d)
+#  endif
 # endif
 #else
 # ifndef NTOHL
Signature · 1 line
1.7.5.3
#1 lore raw

Am 27.05.2012 18:32, schrieb Andreas Färber:

Quoted 42 lines

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.

---
 slirp/ip.h |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)
slirp/ip.h +12 -11
index 88c903f..6e98b1d 100644
@@ -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)

slirp/ip.h line 58

Quoted 10 lines
slirp/ip.h +10 -0
+#  endif
+#  ifndef NTOHS
+#   define NTOHS(d)
+#  endif
+#  ifndef HTONL
+#   define HTONL(d)
+#  endif
+#  ifndef HTONS
+#   define HTONS(d)
+#  endif

Ahem, these would have the same issue. v2 coming up.

Andreas

Quoted 3 lines
slirp/ip.h +0 -0
 # endif
 #else
 # ifndef NTOHL
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg