git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use faster byte swapping when compiling with MSVC
@ 2009-10-19 16:37 Sebastian Schuberth
  2009-10-20  7:04 ` Junio C Hamano
  2009-10-20 12:20 ` Ludvig Strigeus
  0 siblings, 2 replies; 7+ messages in thread
From: Sebastian Schuberth @ 2009-10-19 16:37 UTC (permalink / raw)
  To: git

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>
---
 compat/bswap.h |   10 ++++++++++
 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)
-- 
1.6.5.rc2.13.g1be2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-10-20 16:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-19 16:37 [PATCH] Use faster byte swapping when compiling with MSVC Sebastian Schuberth
2009-10-20  7:04 ` Junio C Hamano
2009-10-20  8:56   ` Sebastian Schuberth
2009-10-20  9:53     ` Johannes Schindelin
2009-10-20 16:55       ` Junio C Hamano
2009-10-20 12:20 ` Ludvig Strigeus
2009-10-20 12:44   ` Erik Faye-Lund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).