-fix endian test
authorChristian Grothoff <christian@grothoff.org>
Mon, 30 Jan 2012 22:10:33 +0000 (22:10 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 30 Jan 2012 22:10:33 +0000 (22:10 +0000)
src/include/gnunet_common.h
src/include/gnunet_tun_lib.h
src/util/common_endian.c

index 04847ee5b05de5775a86fd87d0c6342468722e19..d934c109e14db7b299c58ae92c5cfcda401f69fd 100644 (file)
 
 #define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b))
 
+/* some systems use one underscore only... */
+#ifndef __BYTE_ORDER
+#ifdef _BYTE_ORDER
+#define __BYTE_ORDER _BYTE_ORDER
+#define __LITTLE_ENDIAN _LITTLE_ENDIAN
+#define __BIG_ENDIAN _BIG_ENDIAN
+#endif
+#endif
+
 /**
  * Endian operations
  */
index 33938354b3f2c74656b9903cbf3d810e42e57a02..dac11d6a876ed330f7a1716c55ed82eb4aece006 100644 (file)
@@ -70,10 +70,10 @@ struct GNUNET_TUN_Layer2PacketHeader
  */
 struct GNUNET_TUN_IPv4Header
 {
-#if __BYTE_ORDER == __LITTLE_ENDIAN || _BYTE_ORDER == _LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
   unsigned int header_length:4 GNUNET_PACKED;
   unsigned int version:4 GNUNET_PACKED;
-#elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN
+#elif __BYTE_ORDER == __BIG_ENDIAN
   unsigned int version:4 GNUNET_PACKED;
   unsigned int header_length:4 GNUNET_PACKED;
 #else
@@ -127,12 +127,12 @@ struct GNUNET_TUN_IPv4Header
  */
 struct GNUNET_TUN_IPv6Header
 {
-#if __BYTE_ORDER == __LITTLE_ENDIAN  || _BYTE_ORDER == _LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
   unsigned int traffic_class_h:4 GNUNET_PACKED;
   unsigned int version:4 GNUNET_PACKED;
   unsigned int traffic_class_l:4 GNUNET_PACKED;
   unsigned int flow_label:20 GNUNET_PACKED;
-#elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN
+#elif __BYTE_ORDER == __BIG_ENDIAN
   unsigned int version:4 GNUNET_PACKED;
   unsigned int traffic_class:8 GNUNET_PACKED;
   unsigned int flow_label:20 GNUNET_PACKED;
@@ -183,7 +183,7 @@ struct GNUNET_TUN_TcpHeader
    * Acknowledgement number.
    */
   uint32_t ack GNUNET_PACKED;
-#if __BYTE_ORDER == __LITTLE_ENDIAN  || _BYTE_ORDER == _LITTLE_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
   /**
    * Reserved.  Must be zero.
    */
@@ -192,7 +192,7 @@ struct GNUNET_TUN_TcpHeader
    * Number of 32-bit words in TCP header.
    */
   unsigned int off : 4 GNUNET_PACKED;
-#elif __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN
+#elif __BYTE_ORDER == __BIG_ENDIAN
   /**
    * Number of 32-bit words in TCP header.
    */
index 1867ba01d90a45f1c026c3ec266624b0b03c04f9..117e575e4b228ec3341331a46800f516b0566469 100644 (file)
@@ -32,9 +32,9 @@
 uint64_t
 GNUNET_ntohll (uint64_t n)
 {
-#if __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
   return n;
-#elif __BYTE_ORDER == __LITTLE_ENDIAN  || _BYTE_ORDER == _LITTLE_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
   return (((uint64_t) ntohl (n)) << 32) + ntohl (n >> 32);
 #else
   #error byteorder undefined
@@ -44,9 +44,9 @@ GNUNET_ntohll (uint64_t n)
 uint64_t
 GNUNET_htonll (uint64_t n)
 {
-#if __BYTE_ORDER == __BIG_ENDIAN || _BYTE_ORDER == _BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
   return n;
-#elif __BYTE_ORDER == __LITTLE_ENDIAN  || _BYTE_ORDER == _LITTLE_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
   return (((uint64_t) htonl (n)) << 32) + htonl (n >> 32);
 #else
   #error byteorder undefined