Преглед изворни кода

[Pal] Fix htonl/htons() byte-order macro to __BYTE_ORDER

Dmitrii Kuvaiskii пре 5 година
родитељ
комит
17b3997226
2 измењених фајлова са 8 додато и 5 уклоњено
  1. 7 4
      Pal/lib/network/hton.c
  2. 1 1
      Pal/src/pal_rtld.h

+ 7 - 4
Pal/lib/network/hton.c

@@ -19,11 +19,14 @@
 #include "api.h"
 #include <host_endian.h>
 
+#define __bswap_16(x) ((uint16_t)(__builtin_bswap32(x) >> 16))
+#define __bswap_32(x) ((uint32_t)__builtin_bswap32(x))
+
 uint32_t __htonl (uint32_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
     return x;
-#elif BYTE_ORDER == LITTLE_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
     return __bswap_32 (x);
 #else
 # error "What kind of system is this?"
@@ -37,9 +40,9 @@ uint32_t __ntohl (uint32_t x)
 
 uint16_t __htons (uint16_t x)
 {
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
     return x;
-#elif BYTE_ORDER == LITTLE_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
     return __bswap_16 (x);
 #else
 # error "What kind of system is this?"

+ 1 - 1
Pal/src/pal_rtld.h

@@ -150,7 +150,7 @@ ELF_PREFERRED_ADDRESS_DATA;
 #elif __BYTE_ORDER == __LITTLE_ENDIAN
 # define byteorder ELFDATA2LSB
 #else
-# error "Unknown BYTE_ORDER " BYTE_ORDER
+# error "Unknown __BYTE_ORDER " __BYTE_ORDER
 # define byteorder ELFDATANONE
 #endif