summaryrefslogtreecommitdiffstats
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2015-01-11 16:53:11 +0100
committerYuri Kunde Schlesner <yuriks@yuriks.net>2015-01-30 14:47:05 +0100
commitd9b19be1d9c1baa5e8b92c1960c14e435e6b532f (patch)
treeda083beea826952f0a9c07ab392992ef6ca84c5c /src/core/hle/svc.cpp
parentKernel: Convert SharedMemory to not use Handles (diff)
downloadyuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar.gz
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar.bz2
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar.lz
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar.xz
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.tar.zst
yuzu-d9b19be1d9c1baa5e8b92c1960c14e435e6b532f.zip
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 165da0402..6cbe38bc3 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -374,17 +374,38 @@ static Result GetThreadId(u32* thread_id, Handle handle) {
/// Creates a semaphore
static Result CreateSemaphore(Handle* semaphore, s32 initial_count, s32 max_count) {
- ResultCode res = Kernel::CreateSemaphore(semaphore, initial_count, max_count);
+ using Kernel::Semaphore;
+
+ ResultVal<SharedPtr<Semaphore>> semaphore_res = Semaphore::Create(initial_count, max_count);
+ if (semaphore_res.Failed())
+ return semaphore_res.Code().raw;
+
+ ResultVal<Handle> handle_res = Kernel::g_handle_table.Create(*semaphore_res);
+ if (handle_res.Failed())
+ return handle_res.Code().raw;
+
+ *semaphore = *handle_res;
LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X",
initial_count, max_count, *semaphore);
- return res.raw;
+ return RESULT_SUCCESS.raw;
}
/// Releases a certain number of slots in a semaphore
-static Result ReleaseSemaphore(s32* count, Handle semaphore, s32 release_count) {
- LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, semaphore);
- ResultCode res = Kernel::ReleaseSemaphore(count, semaphore, release_count);
- return res.raw;
+static Result ReleaseSemaphore(s32* count, Handle handle, s32 release_count) {
+ using Kernel::Semaphore;
+
+ LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle);
+
+ SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle);
+ if (semaphore == nullptr)
+ return InvalidHandle(ErrorModule::Kernel).raw;
+
+ ResultVal<s32> release_res = semaphore->Release(release_count);
+ if (release_res.Failed())
+ return release_res.Code().raw;
+
+ *count = *release_res;
+ return RESULT_SUCCESS.raw;
}
/// Query memory