diff options
author | Lioncash <mathew1800@gmail.com> | 2020-07-14 22:21:35 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2020-07-14 22:26:54 +0200 |
commit | 9f027b1af28ad125b32745049c2cd207b0da27b8 (patch) | |
tree | 7fc22397acf5fda1d4361b6d3f5f3fcd6b74d72f /src/common/swap.h | |
parent | Merge pull request #4317 from lioncash/boost (diff) | |
download | yuzu-9f027b1af28ad125b32745049c2cd207b0da27b8.tar yuzu-9f027b1af28ad125b32745049c2cd207b0da27b8.tar.gz yuzu-9f027b1af28ad125b32745049c2cd207b0da27b8.tar.bz2 yuzu-9f027b1af28ad125b32745049c2cd207b0da27b8.tar.lz yuzu-9f027b1af28ad125b32745049c2cd207b0da27b8.tar.xz yuzu-9f027b1af28ad125b32745049c2cd207b0da27b8.tar.zst yuzu-9f027b1af28ad125b32745049c2cd207b0da27b8.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/swap.h | 46 |
1 files changed, 4 insertions, 42 deletions
diff --git a/src/common/swap.h b/src/common/swap.h index 71932c2bb..7665942a2 100644 --- a/src/common/swap.h +++ b/src/common/swap.h @@ -17,43 +17,14 @@ #pragma once -#include <type_traits> - #if defined(_MSC_VER) #include <cstdlib> #endif +#include <bit> #include <cstring> +#include <type_traits> #include "common/common_types.h" -// GCC -#ifdef __GNUC__ - -#if __BYTE_ORDER__ && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) && !defined(COMMON_LITTLE_ENDIAN) -#define COMMON_LITTLE_ENDIAN 1 -#elif __BYTE_ORDER__ && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) && !defined(COMMON_BIG_ENDIAN) -#define COMMON_BIG_ENDIAN 1 -#endif - -// LLVM/clang -#elif defined(__clang__) - -#if __LITTLE_ENDIAN__ && !defined(COMMON_LITTLE_ENDIAN) -#define COMMON_LITTLE_ENDIAN 1 -#elif __BIG_ENDIAN__ && !defined(COMMON_BIG_ENDIAN) -#define COMMON_BIG_ENDIAN 1 -#endif - -// MSVC -#elif defined(_MSC_VER) && !defined(COMMON_BIG_ENDIAN) && !defined(COMMON_LITTLE_ENDIAN) - -#define COMMON_LITTLE_ENDIAN 1 -#endif - -// Worst case, default to little endian. -#if !COMMON_BIG_ENDIAN && !COMMON_LITTLE_ENDIAN -#define COMMON_LITTLE_ENDIAN 1 -#endif - namespace Common { #ifdef _MSC_VER @@ -675,17 +646,8 @@ struct AddEndian<T, SwapTag> { }; // Alias LETag/BETag as KeepTag/SwapTag depending on the system -#if COMMON_LITTLE_ENDIAN - -using LETag = KeepTag; -using BETag = SwapTag; - -#else - -using BETag = KeepTag; -using LETag = SwapTag; - -#endif +using LETag = std::conditional_t<std::endian::native == std::endian::little, KeepTag, SwapTag>; +using BETag = std::conditional_t<std::endian::native == std::endian::big, KeepTag, SwapTag>; // Aliases for LE types using u16_le = AddEndian<u16, LETag>::type; |