From 3749984b29e2ed47ddce7ce0085c8f15b00d091b Mon Sep 17 00:00:00 2001 From: TheASVigilante <65920585+TheASVigilante@users.noreply.github.com> Date: Sat, 6 May 2023 18:08:48 +0200 Subject: [PATCH] Address remaining feedback --- app/src/main/cpp/skyline/kernel/memory.cpp | 19 +++++++++---------- app/src/main/cpp/skyline/kernel/memory.h | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/cpp/skyline/kernel/memory.cpp b/app/src/main/cpp/skyline/kernel/memory.cpp index 57bf329a..15622bbd 100644 --- a/app/src/main/cpp/skyline/kernel/memory.cpp +++ b/app/src/main/cpp/skyline/kernel/memory.cpp @@ -56,15 +56,14 @@ namespace skyline::kernel { } else { // If there are descriptors between first and last chunk, delete them if ((firstChunkBase->first + firstChunk.size) != lastChunkBase->first) { - auto tempChunkBase{firstChunkBase}; + auto tempChunkBase{std::next(firstChunkBase)}; - ++tempChunkBase; while (tempChunkBase->first != lastChunkBase->first) { auto tmp{tempChunkBase++}; if ((tmp->second.state == memory::states::Unmapped) != isUnmapping) needsReprotection = true; - chunks.erase(tmp); } + chunks.erase(std::next(firstChunkBase), lastChunkBase); } bool shouldInsert{true}; @@ -119,7 +118,7 @@ namespace skyline::kernel { Logger::Warn("Reprotection failed: {}", strerror(errno)); } - void MemoryManager::ForeachChunkinRange(span memory, auto editCallback) { + void MemoryManager::ForeachChunkInRange(span memory, auto editCallback) { auto chunkBase{chunks.lower_bound(memory.data())}; if (memory.data() < chunkBase->first) --chunkBase; @@ -349,7 +348,7 @@ namespace skyline::kernel { void MemoryManager::SetRegionBorrowed(span memory, bool value) { std::unique_lock lock{mutex}; - ForeachChunkinRange(memory, [&](std::pair &desc) __attribute__((always_inline)) { + ForeachChunkInRange(memory, [&](std::pair &desc) __attribute__((always_inline)) { desc.second.attributes.isBorrowed = value; MapInternal(desc); }); @@ -358,7 +357,7 @@ namespace skyline::kernel { void MemoryManager::SetRegionCpuCaching(span memory, bool value) { std::unique_lock lock{mutex}; - ForeachChunkinRange(memory, [&](std::pair &desc) __attribute__((always_inline)) { + ForeachChunkInRange(memory, [&](std::pair &desc) __attribute__((always_inline)) { desc.second.attributes.isUncached = value; MapInternal(desc); }); @@ -367,7 +366,7 @@ namespace skyline::kernel { void MemoryManager::SetRegionPermission(span memory, memory::Permission permission) { std::unique_lock lock{mutex}; - ForeachChunkinRange(memory, [&](std::pair &desc) __attribute__((always_inline)) { + ForeachChunkInRange(memory, [&](std::pair &desc) __attribute__((always_inline)) { desc.second.permission = permission; MapInternal(desc); }); @@ -480,7 +479,7 @@ namespace skyline::kernel { __attribute__((always_inline)) void MemoryManager::UnmapMemory(span memory) { std::unique_lock lock{mutex}; - ForeachChunkinRange(memory, [&](const std::pair &desc) { + ForeachChunkInRange(memory, [&](const std::pair &desc) { if (desc.second.state != memory::states::Unmapped) FreeMemory(span(desc.first, desc.second.size)); }); @@ -515,7 +514,7 @@ namespace skyline::kernel { std::memcpy(destination.data(), source.data(), source.size()); - ForeachChunkinRange(source, [&](std::pair &desc) __attribute__((always_inline)) { + ForeachChunkInRange(source, [&](std::pair &desc) __attribute__((always_inline)) { desc.second.permission = {false, false, false}; desc.second.attributes.isBorrowed = true; MapInternal(desc); @@ -532,7 +531,7 @@ namespace skyline::kernel { ++dstChunk; if ((destination.data() + destination.size()) > dstChunk->first) [[likely]] { - ForeachChunkinRange(span{source.data() + (dstChunk->first - destination.data()), dstChunk->second.size}, [&](std::pair &desc) __attribute__((always_inline)) { + ForeachChunkInRange(span{source.data() + (dstChunk->first - destination.data()), dstChunk->second.size}, [&](std::pair &desc) __attribute__((always_inline)) { desc.second.permission = dstChunk->second.permission; desc.second.attributes.isBorrowed = false; MapInternal(desc); diff --git a/app/src/main/cpp/skyline/kernel/memory.h b/app/src/main/cpp/skyline/kernel/memory.h index 37d072ba..e1916033 100644 --- a/app/src/main/cpp/skyline/kernel/memory.h +++ b/app/src/main/cpp/skyline/kernel/memory.h @@ -231,7 +231,7 @@ namespace skyline { void MapInternal(const std::pair &newDesc); - void ForeachChunkinRange(span memory, auto editCallback); + void ForeachChunkInRange(span memory, auto editCallback); public: memory::AddressSpaceType addressSpaceType{};