Skip to content

Commit 0fcabde

Browse files
sschuberthgitster
authored andcommitted
Use faster byte swapping when compiling with MSVC
When compiling with MSVC on x86-compatible, use an intrinsic for byte swapping. In contrast to the GCC path, we do not prefer inline assembly here as it is not supported for the x64 platform. Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent cd0f8e6 commit 0fcabde

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compat/bswap.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ static inline uint32_t default_swab32(uint32_t val)
2828
} \
2929
__res; })
3030

31+
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
32+
33+
#include <stdlib.h>
34+
35+
#define bswap32(x) _byteswap_ulong(x)
36+
37+
#endif
38+
39+
#ifdef bswap32
40+
3141
#undef ntohl
3242
#undef htonl
3343
#define ntohl(x) bswap32(x)

0 commit comments

Comments
 (0)