aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-09-08 16:27:28 +0200
committerMartin Ridgers <[email protected]>2021-09-14 14:29:27 +0200
commit9f17fb842d35b109c895ddcda19e03da3d412bc9 (patch)
tree86fec2554dbe4656dad03c65f639e1a944096daf
parentstd::atomic variants of MSVC's _Interlockm* calls (diff)
downloadzen-9f17fb842d35b109c895ddcda19e03da3d412bc9.tar.xz
zen-9f17fb842d35b109c895ddcda19e03da3d412bc9.zip
Use endian swapping __builtin_bswap*() with GCC-compatible compilers
-rw-r--r--zencore/include/zencore/endian.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/zencore/include/zencore/endian.h b/zencore/include/zencore/endian.h
index 1f79a59e8..d44a27b01 100644
--- a/zencore/include/zencore/endian.h
+++ b/zencore/include/zencore/endian.h
@@ -7,19 +7,31 @@ namespace zen {
inline uint16_t
ByteSwap(uint16_t x)
{
+#if ZEN_COMPILER_MSC
return _byteswap_ushort(x);
+#else
+ return __builtin_bswap16(x);
+#endif
}
inline uint32_t
ByteSwap(uint32_t x)
{
+#if ZEN_COMPILER_MSC
return _byteswap_ulong(x);
+#else
+ return __builtin_bswap32(x);
+#endif
}
inline uint64_t
ByteSwap(uint64_t x)
{
+#if ZEN_COMPILER_MSC
return _byteswap_uint64(x);
+#else
+ return __builtin_bswap64(x);
+#endif
}
inline uint16_t