diff options
| author | 2019-03-14 00:29:54 -0400 | |
|---|---|---|
| committer | 2019-03-14 20:55:52 -0400 | |
| commit | 555cd26ec2b848634370a14d41b7e79b6c6beecd (patch) | |
| tree | 4ec6b8245280f94b44969356c9f2a44b22abd00e /src/core/hle/kernel/svc.cpp | |
| parent | Merge pull request #2230 from lioncash/global (diff) | |
| download | yuzu-555cd26ec2b848634370a14d41b7e79b6c6beecd.tar.gz yuzu-555cd26ec2b848634370a14d41b7e79b6c6beecd.tar.xz yuzu-555cd26ec2b848634370a14d41b7e79b6c6beecd.zip | |
core/hle/kernel: Make Mutex a per-process class.
Makes it an instantiable class like it is in the actual kernel. This
will also allow removing reliance on global accessors in a following
change, now that we can encapsulate a reference to the system instance
in the class.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 77d0e3d96..599609944 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 | ||
| 577 | enum class BreakType : u32 { | 578 | enum class BreakType : u32 { |
| @@ -1336,11 +1337,15 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var | |||
| 1336 | "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", | 1337 | "called mutex_addr={:X}, condition_variable_addr={:X}, thread_handle=0x{:08X}, timeout={}", |
| 1337 | mutex_addr, condition_variable_addr, thread_handle, nano_seconds); | 1338 | mutex_addr, condition_variable_addr, thread_handle, nano_seconds); |
| 1338 | 1339 | ||
| 1339 | const auto& handle_table = Core::CurrentProcess()->GetHandleTable(); | 1340 | auto* const current_process = Core::System::GetInstance().Kernel().CurrentProcess(); |
| 1341 | const auto& handle_table = current_process->GetHandleTable(); | ||
| 1340 | SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); | 1342 | SharedPtr<Thread> thread = handle_table.Get<Thread>(thread_handle); |
| 1341 | ASSERT(thread); | 1343 | ASSERT(thread); |
| 1342 | 1344 | ||
| 1343 | CASCADE_CODE(Mutex::Release(mutex_addr)); | 1345 | const auto release_result = current_process->GetMutex().Release(mutex_addr); |
| 1346 | if (release_result.IsError()) { | ||
| 1347 | return release_result; | ||
| 1348 | } | ||
| 1344 | 1349 | ||
| 1345 | SharedPtr<Thread> current_thread = GetCurrentThread(); | 1350 | SharedPtr<Thread> current_thread = GetCurrentThread(); |
| 1346 | current_thread->SetCondVarWaitAddress(condition_variable_addr); | 1351 | current_thread->SetCondVarWaitAddress(condition_variable_addr); |