changeset 18077:8277c23f5e3c draft

(svn r22898) -Codechange: use MSVC compiler intrinsics for byte swapping
author glx <glx@openttd.org>
date Tue, 06 Sep 2011 00:10:20 +0000
parents 7a1882ed2d36
children 3f5752deb867
files src/core/bitmath_func.hpp
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/bitmath_func.hpp
+++ b/src/core/bitmath_func.hpp
@@ -355,6 +355,10 @@
 	 * warnings if we don't cast those (why?) */
 	#define BSWAP32(x) ((uint32)Endian32_Swap(x))
 	#define BSWAP16(x) ((uint16)Endian16_Swap(x))
+#elif defined(_MSC_VER)
+	/* MSVC has intrinsics for swapping, resulting in faster code */
+	#define BSWAP32(x) (_byteswap_ulong(x))
+	#define BSWAP16(x) (_byteswap_ushort(x))
 #else
 	/**
 	 * Perform a 32 bits endianness bitswap on x.