From bf1b76dcd2382a6b4d2d640b4ee8ecc205f01889 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Tue, 2 Sep 2025 18:01:22 +0200 Subject: [PATCH] LinuxSyscalls: Clean up MappedResource insertion None of the call sites needed this to be a template, and the previous function produced unreadable error messages. --- .../LinuxEmulation/LinuxSyscalls/SyscallsSMCTracking.cpp | 6 +++--- .../LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsSMCTracking.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsSMCTracking.cpp index a3bec6e71..18c4b54da 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsSMCTracking.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsSMCTracking.cpp @@ -375,7 +375,7 @@ void SyscallHandler::TrackMmap(FEXCore::Core::InternalThreadState* Thread, uint6 if (PathLength != -1) { Tmp[PathLength] = '\0'; - auto [Iter, Inserted] = VMATracking.EmplaceMappedResource(mrid, VMATracking::MappedResource {nullptr, nullptr, 0}); + auto [Iter, Inserted] = VMATracking.InsertMappedResource(mrid, {nullptr, nullptr, 0}); Resource = &Iter->second; if (Inserted) { @@ -386,7 +386,7 @@ void SyscallHandler::TrackMmap(FEXCore::Core::InternalThreadState* Thread, uint6 } else if (flags & MAP_SHARED) { VMATracking::MRID mrid {VMATracking::SpecialDev::Anon, AnonSharedId++}; - auto [Iter, Inserted] = VMATracking.EmplaceMappedResource(mrid, VMATracking::MappedResource {nullptr, nullptr, 0}); + auto [Iter, Inserted] = VMATracking.InsertMappedResource(mrid, {nullptr, nullptr, 0}); LOGMAN_THROW_A_FMT(Inserted == true, "VMA tracking error"); Resource = &Iter->second; Resource->Iterator = Iter; @@ -446,7 +446,7 @@ void SyscallHandler::TrackMremap(FEXCore::Core::InternalThreadState* Thread, uin void SyscallHandler::TrackShmat(FEXCore::Core::InternalThreadState* Thread, int shmid, uint64_t shmaddr, int shmflg, uint64_t Length) { VMATracking::MRID mrid {VMATracking::SpecialDev::SHM, static_cast(shmid)}; - auto [Iter, Inserted] = VMATracking.EmplaceMappedResource(mrid, VMATracking::MappedResource {nullptr, nullptr, Length}); + auto [Iter, Inserted] = VMATracking.InsertMappedResource(mrid, {nullptr, nullptr, Length}); auto Resource = &Iter->second; if (Inserted) { Resource->Iterator = Iter; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h index 5c0f0e693..39b3558d5 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h @@ -114,11 +114,9 @@ struct VMATracking { // Returns the Size of the Shm or 0 if not found uintptr_t DeleteSHMRegion(FEXCore::Context::Context* Ctx, uintptr_t Base); - // Emplaces a new `MappedResource` to track. - // Used for `mmap` and `shmat` resources; Anonymous, FD, and SHM depending on flags. - template - inline auto EmplaceMappedResource(Args&&... args) { - return MappedResources.emplace(args...); + // Adds a new `MappedResource` to track. + inline auto InsertMappedResource(const MRID& mrid, MappedResource Resource) { + return MappedResources.emplace(mrid, std::move(Resource)); } private: bool ListRemove(VMAEntry* Mapping);