diff options
| author | 2015-01-20 18:16:45 -0500 | |
|---|---|---|
| committer | 2015-01-21 20:47:49 -0500 | |
| commit | 15b6a4d9add6b260a2a1a84ab6228addced4f851 (patch) | |
| tree | e9934863ebd6483cabae0f6c280fab7e34eee32e /src/core/hle/kernel | |
| parent | WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" p... (diff) | |
| download | yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.gz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.tar.xz yuzu-15b6a4d9add6b260a2a1a84ab6228addced4f851.zip | |
Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/event.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 9 | ||||
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 24 | ||||
| -rw-r--r-- | src/core/hle/kernel/semaphore.cpp | 28 | ||||
| -rw-r--r-- | src/core/hle/kernel/session.h | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/timer.cpp | 8 |
8 files changed, 39 insertions, 64 deletions
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index bed856020..cdacba1d9 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp | |||
| @@ -28,16 +28,16 @@ public: | |||
| 28 | bool signaled; ///< Whether the event has already been signaled | 28 | bool signaled; ///< Whether the event has already been signaled |
| 29 | std::string name; ///< Name of event (optional) | 29 | std::string name; ///< Name of event (optional) |
| 30 | 30 | ||
| 31 | ResultVal<bool> ShouldWait() override { | 31 | bool ShouldWait() override { |
| 32 | return MakeResult<bool>(!signaled); | 32 | return !signaled; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | ResultVal<bool> Acquire() override { | 35 | void Acquire() override { |
| 36 | _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); | ||
| 37 | |||
| 36 | // Release the event if it's not sticky... | 38 | // Release the event if it's not sticky... |
| 37 | if (reset_type != RESETTYPE_STICKY) | 39 | if (reset_type != RESETTYPE_STICKY) |
| 38 | signaled = false; | 40 | signaled = false; |
| 39 | |||
| 40 | return MakeResult<bool>(true); | ||
| 41 | } | 41 | } |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 1bb0b55bd..c26726223 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -120,13 +120,10 @@ public: | |||
| 120 | * Check if the current thread should wait until the object is available | 120 | * Check if the current thread should wait until the object is available |
| 121 | * @return True if the current thread should wait due to this object being unavailable | 121 | * @return True if the current thread should wait due to this object being unavailable |
| 122 | */ | 122 | */ |
| 123 | virtual ResultVal<bool> ShouldWait() = 0; | 123 | virtual bool ShouldWait() = 0; |
| 124 | 124 | ||
| 125 | /** | 125 | /// Acquire/lock the object if it is available |
| 126 | * Acquire/lock the object if it is available | 126 | virtual void Acquire() = 0; |
| 127 | * @return True if we were able to acquire this object, otherwise false | ||
| 128 | */ | ||
| 129 | virtual ResultVal<bool> Acquire() = 0; | ||
| 130 | 127 | ||
| 131 | /** | 128 | /** |
| 132 | * Add a thread to wait on this object | 129 | * Add a thread to wait on this object |
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 01d2263ff..355824e60 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -27,8 +27,8 @@ public: | |||
| 27 | std::string name; ///< Name of mutex (optional) | 27 | std::string name; ///< Name of mutex (optional) |
| 28 | SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex | 28 | SharedPtr<Thread> current_thread; ///< Thread that has acquired the mutex |
| 29 | 29 | ||
| 30 | ResultVal<bool> ShouldWait() override; | 30 | bool ShouldWait() override; |
| 31 | ResultVal<bool> Acquire() override; | 31 | void Acquire() override; |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 34 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -159,20 +159,14 @@ Handle CreateMutex(bool initial_locked, const std::string& name) { | |||
| 159 | return handle; | 159 | return handle; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | ResultVal<bool> Mutex::ShouldWait() { | 162 | bool Mutex::ShouldWait() { |
| 163 | return MakeResult<bool>(locked && (current_thread != GetCurrentThread())); | 163 | return locked && current_thread != GetCurrentThread(); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | ResultVal<bool> Mutex::Acquire() { | 166 | void Mutex::Acquire() { |
| 167 | bool res = false; | 167 | _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); |
| 168 | 168 | locked = true; | |
| 169 | if (!locked) { | 169 | MutexAcquireLock(this); |
| 170 | // Lock the mutex when the first thread accesses it | ||
| 171 | locked = true; | ||
| 172 | res = true; | ||
| 173 | MutexAcquireLock(this); | ||
| 174 | } | ||
| 175 | |||
| 176 | return MakeResult<bool>(res); | ||
| 177 | } | 170 | } |
| 171 | |||
| 178 | } // namespace | 172 | } // namespace |
diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index 24d41c0b3..274680568 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp | |||
| @@ -24,27 +24,13 @@ public: | |||
| 24 | s32 available_count; ///< Number of free slots left in the semaphore | 24 | s32 available_count; ///< Number of free slots left in the semaphore |
| 25 | std::string name; ///< Name of semaphore (optional) | 25 | std::string name; ///< Name of semaphore (optional) |
| 26 | 26 | ||
| 27 | /** | 27 | bool ShouldWait() override { |
| 28 | * Tests whether a semaphore still has free slots | 28 | return available_count <= 0; |
| 29 | * @return Whether the semaphore is available | ||
| 30 | */ | ||
| 31 | bool IsAvailable() const { | ||
| 32 | return available_count > 0; | ||
| 33 | } | 29 | } |
| 34 | 30 | ||
| 35 | ResultVal<bool> ShouldWait() override { | 31 | void Acquire() override { |
| 36 | return MakeResult<bool>(!IsAvailable()); | 32 | _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); |
| 37 | } | 33 | --available_count; |
| 38 | |||
| 39 | ResultVal<bool> Acquire() override { | ||
| 40 | bool res = false; | ||
| 41 | |||
| 42 | if (IsAvailable()) { | ||
| 43 | --available_count; | ||
| 44 | res = true; | ||
| 45 | } | ||
| 46 | |||
| 47 | return MakeResult<bool>(res); | ||
| 48 | } | 34 | } |
| 49 | }; | 35 | }; |
| 50 | 36 | ||
| @@ -84,8 +70,8 @@ ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { | |||
| 84 | 70 | ||
| 85 | // Notify some of the threads that the semaphore has been released | 71 | // Notify some of the threads that the semaphore has been released |
| 86 | // stop once the semaphore is full again or there are no more waiting threads | 72 | // stop once the semaphore is full again or there are no more waiting threads |
| 87 | while (semaphore->IsAvailable() && semaphore->ReleaseNextThread() != nullptr) { | 73 | while (!semaphore->ShouldWait() && semaphore->ReleaseNextThread() != nullptr) { |
| 88 | --semaphore->available_count; | 74 | semaphore->Acquire(); |
| 89 | } | 75 | } |
| 90 | 76 | ||
| 91 | return RESULT_SUCCESS; | 77 | return RESULT_SUCCESS; |
diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index f0343d9b2..1788e4375 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h | |||
| @@ -57,12 +57,12 @@ public: | |||
| 57 | // TODO(bunnei): These functions exist to satisfy a hardware test with a Session object | 57 | // TODO(bunnei): These functions exist to satisfy a hardware test with a Session object |
| 58 | // passed into WaitSynchronization. Figure out the meaning of them. | 58 | // passed into WaitSynchronization. Figure out the meaning of them. |
| 59 | 59 | ||
| 60 | ResultVal<bool> ShouldWait() override { | 60 | bool ShouldWait() override { |
| 61 | return MakeResult<bool>(true); | 61 | return true; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | ResultVal<bool> Acquire() override { | 64 | void Acquire() override { |
| 65 | return MakeResult<bool>(false); | 65 | _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); |
| 66 | } | 66 | } |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 8a2cf8bf4..7a7f430cf 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -22,12 +22,12 @@ | |||
| 22 | 22 | ||
| 23 | namespace Kernel { | 23 | namespace Kernel { |
| 24 | 24 | ||
| 25 | ResultVal<bool> Thread::ShouldWait() { | 25 | bool Thread::ShouldWait() { |
| 26 | return MakeResult<bool>(status != THREADSTATUS_DORMANT); | 26 | return status != THREADSTATUS_DORMANT; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | ResultVal<bool> Thread::Acquire() { | 29 | void Thread::Acquire() { |
| 30 | return MakeResult<bool>(true); | 30 | _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | // Lists all thread ids that aren't deleted/etc. | 33 | // Lists all thread ids that aren't deleted/etc. |
| @@ -269,9 +269,7 @@ void Thread::ReleaseWaitObject(WaitObject* wait_object) { | |||
| 269 | 269 | ||
| 270 | // Iterate through all waiting objects to check availability... | 270 | // Iterate through all waiting objects to check availability... |
| 271 | for (auto itr = wait_objects.begin(); itr != wait_objects.end(); ++itr) { | 271 | for (auto itr = wait_objects.begin(); itr != wait_objects.end(); ++itr) { |
| 272 | auto res = (*itr)->ShouldWait(); | 272 | if ((*itr)->ShouldWait()) |
| 273 | |||
| 274 | if (*res && res.Succeeded()) | ||
| 275 | wait_all_failed = true; | 273 | wait_all_failed = true; |
| 276 | 274 | ||
| 277 | // The output should be the last index of wait_object | 275 | // The output should be the last index of wait_object |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index b23638bd1..bed9f714a 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -58,8 +58,8 @@ public: | |||
| 58 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } | 58 | inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; } |
| 59 | inline bool IsIdle() const { return idle; } | 59 | inline bool IsIdle() const { return idle; } |
| 60 | 60 | ||
| 61 | ResultVal<bool> ShouldWait() override; | 61 | bool ShouldWait() override; |
| 62 | ResultVal<bool> Acquire() override; | 62 | void Acquire() override; |
| 63 | 63 | ||
| 64 | s32 GetPriority() const { return current_priority; } | 64 | s32 GetPriority() const { return current_priority; } |
| 65 | void SetPriority(s32 priority); | 65 | void SetPriority(s32 priority); |
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 1729cca0f..8d9db92a4 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp | |||
| @@ -29,12 +29,12 @@ public: | |||
| 29 | u64 initial_delay; ///< The delay until the timer fires for the first time | 29 | u64 initial_delay; ///< The delay until the timer fires for the first time |
| 30 | u64 interval_delay; ///< The delay until the timer fires after the first time | 30 | u64 interval_delay; ///< The delay until the timer fires after the first time |
| 31 | 31 | ||
| 32 | ResultVal<bool> ShouldWait() override { | 32 | bool ShouldWait() override { |
| 33 | return MakeResult<bool>(!signaled); | 33 | return !signaled; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | ResultVal<bool> Acquire() override { | 36 | void Acquire() override { |
| 37 | return MakeResult<bool>(true); | 37 | _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); |
| 38 | } | 38 | } |
| 39 | }; | 39 | }; |
| 40 | 40 | ||