mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-21 21:09:00 +02:00
[cmake] enable clang-cl and WoA builds (#348)
Compilation and CMake fixes for both Windows on ARM and clang-cl, meaning Windows can now be built on both MSVC and clang on both amd64 and aarch64. Compiling on clang is *dramatically* faster so this should be useful for CI. Co-authored-by: crueter <crueter@eden-emu.dev> Co-authored-by: crueter <crueter@crueter.xyz> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/348 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
428f136a75
commit
9d2681ecc9
276 changed files with 973 additions and 1010 deletions
|
|
@ -1187,6 +1187,7 @@ else()
|
|||
-Wno-cast-function-type
|
||||
|
||||
$<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation>
|
||||
$<$<CXX_COMPILER_ID:Clang>:-Wno-cast-function-type-mismatch>
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -283,9 +283,9 @@ Loader::AppLoader::Modules FindModules(Kernel::KProcess* process) {
|
|||
// Ignore leading directories.
|
||||
char* path_pointer = module_path.path.data();
|
||||
char* path_end =
|
||||
path_pointer + std::min(PathLengthMax, module_path.path_length);
|
||||
path_pointer + (std::min)(PathLengthMax, module_path.path_length);
|
||||
|
||||
for (s32 i = 0; i < std::min(PathLengthMax, module_path.path_length) &&
|
||||
for (s32 i = 0; i < (std::min)(PathLengthMax, module_path.path_length) &&
|
||||
module_path.path[i] != '\0';
|
||||
i++) {
|
||||
if (module_path.path[i] == '/' || module_path.path[i] == '\\') {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ CallbackOrAccessOneWord DynarmicCP15::CompileSendOneWord(bool two, unsigned opc1
|
|||
_mm_lfence();
|
||||
#elif defined(ARCHITECTURE_x86_64)
|
||||
asm volatile("mfence\n\tlfence\n\t" : : : "memory");
|
||||
#elif defined(_MSC_VER) && defined(ARCHITECTURE_arm64)
|
||||
_Memory_barrier();
|
||||
#elif defined(ARCHITECTURE_arm64)
|
||||
asm volatile("dsb sy\n\t" : : : "memory");
|
||||
#else
|
||||
|
|
@ -75,6 +77,8 @@ CallbackOrAccessOneWord DynarmicCP15::CompileSendOneWord(bool two, unsigned opc1
|
|||
_mm_mfence();
|
||||
#elif defined(ARCHITECTURE_x86_64)
|
||||
asm volatile("mfence\n\t" : : : "memory");
|
||||
#elif defined(_MSC_VER) && defined(ARCHITECTURE_arm64)
|
||||
_Memory_barrier();
|
||||
#elif defined(ARCHITECTURE_arm64)
|
||||
asm volatile("dmb sy\n\t" : : : "memory");
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -4,9 +4,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <span>
|
||||
|
||||
#include "core/hle/kernel/k_thread.h"
|
||||
#include "core/memory.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/arm/nce/visitor_base.h"
|
||||
|
||||
namespace Core {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/svc.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/hle/kernel/k_thread.h"
|
||||
|
||||
namespace Core::NCE {
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ struct System::Impl {
|
|||
|
||||
Service::PSC::Time::LocationName name{};
|
||||
auto new_name = Settings::GetTimeZoneString(Settings::values.time_zone_index.GetValue());
|
||||
std::memcpy(name.data(), new_name.data(), std::min(name.size(), new_name.size()));
|
||||
std::memcpy(name.data(), new_name.data(), (std::min)(name.size(), new_name.size()));
|
||||
|
||||
timezone_service->SetDeviceLocationName(name);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ std::size_t XTSEncryptionLayer::Read(u8* data, std::size_t length, std::size_t o
|
|||
buffer.resize(XTS_SECTOR_SIZE);
|
||||
cipher.XTSTranscode(buffer.data(), buffer.size(), buffer.data(), offset / XTS_SECTOR_SIZE,
|
||||
XTS_SECTOR_SIZE, Op::Decrypt);
|
||||
std::memcpy(data, buffer.data(), std::min(buffer.size(), length));
|
||||
return std::min(buffer.size(), length);
|
||||
std::memcpy(data, buffer.data(), (std::min)(buffer.size(), length));
|
||||
return (std::min)(buffer.size(), length);
|
||||
}
|
||||
|
||||
// offset does not fall on block boundary (0x4000)
|
||||
|
|
|
|||
|
|
@ -664,7 +664,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
|
|||
|
||||
if (svc_mem_info.state != Kernel::Svc::MemoryState::Inaccessible ||
|
||||
svc_mem_info.base_address + svc_mem_info.size - 1 !=
|
||||
std::numeric_limits<u64>::max()) {
|
||||
(std::numeric_limits<u64>::max)()) {
|
||||
const char* state = GetMemoryStateName(svc_mem_info.state);
|
||||
const char* perm = GetMemoryPermissionString(svc_mem_info);
|
||||
const char l = True(svc_mem_info.attribute & MemoryAttribute::Locked) ? 'L' : '-';
|
||||
|
|
@ -710,7 +710,7 @@ std::vector<char>::const_iterator GDBStub::CommandEnd() const {
|
|||
const auto end{std::find(current_command.begin(), current_command.end(), GDB_STUB_END)};
|
||||
|
||||
// Require the checksum to be present
|
||||
return std::min(end + 2, current_command.end());
|
||||
return (std::min)(end + 2, current_command.end());
|
||||
}
|
||||
|
||||
std::optional<std::string> GDBStub::DetachCommand() {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ static T HexToValue(std::string_view hex) {
|
|||
static_assert(std::is_trivially_copyable_v<T>);
|
||||
T value{};
|
||||
const auto mem{Common::HexStringToVector(hex, false)};
|
||||
std::memcpy(&value, mem.data(), std::min(mem.size(), sizeof(T)));
|
||||
std::memcpy(&value, mem.data(), (std::min)(mem.size(), sizeof(T)));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ void DeviceMemoryManager<Traits>::WalkBlock(DAddr addr, std::size_t size, auto o
|
|||
while (remaining_size) {
|
||||
const size_t next_pages = static_cast<std::size_t>(continuity_tracker[page_index]);
|
||||
const std::size_t copy_amount =
|
||||
std::min((next_pages << Memory::YUZU_PAGEBITS) - page_offset, remaining_size);
|
||||
(std::min)((next_pages << Memory::YUZU_PAGEBITS) - page_offset, remaining_size);
|
||||
const auto current_vaddr =
|
||||
static_cast<u64>((page_index << Memory::YUZU_PAGEBITS) + page_offset);
|
||||
SCOPE_EXIT{
|
||||
|
|
|
|||
|
|
@ -683,7 +683,7 @@ public:
|
|||
const auto max_mount_len =
|
||||
out_mount_name_buffer_size == 0
|
||||
? MountNameLengthMax + 1
|
||||
: std::min(MountNameLengthMax + 1, out_mount_name_buffer_size);
|
||||
: (std::min)(MountNameLengthMax + 1, out_mount_name_buffer_size);
|
||||
|
||||
// Parse the path until we see a drive separator
|
||||
size_t mount_len = 0;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
private:
|
||||
Result DoRead(s64* out_count, DirectoryEntry* out_entries, s64 max_entries) {
|
||||
const u64 actual_entries =
|
||||
std::min(static_cast<u64>(max_entries), entries.size() - next_entry_index);
|
||||
(std::min)(static_cast<u64>(max_entries), entries.size() - next_entry_index);
|
||||
const auto* begin = reinterpret_cast<u8*>(entries.data() + next_entry_index);
|
||||
const auto* end = reinterpret_cast<u8*>(entries.data() + next_entry_index + actual_entries);
|
||||
const auto range_size = static_cast<std::size_t>(std::distance(begin, end));
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ protected:
|
|||
R_TRY(this->DoGetSize(std::addressof(file_size)));
|
||||
R_UNLESS(offset <= file_size, ResultOutOfRange);
|
||||
|
||||
*out = static_cast<size_t>(std::min(file_size - offset, static_cast<s64>(size)));
|
||||
*out = static_cast<size_t>((std::min)(file_size - offset, static_cast<s64>(size)));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ size_t AesCtrCounterExtendedStorage::Read(u8* buffer, size_t size, size_t offset
|
|||
|
||||
// Determine how much is left.
|
||||
const auto remaining_size = end_offset - cur_offset;
|
||||
const auto cur_size = static_cast<size_t>(std::min(remaining_size, data_size));
|
||||
const auto cur_size = static_cast<size_t>((std::min)(remaining_size, data_size));
|
||||
ASSERT(cur_size <= size);
|
||||
|
||||
// If necessary, perform decryption.
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ size_t AesCtrStorage::Write(const u8* buffer, size_t size, size_t offset) {
|
|||
while (remaining > 0) {
|
||||
// Determine data we're writing and where.
|
||||
const size_t write_size =
|
||||
use_work_buffer ? std::min(pooled_buffer.GetSize(), remaining) : remaining;
|
||||
use_work_buffer ? (std::min)(pooled_buffer.GetSize(), remaining) : remaining;
|
||||
|
||||
void* write_buf;
|
||||
if (use_work_buffer) {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ size_t AesXtsStorage::Read(u8* buffer, size_t size, size_t offset) const {
|
|||
// Determine the size of the pre-data read.
|
||||
const size_t skip_size =
|
||||
static_cast<size_t>(offset - Common::AlignDown(offset, m_block_size));
|
||||
const size_t data_size = std::min(size, m_block_size - skip_size);
|
||||
const size_t data_size = (std::min)(size, m_block_size - skip_size);
|
||||
|
||||
// Decrypt into a pooled buffer.
|
||||
{
|
||||
|
|
@ -84,14 +84,14 @@ size_t AesXtsStorage::Read(u8* buffer, size_t size, size_t offset) const {
|
|||
|
||||
AddCounter(ctr.data(), IvSize, 1);
|
||||
processed_size += data_size;
|
||||
ASSERT(processed_size == std::min(size, m_block_size - skip_size));
|
||||
ASSERT(processed_size == (std::min)(size, m_block_size - skip_size));
|
||||
}
|
||||
|
||||
// Decrypt aligned chunks.
|
||||
char* cur = reinterpret_cast<char*>(buffer) + processed_size;
|
||||
size_t remaining = size - processed_size;
|
||||
while (remaining > 0) {
|
||||
const size_t cur_size = std::min(m_block_size, remaining);
|
||||
const size_t cur_size = (std::min)(m_block_size, remaining);
|
||||
|
||||
m_cipher->SetIV(ctr);
|
||||
m_cipher->Transcode(cur, cur_size, cur, Core::Crypto::Op::Decrypt);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ size_t AlignmentMatchingStorageImpl::Read(VirtualFile base_storage, char* work_b
|
|||
while (remaining_tail_size > 0) {
|
||||
const auto aligned_tail_offset = Common::AlignDown(tail_offset, data_alignment);
|
||||
const auto cur_size =
|
||||
std::min(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
|
||||
(std::min)(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
|
||||
remaining_tail_size);
|
||||
base_storage->Read(reinterpret_cast<u8*>(work_buf), data_alignment, aligned_tail_offset);
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ size_t AlignmentMatchingStorageImpl::Write(VirtualFile base_storage, char* work_
|
|||
|
||||
const auto aligned_tail_offset = Common::AlignDown(tail_offset, data_alignment);
|
||||
const auto cur_size =
|
||||
std::min(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
|
||||
(std::min)(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
|
||||
remaining_tail_size);
|
||||
|
||||
base_storage->Read(reinterpret_cast<u8*>(work_buf), data_alignment, aligned_tail_offset);
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ void GenerateKey(void* dst_key, size_t dst_key_size, const void* src_key, size_t
|
|||
key_type == static_cast<s32>(KeyType::NcaHeaderKey2)) {
|
||||
const s32 key_index = static_cast<s32>(KeyType::NcaHeaderKey2) == key_type;
|
||||
const auto key = instance.GetKey(Core::Crypto::S256KeyType::Header);
|
||||
std::memcpy(dst_key, key.data() + key_index * 0x10, std::min(dst_key_size, key.size() / 2));
|
||||
std::memcpy(dst_key, key.data() + key_index * 0x10, (std::min)(dst_key_size, key.size() / 2));
|
||||
return;
|
||||
}
|
||||
|
||||
const s32 key_generation =
|
||||
std::max(key_type / NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount, 1) - 1;
|
||||
(std::max)(key_type / NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount, 1) - 1;
|
||||
const s32 key_index = key_type % NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount;
|
||||
|
||||
Core::Crypto::AESCipher<Core::Crypto::Key128> cipher(
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void IntegrityVerificationStorage::Initialize(VirtualFile hs,
|
|||
ASSERT(m_verification_block_size == 1ll << m_verification_block_order);
|
||||
|
||||
// Set upper layer block sizes.
|
||||
upper_layer_verif_block_size = std::max(upper_layer_verif_block_size, HashSize);
|
||||
upper_layer_verif_block_size = (std::max)(upper_layer_verif_block_size, HashSize);
|
||||
m_upper_layer_verification_block_size = upper_layer_verif_block_size;
|
||||
m_upper_layer_verification_block_order = ILog2(static_cast<u32>(upper_layer_verif_block_size));
|
||||
ASSERT(m_upper_layer_verification_block_size == 1ll << m_upper_layer_verification_block_order);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
namespace FileSys {
|
||||
|
||||
u8 NcaHeader::GetProperKeyGeneration() const {
|
||||
return std::max(this->key_generation, this->key_generation_2);
|
||||
return (std::max)(this->key_generation, this->key_generation_2);
|
||||
}
|
||||
|
||||
bool NcaPatchInfo::HasIndirectTable() const {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void PooledBuffer::AllocateCore(size_t ideal_size, size_t required_size, bool la
|
|||
ASSERT(required_size <= GetAllocatableSizeMaxCore(large));
|
||||
|
||||
const size_t target_size =
|
||||
std::min(std::max(ideal_size, required_size), GetAllocatableSizeMaxCore(large));
|
||||
(std::min)((std::max)(ideal_size, required_size), GetAllocatableSizeMaxCore(large));
|
||||
|
||||
// Dummy implementation for allocate.
|
||||
if (target_size > 0) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ private:
|
|||
virtual ~ZeroStorage() {}
|
||||
|
||||
virtual size_t GetSize() const override {
|
||||
return std::numeric_limits<size_t>::max();
|
||||
return (std::numeric_limits<size_t>::max)();
|
||||
}
|
||||
|
||||
virtual size_t Read(u8* buffer, size_t size, size_t offset) const override {
|
||||
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
private:
|
||||
void SetZeroStorage() {
|
||||
return this->SetStorage(1, m_zero_storage, 0, std::numeric_limits<s64>::max());
|
||||
return this->SetStorage(1, m_zero_storage, 0, (std::numeric_limits<s64>::max)());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ std::vector<u8> CNMT::Serialize() const {
|
|||
header.type >= TitleType::Application && header.type <= TitleType::AOC;
|
||||
const auto dead_zone = header.table_offset + sizeof(CNMTHeader);
|
||||
std::vector<u8> out(
|
||||
std::max(sizeof(CNMTHeader) + (has_opt_header ? sizeof(OptionalHeader) : 0), dead_zone) +
|
||||
(std::max)(sizeof(CNMTHeader) + (has_opt_header ? sizeof(OptionalHeader) : 0), dead_zone) +
|
||||
content_records.size() * sizeof(ContentRecord) + meta_records.size() * sizeof(MetaRecord));
|
||||
memcpy(out.data(), &header, sizeof(CNMTHeader));
|
||||
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ std::vector<NcaID> PlaceholderCache::List() const {
|
|||
NcaID PlaceholderCache::Generate() {
|
||||
std::random_device device;
|
||||
std::mt19937 gen(device());
|
||||
std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
|
||||
std::uniform_int_distribution<u64> distribution(1, (std::numeric_limits<u64>::max)());
|
||||
|
||||
NcaID out{};
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ std::pair<EntryType, std::string> GetEntry(const RomFSTraversalContext& ctx, siz
|
|||
}
|
||||
std::memcpy(&entry, data + offset, sizeof(EntryType));
|
||||
|
||||
const size_t name_length = std::min(entry_end + entry.name_length, size) - entry_end;
|
||||
const size_t name_length = (std::min)(entry_end + entry.name_length, size) - entry_end;
|
||||
std::string name(reinterpret_cast<const char*>(data + entry_end), name_length);
|
||||
|
||||
return {entry, std::move(name)};
|
||||
|
|
|
|||
|
|
@ -507,9 +507,9 @@ bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t blo
|
|||
if (!dest->Resize(src->GetSize()))
|
||||
return false;
|
||||
|
||||
std::vector<u8> temp(std::min(block_size, src->GetSize()));
|
||||
std::vector<u8> temp((std::min)(block_size, src->GetSize()));
|
||||
for (std::size_t i = 0; i < src->GetSize(); i += block_size) {
|
||||
const auto read = std::min(block_size, src->GetSize() - i);
|
||||
const auto read = (std::min)(block_size, src->GetSize() - i);
|
||||
|
||||
if (src->Read(temp.data(), read, i) != read) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public:
|
|||
}
|
||||
|
||||
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override {
|
||||
const auto read = std::min(length, size - offset);
|
||||
const auto read = (std::min)(length, size - offset);
|
||||
std::fill(data, data + read, value);
|
||||
return read;
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ public:
|
|||
}
|
||||
|
||||
std::vector<u8> ReadBytes(std::size_t length, std::size_t offset) const override {
|
||||
const auto read = std::min(length, size - offset);
|
||||
const auto read = (std::min)(length, size - offset);
|
||||
return std::vector<u8>(read, value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ bool VectorVfsFile::IsReadable() const {
|
|||
}
|
||||
|
||||
std::size_t VectorVfsFile::Read(u8* data_, std::size_t length, std::size_t offset) const {
|
||||
const auto read = std::min(length, data.size() - offset);
|
||||
const auto read = (std::min)(length, data.size() - offset);
|
||||
std::memcpy(data_, data.data() + offset, read);
|
||||
return read;
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ std::size_t VectorVfsFile::Read(u8* data_, std::size_t length, std::size_t offse
|
|||
std::size_t VectorVfsFile::Write(const u8* data_, std::size_t length, std::size_t offset) {
|
||||
if (offset + length > data.size())
|
||||
data.resize(offset + length);
|
||||
const auto write = std::min(length, data.size() - offset);
|
||||
const auto write = (std::min)(length, data.size() - offset);
|
||||
std::memcpy(data.data() + offset, data_, write);
|
||||
return write;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public:
|
|||
}
|
||||
|
||||
std::size_t Read(u8* data_, std::size_t length, std::size_t offset) const override {
|
||||
const auto read = std::min(length, size - offset);
|
||||
const auto read = (std::min)(length, size - offset);
|
||||
std::memcpy(data_, data.data() + offset, read);
|
||||
return read;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ std::pair<f32, f32> EmuWindow::MapToTouchScreen(u32 framebuffer_x, u32 framebuff
|
|||
}
|
||||
|
||||
std::pair<u32, u32> EmuWindow::ClipToTouchScreen(u32 new_x, u32 new_y) const {
|
||||
new_x = std::max(new_x, framebuffer_layout.screen.left);
|
||||
new_x = std::min(new_x, framebuffer_layout.screen.right - 1);
|
||||
new_x = (std::max)(new_x, framebuffer_layout.screen.left);
|
||||
new_x = (std::min)(new_x, framebuffer_layout.screen.right - 1);
|
||||
|
||||
new_y = std::max(new_y, framebuffer_layout.screen.top);
|
||||
new_y = std::min(new_y, framebuffer_layout.screen.bottom - 1);
|
||||
new_y = (std::max)(new_y, framebuffer_layout.screen.top);
|
||||
new_y = (std::min)(new_y, framebuffer_layout.screen.bottom - 1);
|
||||
|
||||
return std::make_pair(new_x, new_y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Layout {
|
|||
template <class T>
|
||||
static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area,
|
||||
float screen_aspect_ratio) {
|
||||
const float scale = std::min(static_cast<float>(window_area.GetWidth()),
|
||||
const float scale = (std::min)(static_cast<float>(window_area.GetWidth()),
|
||||
static_cast<float>(window_area.GetHeight()) / screen_aspect_ratio);
|
||||
return Common::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)),
|
||||
static_cast<T>(std::round(scale * screen_aspect_ratio))};
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ void SetupPoolPartitionMemoryRegions(KMemoryLayout& memory_layout) {
|
|||
// Decide on starting addresses for our pools.
|
||||
const u64 application_pool_start = pool_end - application_pool_size;
|
||||
const u64 applet_pool_start = application_pool_start - applet_pool_size;
|
||||
const u64 unsafe_system_pool_start = std::min(
|
||||
const u64 unsafe_system_pool_start = (std::min)(
|
||||
kernel_dram_start + CarveoutSizeMax,
|
||||
Common::AlignDown(applet_pool_start - unsafe_system_pool_min_size, CarveoutAlignment));
|
||||
const size_t unsafe_system_pool_size = applet_pool_start - unsafe_system_pool_start;
|
||||
|
|
|
|||
|
|
@ -182,13 +182,13 @@ namespace {
|
|||
template <typename F>
|
||||
u64 GenerateUniformRange(u64 min, u64 max, F f) {
|
||||
// Handle the case where the difference is too large to represent.
|
||||
if (max == std::numeric_limits<u64>::max() && min == std::numeric_limits<u64>::min()) {
|
||||
if (max == (std::numeric_limits<u64>::max)() && min == (std::numeric_limits<u64>::min)()) {
|
||||
return f();
|
||||
}
|
||||
|
||||
// Iterate until we get a value in range.
|
||||
const u64 range_size = ((max + 1) - min);
|
||||
const u64 effective_max = (std::numeric_limits<u64>::max() / range_size) * range_size;
|
||||
const u64 effective_max = ((std::numeric_limits<u64>::max)() / range_size) * range_size;
|
||||
while (true) {
|
||||
if (const u64 rnd = f(); rnd < effective_max) {
|
||||
return min + (rnd % range_size);
|
||||
|
|
@ -201,7 +201,7 @@ u64 GenerateUniformRange(u64 min, u64 max, F f) {
|
|||
u64 KSystemControl::GenerateRandomU64() {
|
||||
std::random_device device;
|
||||
std::mt19937 gen(device());
|
||||
std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
|
||||
std::uniform_int_distribution<u64> distribution(1, (std::numeric_limits<u64>::max)());
|
||||
return distribution(gen);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public:
|
|||
|
||||
// Update our tracking.
|
||||
m_page_bitmap.ClearBit(offset);
|
||||
m_peak = std::max(m_peak, (++m_used));
|
||||
m_peak = (std::max)(m_peak, (++m_used));
|
||||
|
||||
return GetPointer<PageBuffer>(m_aligned_address) + offset;
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ public:
|
|||
// Update our tracking.
|
||||
m_page_bitmap.ClearRange(offset, count);
|
||||
m_used += count;
|
||||
m_peak = std::max(m_peak, m_used);
|
||||
m_peak = (std::max)(m_peak, m_used);
|
||||
|
||||
return GetPointer<PageBuffer>(m_aligned_address) + offset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ private:
|
|||
|
||||
m_free_head_index = m_entry_infos[index].GetNextFreeIndex();
|
||||
|
||||
m_max_count = std::max(m_max_count, ++m_count);
|
||||
m_max_count = (std::max)(m_max_count, ++m_count);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ void KHardwareTimer::Initialize() {
|
|||
|
||||
void KHardwareTimer::Finalize() {
|
||||
m_kernel.System().CoreTiming().UnscheduleEvent(m_event_type);
|
||||
m_wakeup_time = std::numeric_limits<s64>::max();
|
||||
m_wakeup_time = (std::numeric_limits<s64>::max)();
|
||||
m_event_type.reset();
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ void KHardwareTimer::DoTask() {
|
|||
// Disable the timer interrupt while we handle this.
|
||||
// Not necessary due to core timing already having popped this event to call it.
|
||||
// this->DisableInterrupt();
|
||||
m_wakeup_time = std::numeric_limits<s64>::max();
|
||||
m_wakeup_time = (std::numeric_limits<s64>::max)();
|
||||
|
||||
if (const s64 next_time = this->DoInterruptTaskImpl(GetTick());
|
||||
0 < next_time && next_time <= m_wakeup_time) {
|
||||
|
|
@ -63,7 +63,7 @@ void KHardwareTimer::EnableInterrupt(s64 wakeup_time) {
|
|||
void KHardwareTimer::DisableInterrupt() {
|
||||
m_kernel.System().CoreTiming().UnscheduleEvent(m_event_type,
|
||||
Core::Timing::UnscheduleEventType::NoWait);
|
||||
m_wakeup_time = std::numeric_limits<s64>::max();
|
||||
m_wakeup_time = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
|
||||
s64 KHardwareTimer::GetTick() const {
|
||||
|
|
@ -71,7 +71,7 @@ s64 KHardwareTimer::GetTick() const {
|
|||
}
|
||||
|
||||
bool KHardwareTimer::GetInterruptEnabled() {
|
||||
return m_wakeup_time != std::numeric_limits<s64>::max();
|
||||
return m_wakeup_time != (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ private:
|
|||
|
||||
private:
|
||||
// Absolute time in nanoseconds
|
||||
s64 m_wakeup_time{std::numeric_limits<s64>::max()};
|
||||
s64 m_wakeup_time{(std::numeric_limits<s64>::max)()};
|
||||
std::shared_ptr<Core::Timing::EventType> m_event_type{};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Kernel {
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr u64 InvalidThreadId = std::numeric_limits<u64>::max();
|
||||
constexpr u64 InvalidThreadId = (std::numeric_limits<u64>::max)();
|
||||
|
||||
class ThreadQueueImplForKLightServerSessionRequest final : public KThreadQueue {
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ private:
|
|||
KLightSession* m_parent{};
|
||||
KThread::WaiterList m_request_list{};
|
||||
KThread* m_current_request{};
|
||||
u64 m_server_thread_id{std::numeric_limits<u64>::max()};
|
||||
u64 m_server_thread_id{(std::numeric_limits<u64>::max)()};
|
||||
KThread* m_server_thread{};
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -551,7 +551,7 @@ public:
|
|||
}
|
||||
|
||||
m_device_disable_merge_left_count =
|
||||
std::min(m_device_disable_merge_left_count, m_device_use_count);
|
||||
(std::min)(m_device_disable_merge_left_count, m_device_use_count);
|
||||
|
||||
if (m_device_disable_merge_left_count == 0) {
|
||||
m_disable_merge_attribute = static_cast<KMemoryBlockDisableMergeAttribute>(
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ bool KMemoryRegionTree::Insert(u64 address, size_t size, u32 type_id, u32 new_at
|
|||
this->insert(*found);
|
||||
|
||||
// Insert a new region for the split.
|
||||
const u64 new_pair = (old_pair != std::numeric_limits<u64>::max())
|
||||
const u64 new_pair = (old_pair != (std::numeric_limits<u64>::max)())
|
||||
? old_pair + (address - old_address)
|
||||
: old_pair;
|
||||
this->insert(*AllocateRegion(m_memory_region_allocator, address, inserted_region_last,
|
||||
|
|
@ -75,7 +75,7 @@ bool KMemoryRegionTree::Insert(u64 address, size_t size, u32 type_id, u32 new_at
|
|||
|
||||
// If we need to insert a region after the region, do so.
|
||||
if (old_last != inserted_region_last) {
|
||||
const u64 after_pair = (old_pair != std::numeric_limits<u64>::max())
|
||||
const u64 after_pair = (old_pair != (std::numeric_limits<u64>::max)())
|
||||
? old_pair + (inserted_region_end - old_address)
|
||||
: old_pair;
|
||||
this->insert(*AllocateRegion(m_memory_region_allocator, inserted_region_end, old_last,
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ Result KMemoryManager::AllocateAndOpen(KPageGroup* out, size_t num_pages, u32 op
|
|||
|
||||
// Process part or all of the block.
|
||||
const size_t cur_pages =
|
||||
std::min(remaining_pages, manager.GetPageOffsetToEnd(cur_address));
|
||||
(std::min)(remaining_pages, manager.GetPageOffsetToEnd(cur_address));
|
||||
manager.OpenFirst(cur_address, cur_pages);
|
||||
|
||||
// Advance.
|
||||
|
|
@ -385,7 +385,7 @@ Result KMemoryManager::AllocateForProcess(KPageGroup* out, size_t num_pages, u32
|
|||
|
||||
// Process part or all of the block.
|
||||
const size_t cur_pages =
|
||||
std::min(remaining_pages, manager.GetPageOffsetToEnd(cur_address));
|
||||
(std::min)(remaining_pages, manager.GetPageOffsetToEnd(cur_address));
|
||||
any_new = manager.ProcessOptimizedAllocation(m_system.Kernel(), cur_address,
|
||||
cur_pages, fill_pattern);
|
||||
|
||||
|
|
@ -409,7 +409,7 @@ Result KMemoryManager::AllocateForProcess(KPageGroup* out, size_t num_pages, u32
|
|||
|
||||
// Track some or all of the current pages.
|
||||
const size_t cur_pages =
|
||||
std::min(remaining_pages, manager.GetPageOffsetToEnd(cur_address));
|
||||
(std::min)(remaining_pages, manager.GetPageOffsetToEnd(cur_address));
|
||||
manager.TrackOptimizedAllocation(m_system.Kernel(), cur_address, cur_pages);
|
||||
|
||||
// Advance.
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public:
|
|||
// Repeatedly open references until we've done so for all pages.
|
||||
while (num_pages) {
|
||||
auto& manager = this->GetManager(address);
|
||||
const size_t cur_pages = std::min(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
const size_t cur_pages = (std::min)(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
|
||||
{
|
||||
KScopedLightLock lk(m_pool_locks[static_cast<size_t>(manager.GetPool())]);
|
||||
|
|
@ -84,7 +84,7 @@ public:
|
|||
// Repeatedly open references until we've done so for all pages.
|
||||
while (num_pages) {
|
||||
auto& manager = this->GetManager(address);
|
||||
const size_t cur_pages = std::min(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
const size_t cur_pages = (std::min)(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
|
||||
{
|
||||
KScopedLightLock lk(m_pool_locks[static_cast<size_t>(manager.GetPool())]);
|
||||
|
|
@ -100,7 +100,7 @@ public:
|
|||
// Repeatedly close references until we've done so for all pages.
|
||||
while (num_pages) {
|
||||
auto& manager = this->GetManager(address);
|
||||
const size_t cur_pages = std::min(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
const size_t cur_pages = (std::min)(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
|
||||
{
|
||||
KScopedLightLock lk(m_pool_locks[static_cast<size_t>(manager.GetPool())]);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public:
|
|||
: m_address(address), m_last_address(last_address), m_pair_address(pair_address),
|
||||
m_attributes(attributes), m_type_id(type_id) {}
|
||||
constexpr KMemoryRegion(u64 address, u64 last_address, u32 attributes, u32 type_id)
|
||||
: KMemoryRegion(address, last_address, std::numeric_limits<u64>::max(), attributes,
|
||||
: KMemoryRegion(address, last_address, (std::numeric_limits<u64>::max)(), attributes,
|
||||
type_id) {}
|
||||
|
||||
~KMemoryRegion() = default;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
}
|
||||
|
||||
// Determine how many bits to take this round.
|
||||
const auto cur_bits = std::min(num_bits, m_bits_available);
|
||||
const auto cur_bits = (std::min)(num_bits, m_bits_available);
|
||||
|
||||
// Generate mask for our current bits.
|
||||
const u64 mask = (static_cast<u64>(1) << cur_bits) - 1;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public:
|
|||
}
|
||||
|
||||
static constexpr s32 GetAlignedBlockIndex(size_t num_pages, size_t align_pages) {
|
||||
const size_t target_pages = std::max(num_pages, align_pages);
|
||||
const size_t target_pages = (std::max)(num_pages, align_pages);
|
||||
for (size_t i = 0; i < NumMemoryBlockPageShifts; i++) {
|
||||
if (target_pages <= (static_cast<size_t>(1) << MemoryBlockPageShifts[i]) / PageSize) {
|
||||
return static_cast<s32>(i);
|
||||
|
|
|
|||
|
|
@ -1731,7 +1731,7 @@ void KPageTableBase::RemapPageGroup(PageLinkedList* page_list, KProcessAddress a
|
|||
}
|
||||
|
||||
// Map whatever we can.
|
||||
const size_t cur_pages = std::min(pg_pages, map_pages);
|
||||
const size_t cur_pages = (std::min)(pg_pages, map_pages);
|
||||
R_ASSERT(this->Operate(page_list, map_address, map_pages, pg_phys_addr, true,
|
||||
map_properties, OperationType::Map, true));
|
||||
|
||||
|
|
@ -1929,7 +1929,7 @@ Result KPageTableBase::GetContiguousMemoryRangeWithState(
|
|||
}
|
||||
|
||||
// Take the minimum size for our region.
|
||||
size = std::min(size, contig_size);
|
||||
size = (std::min)(size, contig_size);
|
||||
|
||||
// Check that the memory is contiguous (modulo the reference count bit).
|
||||
const KMemoryState test_state_mask = state_mask | KMemoryState::FlagReferenceCounted;
|
||||
|
|
@ -5297,7 +5297,7 @@ Result KPageTableBase::MapPhysicalMemory(KProcessAddress address, size_t size) {
|
|||
KMemoryPermission::None, false, false,
|
||||
DisableMergeAttribute::None};
|
||||
const size_t cur_pages =
|
||||
std::min(KProcessAddress(info.GetEndAddress()) - cur_address,
|
||||
(std::min)(KProcessAddress(info.GetEndAddress()) - cur_address,
|
||||
last_unmap_address + 1 - cur_address) /
|
||||
PageSize;
|
||||
|
||||
|
|
@ -5345,7 +5345,7 @@ Result KPageTableBase::MapPhysicalMemory(KProcessAddress address, size_t size) {
|
|||
? DisableMergeAttribute::DisableHead
|
||||
: DisableMergeAttribute::None};
|
||||
size_t map_pages =
|
||||
std::min(KProcessAddress(info.GetEndAddress()) - cur_address,
|
||||
(std::min)(KProcessAddress(info.GetEndAddress()) - cur_address,
|
||||
last_address + 1 - cur_address) /
|
||||
PageSize;
|
||||
|
||||
|
|
@ -5373,7 +5373,7 @@ Result KPageTableBase::MapPhysicalMemory(KProcessAddress address, size_t size) {
|
|||
}
|
||||
|
||||
// Add whatever we can to the current block.
|
||||
const size_t cur_pages = std::min(pg_pages, remain_pages);
|
||||
const size_t cur_pages = (std::min)(pg_pages, remain_pages);
|
||||
R_TRY(cur_pg.AddBlock(pg_phys_addr +
|
||||
((pg_pages - cur_pages) * PageSize),
|
||||
cur_pages));
|
||||
|
|
@ -5535,7 +5535,7 @@ Result KPageTableBase::UnmapPhysicalMemory(KProcessAddress address, size_t size)
|
|||
// Determine the range to unmap.
|
||||
const KPageProperties unmap_properties = {KMemoryPermission::None, false, false,
|
||||
DisableMergeAttribute::None};
|
||||
const size_t cur_pages = std::min(KProcessAddress(info.GetEndAddress()) - cur_address,
|
||||
const size_t cur_pages = (std::min)(KProcessAddress(info.GetEndAddress()) - cur_address,
|
||||
last_address + 1 - cur_address) /
|
||||
PageSize;
|
||||
|
||||
|
|
@ -5656,7 +5656,7 @@ Result KPageTableBase::UnmapProcessMemory(KProcessAddress dst_address, size_t si
|
|||
}
|
||||
|
||||
// Update our current size.
|
||||
m_cur_size = std::min(m_remaining_size, m_cur_size + m_entry.block_size);
|
||||
m_cur_size = (std::min)(m_remaining_size, m_cur_size + m_entry.block_size);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public:
|
|||
static constexpr u64 InitialProcessIdMax = 0x50;
|
||||
|
||||
static constexpr u64 ProcessIdMin = InitialProcessIdMax + 1;
|
||||
static constexpr u64 ProcessIdMax = std::numeric_limits<u64>::max();
|
||||
static constexpr u64 ProcessIdMax = (std::numeric_limits<u64>::max)();
|
||||
|
||||
private:
|
||||
using SharedMemoryInfoList = Common::IntrusiveListBaseTraits<KSharedMemoryInfo>::ListType;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) {
|
|||
if (m_current_values[index] + value <= m_limit_values[index]) {
|
||||
m_current_values[index] += value;
|
||||
m_current_hints[index] += value;
|
||||
m_peak_values[index] = std::max(m_peak_values[index], m_current_values[index]);
|
||||
m_peak_values[index] = (std::max)(m_peak_values[index], m_current_values[index]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public:
|
|||
size_t GetObjectIndex(const void* obj) const {
|
||||
if constexpr (SupportDynamicExpansion) {
|
||||
if (!this->Contains(reinterpret_cast<uintptr_t>(obj))) {
|
||||
return std::numeric_limits<size_t>::max();
|
||||
return (std::numeric_limits<size_t>::max)();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1016,7 +1016,7 @@ void KThread::RestorePriority(KernelCore& kernel, KThread* thread) {
|
|||
s32 new_priority = thread->GetBasePriority();
|
||||
for (const auto& held_lock : thread->m_held_lock_info_list) {
|
||||
new_priority =
|
||||
std::min(new_priority, held_lock.GetHighestPriorityWaiter()->GetPriority());
|
||||
(std::min)(new_priority, held_lock.GetHighestPriorityWaiter()->GetPriority());
|
||||
}
|
||||
|
||||
// If the priority we would inherit is not different from ours, don't do anything.
|
||||
|
|
|
|||
|
|
@ -507,7 +507,7 @@ struct KernelCore::Impl {
|
|||
constexpr size_t MiscRegionAlign = KernelAslrAlignment;
|
||||
constexpr size_t MiscRegionMinimumSize = 32_MiB;
|
||||
const size_t misc_region_size = Common::AlignUp(
|
||||
std::max(misc_region_needed_size, MiscRegionMinimumSize), MiscRegionAlign);
|
||||
(std::max)(misc_region_needed_size, MiscRegionMinimumSize), MiscRegionAlign);
|
||||
ASSERT(misc_region_size > 0);
|
||||
|
||||
// Setup the misc region.
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ Result WaitForAddress(Core::System& system, u64 address, ArbitrationType arb_typ
|
|||
if (offset_tick > 0) {
|
||||
timeout = system.Kernel().HardwareTimer().GetTick() + offset_tick + 2;
|
||||
if (timeout <= 0) {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
} else {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
} else {
|
||||
timeout = timeout_ns;
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ Result WaitProcessWideKeyAtomic(Core::System& system, u64 address, u64 cv_key, u
|
|||
if (offset_tick > 0) {
|
||||
timeout = system.Kernel().HardwareTimer().GetTick() + offset_tick + 2;
|
||||
if (timeout <= 0) {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
} else {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
} else {
|
||||
timeout = timeout_ns;
|
||||
|
|
|
|||
|
|
@ -61,10 +61,10 @@ Result ReplyAndReceiveImpl(KernelCore& kernel, int32_t* out_index, uintptr_t mes
|
|||
if (offset_tick > 0) {
|
||||
timeout = kernel.HardwareTimer().GetTick() + offset_tick + 2;
|
||||
if (timeout <= 0) {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
} else {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
} else {
|
||||
timeout = timeout_ns;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ Result GetProcessList(Core::System& system, s32* out_num_processes, u64 out_proc
|
|||
|
||||
const auto num_processes = process_list.size();
|
||||
const auto copy_amount =
|
||||
std::min(static_cast<std::size_t>(out_process_ids_size), num_processes);
|
||||
(std::min)(static_cast<std::size_t>(out_process_ids_size), num_processes);
|
||||
|
||||
for (std::size_t i = 0; i < copy_amount && it != process_list.end(); ++i, ++it) {
|
||||
memory.Write64(out_process_ids, (*it)->GetProcessId());
|
||||
|
|
|
|||
|
|
@ -117,10 +117,10 @@ void SleepThread(Core::System& system, s64 ns) {
|
|||
if (offset_tick > 0) {
|
||||
timeout = kernel.HardwareTimer().GetTick() + offset_tick + 2;
|
||||
if (timeout <= 0) {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
} else {
|
||||
timeout = std::numeric_limits<s64>::max();
|
||||
timeout = (std::numeric_limits<s64>::max)();
|
||||
}
|
||||
|
||||
// Sleep.
|
||||
|
|
@ -226,7 +226,7 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, u64 out_thread_
|
|||
auto& memory = GetCurrentMemory(system.Kernel());
|
||||
const auto& thread_list = current_process->GetThreadList();
|
||||
const auto num_threads = thread_list.size();
|
||||
const auto copy_amount = std::min(static_cast<std::size_t>(out_thread_ids_size), num_threads);
|
||||
const auto copy_amount = (std::min)(static_cast<std::size_t>(out_thread_ids_size), num_threads);
|
||||
|
||||
auto list_iter = thread_list.cbegin();
|
||||
for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ static void SanitizeJPEGImageSize(std::vector<u8>& image) {
|
|||
}
|
||||
}
|
||||
|
||||
image.resize(std::min(image.size(), max_jpeg_image_size));
|
||||
image.resize((std::min)(image.size(), max_jpeg_image_size));
|
||||
}
|
||||
|
||||
class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void Cabinet::DisplayCompleted(bool apply_changes, std::string_view amiibo_name)
|
|||
case Service::NFP::CabinetMode::StartNicknameAndOwnerSettings: {
|
||||
Service::NFP::RegisterInfoPrivate register_info{};
|
||||
std::memcpy(register_info.amiibo_name.data(), amiibo_name.data(),
|
||||
std::min(amiibo_name.size(), register_info.amiibo_name.size() - 1));
|
||||
(std::min)(amiibo_name.size(), register_info.amiibo_name.size() - 1));
|
||||
register_info.mii_store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All);
|
||||
register_info.mii_store_data.SetNickname({u'y', u'u', u'z', u'u'});
|
||||
nfp_device->SetRegisterInfoPrivate(register_info);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ static Core::Frontend::ControllerParameters ConvertToFrontendParameters(
|
|||
npad_style_set.raw = private_arg.style_set;
|
||||
|
||||
return {
|
||||
.min_players = std::max(s8{1}, header.player_count_min),
|
||||
.min_players = (std::max)(s8{1}, header.player_count_min),
|
||||
.max_players = header.player_count_max,
|
||||
.keep_controllers_connected = header.enable_take_over_connection,
|
||||
.enable_single_mode = header.enable_single_mode,
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ Result IApplicationAccessor::GetApplicationControlProperty(
|
|||
R_TRY(system.GetARPManager().GetControlProperty(&nacp, m_applet->program_id));
|
||||
|
||||
std::memcpy(out_control_property.data(), nacp.data(),
|
||||
std::min(out_control_property.size(), nacp.size()));
|
||||
(std::min)(out_control_property.size(), nacp.size()));
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ Result IApplicationFunctions::GetDisplayVersion(Out<DisplayVersion> out_display_
|
|||
if (res.first != nullptr) {
|
||||
const auto& version = res.first->GetVersionString();
|
||||
std::memcpy(out_display_version->string.data(), version.data(),
|
||||
std::min(version.size(), out_display_version->string.size()));
|
||||
(std::min)(version.size(), out_display_version->string.size()));
|
||||
} else {
|
||||
static constexpr char default_version[]{"1.0.0"};
|
||||
std::memcpy(out_display_version->string.data(), default_version, sizeof(default_version));
|
||||
|
|
@ -284,7 +284,7 @@ Result IApplicationFunctions::GetCacheStorageMax(Out<u32> out_cache_storage_inde
|
|||
R_TRY(system.GetARPManager().GetControlProperty(&nacp, m_applet->program_id));
|
||||
|
||||
auto raw_nacp = std::make_unique<FileSys::RawNACP>();
|
||||
std::memcpy(raw_nacp.get(), nacp.data(), std::min(sizeof(*raw_nacp), nacp.size()));
|
||||
std::memcpy(raw_nacp.get(), nacp.data(), (std::min)(sizeof(*raw_nacp), nacp.size()));
|
||||
|
||||
*out_cache_storage_index_max = static_cast<u32>(raw_nacp->cache_storage_max_index);
|
||||
*out_max_journal_size = static_cast<u64>(raw_nacp->cache_storage_data_and_journal_max_size);
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ Result ILibraryAppletSelfAccessor::GetMainAppletApplicationControlProperty(
|
|||
system.GetARPManager().GetControlProperty(&nacp, application.application_id);
|
||||
|
||||
if (R_SUCCEEDED(result)) {
|
||||
std::memcpy(out_nacp->data(), nacp.data(), std::min(nacp.size(), out_nacp->size()));
|
||||
std::memcpy(out_nacp->data(), nacp.data(), (std::min)(nacp.size(), out_nacp->size()));
|
||||
}
|
||||
|
||||
R_RETURN(result);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ Result IBcatService::SetPassphrase(u64 application_id,
|
|||
|
||||
Passphrase passphrase{};
|
||||
std::memcpy(passphrase.data(), passphrase_buffer.data(),
|
||||
std::min(passphrase.size(), passphrase_buffer.size()));
|
||||
(std::min)(passphrase.size(), passphrase_buffer.size()));
|
||||
|
||||
backend.SetPassphrase(application_id, passphrase);
|
||||
R_SUCCEED();
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ Result IDeliveryCacheDirectoryService::Read(
|
|||
R_UNLESS(current_dir != nullptr, ResultNoOpenEntry);
|
||||
|
||||
const auto files = current_dir->GetFiles();
|
||||
*out_count = static_cast<s32>(std::min(files.size(), out_buffer.size()));
|
||||
*out_count = static_cast<s32>((std::min)(files.size(), out_buffer.size()));
|
||||
std::transform(files.begin(), files.begin() + *out_count, out_buffer.begin(),
|
||||
[](const auto& file) {
|
||||
FileName name{};
|
||||
std::memcpy(name.data(), file->GetName().data(),
|
||||
std::min(file->GetName().size(), name.size()));
|
||||
(std::min)(file->GetName().size(), name.size()));
|
||||
return DeliveryCacheDirectoryEntry{name, file->GetSize(), DigestFile(file)};
|
||||
});
|
||||
R_SUCCEED();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ Result IDeliveryCacheStorageService::EnumerateDeliveryCacheDirectory(
|
|||
LOG_DEBUG(Service_BCAT, "called, size={:016X}", out_directories.size());
|
||||
|
||||
*out_directory_count =
|
||||
static_cast<s32>(std::min(out_directories.size(), entries.size() - next_read_index));
|
||||
static_cast<s32>((std::min)(out_directories.size(), entries.size() - next_read_index));
|
||||
memcpy(out_directories.data(), entries.data() + next_read_index,
|
||||
*out_directory_count * sizeof(DirectoryName));
|
||||
next_read_index += *out_directory_count;
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ void ReadInArgument(bool is_domain, CallArguments& args, const u8* raw_data, HLE
|
|||
buffer = ctx.ReadBufferX(InBufferIndex);
|
||||
}
|
||||
|
||||
std::memcpy(&std::get<ArgIndex>(args), buffer.data(), std::min(BufferSize, buffer.size()));
|
||||
std::memcpy(&std::get<ArgIndex>(args), buffer.data(), (std::min)(BufferSize, buffer.size()));
|
||||
|
||||
return ReadInArgument<MethodArguments, CallArguments, PrevAlign, DataOffset, HandleIndex, InBufferIndex + 1, OutBufferIndex, RawDataFinished, ArgIndex + 1>(is_domain, args, raw_data, ctx, temp);
|
||||
} else if constexpr (ArgumentTraits<ArgType>::Type == ArgumentType::InBuffer) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ private:
|
|||
std::transform(tickets.begin(), tickets.end(), std::back_inserter(ids),
|
||||
[](const auto& pair) { return pair.first; });
|
||||
|
||||
out_entries = std::min(ids.size(), out_entries);
|
||||
out_entries = (std::min)(ids.size(), out_entries);
|
||||
ctx.WriteBuffer(ids.data(), out_entries * sizeof(u128));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
|
|
@ -225,7 +225,7 @@ private:
|
|||
std::transform(tickets.begin(), tickets.end(), std::back_inserter(ids),
|
||||
[](const auto& pair) { return pair.first; });
|
||||
|
||||
out_entries = std::min(ids.size(), out_entries);
|
||||
out_entries = (std::min)(ids.size(), out_entries);
|
||||
ctx.WriteBuffer(ids.data(), out_entries * sizeof(u128));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ Result ISaveDataInfoReader::ReadSaveDataInfo(
|
|||
const u64 count_entries = out_entries.size();
|
||||
|
||||
// Cap at total number of entries.
|
||||
const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index);
|
||||
const u64 actual_entries = (std::min)(count_entries, info.size() - next_entry_index);
|
||||
|
||||
// Determine data start and end
|
||||
const auto* begin = reinterpret_cast<u8*>(info.data() + next_entry_index);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ Result NotificationServiceImpl::ListAlarmSettings(s32* out_count,
|
|||
std::span<AlarmSetting> out_alarms) {
|
||||
LOG_INFO(Service_NOTIF, "called, alarm_count={}", alarms.size());
|
||||
|
||||
const auto count = std::min(out_alarms.size(), alarms.size());
|
||||
const auto count = (std::min)(out_alarms.size(), alarms.size());
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
out_alarms[i] = alarms[i];
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ Result NotificationServiceImpl::LoadApplicationParameter(u32* out_size,
|
|||
|
||||
LOG_WARNING(Service_NOTIF, "(STUBBED) called, alarm_setting_id={}", alarm_setting_id);
|
||||
std::memcpy(out_application_parameter.data(), application_parameter.data(),
|
||||
std::min(sizeof(application_parameter), out_application_parameter.size()));
|
||||
(std::min)(sizeof(application_parameter), out_application_parameter.size()));
|
||||
|
||||
*out_size = static_cast<u32>(application_parameter.size());
|
||||
R_SUCCEED();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ static s64 CalendarTimeToEpoch(Service::PSC::Time::CalendarTime calendar) {
|
|||
};
|
||||
|
||||
s16 month_s16{calendar.month};
|
||||
s8 month{static_cast<s8>(((month_s16 * 43) & ~std::numeric_limits<s16>::max()) +
|
||||
s8 month{static_cast<s8>(((month_s16 * 43) & ~(std::numeric_limits<s16>::max)()) +
|
||||
((month_s16 * 43) >> 9))};
|
||||
s8 month_index{static_cast<s8>(calendar.month - 12 * month)};
|
||||
if (month_index == 0) {
|
||||
|
|
@ -71,13 +71,13 @@ static Service::PSC::Time::LocationName GetTimeZoneString(
|
|||
|
||||
Service::PSC::Time::LocationName configured_name{};
|
||||
std::memcpy(configured_name.data(), configured_zone.data(),
|
||||
std::min(configured_name.size(), configured_zone.size()));
|
||||
(std::min)(configured_name.size(), configured_zone.size()));
|
||||
|
||||
if (!time_zone_binary.IsValid(configured_name)) {
|
||||
configured_zone = Common::TimeZone::FindSystemTimeZone();
|
||||
configured_name = {};
|
||||
std::memcpy(configured_name.data(), configured_zone.data(),
|
||||
std::min(configured_name.size(), configured_zone.size()));
|
||||
(std::min)(configured_name.size(), configured_zone.size()));
|
||||
}
|
||||
|
||||
ASSERT_MSG(time_zone_binary.IsValid(configured_name), "Invalid time zone {}!",
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ Result IHidDebugServer::SetTouchScreenAutoPilotState(
|
|||
AutoPilotState auto_pilot{};
|
||||
|
||||
auto_pilot.count =
|
||||
static_cast<u64>(std::min(auto_pilot_buffer.size(), auto_pilot.state.size()));
|
||||
static_cast<u64>((std::min)(auto_pilot_buffer.size(), auto_pilot.state.size()));
|
||||
memcpy(auto_pilot.state.data(), auto_pilot_buffer.data(),
|
||||
auto_pilot.count * sizeof(TouchState));
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public:
|
|||
|
||||
void AddTicks(u64 ticks) override {}
|
||||
u64 GetTicksRemaining() override {
|
||||
return std::numeric_limits<u32>::max();
|
||||
return (std::numeric_limits<u32>::max)();
|
||||
}
|
||||
u64 GetCNTPCT() override {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ struct Ssid {
|
|||
Ssid() = default;
|
||||
|
||||
constexpr explicit Ssid(std::string_view data) {
|
||||
length = static_cast<u8>(std::min(data.size(), SsidLengthMax));
|
||||
length = static_cast<u8>((std::min)(data.size(), SsidLengthMax));
|
||||
raw = {};
|
||||
data.copy(raw.data(), length);
|
||||
raw[length] = 0;
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ private:
|
|||
if (length == 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto length_to_read = std::min(length, data.size() - offset);
|
||||
const auto length_to_read = (std::min)(length, data.size() - offset);
|
||||
|
||||
std::string output(length_to_read, '\0');
|
||||
std::memcpy(output.data(), data.data() + offset, length_to_read);
|
||||
|
|
|
|||
|
|
@ -978,7 +978,7 @@ Result NfcDevice::GetApplicationArea(std::span<u8> data) const {
|
|||
}
|
||||
|
||||
memcpy(data.data(), tag_data.application_area.data(),
|
||||
std::min(data.size(), sizeof(NFP::ApplicationArea)));
|
||||
(std::min)(data.size(), sizeof(NFP::ApplicationArea)));
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ void IGeneralService::EnumerateNetworkInterfaces(HLERequestContext& ctx) {
|
|||
|
||||
const size_t guest_bytes = ctx.GetWriteBufferSize();
|
||||
if (guest_bytes && !blob.empty())
|
||||
ctx.WriteBuffer(blob.data(), std::min(guest_bytes, blob.size()));
|
||||
ctx.WriteBuffer(blob.data(), (std::min)(guest_bytes, blob.size()));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
|
@ -639,7 +639,7 @@ void IGeneralService::EnumerateNetworkProfiles(HLERequestContext& ctx) {
|
|||
|
||||
const size_t guest_sz = ctx.GetWriteBufferSize();
|
||||
if (guest_sz && uuids.size()) {
|
||||
const size_t to_copy = std::min(guest_sz, uuids.size() * sizeof(u128));
|
||||
const size_t to_copy = (std::min)(guest_sz, uuids.size() * sizeof(u128));
|
||||
ctx.WriteBuffer(uuids.data(), to_copy);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ Result IApplicationManagerInterface::IsAnyApplicationEntityInstalled(
|
|||
Result IApplicationManagerInterface::GetApplicationView(
|
||||
OutArray<ApplicationView, BufferAttr_HipcMapAlias> out_application_views,
|
||||
InArray<u64, BufferAttr_HipcMapAlias> application_ids) {
|
||||
const auto size = std::min(out_application_views.size(), application_ids.size());
|
||||
const auto size = (std::min)(out_application_views.size(), application_ids.size());
|
||||
LOG_WARNING(Service_NS, "(STUBBED) called, size={}", application_ids.size());
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
|
|
@ -428,7 +428,7 @@ Result IApplicationManagerInterface::GetApplicationView(
|
|||
Result IApplicationManagerInterface::GetApplicationViewWithPromotionInfo(
|
||||
OutArray<ApplicationViewWithPromotionInfo, BufferAttr_HipcMapAlias> out_application_views,
|
||||
InArray<u64, BufferAttr_HipcMapAlias> application_ids) {
|
||||
const auto size = std::min(out_application_views.size(), application_ids.size());
|
||||
const auto size = (std::min)(out_application_views.size(), application_ids.size());
|
||||
LOG_WARNING(Service_NS, "(STUBBED) called, size={}", application_ids.size());
|
||||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ Result IPlatformServiceManager::GetSharedFontInOrderOfPriority(
|
|||
constexpr size_t MaxElementCount = 6;
|
||||
|
||||
// TODO(ogniK): Have actual priority order
|
||||
const auto max_size = std::min({MaxElementCount, out_font_codes.size(), out_font_offsets.size(),
|
||||
const auto max_size = (std::min)({MaxElementCount, out_font_codes.size(), out_font_offsets.size(),
|
||||
out_font_sizes.size(), impl->shared_font_regions.size()});
|
||||
|
||||
for (size_t i = 0; i < max_size; i++) {
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ NvResult nvhost_as_gpu::GetVARegions3(IoctlGetVaRegions& params, std::span<VaReg
|
|||
|
||||
GetVARegionsImpl(params);
|
||||
|
||||
const size_t num_regions = std::min(params.regions.size(), regions.size());
|
||||
const size_t num_regions = (std::min)(params.regions.size(), regions.size());
|
||||
for (size_t i = 0; i < num_regions; i++) {
|
||||
regions[i] = params.regions[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,12 +197,12 @@ private:
|
|||
|
||||
struct VM {
|
||||
static constexpr u32 YUZU_PAGESIZE{0x1000};
|
||||
static constexpr u32 PAGE_SIZE_BITS{std::countr_zero(YUZU_PAGESIZE)};
|
||||
static constexpr u32 PAGE_SIZE_BITS{static_cast<u32>(std::countr_zero<u32>(YUZU_PAGESIZE))};
|
||||
|
||||
static constexpr u32 SUPPORTED_BIG_PAGE_SIZES{0x30000};
|
||||
static constexpr u32 DEFAULT_BIG_PAGE_SIZE{0x20000};
|
||||
u32 big_page_size{DEFAULT_BIG_PAGE_SIZE};
|
||||
u32 big_page_size_bits{std::countr_zero(DEFAULT_BIG_PAGE_SIZE)};
|
||||
u32 big_page_size_bits{static_cast<u32>(std::countr_zero<u32>(DEFAULT_BIG_PAGE_SIZE))};
|
||||
|
||||
static constexpr u32 VA_START_SHIFT{10};
|
||||
static constexpr u64 DEFAULT_VA_SPLIT{1ULL << 34};
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ NvResult nvhost_nvdec_common::GetWaitbase(IoctlGetWaitbase& params) {
|
|||
|
||||
NvResult nvhost_nvdec_common::MapBuffer(IoctlMapBuffer& params, std::span<MapBufferEntry> entries,
|
||||
DeviceFD fd) {
|
||||
const size_t num_entries = std::min(params.num_entries, static_cast<u32>(entries.size()));
|
||||
const size_t num_entries = (std::min)(params.num_entries, static_cast<u32>(entries.size()));
|
||||
for (size_t i = 0; i < num_entries; i++) {
|
||||
DAddr pin_address = nvmap.PinHandle(entries[i].map_handle, true);
|
||||
entries[i].map_address = static_cast<u32>(pin_address);
|
||||
|
|
@ -150,7 +150,7 @@ NvResult nvhost_nvdec_common::MapBuffer(IoctlMapBuffer& params, std::span<MapBuf
|
|||
|
||||
NvResult nvhost_nvdec_common::UnmapBuffer(IoctlMapBuffer& params,
|
||||
std::span<MapBufferEntry> entries) {
|
||||
const size_t num_entries = std::min(params.num_entries, static_cast<u32>(entries.size()));
|
||||
const size_t num_entries = (std::min)(params.num_entries, static_cast<u32>(entries.size()));
|
||||
for (size_t i = 0; i < num_entries; i++) {
|
||||
nvmap.UnpinHandle(entries[i].map_handle);
|
||||
entries[i] = {};
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ void BufferQueueConsumer::Transact(u32 code, std::span<const u8> parcel_data,
|
|||
|
||||
const auto serialized = parcel_out.Serialize();
|
||||
std::memcpy(parcel_reply.data(), serialized.data(),
|
||||
std::min(parcel_reply.size(), serialized.size()));
|
||||
(std::min)(parcel_reply.size(), serialized.size()));
|
||||
}
|
||||
|
||||
Kernel::KReadableEvent* BufferQueueConsumer::GetNativeHandle(u32 type_id) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ s32 BufferQueueCore::GetMinMaxBufferCountLocked(bool async) const {
|
|||
|
||||
s32 BufferQueueCore::GetMaxBufferCountLocked(bool async) const {
|
||||
const auto min_buffer_count = GetMinMaxBufferCountLocked(async);
|
||||
auto max_buffer_count = std::max(default_max_buffer_count, min_buffer_count);
|
||||
auto max_buffer_count = (std::max)(default_max_buffer_count, min_buffer_count);
|
||||
|
||||
if (override_max_buffer_count != 0) {
|
||||
ASSERT(override_max_buffer_count >= min_buffer_count);
|
||||
|
|
|
|||
|
|
@ -942,7 +942,7 @@ void BufferQueueProducer::Transact(u32 code, std::span<const u8> parcel_data,
|
|||
|
||||
std::scoped_lock lock{core->mutex};
|
||||
|
||||
auto buffer_history_count = std::min(parcel_in.Read<s32>(), (s32)core->history.size());
|
||||
auto buffer_history_count = (std::min)(parcel_in.Read<s32>(), (s32)core->history.size());
|
||||
|
||||
if (buffer_history_count <= 0) {
|
||||
parcel_out.Write(Status::BadValue);
|
||||
|
|
@ -978,7 +978,7 @@ void BufferQueueProducer::Transact(u32 code, std::span<const u8> parcel_data,
|
|||
|
||||
const auto serialized = parcel_out.Serialize();
|
||||
std::memcpy(parcel_reply.data(), serialized.data(),
|
||||
std::min(parcel_reply.size(), serialized.size()));
|
||||
(std::min)(parcel_reply.size(), serialized.size()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, Display& display,
|
|||
// only swap intervals of 0, 1 and 2 have been observed, but if 3 were
|
||||
// to be introduced, this would cause an issue.
|
||||
if (swap_interval) {
|
||||
swap_interval = std::min(*swap_interval, item_swap_interval);
|
||||
swap_interval = (std::min)(*swap_interval, item_swap_interval);
|
||||
} else {
|
||||
swap_interval = item_swap_interval;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,12 +138,12 @@ constexpr inline std::chrono::nanoseconds ConvertToTimeSpan(s64 ticks) {
|
|||
std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(1)).count()};
|
||||
|
||||
constexpr s64 max{Common::WallClock::CNTFRQ *
|
||||
(std::numeric_limits<s64>::max() / one_second_ns)};
|
||||
((std::numeric_limits<s64>::max)() / one_second_ns)};
|
||||
|
||||
if (ticks > max) {
|
||||
return std::chrono::nanoseconds(std::numeric_limits<s64>::max());
|
||||
return std::chrono::nanoseconds((std::numeric_limits<s64>::max)());
|
||||
} else if (ticks < -max) {
|
||||
return std::chrono::nanoseconds(std::numeric_limits<s64>::min());
|
||||
return std::chrono::nanoseconds((std::numeric_limits<s64>::min)());
|
||||
}
|
||||
|
||||
auto a{ticks / Common::WallClock::CNTFRQ * one_second_ns};
|
||||
|
|
@ -156,9 +156,9 @@ constexpr inline Result GetSpanBetweenTimePoints(s64* out_seconds, const SteadyC
|
|||
const SteadyClockTimePoint& b) {
|
||||
R_UNLESS(out_seconds, ResultInvalidArgument);
|
||||
R_UNLESS(a.IdMatches(b), ResultInvalidArgument);
|
||||
R_UNLESS(a.time_point >= 0 || b.time_point <= a.time_point + std::numeric_limits<s64>::max(),
|
||||
R_UNLESS(a.time_point >= 0 || b.time_point <= a.time_point + (std::numeric_limits<s64>::max)(),
|
||||
ResultOverflow);
|
||||
R_UNLESS(a.time_point < 0 || b.time_point >= a.time_point + std::numeric_limits<s64>::min(),
|
||||
R_UNLESS(a.time_point < 0 || b.time_point >= a.time_point + (std::numeric_limits<s64>::min)(),
|
||||
ResultOverflow);
|
||||
|
||||
*out_seconds = b.time_point - a.time_point;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ PowerStateRequestManager::~PowerStateRequestManager() {
|
|||
void PowerStateRequestManager::UpdatePendingPowerStateRequestPriority(u32 priority) {
|
||||
std::scoped_lock l{m_mutex};
|
||||
if (m_has_pending_request) {
|
||||
m_pending_request_priority = std::max(m_pending_request_priority, priority);
|
||||
m_pending_request_priority = (std::max)(m_pending_request_priority, priority);
|
||||
} else {
|
||||
m_pending_request_priority = priority;
|
||||
m_has_pending_request = true;
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ Result ISettingsServer::GetAvailableLanguageCodes(
|
|||
Out<s32> out_count, OutArray<LanguageCode, BufferAttr_HipcPointer> out_language_codes) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
const std::size_t max_amount = std::min(PRE_4_0_0_MAX_ENTRIES, out_language_codes.size());
|
||||
*out_count = static_cast<s32>(std::min(available_language_codes.size(), max_amount));
|
||||
const std::size_t max_amount = (std::min)(PRE_4_0_0_MAX_ENTRIES, out_language_codes.size());
|
||||
*out_count = static_cast<s32>((std::min)(available_language_codes.size(), max_amount));
|
||||
|
||||
memcpy(out_language_codes.data(), available_language_codes.data(),
|
||||
static_cast<std::size_t>(*out_count) * sizeof(LanguageCode));
|
||||
|
|
@ -159,8 +159,8 @@ Result ISettingsServer::GetAvailableLanguageCodes2(
|
|||
Out<s32> out_count, OutArray<LanguageCode, BufferAttr_HipcMapAlias> language_codes) {
|
||||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
const std::size_t max_amount = std::min(POST_4_0_0_MAX_ENTRIES, language_codes.size());
|
||||
*out_count = static_cast<s32>(std::min(available_language_codes.size(), max_amount));
|
||||
const std::size_t max_amount = (std::min)(POST_4_0_0_MAX_ENTRIES, language_codes.size());
|
||||
*out_count = static_cast<s32>((std::min)(available_language_codes.size(), max_amount));
|
||||
|
||||
memcpy(language_codes.data(), available_language_codes.data(),
|
||||
static_cast<std::size_t>(*out_count) * sizeof(LanguageCode));
|
||||
|
|
@ -233,7 +233,7 @@ Result ISettingsServer::GetDeviceNickName(
|
|||
LOG_DEBUG(Service_SET, "called");
|
||||
|
||||
const std::size_t string_size =
|
||||
std::min(Settings::values.device_name.GetValue().size(), out_device_name->size());
|
||||
(std::min)(Settings::values.device_name.GetValue().size(), out_device_name->size());
|
||||
|
||||
*out_device_name = {};
|
||||
memcpy(out_device_name->data(), Settings::values.device_name.GetValue().data(), string_size);
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ Result ISystemSettingsServer::GetEulaVersions(
|
|||
LOG_INFO(Service_SET, "called, elements={}", m_system_settings.eula_version_count);
|
||||
|
||||
*out_count =
|
||||
std::min(m_system_settings.eula_version_count, static_cast<s32>(out_eula_versions.size()));
|
||||
(std::min)(m_system_settings.eula_version_count, static_cast<s32>(out_eula_versions.size()));
|
||||
memcpy(out_eula_versions.data(), m_system_settings.eula_versions.data(),
|
||||
static_cast<std::size_t>(*out_count) * sizeof(EulaVersion));
|
||||
R_SUCCEED();
|
||||
|
|
@ -599,7 +599,7 @@ Result ISystemSettingsServer::GetAccountNotificationSettings(
|
|||
LOG_INFO(Service_SET, "called, elements={}",
|
||||
m_system_settings.account_notification_settings_count);
|
||||
|
||||
*out_count = std::min(m_system_settings.account_notification_settings_count,
|
||||
*out_count = (std::min)(m_system_settings.account_notification_settings_count,
|
||||
static_cast<s32>(out_account_notification_settings.size()));
|
||||
memcpy(out_account_notification_settings.data(),
|
||||
m_system_settings.account_notification_settings.data(),
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ void Controller::QueryPointerBufferSize(HLERequestContext& ctx) {
|
|||
ASSERT(process != nullptr);
|
||||
|
||||
u32 buffer_size = process->GetPointerBufferSize();
|
||||
if (buffer_size > std::numeric_limits<u16>::max()) {
|
||||
if (buffer_size > (std::numeric_limits<u16>::max)()) {
|
||||
LOG_WARNING(Service, "Pointer buffer size exceeds u16 max, clamping");
|
||||
buffer_size = std::numeric_limits<u16>::max();
|
||||
buffer_size = (std::numeric_limits<u16>::max)();
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
|
|
@ -94,9 +94,9 @@ void Controller::SetPointerBufferSize(HLERequestContext& ctx) {
|
|||
|
||||
u32 requested_size = rp.PopRaw<u32>();
|
||||
|
||||
if (requested_size > std::numeric_limits<u16>::max()) {
|
||||
if (requested_size > (std::numeric_limits<u16>::max)()) {
|
||||
LOG_WARNING(Service, "Requested pointer buffer size too large, clamping to 0xFFFF");
|
||||
requested_size = std::numeric_limits<u16>::max();
|
||||
requested_size = (std::numeric_limits<u16>::max)();
|
||||
}
|
||||
|
||||
process->SetPointerBufferSize(requested_size);
|
||||
|
|
|
|||
|
|
@ -45,13 +45,13 @@ bool IsConnectionBased(Type type) {
|
|||
template <typename T>
|
||||
T GetValue(std::span<const u8> buffer) {
|
||||
T t{};
|
||||
std::memcpy(&t, buffer.data(), std::min(sizeof(T), buffer.size()));
|
||||
std::memcpy(&t, buffer.data(), (std::min)(sizeof(T), buffer.size()));
|
||||
return t;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void PutValue(std::span<u8> buffer, const T& t) {
|
||||
std::memcpy(buffer.data(), &t, std::min(sizeof(T), buffer.size()));
|
||||
std::memcpy(buffer.data(), &t, (std::min)(sizeof(T), buffer.size()));
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ void Module::Interface::GenerateRandomBytes(HLERequestContext& ctx) {
|
|||
|
||||
const std::size_t size = ctx.GetWriteBufferSize();
|
||||
|
||||
std::uniform_int_distribution<u16> distribution(0, std::numeric_limits<u8>::max());
|
||||
std::uniform_int_distribution<u16> distribution(0, (std::numeric_limits<u8>::max)());
|
||||
std::vector<u8> data(size);
|
||||
std::generate(data.begin(), data.end(), [&] { return static_cast<u8>(distribution(rng)); });
|
||||
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ private:
|
|||
|
||||
void GetNextAlpnProto(HLERequestContext& ctx) {
|
||||
const size_t writable = ctx.GetWriteBufferSize();
|
||||
const size_t to_write = std::min(next_alpn_proto.size(), writable);
|
||||
const size_t to_write = (std::min)(next_alpn_proto.size(), writable);
|
||||
|
||||
if (to_write != 0) {
|
||||
ctx.WriteBuffer(std::span<const u8>(next_alpn_proto.data(), to_write));
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ Result IApplicationDisplayService::OpenLayer(Out<u64> out_size,
|
|||
|
||||
const auto buffer = parcel.Serialize();
|
||||
std::memcpy(out_native_window.data(), buffer.data(),
|
||||
std::min(out_native_window.size(), buffer.size()));
|
||||
(std::min)(out_native_window.size(), buffer.size()));
|
||||
*out_size = buffer.size();
|
||||
|
||||
R_SUCCEED();
|
||||
|
|
@ -226,7 +226,7 @@ Result IApplicationDisplayService::CreateStrayLayer(
|
|||
|
||||
const auto buffer = parcel.Serialize();
|
||||
std::memcpy(out_native_window.data(), buffer.data(),
|
||||
std::min(out_native_window.size(), buffer.size()));
|
||||
(std::min)(out_native_window.size(), buffer.size()));
|
||||
|
||||
*out_size = buffer.size();
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ sockaddr TranslateFromSockAddrIn(SockAddrIn input) {
|
|||
}
|
||||
|
||||
LINGER MakeLinger(bool enable, u32 linger_value) {
|
||||
ASSERT(linger_value <= std::numeric_limits<u_short>::max());
|
||||
ASSERT(linger_value <= (std::numeric_limits<u_short>::max)());
|
||||
|
||||
LINGER value;
|
||||
value.l_onoff = enable ? 1 : 0;
|
||||
|
|
@ -798,7 +798,7 @@ Errno Socket::Shutdown(ShutdownHow how) {
|
|||
|
||||
std::pair<s32, Errno> Socket::Recv(int flags, std::span<u8> message) {
|
||||
ASSERT(flags == 0);
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(message.size() < static_cast<size_t>((std::numeric_limits<int>::max)()));
|
||||
|
||||
const auto result =
|
||||
recv(fd, reinterpret_cast<char*>(message.data()), static_cast<int>(message.size()), 0);
|
||||
|
|
@ -811,7 +811,7 @@ std::pair<s32, Errno> Socket::Recv(int flags, std::span<u8> message) {
|
|||
|
||||
std::pair<s32, Errno> Socket::RecvFrom(int flags, std::span<u8> message, SockAddrIn* addr) {
|
||||
ASSERT(flags == 0);
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(message.size() < static_cast<size_t>((std::numeric_limits<int>::max)()));
|
||||
|
||||
sockaddr_in addr_in{};
|
||||
socklen_t addrlen = sizeof(addr_in);
|
||||
|
|
@ -831,7 +831,7 @@ std::pair<s32, Errno> Socket::RecvFrom(int flags, std::span<u8> message, SockAdd
|
|||
}
|
||||
|
||||
std::pair<s32, Errno> Socket::Send(std::span<const u8> message, int flags) {
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(message.size() < static_cast<size_t>((std::numeric_limits<int>::max)()));
|
||||
ASSERT(flags == 0);
|
||||
|
||||
int native_flags = 0;
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ std::vector<Network::NetworkInterface> GetAvailableNetworkInterfaces() {
|
|||
}
|
||||
|
||||
// ignore header
|
||||
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
file.ignore((std::numeric_limits<std::streamsize>::max)(), '\n');
|
||||
|
||||
bool gateway_found = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -105,14 +105,14 @@ Errno ProxySocket::Shutdown(ShutdownHow how) {
|
|||
std::pair<s32, Errno> ProxySocket::Recv(int flags, std::span<u8> message) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
ASSERT(flags == 0);
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(message.size() < static_cast<size_t>((std::numeric_limits<int>::max)()));
|
||||
|
||||
return {static_cast<s32>(0), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::RecvFrom(int flags, std::span<u8> message, SockAddrIn* addr) {
|
||||
ASSERT(flags == 0);
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(message.size() < static_cast<size_t>((std::numeric_limits<int>::max)()));
|
||||
|
||||
// TODO (flTobi): Verify the timeout behavior and break when connection is lost
|
||||
const auto timestamp = std::chrono::steady_clock::now();
|
||||
|
|
@ -183,7 +183,7 @@ std::pair<s32, Errno> ProxySocket::ReceivePacket(int flags, std::span<u8> messag
|
|||
|
||||
std::pair<s32, Errno> ProxySocket::Send(std::span<const u8> message, int flags) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(message.size() < static_cast<size_t>((std::numeric_limits<int>::max)()));
|
||||
ASSERT(flags == 0);
|
||||
|
||||
return {static_cast<s32>(0), Errno::SUCCESS};
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ ResultStatus AppLoader_NCA::VerifyIntegrity(std::function<bool(size_t, size_t)>
|
|||
// Begin iterating the file.
|
||||
while (processed_size < total_size) {
|
||||
// Refill the buffer.
|
||||
const size_t intended_read_size = std::min(buffer.size(), total_size - processed_size);
|
||||
const size_t intended_read_size = (std::min)(buffer.size(), total_size - processed_size);
|
||||
const size_t read_size = file->Read(buffer.data(), intended_read_size, processed_size);
|
||||
|
||||
// Update the hash function with the buffer contents.
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ struct Memory::Impl {
|
|||
explicit Impl(Core::System& system_) : system{system_} {
|
||||
// Initialize thread count based on available cores for parallel memory operations
|
||||
const unsigned int hw_concurrency = std::thread::hardware_concurrency();
|
||||
thread_count = std::max(2u, std::min(hw_concurrency, 8u)); // Limit to 8 threads max
|
||||
thread_count = (std::max)(2u, (std::min)(hw_concurrency, 8u)); // Limit to 8 threads max
|
||||
}
|
||||
|
||||
void SetCurrentPageTable(Kernel::KProcess& process) {
|
||||
|
|
@ -263,7 +263,7 @@ struct Memory::Impl {
|
|||
|
||||
while (remaining_size) {
|
||||
const std::size_t copy_amount =
|
||||
std::min(static_cast<std::size_t>(YUZU_PAGESIZE) - page_offset, remaining_size);
|
||||
(std::min)(static_cast<std::size_t>(YUZU_PAGESIZE) - page_offset, remaining_size);
|
||||
const auto current_vaddr =
|
||||
static_cast<u64>((page_index << YUZU_PAGEBITS) + page_offset);
|
||||
|
||||
|
|
@ -948,7 +948,7 @@ struct Memory::Impl {
|
|||
const auto* p = GetPointerImpl(
|
||||
v_address, []() {}, []() {});
|
||||
constexpr size_t sys_core = Core::Hardware::NUM_CPU_CORES - 1;
|
||||
const size_t core = std::min(system.GetCurrentHostThreadID(),
|
||||
const size_t core = (std::min)(system.GetCurrentHostThreadID(),
|
||||
sys_core); // any other calls threads go to syscore.
|
||||
if (!gpu_device_memory) [[unlikely]] {
|
||||
gpu_device_memory = &system.Host1x().MemoryManager();
|
||||
|
|
@ -989,7 +989,7 @@ struct Memory::Impl {
|
|||
|
||||
void InvalidateGPUMemory(u8* p, size_t size) {
|
||||
constexpr size_t sys_core = Core::Hardware::NUM_CPU_CORES - 1;
|
||||
const size_t core = std::min(system.GetCurrentHostThreadID(),
|
||||
const size_t core = (std::min)(system.GetCurrentHostThreadID(),
|
||||
sys_core); // any other calls threads go to syscore.
|
||||
if (!gpu_device_memory) [[unlikely]] {
|
||||
gpu_device_memory = &system.Host1x().MemoryManager();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue