mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-22 02:45:07 -04:00
Switch atmosphere's build target to C++20. (#952)
* ams: update to build with gcc10/c++20 * remove mno-outline-atomics * ams: take care of most TODO C++20s * fusee/sept: update for gcc10 * whoosh, your code now uses pre-compiled headers * make: dependency fixes
This commit is contained in:
parent
17b6bcfd37
commit
3a1ccdd919
258 changed files with 723 additions and 804 deletions
|
@ -20,27 +20,17 @@
|
|||
|
||||
namespace ams::util {
|
||||
|
||||
/* TODO: C++20 std::endian */
|
||||
|
||||
constexpr bool IsLittleEndian() {
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return std::endian::native == std::endian::little;
|
||||
}
|
||||
|
||||
constexpr bool IsBigEndian() {
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return std::endian::native == std::endian::big;
|
||||
}
|
||||
|
||||
static_assert(IsLittleEndian() ^ IsBigEndian());
|
||||
|
||||
template<typename U> /* requires unsigned_integral<U> */
|
||||
template<typename U> requires std::unsigned_integral<U>
|
||||
constexpr ALWAYS_INLINE U SwapBytes(const U u) {
|
||||
static_assert(BITSIZEOF(u8) == 8);
|
||||
constexpr U ByteMask = 0xFFu;
|
||||
|
@ -85,14 +75,14 @@ namespace ams::util {
|
|||
((u & (ByteMask << 0)) << 40);
|
||||
}
|
||||
|
||||
template<typename T> /* requires integral<T> */
|
||||
template<typename T> requires std::integral<T>
|
||||
constexpr ALWAYS_INLINE void SwapBytes(T *ptr) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
|
||||
*ptr = static_cast<T>(SwapBytes(static_cast<U>(*ptr)));
|
||||
}
|
||||
|
||||
template<typename T> /* requires integral<T> */
|
||||
template<typename T> requires std::integral<T>
|
||||
constexpr ALWAYS_INLINE T ConvertToBigEndian(const T val) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
|
||||
|
@ -104,7 +94,7 @@ namespace ams::util {
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T> /* requires integral<T> */
|
||||
template<typename T> requires std::integral<T>
|
||||
constexpr ALWAYS_INLINE T ConvertToLittleEndian(const T val) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
|
||||
|
@ -116,7 +106,7 @@ namespace ams::util {
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T> /* requires integral<T> */
|
||||
template<typename T> requires std::integral<T>
|
||||
constexpr ALWAYS_INLINE T ConvertToBigEndian48(const T val) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
static_assert(sizeof(T) == sizeof(u64));
|
||||
|
@ -130,7 +120,7 @@ namespace ams::util {
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T> /* requires integral<T> */
|
||||
template<typename T> requires std::integral<T>
|
||||
constexpr ALWAYS_INLINE T ConvertToLittleEndian48(const T val) {
|
||||
using U = typename std::make_unsigned<T>::type;
|
||||
static_assert(sizeof(T) == sizeof(u64));
|
||||
|
@ -144,12 +134,12 @@ namespace ams::util {
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T> /* requires integral<T> */
|
||||
template<typename T> requires std::integral<T>
|
||||
constexpr ALWAYS_INLINE T LoadBigEndian(T *ptr) {
|
||||
return ConvertToBigEndian(*ptr);
|
||||
}
|
||||
|
||||
template<typename T> /* requires integral<T> */
|
||||
template<typename T> requires std::integral<T>
|
||||
constexpr ALWAYS_INLINE T LoadLittleEndian(T *ptr) {
|
||||
return ConvertToLittleEndian(*ptr);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue