git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Don't redefine htonl and ntohl on big-endian

From
Holger Weiß <holger@zedat.fu-berlin.de>
Date
Mar 29, 2010, 10:22 UTC
Message-ID
<20100329102219.GC14869@CIS.FU-Berlin.DE>

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.

Signed-off-by: Holger Weiß <holger@zedat.fu-berlin.de>
---
 compat/bswap.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/compat/bswap.h b/compat/bswap.h
index f3b8c44..54756db 100644
--- a/compat/bswap.h
+++ b/compat/bswap.h
@@ -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) ({ \
-- 
1.7.0.3
Message 1 of 1 in “Don't redefine htonl and ntohl on big-endian”
  1. Don't redefine htonl and ntohl on big-endianHolger Weiß, Mar 29, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.