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>
Sebastian Schuberth committed
Oct 19, 2009 at 18:37 UTC
0fcabdeb52b79775173d009ccc179db104dfbb66
1 file changed
+10
compat/bswap.h
+10
@@ -28,6 +28,16 @@ static inline uint32_t default_swab32(uint32_t val)
28
} \
29
__res; })
30
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
+
41
#undef ntohl
42
#undef htonl
43
#define ntohl(x) bswap32(x)