summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2019-03-21 22:18:36 -0400
committerGravatar GitHub2019-03-21 22:18:36 -0400
commit7b6d516faa788c25e26c79e2e5d19915f73983a5 (patch)
treed477c1598d78ad60360f2ab08d3b201fff9f38bd /src/core/hle/kernel/svc.cpp
parentMerge pull request #2274 from lioncash/include (diff)
parentcore/hle/kernel/mutex: Remove usages of global system accessors (diff)
downloadyuzu-7b6d516faa788c25e26c79e2e5d19915f73983a5.tar.gz
yuzu-7b6d516faa788c25e26c79e2e5d19915f73983a5.tar.xz
yuzu-7b6d516faa788c25e26c79e2e5d19915f73983a5.zip
Merge pull request #2234 from lioncash/mutex
core/hle/kernel: Make Mutex a per-process class.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 047fa0c19..a6a17efe7 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -551,9 +551,9 @@ static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr,
551 return ERR_INVALID_ADDRESS; 551 return ERR_INVALID_ADDRESS;
552 } 552 }
553 553
554 auto& handle_table = Core::CurrentProcess()->GetHandleTable(); 554 auto* const current_process = Core::System::GetInstance().Kernel().CurrentProcess();
555 return Mutex::TryAcquire(handle_table, mutex_addr, holding_thread_handle, 555 return current_process->GetMutex().TryAcquire(mutex_addr, holding_thread_handle,
556 requesting_thread_handle); 556 requesting_thread_handle);
557} 557}
558 558
559/// Unlock a mutex 559/// Unlock a mutex
@@ -571,7 +571,8 @@ static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
571 return ERR_INVALID_ADDRESS; 571 return ERR_INVALID_ADDRESS;
572 } 572 }
573 573
574 return Mutex::Release(mutex_addr); 574 auto* const current_process = Core::System::GetInstance().Kernel().CurrentProcess();
575 return current_process->GetMutex().Release(mutex_addr);
575} 576}
576 577
577enum class BreakType : u32 { 578enum class BreakType : u32 {
@@ -1340,11 +1341,15 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var
1340 "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", 1341 "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}",
1341 mutex_addr, condition_variable_addr, thread_handle, nano_seconds); 1342 mutex_addr, condition_variable_addr, thread_handle, nano_seconds);
1342 1343
1343 const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); 1344 auto* const current_process = Core::System::GetInstance().Kernel().CurrentProcess();
1345 const auto& handle_table = current_process->GetHandleTable();
1344 SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); 1346 SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle);
1345 ASSERT(thread); 1347 ASSERT(thread);
1346 1348
1347 CASCADE_CODE(Mutex::Release(mutex_addr)); 1349 const auto release_result = current_process->GetMutex().Release(mutex_addr);
1350 if (release_result.IsError()) {
1351 return release_result;
1352 }
1348 1353
1349 SharedPtr<Thread> current_thread = GetCurrentThread(); 1354 SharedPtr<Thread> current_thread = GetCurrentThread();
1350 current_thread->SetCondVarWaitAddress(condition_variable_addr); 1355 current_thread->SetCondVarWaitAddress(condition_variable_addr);