summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-04-12 02:26:37 +0200
committerLioncash <mathew1800@gmail.com>2019-04-12 02:36:19 +0200
commit9cb4b7be40dd93d4982d78a5f420326fd9c628a8 (patch)
tree31a11148138dece030895b70a0e5304d27401129 /src/common
parentcommon/swap: Remove 32-bit ARM path (diff)
downloadyuzu-9cb4b7be40dd93d4982d78a5f420326fd9c628a8.tar
yuzu-9cb4b7be40dd93d4982d78a5f420326fd9c628a8.tar.gz
yuzu-9cb4b7be40dd93d4982d78a5f420326fd9c628a8.tar.bz2
yuzu-9cb4b7be40dd93d4982d78a5f420326fd9c628a8.tar.lz
yuzu-9cb4b7be40dd93d4982d78a5f420326fd9c628a8.tar.xz
yuzu-9cb4b7be40dd93d4982d78a5f420326fd9c628a8.tar.zst
yuzu-9cb4b7be40dd93d4982d78a5f420326fd9c628a8.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/swap.h63
1 files changed, 15 insertions, 48 deletions
diff --git a/src/common/swap.h b/src/common/swap.h
index cb723cb8a..fad0f35a7 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -21,11 +21,6 @@
#if defined(_MSC_VER)
#include <cstdlib>
-#elif defined(__linux__)
-#include <byteswap.h>
-#elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || \
- defined(__NetBSD__) || defined(__OpenBSD__)
-#include <sys/endian.h>
#endif
#include <cstring>
#include "common/common_types.h"
@@ -62,58 +57,30 @@
namespace Common {
#ifdef _MSC_VER
-inline u16 swap16(u16 _data) {
- return _byteswap_ushort(_data);
-}
-inline u32 swap32(u32 _data) {
- return _byteswap_ulong(_data);
-}
-inline u64 swap64(u64 _data) {
- return _byteswap_uint64(_data);
-}
-#elif __linux__
-inline u16 swap16(u16 _data) {
- return bswap_16(_data);
-}
-inline u32 swap32(u32 _data) {
- return bswap_32(_data);
-}
-inline u64 swap64(u64 _data) {
- return bswap_64(_data);
-}
-#elif __APPLE__
-inline __attribute__((always_inline)) u16 swap16(u16 _data) {
- return (_data >> 8) | (_data << 8);
+inline u16 swap16(u16 data) {
+ return _byteswap_ushort(data);
}
-inline __attribute__((always_inline)) u32 swap32(u32 _data) {
- return __builtin_bswap32(_data);
+inline u32 swap32(u32 data) {
+ return _byteswap_ulong(data);
}
-inline __attribute__((always_inline)) u64 swap64(u64 _data) {
- return __builtin_bswap64(_data);
+inline u64 swap64(u64 data) {
+ return _byteswap_uint64(data);
}
-#elif defined(__Bitrig__) || defined(__OpenBSD__)
+#elif defined(__clang__) || defined(__GNUC__)
+#if defined(__Bitrig__) || defined(__OpenBSD__)
// redefine swap16, swap32, swap64 as inline functions
#undef swap16
#undef swap32
#undef swap64
-inline u16 swap16(u16 _data) {
- return __swap16(_data);
-}
-inline u32 swap32(u32 _data) {
- return __swap32(_data);
-}
-inline u64 swap64(u64 _data) {
- return __swap64(_data);
-}
-#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
-inline u16 swap16(u16 _data) {
- return bswap16(_data);
+#endif
+inline u16 swap16(u16 data) {
+ return __builtin_bswap16(data);
}
-inline u32 swap32(u32 _data) {
- return bswap32(_data);
+inline u32 swap32(u32 data) {
+ return __builtin_bswap32(data);
}
-inline u64 swap64(u64 _data) {
- return bswap64(_data);
+inline u64 swap64(u64 data) {
+ return __builtin_bswap64(data);
}
#else
// Slow generic implementation.