From 1ce0b676286403fc400950bf00dddadfefb0fd5b Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Fri, 29 Apr 2011 17:52:57 +0300 Subject: [PATCH] endian: ignore system Xtoh/htoX defines MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/usual/endian.h b/usual/endian.h index 4f7641e..27d7904 100644 --- a/usual/endian.h +++ b/usual/endian.h @@ -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 -- 2.39.5