From: Sebastian Schuberth Date: Mon, 19 Oct 2009 16:37:05 +0000 (+0200) Subject: Use faster byte swapping when compiling with MSVC X-Git-Tag: v1.6.6-rc0~90 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0fcabdeb52b79775173d009ccc179db104dfbb66;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/compat/bswap.h b/compat/bswap.h index 5cc4acbfc..279e0b48b 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -28,6 +28,16 @@ static inline uint32_t default_swab32(uint32_t val) } \ __res; }) +#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) + +#include + +#define bswap32(x) _byteswap_ulong(x) + +#endif + +#ifdef bswap32 + #undef ntohl #undef htonl #define ntohl(x) bswap32(x)