mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
Fix u128 constructors (MSVC)
This commit is contained in:
parent
33c3977036
commit
cb19316a17
2 changed files with 13 additions and 17 deletions
|
@ -267,12 +267,20 @@ struct alignas(16) u128
|
||||||
|
|
||||||
u128() noexcept = default;
|
u128() noexcept = default;
|
||||||
|
|
||||||
constexpr u128(u64 l) noexcept
|
template <typename T, std::enable_if_t<std::is_unsigned_v<T>, u64> = 0>
|
||||||
: lo(l)
|
constexpr u128(T arg) noexcept
|
||||||
|
: lo(arg)
|
||||||
, hi(0)
|
, hi(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, std::enable_if_t<std::is_signed_v<T>, s64> = 0>
|
||||||
|
constexpr u128(T arg) noexcept
|
||||||
|
: lo(s64{arg})
|
||||||
|
, hi(s64{arg} >> 63)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
constexpr explicit operator bool() const noexcept
|
constexpr explicit operator bool() const noexcept
|
||||||
{
|
{
|
||||||
return !!(lo | hi);
|
return !!(lo | hi);
|
||||||
|
@ -490,24 +498,9 @@ struct alignas(16) s128
|
||||||
s64 hi;
|
s64 hi;
|
||||||
|
|
||||||
s128() = default;
|
s128() = default;
|
||||||
|
|
||||||
constexpr s128(s64 l)
|
|
||||||
: hi(l >> 63)
|
|
||||||
, lo(l)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr s128(u64 l)
|
|
||||||
: hi(0)
|
|
||||||
, lo(l)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CHECK_SIZE_ALIGN(u128, 16, 16);
|
|
||||||
CHECK_SIZE_ALIGN(s128, 16, 16);
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct get_int_impl<16>
|
struct get_int_impl<16>
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,5 +3,8 @@
|
||||||
|
|
||||||
static_assert(std::endian::native == std::endian::little || std::endian::native == std::endian::big);
|
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<u16>(1) + be_t<u32>(2) + be_t<u64>(3) == 6);
|
static_assert(be_t<u16>(1) + be_t<u32>(2) + be_t<u64>(3) == 6);
|
||||||
static_assert(le_t<u16>(1) + le_t<u32>(2) + le_t<u64>(3) == 6);
|
static_assert(le_t<u16>(1) + le_t<u32>(2) + le_t<u64>(3) == 6);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue