From: Sebastian Schuberth <sschuberth@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Use faster byte swapping when compiling with MSVC
Date: Mon, 19 Oct 2009 18:37:05 +0200 [thread overview]
Message-ID: <hbi4mt$tjt$1@ger.gmane.org> (raw)
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
next reply other threads:[~2009-10-19 16:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-19 16:37 Sebastian Schuberth [this message]
2009-10-20 7:04 ` [PATCH] Use faster byte swapping when compiling with MSVC 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='hbi4mt$tjt$1@ger.gmane.org' \
--to=sschuberth@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).