]> git.ipfire.org Git - thirdparty/git.git/commit
bswap.h: always overwrite ntohl/ ntohll macros
authorSebastian Andrzej Siewior <sebastian@breakpoint.cc>
Tue, 15 Jul 2025 19:12:28 +0000 (21:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jul 2025 21:36:41 +0000 (14:36 -0700)
commit4544cd19e429975882e20fa89dab7e73956f26e4
treea0599052be980305e481966d48a2b61da173bfe7
parent30dea7ddf7a10d11818e754deba8120cef8446ca
bswap.h: always overwrite ntohl/ ntohll macros

The ntohl and htonl macros are redefined because the provided macros were
not always optimal. Sometimes it was a function call, sometimes it was a
macro which did the shifting. Using the 'bswap' opcode on x86 provides
probably better performance than performing the shifting.
These macros are only overwritten on x86 if the "optimized" version is
available.

The ntohll and htonll macros are not available on every platform (at
least glibc does not provide them) which means they need to be defined
once the endianness of the system is determined.

In order to get a more symmetrical setup, redfine the macros once the
endianness of the system has been determined.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/bswap.h