summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-07-19 21:39:05 -0400
committerGravatar Lioncash2018-07-19 22:08:56 -0400
commitdbfe82773d98fadac481cd9061f5eda98aebf308 (patch)
treeee1c5f480bcbf95339eff8677f061bbb57d8ee95 /src/core/hle/kernel/svc.cpp
parentMerge pull request #726 from lioncash/overload (diff)
downloadyuzu-dbfe82773d98fadac481cd9061f5eda98aebf308.tar.gz
yuzu-dbfe82773d98fadac481cd9061f5eda98aebf308.tar.xz
yuzu-dbfe82773d98fadac481cd9061f5eda98aebf308.zip
thread: Convert ThreadStatus into an enum class
Makes the thread status strongly typed, so implicit conversions can't happen. It also makes it easier to catch mistakes at compile time.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index c6b0bb442..6b2995fe2 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -133,7 +133,7 @@ static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
133/// Default thread wakeup callback for WaitSynchronization 133/// Default thread wakeup callback for WaitSynchronization
134static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> thread, 134static bool DefaultThreadWakeupCallback(ThreadWakeupReason reason, SharedPtr<Thread> thread,
135 SharedPtr<WaitObject> object, size_t index) { 135 SharedPtr<WaitObject> object, size_t index) {
136 ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY); 136 ASSERT(thread->status == ThreadStatus::WaitSynchAny);
137 137
138 if (reason == ThreadWakeupReason::Timeout) { 138 if (reason == ThreadWakeupReason::Timeout) {
139 thread->SetWaitSynchronizationResult(RESULT_TIMEOUT); 139 thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
@@ -197,7 +197,7 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64
197 object->AddWaitingThread(thread); 197 object->AddWaitingThread(thread);
198 198
199 thread->wait_objects = std::move(objects); 199 thread->wait_objects = std::move(objects);
200 thread->status = THREADSTATUS_WAIT_SYNCH_ANY; 200 thread->status = ThreadStatus::WaitSynchAny;
201 201
202 // Create an event to wake the thread up after the specified nanosecond delay has passed 202 // Create an event to wake the thread up after the specified nanosecond delay has passed
203 thread->WakeAfterDelay(nano_seconds); 203 thread->WakeAfterDelay(nano_seconds);
@@ -217,7 +217,7 @@ static ResultCode CancelSynchronization(Handle thread_handle) {
217 return ERR_INVALID_HANDLE; 217 return ERR_INVALID_HANDLE;
218 } 218 }
219 219
220 ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY); 220 ASSERT(thread->status == ThreadStatus::WaitSynchAny);
221 thread->SetWaitSynchronizationResult( 221 thread->SetWaitSynchronizationResult(
222 ResultCode(ErrorModule::Kernel, ErrCodes::SynchronizationCanceled)); 222 ResultCode(ErrorModule::Kernel, ErrCodes::SynchronizationCanceled));
223 thread->ResumeFromWait(); 223 thread->ResumeFromWait();
@@ -468,8 +468,8 @@ static void ExitProcess() {
468 continue; 468 continue;
469 469
470 // TODO(Subv): When are the other running/ready threads terminated? 470 // TODO(Subv): When are the other running/ready threads terminated?
471 ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY || 471 ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny ||
472 thread->status == THREADSTATUS_WAIT_SYNCH_ALL, 472 thread->status == ThreadStatus::WaitSynchAll,
473 "Exiting processes with non-waiting threads is currently unimplemented"); 473 "Exiting processes with non-waiting threads is currently unimplemented");
474 474
475 thread->Stop(); 475 thread->Stop();
@@ -545,7 +545,7 @@ static ResultCode StartThread(Handle thread_handle) {
545 return ERR_INVALID_HANDLE; 545 return ERR_INVALID_HANDLE;
546 } 546 }
547 547
548 ASSERT(thread->status == THREADSTATUS_DORMANT); 548 ASSERT(thread->status == ThreadStatus::Dormant);
549 549
550 thread->ResumeFromWait(); 550 thread->ResumeFromWait();
551 Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule(); 551 Core::System::GetInstance().CpuCore(thread->processor_id).PrepareReschedule();
@@ -596,7 +596,7 @@ static ResultCode WaitProcessWideKeyAtomic(VAddr mutex_addr, VAddr condition_var
596 current_thread->condvar_wait_address = condition_variable_addr; 596 current_thread->condvar_wait_address = condition_variable_addr;
597 current_thread->mutex_wait_address = mutex_addr; 597 current_thread->mutex_wait_address = mutex_addr;
598 current_thread->wait_handle = thread_handle; 598 current_thread->wait_handle = thread_handle;
599 current_thread->status = THREADSTATUS_WAIT_MUTEX; 599 current_thread->status = ThreadStatus::WaitMutex;
600 current_thread->wakeup_callback = nullptr; 600 current_thread->wakeup_callback = nullptr;
601 601
602 current_thread->WakeAfterDelay(nano_seconds); 602 current_thread->WakeAfterDelay(nano_seconds);
@@ -656,7 +656,7 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
656 if (mutex_val == 0) { 656 if (mutex_val == 0) {
657 // We were able to acquire the mutex, resume this thread. 657 // We were able to acquire the mutex, resume this thread.
658 Memory::Write32(thread->mutex_wait_address, thread->wait_handle); 658 Memory::Write32(thread->mutex_wait_address, thread->wait_handle);
659 ASSERT(thread->status == THREADSTATUS_WAIT_MUTEX); 659 ASSERT(thread->status == ThreadStatus::WaitMutex);
660 thread->ResumeFromWait(); 660 thread->ResumeFromWait();
661 661
662 auto lock_owner = thread->lock_owner; 662 auto lock_owner = thread->lock_owner;
@@ -672,8 +672,8 @@ static ResultCode SignalProcessWideKey(VAddr condition_variable_addr, s32 target
672 Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask); 672 Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask);
673 auto owner = g_handle_table.Get<Thread>(owner_handle); 673 auto owner = g_handle_table.Get<Thread>(owner_handle);
674 ASSERT(owner); 674 ASSERT(owner);
675 ASSERT(thread->status != THREADSTATUS_RUNNING); 675 ASSERT(thread->status != ThreadStatus::Running);
676 thread->status = THREADSTATUS_WAIT_MUTEX; 676 thread->status = ThreadStatus::WaitMutex;
677 thread->wakeup_callback = nullptr; 677 thread->wakeup_callback = nullptr;
678 678
679 // Signal that the mutex now has a waiting thread. 679 // Signal that the mutex now has a waiting thread.