From 9f17fb842d35b109c895ddcda19e03da3d412bc9 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Wed, 8 Sep 2021 16:27:28 +0200 Subject: Use endian swapping __builtin_bswap*() with GCC-compatible compilers --- zencore/include/zencore/endian.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'zencore/include') 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 -- cgit v1.2.3