Skip to content

Commit

Permalink
Merge pull request #4178 from Sonicadvance1/move_statuscode_frontend
Browse files Browse the repository at this point in the history
FEXCore: Moves StatusCode to the frontend
  • Loading branch information
Sonicadvance1 authored Nov 29, 2024
2 parents fad2214 + 1bf7e25 commit aa2180d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion FEXCore/include/FEXCore/Debug/InternalThreadState.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ struct InternalThreadState : public FEXCore::Allocator::FEXAllocOperators {
NonMovableUniquePtr<FEXCore::IR::PassManager> PassManager;
NonMovableUniquePtr<JITSymbolBuffer> SymbolBuffer;

int StatusCode {};
FEXCore::Context::ExitReason ExitReason {FEXCore::Context::ExitReason::EXIT_WAITING};
std::shared_ptr<FEXCore::CompileService> CompileService;

Expand Down
2 changes: 1 addition & 1 deletion Source/Tools/FEXLoader/FEXLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ int main(int argc, char** argv, char** const envp) {
}
}

auto ProgramStatus = ParentThread->Thread->StatusCode;
auto ProgramStatus = ParentThread->StatusCode;

SignalDelegation->UninstallTLSState(ParentThread);
SyscallHandler->TM.DestroyThread(ParentThread);
Expand Down
6 changes: 2 additions & 4 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ uint64_t HandleNewClone(FEX::HLE::ThreadStateObject* Thread, FEXCore::Context::C
FEX::HLE::_SyscallHandler->UninstallTLSState(Thread);

// The rest of the context remains as is and the thread will continue executing
return Thread->Thread->StatusCode;
return Thread->StatusCode;
}

static int Clone3Fork(uint32_t flags) {
Expand Down Expand Up @@ -390,8 +390,6 @@ void RegisterThread(FEX::HLE::SyscallHandler* Handler) {

REGISTER_SYSCALL_IMPL_FLAGS(exit, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY | SyscallFlags::NORETURN,
[](FEXCore::Core::CpuStateFrame* Frame, int status) -> uint64_t {
auto Thread = Frame->Thread;

// TLS/DTV teardown is something FEX can't control. Disable glibc checking when we leave a pthread.
// Since this thread is hard stopping, we can't track the TLS/DTV teardown in FEX's thread handling.
FEXCore::Allocator::YesIKnowImNotSupposedToUseTheGlibcAllocator::HardDisable();
Expand All @@ -403,7 +401,7 @@ void RegisterThread(FEX::HLE::SyscallHandler* Handler) {
syscall(SYSCALL_DEF(futex), ThreadObject->ThreadInfo.clear_child_tid, FUTEX_WAKE, ~0ULL, 0, 0, 0);
}

Thread->StatusCode = status;
ThreadObject->StatusCode = status;
FEX::HLE::_SyscallHandler->TM.StopThread(ThreadObject);

return 0;
Expand Down
2 changes: 2 additions & 0 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ struct ThreadStateObject : public FEXCore::Allocator::FEXAllocOperators {

// Thread signaling information
std::atomic<SignalEvent> SignalReason {SignalEvent::Nothing};

int StatusCode {};
};

class ThreadManager final {
Expand Down

0 comments on commit aa2180d

Please sign in to comment.