Skip to contentSkip to conversation

Don't redefine htonl and ntohl on big-endian

PATCH New Holger Weiß 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't redefine htonl and ntohl on big-endian

Since commit 0fcabdeb52b79775173d009ccc179db104dfbb66, compat/bswap.h redefined htonl and ntohl to bswap32 not only if bswap32 has been defined earlier in compat/bswap.h (which is done only on selected platforms), but also if bswap32 has been defined anywhere else. This broke Git at least for NetBSD systems running on big-endian machines (where ntohl and htonl should, of course, be NOOPs), since NetBSD defines a bswap32 macro in the system headers.

So, we now undefine any previously defined bswap32 in compat/bswap.h before defining our own.

---
 compat/bswap.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
compat/bswap.h +2 -0
index f3b8c44..54756db 100644
@@ -17,6 +17,8 @@ static inline uint32_t default_swab32(uint32_t val)
 		((val & 0x000000ff) << 24));
 }
 
+#undef bswap32
+
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 
 #define bswap32(x) ({ \
Signature · 1 line
1.7.0.3