summaryrefslogtreecommitdiff
path: root/compat/bswap.h
diff options
context:
space:
mode:
authorSebastian Schuberth <sschuberth@gmail.com>2009-10-19 16:37:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-10-30 16:37:48 (GMT)
commit0fcabdeb52b79775173d009ccc179db104dfbb66 (patch)
tree14fc7689c760602132f22e5988dd096e70d136a6 /compat/bswap.h
parentcd0f8e6d63d3e2744d7d3b2329238be7d064a8ea (diff)
downloadgit-0fcabdeb52b79775173d009ccc179db104dfbb66.zip
git-0fcabdeb52b79775173d009ccc179db104dfbb66.tar.gz
git-0fcabdeb52b79775173d009ccc179db104dfbb66.tar.bz2
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>
Diffstat (limited to 'compat/bswap.h')
-rw-r--r--compat/bswap.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/compat/bswap.h b/compat/bswap.h
index 5cc4acb..279e0b4 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 <stdlib.h>
+
+#define bswap32(x) _byteswap_ulong(x)
+
+#endif
+
+#ifdef bswap32
+
#undef ntohl
#undef htonl
#define ntohl(x) bswap32(x)