diff options
| author | lizzie <lizzie@eden-emu.dev> | 2025-09-09 20:47:49 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2025-09-09 20:47:49 +0200 |
| commit | 9d2681ecc9565681db623fb71799e76381998512 (patch) | |
| tree | 3133129860a1569a8be8e7e0c9c5985adbd992ca /src/core | |
| parent | 428f136a754096e34c7bfec902684e2546a43ca4 (diff) | |
[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>
Diffstat (limited to 'src/core')
101 files changed, 186 insertions, 169 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 1979d427b5..0be60b55c6 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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() diff --git a/src/core/arm/debug.cpp b/src/core/arm/debug.cpp index 854509463b..20f1ea00df 100644 --- a/src/core/arm/debug.cpp +++ b/src/core/arm/debug.cpp @@ -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] == '\\') { diff --git a/src/core/arm/dynarmic/dynarmic_cp15.cpp b/src/core/arm/dynarmic/dynarmic_cp15.cpp index c663adda19..0d5e5912ae 100644 --- a/src/core/arm/dynarmic/dynarmic_cp15.cpp +++ b/src/core/arm/dynarmic/dynarmic_cp15.cpp @@ -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 diff --git a/src/core/arm/nce/interpreter_visitor.h b/src/core/arm/nce/interpreter_visitor.h index f90d876abb..9dfbdb2fe9 100644 --- a/src/core/arm/nce/interpreter_visitor.h +++ b/src/core/arm/nce/interpreter_visitor.h @@ -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 { diff --git a/src/core/arm/nce/patcher.cpp b/src/core/arm/nce/patcher.cpp index b8387ce7cb..9321258ae9 100644 --- a/src/core/arm/nce/patcher.cpp +++ b/src/core/arm/nce/patcher.cpp @@ -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 { diff --git a/src/core/core.cpp b/src/core/core.cpp index c2852e66f0..7315f35e0c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -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); diff --git a/src/core/crypto/xts_encryption_layer.cpp b/src/core/crypto/xts_encryption_layer.cpp index b60303412b..34e58463de 100644 --- a/src/core/crypto/xts_encryption_layer.cpp +++ b/src/core/crypto/xts_encryption_layer.cpp @@ -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) diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index fcb5787147..5c3c045b3c 100644 --- a/src/core/debugger/gdbstub.cpp +++ b/src/core/debugger/gdbstub.cpp @@ -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() { diff --git a/src/core/debugger/gdbstub_arch.cpp b/src/core/debugger/gdbstub_arch.cpp index 452f565bec..ee7108376a 100644 --- a/src/core/debugger/gdbstub_arch.cpp +++ b/src/core/debugger/gdbstub_arch.cpp @@ -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; } diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index f104d495bb..52dff5df9a 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -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{ diff --git a/src/core/file_sys/fs_path_utility.h b/src/core/file_sys/fs_path_utility.h index cdfd8c7729..3af23b0bba 100644 --- a/src/core/file_sys/fs_path_utility.h +++ b/src/core/file_sys/fs_path_utility.h @@ -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; diff --git a/src/core/file_sys/fsa/fs_i_directory.h b/src/core/file_sys/fsa/fs_i_directory.h index c8e895eab0..a4adcd2beb 100644 --- a/src/core/file_sys/fsa/fs_i_directory.h +++ b/src/core/file_sys/fsa/fs_i_directory.h @@ -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)); diff --git a/src/core/file_sys/fsa/fs_i_file.h b/src/core/file_sys/fsa/fs_i_file.h index 1188ae8ca7..99468ef0e2 100644 --- a/src/core/file_sys/fsa/fs_i_file.h +++ b/src/core/file_sys/fsa/fs_i_file.h @@ -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(); } diff --git a/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp b/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp index bc1cddbb0c..c9fb5f64d6 100644 --- a/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp +++ b/src/core/file_sys/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp @@ -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. diff --git a/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.cpp b/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.cpp index b65aca18d9..c18fde18f4 100644 --- a/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.cpp +++ b/src/core/file_sys/fssystem/fssystem_aes_ctr_storage.cpp @@ -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) { diff --git a/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp b/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp index efc5aa0b12..5ef2544dfb 100644 --- a/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp +++ b/src/core/file_sys/fssystem/fssystem_aes_xts_storage.cpp @@ -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); diff --git a/src/core/file_sys/fssystem/fssystem_alignment_matching_storage_impl.cpp b/src/core/file_sys/fssystem/fssystem_alignment_matching_storage_impl.cpp index 641c888aed..08b77d790a 100644 --- a/src/core/file_sys/fssystem/fssystem_alignment_matching_storage_impl.cpp +++ b/src/core/file_sys/fssystem/fssystem_alignment_matching_storage_impl.cpp @@ -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); diff --git a/src/core/file_sys/fssystem/fssystem_crypto_configuration.cpp b/src/core/file_sys/fssystem/fssystem_crypto_configuration.cpp index a4f0cde281..0a9f28975b 100644 --- a/src/core/file_sys/fssystem/fssystem_crypto_configuration.cpp +++ b/src/core/file_sys/fssystem/fssystem_crypto_configuration.cpp @@ -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( diff --git a/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp b/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp index 046571e9ef..57cdc19248 100644 --- a/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp +++ b/src/core/file_sys/fssystem/fssystem_integrity_verification_storage.cpp @@ -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); diff --git a/src/core/file_sys/fssystem/fssystem_nca_header.cpp b/src/core/file_sys/fssystem/fssystem_nca_header.cpp index cef0f0bb94..2226c087c0 100644 --- a/src/core/file_sys/fssystem/fssystem_nca_header.cpp +++ b/src/core/file_sys/fssystem/fssystem_nca_header.cpp @@ -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 { diff --git a/src/core/file_sys/fssystem/fssystem_pooled_buffer.cpp b/src/core/file_sys/fssystem/fssystem_pooled_buffer.cpp index bbfaab2557..dcd08dac3e 100644 --- a/src/core/file_sys/fssystem/fssystem_pooled_buffer.cpp +++ b/src/core/file_sys/fssystem/fssystem_pooled_buffer.cpp @@ -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) { diff --git a/src/core/file_sys/fssystem/fssystem_sparse_storage.h b/src/core/file_sys/fssystem/fssystem_sparse_storage.h index 6c196ec611..1cc7e7b1eb 100644 --- a/src/core/file_sys/fssystem/fssystem_sparse_storage.h +++ b/src/core/file_sys/fssystem/fssystem_sparse_storage.h @@ -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: diff --git a/src/core/file_sys/nca_metadata.cpp b/src/core/file_sys/nca_metadata.cpp index 9e855c50d1..55ea4d0803 100644 --- a/src/core/file_sys/nca_metadata.cpp +++ b/src/core/file_sys/nca_metadata.cpp @@ -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)); diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 85d30543c1..cb2089e9b3 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -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{}; diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index a2b2809734..fee75f9de6 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp @@ -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)}; diff --git a/src/core/file_sys/vfs/vfs.cpp b/src/core/file_sys/vfs/vfs.cpp index a04292760f..2be7084209 100644 --- a/src/core/file_sys/vfs/vfs.cpp +++ b/src/core/file_sys/vfs/vfs.cpp @@ -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; diff --git a/src/core/file_sys/vfs/vfs_static.h b/src/core/file_sys/vfs/vfs_static.h index bb53560ac7..6dc4ef8fbf 100644 --- a/src/core/file_sys/vfs/vfs_static.h +++ b/src/core/file_sys/vfs/vfs_static.h @@ -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); } diff --git a/src/core/file_sys/vfs/vfs_vector.cpp b/src/core/file_sys/vfs/vfs_vector.cpp index 0d54461c8f..7576a023cf 100644 --- a/src/core/file_sys/vfs/vfs_vector.cpp +++ b/src/core/file_sys/vfs/vfs_vector.cpp @@ -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; } diff --git a/src/core/file_sys/vfs/vfs_vector.h b/src/core/file_sys/vfs/vfs_vector.h index 587187dd26..27f2c03ca7 100644 --- a/src/core/file_sys/vfs/vfs_vector.h +++ b/src/core/file_sys/vfs/vfs_vector.h @@ -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; } diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index d1f1ca8c97..ec5cec8fa0 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -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); } diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index 2590b20da4..3de975c20f 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp @@ -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))}; diff --git a/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp index 24eb3f8866..fa918ff204 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_memory_layout.cpp @@ -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; diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index f62f3e4767..db654d730d 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp @@ -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); } diff --git a/src/core/hle/kernel/k_dynamic_page_manager.h b/src/core/hle/kernel/k_dynamic_page_manager.h index ad11e84b71..2357fe0f4d 100644 --- a/src/core/hle/kernel/k_dynamic_page_manager.h +++ b/src/core/hle/kernel/k_dynamic_page_manager.h @@ -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; } diff --git a/src/core/hle/kernel/k_handle_table.h b/src/core/hle/kernel/k_handle_table.h index 1bf68e6b04..22fdc7e47a 100644 --- a/src/core/hle/kernel/k_handle_table.h +++ b/src/core/hle/kernel/k_handle_table.h @@ -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; } diff --git a/src/core/hle/kernel/k_hardware_timer.cpp b/src/core/hle/kernel/k_hardware_timer.cpp index 4e947dd6bc..f3098a59e0 100644 --- a/src/core/hle/kernel/k_hardware_timer.cpp +++ b/src/core/hle/kernel/k_hardware_timer.cpp @@ -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 diff --git a/src/core/hle/kernel/k_hardware_timer.h b/src/core/hle/kernel/k_hardware_timer.h index 27f43cd194..cb83e9c5b5 100644 --- a/src/core/hle/kernel/k_hardware_timer.h +++ b/src/core/hle/kernel/k_hardware_timer.h @@ -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{}; }; diff --git a/src/core/hle/kernel/k_light_server_session.cpp b/src/core/hle/kernel/k_light_server_session.cpp index e5ceb01f2a..5ea448b998 100644 --- a/src/core/hle/kernel/k_light_server_session.cpp +++ b/src/core/hle/kernel/k_light_server_session.cpp @@ -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: diff --git a/src/core/hle/kernel/k_light_server_session.h b/src/core/hle/kernel/k_light_server_session.h index 8eca3eab69..87ec9db016 100644 --- a/src/core/hle/kernel/k_light_server_session.h +++ b/src/core/hle/kernel/k_light_server_session.h @@ -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: diff --git a/src/core/hle/kernel/k_memory_block.h b/src/core/hle/kernel/k_memory_block.h index d2b7e9a66e..acf48cb757 100644 --- a/src/core/hle/kernel/k_memory_block.h +++ b/src/core/hle/kernel/k_memory_block.h @@ -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>( diff --git a/src/core/hle/kernel/k_memory_layout.cpp b/src/core/hle/kernel/k_memory_layout.cpp index bec7146688..6821f4c07e 100644 --- a/src/core/hle/kernel/k_memory_layout.cpp +++ b/src/core/hle/kernel/k_memory_layout.cpp @@ -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, diff --git a/src/core/hle/kernel/k_memory_manager.cpp b/src/core/hle/kernel/k_memory_manager.cpp index d6bd272962..2aa393ac06 100644 --- a/src/core/hle/kernel/k_memory_manager.cpp +++ b/src/core/hle/kernel/k_memory_manager.cpp @@ -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. diff --git a/src/core/hle/kernel/k_memory_manager.h b/src/core/hle/kernel/k_memory_manager.h index c5a487af92..41d33fa55d 100644 --- a/src/core/hle/kernel/k_memory_manager.h +++ b/src/core/hle/kernel/k_memory_manager.h @@ -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())]); diff --git a/src/core/hle/kernel/k_memory_region.h b/src/core/hle/kernel/k_memory_region.h index e3044f0227..cad7b31126 100644 --- a/src/core/hle/kernel/k_memory_region.h +++ b/src/core/hle/kernel/k_memory_region.h @@ -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; diff --git a/src/core/hle/kernel/k_page_bitmap.h b/src/core/hle/kernel/k_page_bitmap.h index 0ff9877326..4ad5483b28 100644 --- a/src/core/hle/kernel/k_page_bitmap.h +++ b/src/core/hle/kernel/k_page_bitmap.h @@ -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; diff --git a/src/core/hle/kernel/k_page_heap.h b/src/core/hle/kernel/k_page_heap.h index c55225bac6..0d63a6b1f5 100644 --- a/src/core/hle/kernel/k_page_heap.h +++ b/src/core/hle/kernel/k_page_heap.h @@ -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); diff --git a/src/core/hle/kernel/k_page_table_base.cpp b/src/core/hle/kernel/k_page_table_base.cpp index 5e39fbeb14..6b3f60f52e 100644 --- a/src/core/hle/kernel/k_page_table_base.cpp +++ b/src/core/hle/kernel/k_page_table_base.cpp @@ -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); } } }; diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index df3e540dc2..d6742f0637 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h @@ -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; diff --git a/src/core/hle/kernel/k_resource_limit.cpp b/src/core/hle/kernel/k_resource_limit.cpp index d8a63aaf8c..1403317d72 100644 --- a/src/core/hle/kernel/k_resource_limit.cpp +++ b/src/core/hle/kernel/k_resource_limit.cpp @@ -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; } diff --git a/src/core/hle/kernel/k_slab_heap.h b/src/core/hle/kernel/k_slab_heap.h index 334afebb71..2ec3d185dc 100644 --- a/src/core/hle/kernel/k_slab_heap.h +++ b/src/core/hle/kernel/k_slab_heap.h @@ -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)(); } } diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 8a360a839b..6aef191c87 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -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. diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 00177dc943..0ff81066e9 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -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. diff --git a/src/core/hle/kernel/svc/svc_address_arbiter.cpp b/src/core/hle/kernel/svc/svc_address_arbiter.cpp index ab91d74433..688d6abce0 100644 --- a/src/core/hle/kernel/svc/svc_address_arbiter.cpp +++ b/src/core/hle/kernel/svc/svc_address_arbiter.cpp @@ -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; diff --git a/src/core/hle/kernel/svc/svc_condition_variable.cpp b/src/core/hle/kernel/svc/svc_condition_variable.cpp index 0f4550a795..2aed6a77be 100644 --- a/src/core/hle/kernel/svc/svc_condition_variable.cpp +++ b/src/core/hle/kernel/svc/svc_condition_variable.cpp @@ -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; diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp index b619bd70ab..bc0684e76c 100644 --- a/src/core/hle/kernel/svc/svc_ipc.cpp +++ b/src/core/hle/kernel/svc/svc_ipc.cpp @@ -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; diff --git a/src/core/hle/kernel/svc/svc_process.cpp b/src/core/hle/kernel/svc/svc_process.cpp index 87845d64a6..6d63892a94 100644 --- a/src/core/hle/kernel/svc/svc_process.cpp +++ b/src/core/hle/kernel/svc/svc_process.cpp @@ -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()); diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index 77cd634c0d..ca5ce6fe07 100644 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp @@ -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) { diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 51a542e5e6..73f54f89b2 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -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> { diff --git a/src/core/hle/service/am/frontend/applet_cabinet.cpp b/src/core/hle/service/am/frontend/applet_cabinet.cpp index 4cbc80d639..58401479d3 100644 --- a/src/core/hle/service/am/frontend/applet_cabinet.cpp +++ b/src/core/hle/service/am/frontend/applet_cabinet.cpp @@ -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); diff --git a/src/core/hle/service/am/frontend/applet_controller.cpp b/src/core/hle/service/am/frontend/applet_controller.cpp index 66f52686d7..d457885773 100644 --- a/src/core/hle/service/am/frontend/applet_controller.cpp +++ b/src/core/hle/service/am/frontend/applet_controller.cpp @@ -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, diff --git a/src/core/hle/service/am/service/application_accessor.cpp b/src/core/hle/service/am/service/application_accessor.cpp index 986abc716a..2ac07f838e 100644 --- a/src/core/hle/service/am/service/application_accessor.cpp +++ b/src/core/hle/service/am/service/application_accessor.cpp @@ -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(); } diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index b736e2821b..eacc345e15 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -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); diff --git a/src/core/hle/service/am/service/library_applet_self_accessor.cpp b/src/core/hle/service/am/service/library_applet_self_accessor.cpp index cbe45189f8..091aadc9fc 100644 --- a/src/core/hle/service/am/service/library_applet_self_accessor.cpp +++ b/src/core/hle/service/am/service/library_applet_self_accessor.cpp @@ -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); diff --git a/src/core/hle/service/bcat/bcat_service.cpp b/src/core/hle/service/bcat/bcat_service.cpp index 63b1072d2a..5c23760113 100644 --- a/src/core/hle/service/bcat/bcat_service.cpp +++ b/src/core/hle/service/bcat/bcat_service.cpp @@ -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(); diff --git a/src/core/hle/service/bcat/delivery_cache_directory_service.cpp b/src/core/hle/service/bcat/delivery_cache_directory_service.cpp index 01f08a2fc5..fea373a607 100644 --- a/src/core/hle/service/bcat/delivery_cache_directory_service.cpp +++ b/src/core/hle/service/bcat/delivery_cache_directory_service.cpp @@ -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(); diff --git a/src/core/hle/service/bcat/delivery_cache_storage_service.cpp b/src/core/hle/service/bcat/delivery_cache_storage_service.cpp index 4c79d71f41..0ce798eb75 100644 --- a/src/core/hle/service/bcat/delivery_cache_storage_service.cpp +++ b/src/core/hle/service/bcat/delivery_cache_storage_service.cpp @@ -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; diff --git a/src/core/hle/service/cmif_serialization.h b/src/core/hle/service/cmif_serialization.h index 5a5f610f34..03b2a130a1 100644 --- a/src/core/hle/service/cmif_serialization.h +++ b/src/core/hle/service/cmif_serialization.h @@ -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) { diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index 9eaae4c4bd..9ad8d0e9b5 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp @@ -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}; diff --git a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp index ff823586b3..490ac49d42 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp @@ -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); diff --git a/src/core/hle/service/glue/notif.cpp b/src/core/hle/service/glue/notif.cpp index 5a03d34c12..dd3f1954de 100644 --- a/src/core/hle/service/glue/notif.cpp +++ b/src/core/hle/service/glue/notif.cpp @@ -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(); diff --git a/src/core/hle/service/glue/time/manager.cpp b/src/core/hle/service/glue/time/manager.cpp index 77bf8896cd..bfe57999c8 100644 --- a/src/core/hle/service/glue/time/manager.cpp +++ b/src/core/hle/service/glue/time/manager.cpp @@ -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 {}!", diff --git a/src/core/hle/service/hid/hid_debug_server.cpp b/src/core/hle/service/hid/hid_debug_server.cpp index 738c6d9ae2..450c1e953f 100644 --- a/src/core/hle/service/hid/hid_debug_server.cpp +++ b/src/core/hle/service/hid/hid_debug_server.cpp @@ -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)); diff --git a/src/core/hle/service/jit/jit_context.cpp b/src/core/hle/service/jit/jit_context.cpp index 0090e8568d..06a2368fe5 100644 --- a/src/core/hle/service/jit/jit_context.cpp +++ b/src/core/hle/service/jit/jit_context.cpp @@ -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; diff --git a/src/core/hle/service/ldn/ldn_types.h b/src/core/hle/service/ldn/ldn_types.h index fa0cdcbfa7..56a3cd1b4b 100644 --- a/src/core/hle/service/ldn/ldn_types.h +++ b/src/core/hle/service/ldn/ldn_types.h @@ -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; diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index 20df002330..508f91546d 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -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); diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index 30eab469a1..c026d47e86 100644 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp @@ -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; } diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 4710167364..15c7d8d2c7 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -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); } diff --git a/src/core/hle/service/ns/application_manager_interface.cpp b/src/core/hle/service/ns/application_manager_interface.cpp index 517ec75743..60ecd5c2b9 100644 --- a/src/core/hle/service/ns/application_manager_interface.cpp +++ b/src/core/hle/service/ns/application_manager_interface.cpp @@ -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++) { diff --git a/src/core/hle/service/ns/platform_service_manager.cpp b/src/core/hle/service/ns/platform_service_manager.cpp index 23cf05005c..301cf4ac4f 100644 --- a/src/core/hle/service/ns/platform_service_manager.cpp +++ b/src/core/hle/service/ns/platform_service_manager.cpp @@ -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++) { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 02913a5817..140c6eb6e3 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -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]; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h index cad6457293..c9a6737ba9 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h @@ -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}; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp index 9ca6308e6f..fa46c2f280 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp @@ -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] = {}; diff --git a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp index 91ba35aef5..a9b0f9d2f3 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp @@ -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) { diff --git a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp index 30095b0f73..27ac930f96 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp @@ -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); diff --git a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp index 1bb88a45fa..f9e1dba965 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_producer.cpp @@ -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())); } diff --git a/src/core/hle/service/nvnflinger/hardware_composer.cpp b/src/core/hle/service/nvnflinger/hardware_composer.cpp index 77622a7832..7098f4709d 100644 --- a/src/core/hle/service/nvnflinger/hardware_composer.cpp +++ b/src/core/hle/service/nvnflinger/hardware_composer.cpp @@ -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; } diff --git a/src/core/hle/service/psc/time/common.h b/src/core/hle/service/psc/time/common.h index 954aed666a..0ad2ed51f8 100644 --- a/src/core/hle/service/psc/time/common.h +++ b/src/core/hle/service/psc/time/common.h @@ -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; diff --git a/src/core/hle/service/psc/time/power_state_request_manager.cpp b/src/core/hle/service/psc/time/power_state_request_manager.cpp index 17de0bf4dd..15fe8e2918 100644 --- a/src/core/hle/service/psc/time/power_state_request_manager.cpp +++ b/src/core/hle/service/psc/time/power_state_request_manager.cpp @@ -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; diff --git a/src/core/hle/service/set/settings_server.cpp b/src/core/hle/service/set/settings_server.cpp index aa873bc8c5..7d1869a4e8 100644 --- a/src/core/hle/service/set/settings_server.cpp +++ b/src/core/hle/service/set/settings_server.cpp @@ -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); diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp index d246b95d0e..c70fdea24b 100644 --- a/src/core/hle/service/set/system_settings_server.cpp +++ b/src/core/hle/service/set/system_settings_server.cpp @@ -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(), diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp index 9e25eae4d4..3b63d162c4 100644 --- a/src/core/hle/service/sm/sm_controller.cpp +++ b/src/core/hle/service/sm/sm_controller.cpp @@ -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); diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index fffbc413bb..a31bf45238 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -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 diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp index 549e6f4fa8..f59eeac06c 100644 --- a/src/core/hle/service/spl/spl_module.cpp +++ b/src/core/hle/service/spl/spl_module.cpp @@ -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)); }); diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 2d10bd04d2..7720c93d5a 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -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)); diff --git a/src/core/hle/service/vi/application_display_service.cpp b/src/core/hle/service/vi/application_display_service.cpp index 289ad7073c..cd28b81dc1 100644 --- a/src/core/hle/service/vi/application_display_service.cpp +++ b/src/core/hle/service/vi/application_display_service.cpp @@ -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(); diff --git a/src/core/internal_network/network.cpp b/src/core/internal_network/network.cpp index 6a3c6e9c41..400bd04bdf 100644 --- a/src/core/internal_network/network.cpp +++ b/src/core/internal_network/network.cpp @@ -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; diff --git a/src/core/internal_network/network_interface.cpp b/src/core/internal_network/network_interface.cpp index f62381b9e3..ae9755113a 100644 --- a/src/core/internal_network/network_interface.cpp +++ b/src/core/internal_network/network_interface.cpp @@ -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; diff --git a/src/core/internal_network/socket_proxy.cpp b/src/core/internal_network/socket_proxy.cpp index c263fb4ca8..1600c061f0 100644 --- a/src/core/internal_network/socket_proxy.cpp +++ b/src/core/internal_network/socket_proxy.cpp @@ -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}; diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 4a87ab53e7..9a82dae144 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -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. diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 0035c626e2..2583aae867 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -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(); diff --git a/src/core/tools/renderdoc.cpp b/src/core/tools/renderdoc.cpp index 947fa6cb37..d3a47e1d96 100644 --- a/src/core/tools/renderdoc.cpp +++ b/src/core/tools/renderdoc.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -18,10 +21,12 @@ namespace Tools { RenderdocAPI::RenderdocAPI() { #ifdef WIN32 if (HMODULE mod = GetModuleHandleA("renderdoc.dll")) { - const auto RENDERDOC_GetAPI = - reinterpret_cast<pRENDERDOC_GetAPI>(GetProcAddress(mod, "RENDERDOC_GetAPI")); - const s32 ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void**)&rdoc_api); - ASSERT(ret == 1); + void* proc = reinterpret_cast<void*>(GetProcAddress(mod, "RENDERDOC_GetAPI")); + if (proc) { + const auto RENDERDOC_GetAPI = reinterpret_cast<pRENDERDOC_GetAPI>(proc); + const s32 ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_6_0, (void**)&rdoc_api); + ASSERT(ret == 1); + } } #else #ifdef ANDROID |
