diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-23 02:12:19 +0100 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-30 14:47:06 +0100 |
commit | 882b6fed75b7bf34809493482496e98c498a14e0 (patch) | |
tree | 7d44259e18b47559774f1d7e159fbd0c235d0318 /src/core/hle/svc.cpp | |
parent | Kernel: Convert AddressArbiter to not use Handles (diff) | |
download | yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.gz yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.bz2 yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.lz yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.xz yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.zst yuzu-882b6fed75b7bf34809493482496e98c498a14e0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/svc.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index b093d0368..76ce59b29 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -364,18 +364,32 @@ static Result SetThreadPriority(Handle handle, s32 priority) { } /// Create a mutex -static Result CreateMutex(Handle* mutex, u32 initial_locked) { - *mutex = Kernel::CreateMutex((initial_locked != 0)); +static Result CreateMutex(Handle* handle, u32 initial_locked) { + using Kernel::Mutex; + + auto mutex_res = Mutex::Create(initial_locked != 0); + if (mutex_res.Failed()) + return mutex_res.Code().raw; + SharedPtr<Mutex> mutex = mutex_res.MoveFrom(); + + *handle = Kernel::g_handle_table.Create(mutex).MoveFrom(); LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", - initial_locked ? "true" : "false", *mutex); + initial_locked ? "true" : "false", *handle); return 0; } /// Release a mutex static Result ReleaseMutex(Handle handle) { + using Kernel::Mutex; + LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); - ResultCode res = Kernel::ReleaseMutex(handle); - return res.raw; + + SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle); + if (mutex == nullptr) + return InvalidHandle(ErrorModule::Kernel).raw; + + mutex->Release(); + return RESULT_SUCCESS.raw; } /// Get the ID for the specified thread. |