endian: ignore system Xtoh/htoX defines
authorMarko Kreen <markokr@gmail.com>
Fri, 29 Apr 2011 14:52:57 +0000 (17:52 +0300)
committerMarko Kreen <markokr@gmail.com>
Fri, 29 Apr 2011 14:52:57 +0000 (17:52 +0300)
At least OpenBSD defines only subset of them.  As this
may happen on other OS'es too, the best way to avoid
future problems is to ignore system defines completely.

Reported-by: Pierre-Emmanuel André
usual/endian.h

index 4f7641e61e3fea5e8bdf5dd71f9743e3ff666bbe..27d79047b7f1d82e51aa3e7fa77efdcefe17190e 100644 (file)
@@ -87,9 +87,22 @@ static inline uint64_t bswap64(uint64_t x)
  * @{
  */
 
-#ifndef le64toh
+/* Ignore OS defines, as they may define only some subset of functions */
+#undef htobe16
+#undef htobe32
+#undef htobe64
+#undef htole16
+#undef htole32
+#undef htole64
+#undef be16toh
+#undef be32toh
+#undef be64toh
+#undef le16toh
+#undef le32toh
+#undef le64toh
 
 #ifdef WORDS_BIGENDIAN
+
 #define        htobe16(x)      ((uint16_t)(x))
 #define        htobe32(x)      ((uint32_t)(x))
 #define        htobe64(x)      ((uint64_t)(x))
@@ -119,7 +132,6 @@ static inline uint64_t bswap64(uint64_t x)
 #define        le16toh(x)      ((uint16_t)(x))
 #define        le32toh(x)      ((uint32_t)(x))
 #define        le64toh(x)      ((uint64_t)(x))
-#endif
 
 #endif