Skip to content

Commit

Permalink
Don't redefine htonl and ntohl on big-endian
Browse files Browse the repository at this point in the history
Since commit 0fcabde, 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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Holger Weiß authored and Junio C Hamano committed Mar 31, 2010
1 parent 7a49c25 commit 21e403a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compat/bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) ({ \
Expand Down

0 comments on commit 21e403a

Please sign in to comment.