VERY experimental Nintendo Switch 2 emulator
C++
Kernel: Correct Cancel Synchronization.
Fernando Sahmkow323a0e17e7b6
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cppindex c63a9ba8bb..b2cef3be99 100644--- a/src/core/hle/kernel/svc.cpp+++ b/src/core/hle/kernel/svc.cpp@@ -505,6 +505,11 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddrreturn RESULT_TIMEOUT;}+ if (thread->IsSyncCancelled()) {+ thread->SetSyncCancelled(false);+ return ERR_SYNCHRONIZATION_CANCELED;+ }+for (auto& object : objects) {object->AddWaitingThread(thread);}diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cppindex 962530d2d2..538e479922 100644--- a/src/core/hle/kernel/thread.cpp+++ b/src/core/hle/kernel/thread.cpp@@ -132,8 +132,11 @@ void Thread::ResumeFromWait() {}void Thread::CancelWait() {- ASSERT(GetStatus() == ThreadStatus::WaitSynch);- ClearWaitObjects();+ if (GetSchedulingStatus() != ThreadSchedStatus::Paused) {+ is_sync_cancelled = true;+ return;+ }+ is_sync_cancelled = false;SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED);ResumeFromWait();}diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.hindex c9870873d5..25a6ed234e 100644--- a/src/core/hle/kernel/thread.h+++ b/src/core/hle/kernel/thread.h@@ -440,6 +440,14 @@ public:is_running = value;}+ bool IsSyncCancelled() const {+ return is_sync_cancelled;+ }++ void SetSyncCancelled(bool value) {+ is_sync_cancelled = value;+ }+private:explicit Thread(KernelCore& kernel);~Thread() override;@@ -524,6 +532,7 @@ private:u32 scheduling_state = 0;bool is_running = false;+ bool is_sync_cancelled = false;std::string name;};