diff options
| author | 2015-01-22 23:12:19 -0200 | |
|---|---|---|
| committer | 2015-01-30 11:47:06 -0200 | |
| commit | 882b6fed75b7bf34809493482496e98c498a14e0 (patch) | |
| tree | 7d44259e18b47559774f1d7e159fbd0c235d0318 /src/core/hle/svc.cpp | |
| parent | Kernel: Convert AddressArbiter to not use Handles (diff) | |
| download | yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.gz yuzu-882b6fed75b7bf34809493482496e98c498a14e0.tar.xz yuzu-882b6fed75b7bf34809493482496e98c498a14e0.zip | |
Kernel: Convert Mutex to not use Handles
Diffstat (limited to 'src/core/hle/svc.cpp')
| -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) { | |||
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | /// Create a mutex | 366 | /// Create a mutex |
| 367 | static Result CreateMutex(Handle* mutex, u32 initial_locked) { | 367 | static Result CreateMutex(Handle* handle, u32 initial_locked) { |
| 368 | *mutex = Kernel::CreateMutex((initial_locked != 0)); | 368 | using Kernel::Mutex; |
| 369 | |||
| 370 | auto mutex_res = Mutex::Create(initial_locked != 0); | ||
| 371 | if (mutex_res.Failed()) | ||
| 372 | return mutex_res.Code().raw; | ||
| 373 | SharedPtr<Mutex> mutex = mutex_res.MoveFrom(); | ||
| 374 | |||
| 375 | *handle = Kernel::g_handle_table.Create(mutex).MoveFrom(); | ||
| 369 | LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", | 376 | LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", |
| 370 | initial_locked ? "true" : "false", *mutex); | 377 | initial_locked ? "true" : "false", *handle); |
| 371 | return 0; | 378 | return 0; |
| 372 | } | 379 | } |
| 373 | 380 | ||
| 374 | /// Release a mutex | 381 | /// Release a mutex |
| 375 | static Result ReleaseMutex(Handle handle) { | 382 | static Result ReleaseMutex(Handle handle) { |
| 383 | using Kernel::Mutex; | ||
| 384 | |||
| 376 | LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); | 385 | LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); |
| 377 | ResultCode res = Kernel::ReleaseMutex(handle); | 386 | |
| 378 | return res.raw; | 387 | SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle); |
| 388 | if (mutex == nullptr) | ||
| 389 | return InvalidHandle(ErrorModule::Kernel).raw; | ||
| 390 | |||
| 391 | mutex->Release(); | ||
| 392 | return RESULT_SUCCESS.raw; | ||
| 379 | } | 393 | } |
| 380 | 394 | ||
| 381 | /// Get the ID for the specified thread. | 395 | /// Get the ID for the specified thread. |