aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-01-11 13:53:11 -0200
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-01-30 11:47:05 -0200
commitd9b19be1d9c1baa5e8b92c1960c14e435e6b532f (patch)
treeda083beea826952f0a9c07ab392992ef6ca84c5c /src/core/hle/svc.cpp
parent4bb33dfc30768c536d3f0ffb980464b1ab2d25d9 (diff)
Kernel: Convert Semaphore to not use Handles
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 165da040..6cbe38bc 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