summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/mutex.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-11-24 21:31:53 +0100
committerbunnei <bunneidev@gmail.com>2014-11-24 21:31:53 +0100
commitbb730855e58d18d8964d158a55822c40503d548f (patch)
tree9c3ff113839583d1deca837e9888d81f25d485a0 /src/core/hle/kernel/mutex.cpp
parentMerge pull request #191 from archshift/deletexyz (diff)
parentUse pointers instead of passing handles around in some functions. (diff)
downloadyuzu-bb730855e58d18d8964d158a55822c40503d548f.tar
yuzu-bb730855e58d18d8964d158a55822c40503d548f.tar.gz
yuzu-bb730855e58d18d8964d158a55822c40503d548f.tar.bz2
yuzu-bb730855e58d18d8964d158a55822c40503d548f.tar.lz
yuzu-bb730855e58d18d8964d158a55822c40503d548f.tar.xz
yuzu-bb730855e58d18d8964d158a55822c40503d548f.tar.zst
yuzu-bb730855e58d18d8964d158a55822c40503d548f.zip
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
-rw-r--r--src/core/hle/kernel/mutex.cpp35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 31129fd86..b303ba128 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -27,31 +27,20 @@ public:
std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex
std::string name; ///< Name of mutex (optional)
- /**
- * Synchronize kernel object
- * @param wait Boolean wait set if current thread should wait as a result of sync operation
- * @return Result of operation, 0 on success, otherwise error code
- */
- Result SyncRequest(bool* wait) override {
+ ResultVal<bool> SyncRequest() override {
// TODO(bunnei): ImplementMe
locked = true;
- return 0;
+ return MakeResult<bool>(false);
}
- /**
- * Wait for kernel object to synchronize
- * @param wait Boolean wait set if current thread should wait as a result of sync operation
- * @return Result of operation, 0 on success, otherwise error code
- */
- Result WaitSynchronization(bool* wait) override {
+ ResultVal<bool> WaitSynchronization() override {
// TODO(bunnei): ImplementMe
- *wait = locked;
-
+ bool wait = locked;
if (locked) {
Kernel::WaitCurrentThread(WAITTYPE_MUTEX, GetHandle());
}
- return 0;
+ return MakeResult<bool>(wait);
}
};
@@ -119,15 +108,17 @@ bool ReleaseMutex(Mutex* mutex) {
* Releases a mutex
* @param handle Handle to mutex to release
*/
-Result ReleaseMutex(Handle handle) {
- Mutex* mutex = Kernel::g_object_pool.GetFast<Mutex>(handle);
-
- _assert_msg_(KERNEL, (mutex != nullptr), "ReleaseMutex tried to release a nullptr mutex!");
+ResultCode ReleaseMutex(Handle handle) {
+ Mutex* mutex = Kernel::g_object_pool.Get<Mutex>(handle);
+ if (mutex == nullptr) return InvalidHandle(ErrorModule::Kernel);
if (!ReleaseMutex(mutex)) {
- return -1;
+ // TODO(yuriks): Verify error code, this one was pulled out of thin air. I'm not even sure
+ // what error condition this is supposed to be signaling.
+ return ResultCode(ErrorDescription::AlreadyDone, ErrorModule::Kernel,
+ ErrorSummary::NothingHappened, ErrorLevel::Temporary);
}
- return 0;
+ return RESULT_SUCCESS;
}
/**