diff --git a/Utilities/types.h b/Utilities/types.h index 83fe7a3141..f6aa9469bc 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -267,12 +267,20 @@ struct alignas(16) u128 u128() noexcept = default; - constexpr u128(u64 l) noexcept - : lo(l) + template , u64> = 0> + constexpr u128(T arg) noexcept + : lo(arg) , hi(0) { } + template , s64> = 0> + constexpr u128(T arg) noexcept + : lo(s64{arg}) + , hi(s64{arg} >> 63) + { + } + constexpr explicit operator bool() const noexcept { return !!(lo | hi); @@ -490,24 +498,9 @@ struct alignas(16) s128 s64 hi; s128() = default; - - constexpr s128(s64 l) - : hi(l >> 63) - , lo(l) - { - } - - constexpr s128(u64 l) - : hi(0) - , lo(l) - { - } }; #endif -CHECK_SIZE_ALIGN(u128, 16, 16); -CHECK_SIZE_ALIGN(s128, 16, 16); - template <> struct get_int_impl<16> { diff --git a/rpcs3/stdafx.cpp b/rpcs3/stdafx.cpp index 194e83c838..e40f3479b3 100644 --- a/rpcs3/stdafx.cpp +++ b/rpcs3/stdafx.cpp @@ -3,5 +3,8 @@ static_assert(std::endian::native == std::endian::little || std::endian::native == std::endian::big); +CHECK_SIZE_ALIGN(u128, 16, 16); +CHECK_SIZE_ALIGN(s128, 16, 16); + static_assert(be_t(1) + be_t(2) + be_t(3) == 6); static_assert(le_t(1) + le_t(2) + le_t(3) == 6);