[Spice-devel] [PATCH spice-protocol 2/2] macros: Use Visual C++ built-ins for byte swapping if available

Frediano Ziglio fziglio at redhat.com
Fri Mar 9 13:06:39 UTC 2018


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 spice/macros.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/spice/macros.h b/spice/macros.h
index 023fd6a..ab1d056 100644
--- a/spice/macros.h
+++ b/spice/macros.h
@@ -252,6 +252,10 @@
 #  define SPICE_BYTESWAP16(val) __builtin_bswap16(val)
 #  define SPICE_BYTESWAP32(val) __builtin_bswap32(val)
 #  define SPICE_BYTESWAP64(val) __builtin_bswap64(val)
+#elif defined(_MSC_VER)
+#  define SPICE_BYTESWAP16(val) _byteswap_ushort(val)
+#  define SPICE_BYTESWAP32(val) _byteswap_ulong(val)
+#  define SPICE_BYTESWAP64(val) _byteswap_uint64(val)
 #else /* generic */
 #  define SPICE_BYTESWAP16(val) (SPICE_BYTESWAP16_CONSTANT (val))
 #  define SPICE_BYTESWAP32(val) (SPICE_BYTESWAP32_CONSTANT (val))
-- 
2.14.3



More information about the Spice-devel mailing list