summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2021-12-05 23:36:15 -0800
committerGravatar bunnei2021-12-06 16:39:18 -0800
commite596fac6ee174d9e232c1a2291dfb8e8b5825aba (patch)
tree9daa608797871adac65c1c87dad23d6de55fdc4e
parenthle: kernel: service_thread: Use std::jthread. (diff)
downloadyuzu-e596fac6ee174d9e232c1a2291dfb8e8b5825aba.tar.gz
yuzu-e596fac6ee174d9e232c1a2291dfb8e8b5825aba.tar.xz
yuzu-e596fac6ee174d9e232c1a2291dfb8e8b5825aba.zip
hle: kernel: k_light_lock: Implement CancelWait.
- Fixes a crash in Megadimension Neptunia VII.
-rw-r--r--src/core/hle/kernel/k_light_lock.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/core/hle/kernel/k_light_lock.cpp b/src/core/hle/kernel/k_light_lock.cpp
index 5e8f1a510..9830506ff 100644
--- a/src/core/hle/kernel/k_light_lock.cpp
+++ b/src/core/hle/kernel/k_light_lock.cpp
@@ -16,10 +16,15 @@ class ThreadQueueImplForKLightLock final : public KThreadQueue {
16public: 16public:
17 explicit ThreadQueueImplForKLightLock(KernelCore& kernel_) : KThreadQueue(kernel_) {} 17 explicit ThreadQueueImplForKLightLock(KernelCore& kernel_) : KThreadQueue(kernel_) {}
18 18
19 virtual void CancelWait([[maybe_unused]] KThread* waiting_thread, 19 virtual void CancelWait(KThread* waiting_thread, ResultCode wait_result,
20 [[maybe_unused]] ResultCode wait_result, 20 bool cancel_timer_task) override {
21 [[maybe_unused]] bool cancel_timer_task) override { 21 // Remove the thread as a waiter from its owner.
22 // Do nothing, waiting to acquire a light lock cannot be canceled. 22 if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) {
23 owner->RemoveWaiter(waiting_thread);
24 }
25
26 // Invoke the base cancel wait handler.
27 KThreadQueue::CancelWait(waiting_thread, wait_result, cancel_timer_task);
23 } 28 }
24}; 29};
25 30
@@ -64,7 +69,7 @@ bool KLightLock::LockSlowPath(uintptr_t _owner, uintptr_t _cur_thread) {
64 } 69 }
65 70
66 // Add the current thread as a waiter on the owner. 71 // Add the current thread as a waiter on the owner.
67 KThread* owner_thread = reinterpret_cast<KThread*>(_owner & ~1ul); 72 KThread* owner_thread = reinterpret_cast<KThread*>(_owner & ~1ULL);
68 cur_thread->SetAddressKey(reinterpret_cast<uintptr_t>(std::addressof(tag))); 73 cur_thread->SetAddressKey(reinterpret_cast<uintptr_t>(std::addressof(tag)));
69 owner_thread->AddWaiter(cur_thread); 74 owner_thread->AddWaiter(cur_thread);
70 75