mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-04 14:08:30 +00:00
Add usz alias for std::size_t
This commit is contained in:
parent
360c4d1554
commit
fb29933d3d
173 changed files with 718 additions and 717 deletions
|
|
@ -176,7 +176,7 @@ public:
|
|||
};
|
||||
u_int miblen = std::size(mib);
|
||||
struct kinfo_proc info;
|
||||
size_t size = sizeof(info);
|
||||
usz size = sizeof(info);
|
||||
if (sysctl(mib, miblen, &info, &size, NULL, 0))
|
||||
{
|
||||
return 0;
|
||||
|
|
@ -194,7 +194,7 @@ public:
|
|||
u_int miblen = std::size(mib);
|
||||
|
||||
// get number of structs
|
||||
size_t size;
|
||||
usz size;
|
||||
if (sysctl(mib, miblen, NULL, &size, NULL, 0))
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ using namespace std::literals::string_literals;
|
|||
static std::unique_ptr<wchar_t[]> to_wchar(const std::string& source)
|
||||
{
|
||||
// String size + null terminator
|
||||
const std::size_t buf_size = source.size() + 1;
|
||||
const usz buf_size = source.size() + 1;
|
||||
|
||||
// Safe size
|
||||
const int size = narrow<int>(buf_size);
|
||||
|
|
@ -51,7 +51,7 @@ static std::unique_ptr<wchar_t[]> to_wchar(const std::string& source)
|
|||
static void to_utf8(std::string& out, const wchar_t* source)
|
||||
{
|
||||
// String size
|
||||
const std::size_t length = std::wcslen(source);
|
||||
const usz length = std::wcslen(source);
|
||||
|
||||
// Safe buffer size for max possible output length (including null terminator)
|
||||
const int buf_size = narrow<int>(length * 3 + 1);
|
||||
|
|
@ -181,7 +181,7 @@ static std::string path_append(std::string_view path, std::string_view more)
|
|||
{
|
||||
std::string result;
|
||||
|
||||
if (const size_t src_slash_pos = path.find_last_not_of('/'); src_slash_pos != path.npos)
|
||||
if (const usz src_slash_pos = path.find_last_not_of('/'); src_slash_pos != path.npos)
|
||||
{
|
||||
path.remove_suffix(path.length() - src_slash_pos - 1);
|
||||
result = path;
|
||||
|
|
@ -189,7 +189,7 @@ static std::string path_append(std::string_view path, std::string_view more)
|
|||
|
||||
result.push_back('/');
|
||||
|
||||
if (const size_t dst_slash_pos = more.find_first_not_of('/'); dst_slash_pos != more.npos)
|
||||
if (const usz dst_slash_pos = more.find_first_not_of('/'); dst_slash_pos != more.npos)
|
||||
{
|
||||
more.remove_prefix(dst_slash_pos);
|
||||
result.append(more);
|
||||
|
|
@ -505,7 +505,7 @@ bool fs::statfs(const std::string& path, fs::device_stat& info)
|
|||
// Keep cutting path from right until it's short enough
|
||||
while (str.size() > 256)
|
||||
{
|
||||
if (std::size_t x = str.find_last_of('\\') + 1)
|
||||
if (usz x = str.find_last_of('\\') + 1)
|
||||
str.resize(x - 1);
|
||||
else
|
||||
break;
|
||||
|
|
@ -1240,7 +1240,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
|
|||
#endif
|
||||
}
|
||||
|
||||
fs::file::file(const void* ptr, std::size_t size)
|
||||
fs::file::file(const void* ptr, usz size)
|
||||
{
|
||||
class memory_stream : public file_base
|
||||
{
|
||||
|
|
@ -1355,7 +1355,7 @@ bool fs::dir::open(const std::string& path)
|
|||
class windows_dir final : public dir_base
|
||||
{
|
||||
std::vector<dir_entry> m_entries;
|
||||
std::size_t m_pos = 0;
|
||||
usz m_pos = 0;
|
||||
|
||||
void add_entry(const WIN32_FIND_DATAW& found)
|
||||
{
|
||||
|
|
@ -1605,13 +1605,13 @@ std::string fs::escape_path(std::string_view path)
|
|||
{
|
||||
std::string real; real.resize(path.size());
|
||||
|
||||
auto get_char = [&](std::size_t& from, std::size_t& to, std::size_t count)
|
||||
auto get_char = [&](usz& from, usz& to, usz count)
|
||||
{
|
||||
std::memcpy(&real[to], &path[from], count);
|
||||
from += count, to += count;
|
||||
};
|
||||
|
||||
std::size_t i = 0, j = -1, pos_nondelim = 0, after_delim = 0;
|
||||
usz i = 0, j = -1, pos_nondelim = 0, after_delim = 0;
|
||||
|
||||
if (i < path.size())
|
||||
{
|
||||
|
|
@ -1648,7 +1648,7 @@ std::string fs::escape_path(std::string_view path)
|
|||
case '.':
|
||||
{
|
||||
bool remove_element = true;
|
||||
std::size_t k = 1;
|
||||
usz k = 1;
|
||||
|
||||
for (; k + i != path.size(); k++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace fs
|
|||
struct iovec_clone
|
||||
{
|
||||
const void* iov_base;
|
||||
std::size_t iov_len;
|
||||
usz iov_len;
|
||||
};
|
||||
|
||||
// File handle base
|
||||
|
|
@ -200,7 +200,7 @@ namespace fs
|
|||
explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read);
|
||||
|
||||
// Open memory for read
|
||||
explicit file(const void* ptr, std::size_t size);
|
||||
explicit file(const void* ptr, usz size);
|
||||
|
||||
// Open file with specified args (forward to constructor)
|
||||
template <typename... Args>
|
||||
|
|
@ -370,7 +370,7 @@ namespace fs
|
|||
|
||||
// Read std::basic_string
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::basic_string<T>& str, std::size_t size,
|
||||
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::basic_string<T>& str, usz size,
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION(),
|
||||
u32 line = __builtin_LINE(),
|
||||
|
|
@ -405,7 +405,7 @@ namespace fs
|
|||
|
||||
// Read POD std::vector
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::vector<T>& vec, std::size_t size,
|
||||
std::enable_if_t<std::is_trivially_copyable_v<T> && !std::is_pointer_v<T>, bool> read(std::vector<T>& vec, usz size,
|
||||
const char* file = __builtin_FILE(),
|
||||
const char* func = __builtin_FUNCTION(),
|
||||
u32 line = __builtin_LINE(),
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ static atomic_t<u64> s_code_pos{0}, s_data_pos{0};
|
|||
static std::vector<u8> s_code_init, s_data_init;
|
||||
|
||||
template <atomic_t<u64>& Ctr, uint Off, utils::protection Prot>
|
||||
static u8* add_jit_memory(std::size_t size, uint align)
|
||||
static u8* add_jit_memory(usz size, uint align)
|
||||
{
|
||||
// Select subrange
|
||||
u8* pointer = get_jit_memory() + Off;
|
||||
|
|
@ -112,7 +112,7 @@ jit_runtime::~jit_runtime()
|
|||
|
||||
asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept
|
||||
{
|
||||
std::size_t codeSize = code->getCodeSize();
|
||||
usz codeSize = code->getCodeSize();
|
||||
if (!codeSize) [[unlikely]]
|
||||
{
|
||||
*dst = nullptr;
|
||||
|
|
@ -126,7 +126,7 @@ asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept
|
|||
return asmjit::kErrorNoVirtualMemory;
|
||||
}
|
||||
|
||||
std::size_t relocSize = code->relocate(p);
|
||||
usz relocSize = code->relocate(p);
|
||||
if (!relocSize) [[unlikely]]
|
||||
{
|
||||
*dst = nullptr;
|
||||
|
|
@ -144,7 +144,7 @@ asmjit::Error jit_runtime::_release(void* ptr) noexcept
|
|||
return asmjit::kErrorOk;
|
||||
}
|
||||
|
||||
u8* jit_runtime::alloc(std::size_t size, uint align, bool exec) noexcept
|
||||
u8* jit_runtime::alloc(usz size, uint align, bool exec) noexcept
|
||||
{
|
||||
if (exec)
|
||||
{
|
||||
|
|
@ -216,7 +216,7 @@ asmjit::Runtime& asmjit::get_global_runtime()
|
|||
|
||||
asmjit::Error _add(void** dst, asmjit::CodeHolder* code) noexcept override
|
||||
{
|
||||
std::size_t codeSize = code->getCodeSize();
|
||||
usz codeSize = code->getCodeSize();
|
||||
if (!codeSize) [[unlikely]]
|
||||
{
|
||||
*dst = nullptr;
|
||||
|
|
@ -230,7 +230,7 @@ asmjit::Runtime& asmjit::get_global_runtime()
|
|||
return asmjit::kErrorNoVirtualMemory;
|
||||
}
|
||||
|
||||
std::size_t relocSize = code->relocate(p);
|
||||
usz relocSize = code->relocate(p);
|
||||
if (!relocSize) [[unlikely]]
|
||||
{
|
||||
*dst = nullptr;
|
||||
|
|
@ -389,7 +389,7 @@ struct MemoryManager1 : llvm::RTDyldMemoryManager
|
|||
return false;
|
||||
}
|
||||
|
||||
void registerEHFrames(u8* addr, u64 load_addr, std::size_t size) override
|
||||
void registerEHFrames(u8* addr, u64 load_addr, usz size) override
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ struct MemoryManager2 : llvm::RTDyldMemoryManager
|
|||
return false;
|
||||
}
|
||||
|
||||
void registerEHFrames(u8* addr, u64 load_addr, std::size_t size) override
|
||||
void registerEHFrames(u8* addr, u64 load_addr, usz size) override
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ struct jit_runtime final : asmjit::HostRuntime
|
|||
asmjit::Error _release(void* p) noexcept override;
|
||||
|
||||
// Allocate memory
|
||||
static u8* alloc(std::size_t size, uint align, bool exec = true) noexcept;
|
||||
static u8* alloc(usz size, uint align, bool exec = true) noexcept;
|
||||
|
||||
// Should be called at least once after global initialization
|
||||
static void initialize();
|
||||
|
|
|
|||
|
|
@ -79,14 +79,14 @@ void fmt_class_string<fmt::base57>::format(std::string& out, u64 arg)
|
|||
static constexpr u8 s_tail[8] = {0, 2, 3, 5, 6, 7, 9, 10};
|
||||
|
||||
// Get full output size
|
||||
const std::size_t out_size = _arg.size / 8 * 11 + s_tail[_arg.size % 8];
|
||||
const usz out_size = _arg.size / 8 * 11 + s_tail[_arg.size % 8];
|
||||
|
||||
out.resize(out.size() + out_size);
|
||||
|
||||
const auto ptr = &out.front() + (out.size() - out_size);
|
||||
|
||||
// Each 8 bytes of input data produce 11 bytes of base57 output
|
||||
for (std::size_t i = 0, p = 0; i < _arg.size; i += 8, p += 11)
|
||||
for (usz i = 0, p = 0; i < _arg.size; i += 8, p += 11)
|
||||
{
|
||||
// Load up to 8 bytes
|
||||
be_t<u64> be_value;
|
||||
|
|
@ -321,7 +321,7 @@ struct fmt::cfmt_src
|
|||
const fmt_type_info* sup;
|
||||
const u64* args;
|
||||
|
||||
bool test(std::size_t index) const
|
||||
bool test(usz index) const
|
||||
{
|
||||
if (!sup[index].fmt_string)
|
||||
{
|
||||
|
|
@ -332,26 +332,26 @@ struct fmt::cfmt_src
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
T get(std::size_t index) const
|
||||
T get(usz index) const
|
||||
{
|
||||
return *reinterpret_cast<const T*>(reinterpret_cast<const u8*>(args + index));
|
||||
}
|
||||
|
||||
void skip(std::size_t extra)
|
||||
void skip(usz extra)
|
||||
{
|
||||
sup += extra + 1;
|
||||
args += extra + 1;
|
||||
}
|
||||
|
||||
std::size_t fmt_string(std::string& out, std::size_t extra) const
|
||||
usz fmt_string(std::string& out, usz extra) const
|
||||
{
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
sup[extra].fmt_string(out, args[extra]);
|
||||
return out.size() - start;
|
||||
}
|
||||
|
||||
// Returns type size (0 if unknown, pointer, unsigned, assumed max)
|
||||
std::size_t type(std::size_t extra) const
|
||||
usz type(usz extra) const
|
||||
{
|
||||
// Hack: use known function pointers to determine type
|
||||
#define TYPE(type) \
|
||||
|
|
@ -369,14 +369,14 @@ struct fmt::cfmt_src
|
|||
return 0;
|
||||
}
|
||||
|
||||
static constexpr std::size_t size_char = 1;
|
||||
static constexpr std::size_t size_short = 2;
|
||||
static constexpr std::size_t size_int = 0;
|
||||
static constexpr std::size_t size_long = sizeof(ulong);
|
||||
static constexpr std::size_t size_llong = sizeof(ullong);
|
||||
static constexpr std::size_t size_size = sizeof(std::size_t);
|
||||
static constexpr std::size_t size_max = sizeof(std::uintmax_t);
|
||||
static constexpr std::size_t size_diff = sizeof(std::ptrdiff_t);
|
||||
static constexpr usz size_char = 1;
|
||||
static constexpr usz size_short = 2;
|
||||
static constexpr usz size_int = 0;
|
||||
static constexpr usz size_long = sizeof(ulong);
|
||||
static constexpr usz size_llong = sizeof(ullong);
|
||||
static constexpr usz size_size = sizeof(usz);
|
||||
static constexpr usz size_max = sizeof(std::uintmax_t);
|
||||
static constexpr usz size_diff = sizeof(std::ptrdiff_t);
|
||||
};
|
||||
|
||||
void fmt::raw_append(std::string& out, const char* fmt, const fmt_type_info* sup, const u64* args) noexcept
|
||||
|
|
@ -412,9 +412,9 @@ std::vector<std::string> fmt::split(const std::string& source, std::initializer_
|
|||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
size_t cursor_begin = 0;
|
||||
usz cursor_begin = 0;
|
||||
|
||||
for (size_t cursor_end = 0; cursor_end < source.length(); ++cursor_end)
|
||||
for (usz cursor_end = 0; cursor_end < source.length(); ++cursor_end)
|
||||
{
|
||||
for (auto& separator : separators)
|
||||
{
|
||||
|
|
@ -441,7 +441,7 @@ std::vector<std::string> fmt::split(const std::string& source, std::initializer_
|
|||
|
||||
std::string fmt::trim(const std::string& source, const std::string& values)
|
||||
{
|
||||
std::size_t begin = source.find_first_not_of(values);
|
||||
usz begin = source.find_first_not_of(values);
|
||||
|
||||
if (begin == source.npos)
|
||||
return {};
|
||||
|
|
@ -467,7 +467,7 @@ std::string fmt::to_lower(const std::string& string)
|
|||
|
||||
bool fmt::match(const std::string& source, const std::string& mask)
|
||||
{
|
||||
std::size_t source_position = 0, mask_position = 0;
|
||||
usz source_position = 0, mask_position = 0;
|
||||
|
||||
for (; source_position < source.size() && mask_position < mask.size(); ++mask_position, ++source_position)
|
||||
{
|
||||
|
|
@ -476,7 +476,7 @@ bool fmt::match(const std::string& source, const std::string& mask)
|
|||
case '?': break;
|
||||
|
||||
case '*':
|
||||
for (std::size_t test_source_position = source_position; test_source_position < source.size(); ++test_source_position)
|
||||
for (usz test_source_position = source_position; test_source_position < source.size(); ++test_source_position)
|
||||
{
|
||||
if (match(source.substr(test_source_position), mask.substr(mask_position + 1)))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace fmt
|
||||
{
|
||||
template <typename CharT, std::size_t N, typename... Args>
|
||||
template <typename CharT, usz N, typename... Args>
|
||||
static std::string format(const CharT(&)[N], const Args&...);
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ struct fmt_unveil<T*, void>
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
template <typename T, usz N>
|
||||
struct fmt_unveil<T[N], void>
|
||||
{
|
||||
using type = std::add_const_t<T>*;
|
||||
|
|
@ -119,7 +119,7 @@ struct fmt_unveil<b8, void>
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T, bool Se, std::size_t Align>
|
||||
template <typename T, bool Se, usz Align>
|
||||
struct fmt_unveil<se_t<T, Se, Align>, void>
|
||||
{
|
||||
using type = typename fmt_unveil<T>::type;
|
||||
|
|
@ -251,7 +251,7 @@ namespace fmt
|
|||
struct base57
|
||||
{
|
||||
const uchar* data;
|
||||
std::size_t size;
|
||||
usz size;
|
||||
|
||||
template <typename T>
|
||||
base57(const T& arg)
|
||||
|
|
@ -260,7 +260,7 @@ namespace fmt
|
|||
{
|
||||
}
|
||||
|
||||
base57(const uchar* data, std::size_t size)
|
||||
base57(const uchar* data, usz size)
|
||||
: data(data)
|
||||
, size(size)
|
||||
{
|
||||
|
|
@ -283,7 +283,7 @@ namespace fmt
|
|||
void raw_append(std::string& out, const char*, const fmt_type_info*, const u64*) noexcept;
|
||||
|
||||
// Formatting function
|
||||
template <typename CharT, std::size_t N, typename... Args>
|
||||
template <typename CharT, usz N, typename... Args>
|
||||
SAFE_BUFFERS FORCE_INLINE void append(std::string& out, const CharT(&fmt)[N], const Args&... args)
|
||||
{
|
||||
static constexpr fmt_type_info type_list[sizeof...(Args) + 1]{fmt_type_info::make<fmt_unveil_t<Args>>()...};
|
||||
|
|
@ -291,7 +291,7 @@ namespace fmt
|
|||
}
|
||||
|
||||
// Formatting function
|
||||
template <typename CharT, std::size_t N, typename... Args>
|
||||
template <typename CharT, usz N, typename... Args>
|
||||
SAFE_BUFFERS FORCE_INLINE std::string format(const CharT(&fmt)[N], const Args&... args)
|
||||
{
|
||||
std::string result;
|
||||
|
|
@ -303,7 +303,7 @@ namespace fmt
|
|||
[[noreturn]] void raw_throw_exception(const src_loc&, const char*, const fmt_type_info*, const u64*);
|
||||
|
||||
// Throw exception with formatting
|
||||
template <typename CharT, std::size_t N, typename... Args>
|
||||
template <typename CharT, usz N, typename... Args>
|
||||
struct throw_exception
|
||||
{
|
||||
[[noreturn]] SAFE_BUFFERS FORCE_INLINE throw_exception(const CharT(&fmt)[N], const Args&... args,
|
||||
|
|
@ -317,6 +317,6 @@ namespace fmt
|
|||
}
|
||||
};
|
||||
|
||||
template <typename CharT, std::size_t N, typename... Args>
|
||||
template <typename CharT, usz N, typename... Args>
|
||||
throw_exception(const CharT(&)[N], const Args&...) -> throw_exception<CharT, N, Args...>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ std::string utf8_path_to_ansi_path(const std::string& src);
|
|||
template <typename D, typename T>
|
||||
inline void strcpy_trunc(D& dst, const T& src)
|
||||
{
|
||||
const std::size_t count = std::size(src) >= std::size(dst) ? std::size(dst) - 1 : std::size(src);
|
||||
const usz count = std::size(src) >= std::size(dst) ? std::size(dst) - 1 : std::size(src);
|
||||
std::memcpy(std::data(dst), std::data(src), count);
|
||||
std::memset(std::data(dst) + count, 0, std::size(dst) - count);
|
||||
}
|
||||
|
|
@ -27,14 +27,14 @@ namespace fmt
|
|||
std::string replace_first(const std::string& src, const std::string& from, const std::string& to);
|
||||
std::string replace_all(const std::string& src, const std::string& from, const std::string& to);
|
||||
|
||||
template <size_t list_size>
|
||||
template <usz list_size>
|
||||
std::string replace_all(std::string src, const std::pair<std::string, std::string> (&list)[list_size])
|
||||
{
|
||||
for (size_t pos = 0; pos < src.length(); ++pos)
|
||||
for (usz pos = 0; pos < src.length(); ++pos)
|
||||
{
|
||||
for (size_t i = 0; i < list_size; ++i)
|
||||
for (usz i = 0; i < list_size; ++i)
|
||||
{
|
||||
const size_t comp_length = list[i].first.length();
|
||||
const usz comp_length = list[i].first.length();
|
||||
|
||||
if (src.length() - pos < comp_length)
|
||||
continue;
|
||||
|
|
@ -51,14 +51,14 @@ namespace fmt
|
|||
return src;
|
||||
}
|
||||
|
||||
template <size_t list_size>
|
||||
template <usz list_size>
|
||||
std::string replace_all(std::string src, const std::pair<std::string, std::function<std::string()>> (&list)[list_size])
|
||||
{
|
||||
for (size_t pos = 0; pos < src.length(); ++pos)
|
||||
for (usz pos = 0; pos < src.length(); ++pos)
|
||||
{
|
||||
for (size_t i = 0; i < list_size; ++i)
|
||||
for (usz i = 0; i < list_size; ++i)
|
||||
{
|
||||
const size_t comp_length = list[i].first.length();
|
||||
const usz comp_length = list[i].first.length();
|
||||
|
||||
if (src.length() - pos < comp_length)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ bool IsDebuggerPresent()
|
|||
};
|
||||
u_int miblen = std::size(mib);
|
||||
struct kinfo_proc info;
|
||||
size_t size = sizeof(info);
|
||||
usz size = sizeof(info);
|
||||
|
||||
if (sysctl(mib, miblen, &info, &size, NULL, 0))
|
||||
{
|
||||
|
|
@ -259,7 +259,7 @@ enum x64_op_t : u32
|
|||
X64OP_SBB, // lock sbb [mem], ...
|
||||
};
|
||||
|
||||
void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, size_t& out_size, size_t& out_length)
|
||||
void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, usz& out_size, usz& out_length)
|
||||
{
|
||||
// simple analysis of x64 code allows to reinterpret MOV or other instructions in any desired way
|
||||
out_length = 0;
|
||||
|
|
@ -385,12 +385,12 @@ void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, siz
|
|||
return x64_reg_t{((*code & 0x38) >> 3) + X64R_AL};
|
||||
};
|
||||
|
||||
auto get_op_size = [](const u8 rex, const bool oso) -> size_t
|
||||
auto get_op_size = [](const u8 rex, const bool oso) -> usz
|
||||
{
|
||||
return rex & 8 ? 8 : (oso ? 2 : 4);
|
||||
};
|
||||
|
||||
auto get_modRM_size = [](const u8* code) -> size_t
|
||||
auto get_modRM_size = [](const u8* code) -> usz
|
||||
{
|
||||
switch (*code >> 6) // check Mod
|
||||
{
|
||||
|
|
@ -976,7 +976,7 @@ static const int reg_table[] =
|
|||
#define RDI(c) (*X64REG((c), 7))
|
||||
#define RIP(c) (*X64REG((c), 16))
|
||||
|
||||
bool get_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, size_t i_size, u64& out_value)
|
||||
bool get_x64_reg_value(x64_context* context, x64_reg_t reg, usz d_size, usz i_size, u64& out_value)
|
||||
{
|
||||
// get x64 reg value (for store operations)
|
||||
if (reg - X64R_RAX < 16)
|
||||
|
|
@ -1067,7 +1067,7 @@ bool get_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, size_
|
|||
return false;
|
||||
}
|
||||
|
||||
bool put_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, u64 value)
|
||||
bool put_x64_reg_value(x64_context* context, x64_reg_t reg, usz d_size, u64 value)
|
||||
{
|
||||
// save x64 reg value (for load operations)
|
||||
if (reg - X64R_RAX < 16)
|
||||
|
|
@ -1086,7 +1086,7 @@ bool put_x64_reg_value(x64_context* context, x64_reg_t reg, size_t d_size, u64 v
|
|||
return false;
|
||||
}
|
||||
|
||||
bool set_x64_cmp_flags(x64_context* context, size_t d_size, u64 x, u64 y, bool carry = true)
|
||||
bool set_x64_cmp_flags(x64_context* context, usz d_size, u64 x, u64 y, bool carry = true)
|
||||
{
|
||||
switch (d_size)
|
||||
{
|
||||
|
|
@ -1162,7 +1162,7 @@ bool set_x64_cmp_flags(x64_context* context, size_t d_size, u64 x, u64 y, bool c
|
|||
return true;
|
||||
}
|
||||
|
||||
size_t get_x64_access_size(x64_context* context, x64_op_t op, x64_reg_t reg, size_t d_size, size_t i_size)
|
||||
usz get_x64_access_size(x64_context* context, x64_op_t op, x64_reg_t reg, usz d_size, usz i_size)
|
||||
{
|
||||
if (op == X64OP_MOVS || op == X64OP_STOS)
|
||||
{
|
||||
|
|
@ -1227,8 +1227,8 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
|
|||
|
||||
x64_op_t op;
|
||||
x64_reg_t reg;
|
||||
size_t d_size;
|
||||
size_t i_size;
|
||||
usz d_size;
|
||||
usz i_size;
|
||||
|
||||
// decode single x64 instruction that causes memory access
|
||||
decode_x64_reg_op(code, op, reg, d_size, i_size);
|
||||
|
|
@ -1249,7 +1249,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no
|
|||
}
|
||||
|
||||
// get length of data being accessed
|
||||
size_t a_size = get_x64_access_size(context, op, reg, d_size, i_size);
|
||||
usz a_size = get_x64_access_size(context, op, reg, d_size, i_size);
|
||||
|
||||
if (0x1'0000'0000ull - addr < a_size)
|
||||
{
|
||||
|
|
@ -1954,14 +1954,14 @@ void thread_base::set_name(std::string name)
|
|||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
name.resize(std::min<std::size_t>(15, name.size()));
|
||||
name.resize(std::min<usz>(15, name.size()));
|
||||
pthread_setname_np(name.c_str());
|
||||
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
pthread_set_name_np(pthread_self(), name.c_str());
|
||||
#elif defined(__NetBSD__)
|
||||
pthread_setname_np(pthread_self(), "%s", name.data());
|
||||
#elif !defined(_WIN32)
|
||||
name.resize(std::min<std::size_t>(15, name.size()));
|
||||
name.resize(std::min<usz>(15, name.size()));
|
||||
pthread_setname_np(pthread_self(), name.c_str());
|
||||
#endif
|
||||
}
|
||||
|
|
@ -2791,17 +2791,17 @@ u64 thread_ctrl::get_thread_affinity_mask()
|
|||
#endif
|
||||
}
|
||||
|
||||
std::pair<void*, std::size_t> thread_ctrl::get_thread_stack()
|
||||
std::pair<void*, usz> thread_ctrl::get_thread_stack()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
ULONG_PTR _min = 0;
|
||||
ULONG_PTR _max = 0;
|
||||
GetCurrentThreadStackLimits(&_min, &_max);
|
||||
const std::size_t ssize = _max - _min;
|
||||
const usz ssize = _max - _min;
|
||||
const auto saddr = reinterpret_cast<void*>(_min);
|
||||
#else
|
||||
void* saddr = 0;
|
||||
std::size_t ssize = 0;
|
||||
usz ssize = 0;
|
||||
pthread_attr_t attr;
|
||||
#ifdef __linux__
|
||||
pthread_getattr_np(pthread_self(), &attr);
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ public:
|
|||
static u64 get_thread_affinity_mask();
|
||||
|
||||
// Get current thread stack addr and size
|
||||
static std::pair<void*, std::size_t> get_thread_stack();
|
||||
static std::pair<void*, usz> get_thread_stack();
|
||||
|
||||
private:
|
||||
// Miscellaneous
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ namespace utils
|
|||
|
||||
public:
|
||||
// Wrapped functions
|
||||
inline void reserve(size_t nr) { data.reserve(nr); }
|
||||
inline void reserve(usz nr) { data.reserve(nr); }
|
||||
inline void clear() { data.clear(); }
|
||||
inline size_type size() const { return data.size(); }
|
||||
inline bool empty() const { return data.empty(); }
|
||||
|
|
@ -456,9 +456,9 @@ namespace utils
|
|||
// Will fail if ranges within the vector overlap our touch each-other
|
||||
bool check_consistency() const
|
||||
{
|
||||
size_t _size = data.size();
|
||||
usz _size = data.size();
|
||||
|
||||
for (size_t i = 0; i < _size; ++i)
|
||||
for (usz i = 0; i < _size; ++i)
|
||||
{
|
||||
const auto &r1 = data[i];
|
||||
if (!r1.valid())
|
||||
|
|
@ -466,7 +466,7 @@ namespace utils
|
|||
continue;
|
||||
}
|
||||
|
||||
for (size_t j = i + 1; j < _size; ++j)
|
||||
for (usz j = i + 1; j < _size; ++j)
|
||||
{
|
||||
const auto &r2 = data[j];
|
||||
if (!r2.valid())
|
||||
|
|
@ -582,15 +582,15 @@ namespace utils
|
|||
|
||||
namespace std
|
||||
{
|
||||
static_assert(sizeof(size_t) >= 2 * sizeof(u32), "size_t must be at least twice the size of u32");
|
||||
static_assert(sizeof(usz) >= 2 * sizeof(u32), "usz must be at least twice the size of u32");
|
||||
|
||||
template <>
|
||||
struct hash<utils::address_range>
|
||||
{
|
||||
std::size_t operator()(const utils::address_range& k) const
|
||||
usz operator()(const utils::address_range& k) const
|
||||
{
|
||||
// we can guarantee a unique hash since our type is 64 bits and size_t as well
|
||||
return (size_t{ k.start } << 32) | size_t{ k.end };
|
||||
// we can guarantee a unique hash since our type is 64 bits and usz as well
|
||||
return (usz{ k.start } << 32) | usz{ k.end };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -577,20 +577,20 @@ void patch_engine::append_title_patches(const std::string& title_id)
|
|||
load(m_map, get_patches_path() + title_id + "_patch.yml");
|
||||
}
|
||||
|
||||
std::size_t patch_engine::apply(const std::string& name, u8* dst)
|
||||
usz patch_engine::apply(const std::string& name, u8* dst)
|
||||
{
|
||||
return apply_patch<false>(name, dst, 0, 0);
|
||||
}
|
||||
|
||||
std::size_t patch_engine::apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr)
|
||||
usz patch_engine::apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr)
|
||||
{
|
||||
return apply_patch<true>(name, dst, filesz, ls_addr);
|
||||
}
|
||||
|
||||
template <bool check_local_storage>
|
||||
static std::size_t apply_modification(const patch_engine::patch_info& patch, u8* dst, u32 filesz, u32 ls_addr)
|
||||
static usz apply_modification(const patch_engine::patch_info& patch, u8* dst, u32 filesz, u32 ls_addr)
|
||||
{
|
||||
size_t applied = 0;
|
||||
usz applied = 0;
|
||||
|
||||
for (const auto& p : patch.data_list)
|
||||
{
|
||||
|
|
@ -681,14 +681,14 @@ static std::size_t apply_modification(const patch_engine::patch_info& patch, u8*
|
|||
}
|
||||
|
||||
template <bool check_local_storage>
|
||||
std::size_t patch_engine::apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr)
|
||||
usz patch_engine::apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr)
|
||||
{
|
||||
if (m_map.find(name) == m_map.cend())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t applied_total = 0;
|
||||
usz applied_total = 0;
|
||||
const auto& container = m_map.at(name);
|
||||
const auto serial = Emu.GetTitleID();
|
||||
const auto app_version = Emu.GetAppVersion();
|
||||
|
|
@ -799,7 +799,7 @@ std::size_t patch_engine::apply_patch(const std::string& name, u8* dst, u32 file
|
|||
m_applied_groups.insert(patch.patch_group);
|
||||
}
|
||||
|
||||
const size_t applied = apply_modification<check_local_storage>(patch, dst, filesz, ls_addr);
|
||||
const usz applied = apply_modification<check_local_storage>(patch, dst, filesz, ls_addr);
|
||||
applied_total += applied;
|
||||
|
||||
if (patch.is_legacy)
|
||||
|
|
@ -906,7 +906,7 @@ void patch_engine::save_config(const patch_map& patches_map, bool enable_legacy_
|
|||
file.write(out.c_str(), out.size());
|
||||
}
|
||||
|
||||
static void append_patches(patch_engine::patch_map& existing_patches, const patch_engine::patch_map& new_patches, size_t& count, size_t& total, std::stringstream* log_messages)
|
||||
static void append_patches(patch_engine::patch_map& existing_patches, const patch_engine::patch_map& new_patches, usz& count, usz& total, std::stringstream* log_messages)
|
||||
{
|
||||
for (const auto& [hash, new_container] : new_patches)
|
||||
{
|
||||
|
|
@ -1058,7 +1058,7 @@ bool patch_engine::save_patches(const patch_map& patches, const std::string& pat
|
|||
return true;
|
||||
}
|
||||
|
||||
bool patch_engine::import_patches(const patch_engine::patch_map& patches, const std::string& path, size_t& count, size_t& total, std::stringstream* log_messages)
|
||||
bool patch_engine::import_patches(const patch_engine::patch_map& patches, const std::string& path, usz& count, usz& total, std::stringstream* log_messages)
|
||||
{
|
||||
patch_engine::patch_map existing_patches;
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public:
|
|||
static bool save_patches(const patch_map& patches, const std::string& path, std::stringstream* log_messages = nullptr);
|
||||
|
||||
// Create or append patches to a file
|
||||
static bool import_patches(const patch_map& patches, const std::string& path, size_t& count, size_t& total, std::stringstream* log_messages = nullptr);
|
||||
static bool import_patches(const patch_map& patches, const std::string& path, usz& count, usz& total, std::stringstream* log_messages = nullptr);
|
||||
|
||||
// Remove a patch from a file
|
||||
static bool remove_patch(const patch_info& info);
|
||||
|
|
@ -132,15 +132,15 @@ public:
|
|||
void append_title_patches(const std::string& title_id);
|
||||
|
||||
// Apply patch (returns the number of entries applied)
|
||||
std::size_t apply(const std::string& name, u8* dst);
|
||||
usz apply(const std::string& name, u8* dst);
|
||||
|
||||
// Apply patch with a check that the address exists in SPU local storage
|
||||
std::size_t apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr);
|
||||
usz apply_with_ls_check(const std::string& name, u8* dst, u32 filesz, u32 ls_addr);
|
||||
|
||||
private:
|
||||
// Internal: Apply patch (returns the number of entries applied)
|
||||
template <bool check_local_storage>
|
||||
std::size_t apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr);
|
||||
usz apply_patch(const std::string& name, u8* dst, u32 filesz, u32 ls_addr);
|
||||
|
||||
// Database
|
||||
patch_map m_map;
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
static constexpr std::size_t bitmax = sizeof(T) * 8;
|
||||
static constexpr std::size_t bitsize = static_cast<under>(T::__bitset_enum_max);
|
||||
static constexpr usz bitmax = sizeof(T) * 8;
|
||||
static constexpr usz bitsize = static_cast<under>(T::__bitset_enum_max);
|
||||
|
||||
static_assert(std::is_enum<T>::value, "bs_t<> error: invalid type (must be enum)");
|
||||
static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
static const std::size_t size_dropped = -1;
|
||||
static const usz size_dropped = -1;
|
||||
|
||||
/*
|
||||
C-style format parser. Appends formatted string to `out`, returns number of characters written.
|
||||
|
|
@ -15,13 +15,13 @@ C-style format parser. Appends formatted string to `out`, returns number of char
|
|||
`src`: rvalue reference to argument provider.
|
||||
*/
|
||||
template<typename Dst, typename Char, typename Src>
|
||||
std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
||||
usz cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
||||
{
|
||||
const std::size_t start_pos = out.size();
|
||||
const usz start_pos = out.size();
|
||||
|
||||
struct cfmt_context
|
||||
{
|
||||
std::size_t size; // Size of current format sequence
|
||||
usz size; // Size of current format sequence
|
||||
|
||||
u8 args; // Number of extra args used
|
||||
u8 type; // Integral type bytesize
|
||||
|
|
@ -80,7 +80,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
|
||||
const auto write_decimal = [&](u64 value, s64 min_size)
|
||||
{
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
|
||||
do
|
||||
{
|
||||
|
|
@ -90,7 +90,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
while (0 < --min_size || value);
|
||||
|
||||
// Revert written characters
|
||||
for (std::size_t i = start, j = out.size() - 1; i < j; i++, j--)
|
||||
for (usz i = start, j = out.size() - 1; i < j; i++, j--)
|
||||
{
|
||||
std::swap(out[i], out[j]);
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
break;
|
||||
}
|
||||
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
out.push_back(src.template get<Char>(ctx.args));
|
||||
|
||||
if (1 < ctx.width)
|
||||
|
|
@ -307,8 +307,8 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
break;
|
||||
}
|
||||
|
||||
const std::size_t start = out.size();
|
||||
const std::size_t size1 = src.fmt_string(out, ctx.args);
|
||||
const usz start = out.size();
|
||||
const usz size1 = src.fmt_string(out, ctx.args);
|
||||
|
||||
if (ctx.dot && size1 > ctx.prec)
|
||||
{
|
||||
|
|
@ -316,7 +316,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
out.resize(start + ctx.prec);
|
||||
}
|
||||
|
||||
const std::size_t size2 = out.size() - start;
|
||||
const usz size2 = out.size() - start;
|
||||
|
||||
if (size2 < ctx.width)
|
||||
{
|
||||
|
|
@ -352,7 +352,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
const u64 val = src.template get<u64>(ctx.args);
|
||||
const bool negative = ctx.type && static_cast<s64>(val) < 0;
|
||||
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
|
||||
if (!ctx.dot || ctx.prec)
|
||||
{
|
||||
|
|
@ -372,7 +372,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
write_decimal(negative ? 0 - val : val, ctx.prec);
|
||||
}
|
||||
|
||||
const std::size_t size2 = out.size() - start;
|
||||
const usz size2 = out.size() - start;
|
||||
|
||||
if (size2 < ctx.width)
|
||||
{
|
||||
|
|
@ -419,7 +419,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
// Trunc sign-extended signed types
|
||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
|
||||
if (ctx.alter)
|
||||
{
|
||||
|
|
@ -435,7 +435,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
write_octal(val, ctx.prec);
|
||||
}
|
||||
|
||||
const std::size_t size2 = out.size() - start;
|
||||
const usz size2 = out.size() - start;
|
||||
|
||||
if (size2 < ctx.width)
|
||||
{
|
||||
|
|
@ -476,7 +476,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
// Trunc sign-extended signed types
|
||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
|
||||
if (ctx.alter)
|
||||
{
|
||||
|
|
@ -493,7 +493,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
write_hex(val, ch == 'X', ctx.prec);
|
||||
}
|
||||
|
||||
const std::size_t size2 = out.size() - start;
|
||||
const usz size2 = out.size() - start;
|
||||
|
||||
if (size2 < ctx.width)
|
||||
{
|
||||
|
|
@ -540,14 +540,14 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
// Trunc sign-extended signed types
|
||||
const u64 val = src.template get<u64>(ctx.args) & mask;
|
||||
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
|
||||
if (!ctx.dot || ctx.prec)
|
||||
{
|
||||
write_decimal(val, ctx.prec);
|
||||
}
|
||||
|
||||
const std::size_t size2 = out.size() - start;
|
||||
const usz size2 = out.size() - start;
|
||||
|
||||
if (size2 < ctx.width)
|
||||
{
|
||||
|
|
@ -570,11 +570,11 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
|
||||
const u64 val = src.template get<u64>(ctx.args);
|
||||
|
||||
const std::size_t start = out.size();
|
||||
const usz start = out.size();
|
||||
|
||||
write_hex(val, false, sizeof(void*) * 2);
|
||||
|
||||
const std::size_t size2 = out.size() - start;
|
||||
const usz size2 = out.size() - start;
|
||||
|
||||
if (size2 < ctx.width)
|
||||
{
|
||||
|
|
@ -610,7 +610,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
|
|||
const u64 arg1 = ctx.args >= 1 ? src.template get<u64>(1) : 0;
|
||||
const u64 arg2 = ctx.args >= 2 ? src.template get<u64>(2) : 0;
|
||||
|
||||
if (const std::size_t _size = std::snprintf(0, 0, _fmt.c_str(), arg0, arg1, arg2))
|
||||
if (const usz _size = std::snprintf(0, 0, _fmt.c_str(), arg0, arg1, arg2))
|
||||
{
|
||||
out.resize(out.size() + _size);
|
||||
std::snprintf(&out.front() + out.size() - _size, _size + 1, _fmt.c_str(), arg0, arg1, arg2);
|
||||
|
|
|
|||
|
|
@ -5,19 +5,19 @@
|
|||
namespace rpcs3
|
||||
{
|
||||
template<typename T>
|
||||
static size_t hash_base(T value)
|
||||
static usz hash_base(T value)
|
||||
{
|
||||
return static_cast<size_t>(value);
|
||||
return static_cast<usz>(value);
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
static size_t hash_struct_base(const T& value)
|
||||
static usz hash_struct_base(const T& value)
|
||||
{
|
||||
// FNV 64-bit
|
||||
size_t result = 14695981039346656037ull;
|
||||
usz result = 14695981039346656037ull;
|
||||
const U *bits = reinterpret_cast<const U*>(&value);
|
||||
|
||||
for (size_t n = 0; n < (sizeof(T) / sizeof(U)); ++n)
|
||||
for (usz n = 0; n < (sizeof(T) / sizeof(U)); ++n)
|
||||
{
|
||||
result ^= bits[n];
|
||||
result *= 1099511628211ull;
|
||||
|
|
@ -27,7 +27,7 @@ namespace rpcs3
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static size_t hash_struct(const T& value)
|
||||
static usz hash_struct(const T& value)
|
||||
{
|
||||
static constexpr auto block_sz = sizeof(T);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
//!
|
||||
//! T is the type of elements. Currently, default constructor of T shall be constexpr.
|
||||
//! N is initial element count, available without any memory allocation and only stored contiguously.
|
||||
template <typename T, std::size_t N>
|
||||
template <typename T, usz N>
|
||||
class lf_array
|
||||
{
|
||||
// Data (default-initialized)
|
||||
|
|
@ -28,7 +28,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
T& operator [](std::size_t index)
|
||||
T& operator [](usz index)
|
||||
{
|
||||
if (index < N) [[likely]]
|
||||
{
|
||||
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
//! Simple lock-free FIFO queue base. Based on lf_array<T, N> itself. Currently uses 32-bit counters.
|
||||
//! There is no "push_end" or "pop_begin" provided, the queue element must signal its state on its own.
|
||||
template<typename T, std::size_t N>
|
||||
template<typename T, usz N>
|
||||
class lf_fifo : public lf_array<T, N>
|
||||
{
|
||||
// LSB 32-bit: push, MSB 32-bit: pop
|
||||
|
|
@ -354,9 +354,9 @@ public:
|
|||
|
||||
// Apply func(data) to each element, return the total length
|
||||
template <typename F>
|
||||
std::size_t apply(F func)
|
||||
usz apply(F func)
|
||||
{
|
||||
std::size_t count = 0;
|
||||
usz count = 0;
|
||||
|
||||
for (auto slice = pop_all(); slice; slice.pop_front())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -217,13 +217,13 @@ std::string utils::get_firmware_version()
|
|||
std::string version = version_file.to_string();
|
||||
|
||||
// Extract version
|
||||
const size_t start = version.find_first_of(':') + 1;
|
||||
const size_t end = version.find_first_of(':', start);
|
||||
const usz start = version.find_first_of(':') + 1;
|
||||
const usz end = version.find_first_of(':', start);
|
||||
version = version.substr(start, end - start);
|
||||
|
||||
// Trim version
|
||||
const size_t trim_start = version.find_first_not_of('0');
|
||||
const size_t trim_end = version.find_last_not_of('0');
|
||||
const usz trim_start = version.find_first_not_of('0');
|
||||
const usz trim_end = version.find_last_not_of('0');
|
||||
version = version.substr(trim_start, trim_end);
|
||||
|
||||
return version;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ namespace utils
|
|||
template <typename T>
|
||||
class refctr final
|
||||
{
|
||||
atomic_t<std::size_t> m_ref{1};
|
||||
atomic_t<usz> m_ref{1};
|
||||
|
||||
public:
|
||||
T object;
|
||||
|
|
@ -168,7 +168,7 @@ namespace utils
|
|||
m_ref++;
|
||||
}
|
||||
|
||||
std::size_t remove_ref() noexcept
|
||||
usz remove_ref() noexcept
|
||||
{
|
||||
return --m_ref;
|
||||
}
|
||||
|
|
@ -464,8 +464,8 @@ namespace utils
|
|||
uint get_id() const
|
||||
{
|
||||
// It's not often needed so figure it out instead of storing it
|
||||
const std::size_t diff = reinterpret_cast<uchar*>(m_block) - m_head->m_ptr;
|
||||
const std::size_t quot = diff / m_head->m_ssize;
|
||||
const usz diff = reinterpret_cast<uchar*>(m_block) - m_head->m_ptr;
|
||||
const usz quot = diff / m_head->m_ssize;
|
||||
|
||||
if (diff % m_head->m_ssize || quot > typeinfo_count<T>::max_count)
|
||||
{
|
||||
|
|
@ -498,7 +498,7 @@ namespace utils
|
|||
void* m_memory = nullptr;
|
||||
|
||||
// Virtual memory size
|
||||
std::size_t m_total = 0;
|
||||
usz m_total = 0;
|
||||
|
||||
template <typename T>
|
||||
typemap_head* get_head() const
|
||||
|
|
@ -555,7 +555,7 @@ namespace utils
|
|||
// Delete objects (there shall be no threads accessing them)
|
||||
const uint lim = m_map[i].m_count != 1 ? +m_map[i].m_limit : 1;
|
||||
|
||||
for (std::size_t j = 0; j < lim; j++)
|
||||
for (usz j = 0; j < lim; j++)
|
||||
{
|
||||
const auto block = reinterpret_cast<typemap_block*>(m_map[i].m_ptr + j * m_map[i].m_ssize);
|
||||
|
||||
|
|
@ -585,7 +585,7 @@ namespace utils
|
|||
{
|
||||
const uint align = type->align;
|
||||
const uint ssize = ::align<uint>(sizeof(typemap_block), align) + ::align(type->size, align);
|
||||
const auto total = std::size_t{ssize} * type->count;
|
||||
const auto total = usz{ssize} * type->count;
|
||||
const auto start = uptr{::align(m_total, align)};
|
||||
|
||||
if (total)
|
||||
|
|
@ -624,7 +624,7 @@ namespace utils
|
|||
}
|
||||
|
||||
// Return allocated virtual memory block size (not aligned)
|
||||
std::size_t get_memory_size() const
|
||||
usz get_memory_size() const
|
||||
{
|
||||
return m_total;
|
||||
}
|
||||
|
|
@ -664,7 +664,7 @@ namespace utils
|
|||
// Find empty location and lock it, starting from hint index
|
||||
for (uint lim = head->m_limit, i = (lim > last ? 0 : lim);; i = (i == last ? 0 : i + 1))
|
||||
{
|
||||
block = reinterpret_cast<typemap_block*>(head->m_ptr + std::size_t{i} * head->m_ssize);
|
||||
block = reinterpret_cast<typemap_block*>(head->m_ptr + usz{i} * head->m_ssize);
|
||||
|
||||
if (block->m_type == 0 && block->m_mutex.try_lock())
|
||||
{
|
||||
|
|
@ -703,7 +703,7 @@ namespace utils
|
|||
else if constexpr (std::is_invocable_r_v<bool, const Arg&, const Type&>)
|
||||
{
|
||||
// Access with a lookup function
|
||||
for (std::size_t j = 0; j < (typeinfo_count<Type>::max_count != 1 ? +head->m_limit : 1); j++)
|
||||
for (usz j = 0; j < (typeinfo_count<Type>::max_count != 1 ? +head->m_limit : 1); j++)
|
||||
{
|
||||
block = reinterpret_cast<typemap_block*>(head->m_ptr + j * head->m_ssize);
|
||||
|
||||
|
|
@ -731,7 +731,7 @@ namespace utils
|
|||
const uint unbiased = static_cast<uint>(std::forward<Arg>(id)) - bias;
|
||||
const uint unscaled = unbiased / step;
|
||||
|
||||
block = reinterpret_cast<typemap_block*>(head->m_ptr + std::size_t{head->m_ssize} * unscaled);
|
||||
block = reinterpret_cast<typemap_block*>(head->m_ptr + usz{head->m_ssize} * unscaled);
|
||||
|
||||
// Check id range and type
|
||||
if (unscaled >= typeinfo_count<Type>::max_count || unbiased % step) [[unlikely]]
|
||||
|
|
@ -866,7 +866,7 @@ namespace utils
|
|||
}
|
||||
}
|
||||
|
||||
template <std::size_t I, typename Type, typename... Types, bool Lock, bool... Locks, std::size_t N>
|
||||
template <usz I, typename Type, typename... Types, bool Lock, bool... Locks, usz N>
|
||||
bool try_lock(const std::array<typeptr_base, N>& array, uint locked, std::integer_sequence<bool, Lock, Locks...>) const
|
||||
{
|
||||
// Try to lock mutex if not locked from the previous step
|
||||
|
|
@ -905,8 +905,8 @@ namespace utils
|
|||
return false;
|
||||
}
|
||||
|
||||
template <typename... Types, std::size_t N, std::size_t... I, bool... Locks>
|
||||
uint lock_array(const std::array<typeptr_base, N>& array, std::integer_sequence<std::size_t, I...>, std::integer_sequence<bool, Locks...>) const
|
||||
template <typename... Types, usz N, usz... I, bool... Locks>
|
||||
uint lock_array(const std::array<typeptr_base, N>& array, std::integer_sequence<usz, I...>, std::integer_sequence<bool, Locks...>) const
|
||||
{
|
||||
// Verify all mutexes are free or wait for one of them and return its index
|
||||
uint locked = 0;
|
||||
|
|
@ -914,15 +914,15 @@ namespace utils
|
|||
return locked;
|
||||
}
|
||||
|
||||
template <typename... Types, std::size_t N, std::size_t... I, typename... Args>
|
||||
void check_array(std::array<typeptr_base, N>& array, std::integer_sequence<std::size_t, I...>, Args&&... ids) const
|
||||
template <typename... Types, usz N, usz... I, typename... Args>
|
||||
void check_array(std::array<typeptr_base, N>& array, std::integer_sequence<usz, I...>, Args&&... ids) const
|
||||
{
|
||||
// Check types and unlock on mismatch
|
||||
(check_ptr<Types, Args>(array[I].m_block, std::forward<Args>(ids)), ...);
|
||||
}
|
||||
|
||||
template <typename... Types, std::size_t N, std::size_t... I>
|
||||
std::tuple<typeptr<Types>...> array_to_tuple(const std::array<typeptr_base, N>& array, std::integer_sequence<std::size_t, I...>) const
|
||||
template <typename... Types, usz N, usz... I>
|
||||
std::tuple<typeptr<Types>...> array_to_tuple(const std::array<typeptr_base, N>& array, std::integer_sequence<usz, I...>) const
|
||||
{
|
||||
return {array[I]...};
|
||||
}
|
||||
|
|
@ -1000,7 +1000,7 @@ namespace utils
|
|||
|
||||
const ullong ix = head->m_create_count;
|
||||
|
||||
for (std::size_t j = 0; j < (typeinfo_count<decode_t<Type>>::max_count != 1 ? +head->m_limit : 1); j++)
|
||||
for (usz j = 0; j < (typeinfo_count<decode_t<Type>>::max_count != 1 ? +head->m_limit : 1); j++)
|
||||
{
|
||||
const auto block = reinterpret_cast<typemap_block*>(head->m_ptr + j * head->m_ssize);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace utils
|
|||
int vnum2 = 0;
|
||||
|
||||
// Loop until both strings are processed
|
||||
for (size_t i = 0, j = 0; (i < v1.length() || j < v2.length());)
|
||||
for (usz i = 0, j = 0; (i < v1.length() || j < v2.length());)
|
||||
{
|
||||
// Storing numeric part of version 1 in vnum1
|
||||
while (i < v1.length() && v1[i] != '.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue