mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 16:00:18 +02:00
Linux: Consolidate LockBeforeFork usage
Moves the CTX LockBeforeFork in to the Syscallhandler's LockBeforeFork. This lets the syscall handler just call its own LockBeforeFork and UnlockAfterFork functions rather than two on each call site. Also moves the CTX->UnlockAfterFork in to the SyscallHandler's to be consistent with the LockBeforeFork half. No functional change.
This commit is contained in:
1 parent
d4aa64ebd1
commit
577372c203
4 files changed
+7
-10
No files matched your search
@@ -580,7 +580,6 @@ uint64_t CloneHandler(FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::clone3_args
|
||||
if (!AnyFlagsSet(flags, CLONE_THREAD)) {
|
||||
// Has an unsupported flag
|
||||
// Fall to a handler that can handle this case
|
||||
auto Thread = Frame->Thread;
|
||||
|
||||
args->SignalMask = ~0ULL;
|
||||
::syscall(SYS_rt_sigprocmask, SIG_SETMASK, &args->SignalMask, &args->SignalMask, sizeof(args->SignalMask));
|
||||
@@ -590,9 +589,7 @@ uint64_t CloneHandler(FEXCore::Core::CpuStateFrame *Frame, FEX::HLE::clone3_args
|
||||
args->StackSize = FEX::LinuxEmulation::Threads::STACK_SIZE;
|
||||
args->NewStack = FEX::LinuxEmulation::Threads::AllocateStackObject();
|
||||
|
||||
Thread->CTX->LockBeforeFork(Frame->Thread);
|
||||
|
||||
FEX::HLE::_SyscallHandler->LockBeforeFork();
|
||||
FEX::HLE::_SyscallHandler->LockBeforeFork(Frame->Thread);
|
||||
|
||||
uint64_t Result{};
|
||||
if (args->Type == TYPE_CLONE2) {
|
||||
@@ -829,7 +826,8 @@ uint64_t UnimplementedSyscallSafe(FEXCore::Core::CpuStateFrame *Frame, uint64_t
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
void SyscallHandler::LockBeforeFork() {
|
||||
void SyscallHandler::LockBeforeFork(FEXCore::Core::InternalThreadState *Thread) {
|
||||
Thread->CTX->LockBeforeFork(Thread);
|
||||
VMATracking.Mutex.lock();
|
||||
}
|
||||
|
||||
@@ -841,6 +839,8 @@ void SyscallHandler::UnlockAfterFork(FEXCore::Core::InternalThreadState *LiveThr
|
||||
VMATracking.Mutex.unlock();
|
||||
}
|
||||
|
||||
CTX->UnlockAfterFork(LiveThread, Child);
|
||||
|
||||
// Clear all the other threads that are being tracked
|
||||
TM.UnlockAfterFork(LiveThread, Child);
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
FEXCore::HLE::AOTIRCacheEntryLookupResult LookupAOTIRCacheEntry(FEXCore::Core::InternalThreadState *Thread, uint64_t GuestAddr) final override;
|
||||
|
||||
///// FORK tracking /////
|
||||
void LockBeforeFork();
|
||||
void LockBeforeFork(FEXCore::Core::InternalThreadState *Thread);
|
||||
void UnlockAfterFork(FEXCore::Core::InternalThreadState *LiveThread, bool Child);
|
||||
|
||||
SourcecodeResolver *GetSourcecodeResolver() override { return this; }
|
||||
|
||||
@@ -233,9 +233,8 @@ namespace FEX::HLE {
|
||||
|
||||
uint64_t Mask{~0ULL};
|
||||
::syscall(SYS_rt_sigprocmask, SIG_SETMASK, &Mask, &Mask, sizeof(Mask));
|
||||
Thread->CTX->LockBeforeFork(Frame->Thread);
|
||||
|
||||
FEX::HLE::_SyscallHandler->LockBeforeFork();
|
||||
FEX::HLE::_SyscallHandler->LockBeforeFork(Frame->Thread);
|
||||
|
||||
const bool IsVFork = flags & CLONE_VFORK;
|
||||
pid_t Result{};
|
||||
|
||||
@@ -185,8 +185,6 @@ namespace FEX::HLE {
|
||||
}
|
||||
|
||||
void ThreadManager::UnlockAfterFork(FEXCore::Core::InternalThreadState *LiveThread, bool Child) {
|
||||
CTX->UnlockAfterFork(LiveThread, Child);
|
||||
|
||||
if (!Child) return;
|
||||
|
||||
// This function is called after fork
|
||||
|
||||
Reference in new issue
Block a user