mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
Correct get_int_t to get_uint_t.
Add get_sint_t.
This commit is contained in:
parent
997e3046e3
commit
ec2db8edbc
3 changed files with 39 additions and 32 deletions
|
@ -412,10 +412,10 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
||||||
}
|
}
|
||||||
|
|
||||||
const u64 mask =
|
const u64 mask =
|
||||||
ctx.type == 1 ? u64{std::numeric_limits<get_int_t<1>>::max()} :
|
ctx.type == 1 ? 0xff :
|
||||||
ctx.type == 2 ? u64{std::numeric_limits<get_int_t<2>>::max()} :
|
ctx.type == 2 ? 0xffff :
|
||||||
ctx.type == 4 ? u64{std::numeric_limits<get_int_t<4>>::max()} :
|
ctx.type == 4 ? 0xffff'ffffu :
|
||||||
u64{std::numeric_limits<get_int_t<8>>::max()};
|
0xffff'ffff'ffff'ffffu;
|
||||||
|
|
||||||
// Trunc sign-extended signed types
|
// Trunc sign-extended signed types
|
||||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||||
|
@ -469,10 +469,10 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
||||||
}
|
}
|
||||||
|
|
||||||
const u64 mask =
|
const u64 mask =
|
||||||
ctx.type == 1 ? u64{std::numeric_limits<get_int_t<1>>::max()} :
|
ctx.type == 1 ? 0xff :
|
||||||
ctx.type == 2 ? u64{std::numeric_limits<get_int_t<2>>::max()} :
|
ctx.type == 2 ? 0xffff :
|
||||||
ctx.type == 4 ? u64{std::numeric_limits<get_int_t<4>>::max()} :
|
ctx.type == 4 ? 0xffff'ffffu :
|
||||||
u64{std::numeric_limits<get_int_t<8>>::max()};
|
0xffff'ffff'ffff'ffffu;
|
||||||
|
|
||||||
// Trunc sign-extended signed types
|
// Trunc sign-extended signed types
|
||||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||||
|
@ -533,10 +533,10 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
||||||
}
|
}
|
||||||
|
|
||||||
const u64 mask =
|
const u64 mask =
|
||||||
ctx.type == 1 ? u64{std::numeric_limits<get_int_t<1>>::max()} :
|
ctx.type == 1 ? 0xff :
|
||||||
ctx.type == 2 ? u64{std::numeric_limits<get_int_t<2>>::max()} :
|
ctx.type == 2 ? 0xffff :
|
||||||
ctx.type == 4 ? u64{std::numeric_limits<get_int_t<4>>::max()} :
|
ctx.type == 4 ? 0xffff'ffffu :
|
||||||
u64{std::numeric_limits<get_int_t<8>>::max()};
|
0xffff'ffff'ffff'ffffu;
|
||||||
|
|
||||||
// Trunc sign-extended signed types
|
// Trunc sign-extended signed types
|
||||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||||
|
|
|
@ -131,38 +131,45 @@ using steady_clock = std::conditional<
|
||||||
std::chrono::high_resolution_clock::is_steady,
|
std::chrono::high_resolution_clock::is_steady,
|
||||||
std::chrono::high_resolution_clock, std::chrono::steady_clock>::type;
|
std::chrono::high_resolution_clock, std::chrono::steady_clock>::type;
|
||||||
|
|
||||||
// Get unsigned integral type from type size
|
// Get integral type from type size
|
||||||
template<size_t N>
|
template <std::size_t N>
|
||||||
struct get_int_impl
|
struct get_int_impl
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template <>
|
||||||
struct get_int_impl<sizeof(u8)>
|
struct get_int_impl<sizeof(u8)>
|
||||||
{
|
{
|
||||||
using type = u8;
|
using utype = u8;
|
||||||
|
using stype = s8;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template <>
|
||||||
struct get_int_impl<sizeof(u16)>
|
struct get_int_impl<sizeof(u16)>
|
||||||
{
|
{
|
||||||
using type = u16;
|
using utype = u16;
|
||||||
|
using stype = s16;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template <>
|
||||||
struct get_int_impl<sizeof(u32)>
|
struct get_int_impl<sizeof(u32)>
|
||||||
{
|
{
|
||||||
using type = u32;
|
using utype = u32;
|
||||||
|
using stype = s32;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template <>
|
||||||
struct get_int_impl<sizeof(u64)>
|
struct get_int_impl<sizeof(u64)>
|
||||||
{
|
{
|
||||||
using type = u64;
|
using utype = u64;
|
||||||
|
using stype = s64;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <size_t N>
|
template <std::size_t N>
|
||||||
using get_int_t = typename get_int_impl<N>::type;
|
using get_uint_t = typename get_int_impl<N>::utype;
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
using get_sint_t = typename get_int_impl<N>::stype;
|
||||||
|
|
||||||
namespace gsl
|
namespace gsl
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct registers_decoder
|
||||||
{};
|
{};
|
||||||
|
|
||||||
// Use the smallest type by default
|
// Use the smallest type by default
|
||||||
template<u32 I, u32 N, typename T = get_int_t<std::max<size_t>(static_cast<size_t>((UINTMAX_C(1) << ::ceil2(N)) / CHAR_BIT), 1)>>
|
template <u32 I, u32 N, typename T = get_uint_t<std::max<size_t>(static_cast<size_t>((UINTMAX_C(1) << ::ceil2(N)) / CHAR_BIT), 1)>>
|
||||||
static constexpr inline T bf_decoder(const u32& bits)
|
static constexpr inline T bf_decoder(const u32& bits)
|
||||||
{
|
{
|
||||||
return static_cast<T>(bf_t<u32, I, N>::extract(bits));
|
return static_cast<T>(bf_t<u32, I, N>::extract(bits));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue