diff options
| author | 2014-11-24 15:31:53 -0500 | |
|---|---|---|
| committer | 2014-11-24 15:31:53 -0500 | |
| commit | bb730855e58d18d8964d158a55822c40503d548f (patch) | |
| tree | 9c3ff113839583d1deca837e9888d81f25d485a0 /src/core/hle/kernel/mutex.cpp | |
| parent | Merge pull request #191 from archshift/deletexyz (diff) | |
| parent | Use pointers instead of passing handles around in some functions. (diff) | |
| download | yuzu-bb730855e58d18d8964d158a55822c40503d548f.tar.gz yuzu-bb730855e58d18d8964d158a55822c40503d548f.tar.xz yuzu-bb730855e58d18d8964d158a55822c40503d548f.zip | |
Merge pull request #147 from yuriks/error-codes
Error codes
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 35 |
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: | |||
| 27 | std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex | 27 | std::vector<Handle> waiting_threads; ///< Threads that are waiting for the mutex |
| 28 | std::string name; ///< Name of mutex (optional) | 28 | std::string name; ///< Name of mutex (optional) |
| 29 | 29 | ||
| 30 | /** | 30 | ResultVal<bool> SyncRequest() override { |
| 31 | * Synchronize kernel object | ||
| 32 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | ||
| 33 | * @return Result of operation, 0 on success, otherwise error code | ||
| 34 | */ | ||
| 35 | Result SyncRequest(bool* wait) override { | ||
| 36 | // TODO(bunnei): ImplementMe | 31 | // TODO(bunnei): ImplementMe |
| 37 | locked = true; | 32 | locked = true; |
| 38 | return 0; | 33 | return MakeResult<bool>(false); |
| 39 | } | 34 | } |
| 40 | 35 | ||
| 41 | /** | 36 | ResultVal<bool> WaitSynchronization() override { |
| 42 | * Wait for kernel object to synchronize | ||
| 43 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | ||
| 44 | * @return Result of operation, 0 on success, otherwise error code | ||
| 45 | */ | ||
| 46 | Result WaitSynchronization(bool* wait) override { | ||
| 47 | // TODO(bunnei): ImplementMe | 37 | // TODO(bunnei): ImplementMe |
| 48 | *wait = locked; | 38 | bool wait = locked; |
| 49 | |||
| 50 | if (locked) { | 39 | if (locked) { |
| 51 | Kernel::WaitCurrentThread(WAITTYPE_MUTEX, GetHandle()); | 40 | Kernel::WaitCurrentThread(WAITTYPE_MUTEX, GetHandle()); |
| 52 | } | 41 | } |
| 53 | 42 | ||
| 54 | return 0; | 43 | return MakeResult<bool>(wait); |
| 55 | } | 44 | } |
| 56 | }; | 45 | }; |
| 57 | 46 | ||
| @@ -119,15 +108,17 @@ bool ReleaseMutex(Mutex* mutex) { | |||
| 119 | * Releases a mutex | 108 | * Releases a mutex |
| 120 | * @param handle Handle to mutex to release | 109 | * @param handle Handle to mutex to release |
| 121 | */ | 110 | */ |
| 122 | Result ReleaseMutex(Handle handle) { | 111 | ResultCode ReleaseMutex(Handle handle) { |
| 123 | Mutex* mutex = Kernel::g_object_pool.GetFast<Mutex>(handle); | 112 | Mutex* mutex = Kernel::g_object_pool.Get<Mutex>(handle); |
| 124 | 113 | if (mutex == nullptr) return InvalidHandle(ErrorModule::Kernel); | |
| 125 | _assert_msg_(KERNEL, (mutex != nullptr), "ReleaseMutex tried to release a nullptr mutex!"); | ||
| 126 | 114 | ||
| 127 | if (!ReleaseMutex(mutex)) { | 115 | if (!ReleaseMutex(mutex)) { |
| 128 | return -1; | 116 | // TODO(yuriks): Verify error code, this one was pulled out of thin air. I'm not even sure |
| 117 | // what error condition this is supposed to be signaling. | ||
| 118 | return ResultCode(ErrorDescription::AlreadyDone, ErrorModule::Kernel, | ||
| 119 | ErrorSummary::NothingHappened, ErrorLevel::Temporary); | ||
| 129 | } | 120 | } |
| 130 | return 0; | 121 | return RESULT_SUCCESS; |
| 131 | } | 122 | } |
| 132 | 123 | ||
| 133 | /** | 124 | /** |