VERY experimental Nintendo Switch 2 emulator
C++
SCC: Small corrections to CancelSynchronization
Fernando Sahmkowc1f6b9965326
diff --git a/src/core/hle/kernel/synchronization.cpp b/src/core/hle/kernel/synchronization.cppindex ac43a70946..a7e3fbe92f 100644--- a/src/core/hle/kernel/synchronization.cpp+++ b/src/core/hle/kernel/synchronization.cpp@@ -74,7 +74,9 @@ std::pair<ResultCode, Handle> Synchronization::WaitFor(thread->SetSynchronizationObjects(&sync_objects);thread->SetSynchronizationResults(nullptr, RESULT_TIMEOUT);thread->SetStatus(ThreadStatus::WaitSynch);+ thread->SetWaitingSync(true);}+ thread->SetWaitingSync(false);if (event_handle != InvalidHandle) {auto& time_manager = kernel.TimeManager();diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cppindex fb17518605..e8962a0d8f 100644--- a/src/core/hle/kernel/thread.cpp+++ b/src/core/hle/kernel/thread.cpp@@ -139,13 +139,14 @@ ResultCode Thread::Start() {void Thread::CancelWait() {SchedulerLock lock(kernel);- if (GetSchedulingStatus() != ThreadSchedStatus::Paused) {+ if (GetSchedulingStatus() != ThreadSchedStatus::Paused || !is_waiting_on_sync) {is_sync_cancelled = true;return;}+ //TODO(Blinkhawk): Implement cancel of server sessionis_sync_cancelled = false;SetSynchronizationResults(nullptr, ERR_SYNCHRONIZATION_CANCELED);- ResumeFromWait();+ SetStatus(ThreadStatus::Ready);}static void ResetThreadContext32(Core::ARM_Interface::ThreadContext32& context, u32 stack_top,diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.hindex e8355bbd13..d8a983200c 100644--- a/src/core/hle/kernel/thread.h+++ b/src/core/hle/kernel/thread.h@@ -556,6 +556,14 @@ public:waiting_for_arbitration = set;}+ bool IsWaitingSync() const {+ return is_waiting_on_sync;+ }++ void SetWaitingSync(bool is_waiting) {+ is_waiting_on_sync = is_waiting;+ }+private:friend class GlobalScheduler;friend class Scheduler;@@ -650,6 +658,7 @@ private:u32 scheduling_state = 0;bool is_running = false;+ bool is_waiting_on_sync = false;bool is_sync_cancelled = false;bool will_be_terminated{};