Merge pull request #4224 from FearlessTobi/port-1310

Port #734 and #1310 from yuzu: Changes to Thread-related enums
This commit is contained in:
Weiyi Wang 2018-09-25 23:07:43 -04:00 committed by GitHub
commit f05740a5fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 126 additions and 124 deletions

View file

@ -161,8 +161,8 @@ static void ExitProcess() {
continue;
// TODO(Subv): When are the other running/ready threads terminated?
ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY ||
thread->status == THREADSTATUS_WAIT_SYNCH_ALL,
ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny ||
thread->status == ThreadStatus::WaitSynchAll,
"Exiting processes with non-waiting threads is currently unimplemented");
thread->Stop();
@ -283,14 +283,14 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
thread->wait_objects = {object};
object->AddWaitingThread(thread);
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
thread->status = ThreadStatus::WaitSynchAny;
// Create an event to wake the thread up after the specified nanosecond delay has passed
thread->WakeAfterDelay(nano_seconds);
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
SharedPtr<WaitObject> object) {
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
if (reason == ThreadWakeupReason::Timeout) {
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
@ -365,7 +365,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
return RESULT_TIMEOUT;
// Put the thread to sleep
thread->status = THREADSTATUS_WAIT_SYNCH_ALL;
thread->status = ThreadStatus::WaitSynchAll;
// Add the thread to each of the objects' waiting threads.
for (auto& object : objects) {
@ -379,7 +379,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
SharedPtr<WaitObject> object) {
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ALL);
ASSERT(thread->status == ThreadStatus::WaitSynchAll);
if (reason == ThreadWakeupReason::Timeout) {
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
@ -421,7 +421,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
return RESULT_TIMEOUT;
// Put the thread to sleep
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
thread->status = ThreadStatus::WaitSynchAny;
// Add the thread to each of the objects' waiting threads.
for (std::size_t i = 0; i < objects.size(); ++i) {
@ -439,7 +439,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
SharedPtr<WaitObject> object) {
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
if (reason == ThreadWakeupReason::Timeout) {
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
@ -578,7 +578,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
// No objects were ready to be acquired, prepare to suspend the thread.
// Put the thread to sleep
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
thread->status = ThreadStatus::WaitSynchAny;
// Add the thread to each of the objects' waiting threads.
for (std::size_t i = 0; i < objects.size(); ++i) {
@ -590,7 +590,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
SharedPtr<WaitObject> object) {
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
ASSERT(reason == ThreadWakeupReason::Signal);
ResultCode result = RESULT_SUCCESS;
@ -729,7 +729,7 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
u32 stack_top, s32 processor_id) {
std::string name = fmt::format("thread-{:08X}", entry_point);
if (priority > THREADPRIO_LOWEST) {
if (priority > ThreadPrioLowest) {
return ERR_OUT_OF_RANGE;
}
@ -738,20 +738,20 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
return ERR_NOT_AUTHORIZED;
}
if (processor_id == THREADPROCESSORID_DEFAULT) {
if (processor_id == ThreadProcessorIdDefault) {
// Set the target CPU to the one specified in the process' exheader.
processor_id = g_current_process->ideal_processor;
ASSERT(processor_id != THREADPROCESSORID_DEFAULT);
ASSERT(processor_id != ThreadProcessorIdDefault);
}
switch (processor_id) {
case THREADPROCESSORID_0:
case ThreadProcessorId0:
break;
case THREADPROCESSORID_ALL:
case ThreadProcessorIdAll:
LOG_INFO(Kernel_SVC,
"Newly created thread is allowed to be run in any Core, unimplemented.");
break;
case THREADPROCESSORID_1:
case ThreadProcessorId1:
LOG_ERROR(Kernel_SVC,
"Newly created thread must run in the SysCore (Core1), unimplemented.");
break;
@ -800,7 +800,7 @@ static ResultCode GetThreadPriority(u32* priority, Handle handle) {
/// Sets the priority for the specified thread
static ResultCode SetThreadPriority(Handle handle, u32 priority) {
if (priority > THREADPRIO_LOWEST) {
if (priority > ThreadPrioLowest) {
return ERR_OUT_OF_RANGE;
}