From bc91ebacc1810db003d4a87cb595e0d07fc14000 Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 9 Jan 2018 15:02:04 -0500 Subject: SVC: Implemented CancelSynchronization. --- src/core/hle/kernel/svc.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/core/hle/kernel/svc.cpp') diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index c3280bfa3..b7cad2248 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -216,6 +216,22 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 return WaitSynchronization1(objects[0], GetCurrentThread(), nano_seconds); } +/// Resumes a thread waiting on WaitSynchronization +static ResultCode CancelSynchronization(Handle thread_handle) { + LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); + + const SharedPtr thread = g_handle_table.Get(thread_handle); + if (!thread) { + return ERR_INVALID_HANDLE; + } + + ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY); + thread->SetWaitSynchronizationResult( + ResultCode(ErrorModule::Kernel, ErrCodes::SynchronizationCanceled)); + thread->ResumeFromWait(); + return RESULT_SUCCESS; +} + /// Attempts to locks a mutex, creating it if it does not already exist static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, Handle requesting_thread_handle) { @@ -646,7 +662,7 @@ static const FunctionDef SVC_Table[] = { {0x16, SvcWrap, "CloseHandle"}, {0x17, nullptr, "ResetSignal"}, {0x18, SvcWrap, "WaitSynchronization"}, - {0x19, nullptr, "CancelSynchronization"}, + {0x19, SvcWrap, "CancelSynchronization"}, {0x1A, SvcWrap, "LockMutex"}, {0x1B, SvcWrap, "UnlockMutex"}, {0x1C, SvcWrap, "WaitProcessWideKeyAtomic"}, -- cgit v1.2.3