From 6b7ebb3f82ae9674f2a4d66e870a53102b412003 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 21 Mar 2016 02:48:40 -0400 Subject: [PATCH 1/2] hle: Get rid of global access to g_reschedule This shouldn't be directly exposed if there's already a partial API that operates on it. We can just provide the rest of that API. --- src/core/core.cpp | 2 +- src/core/hle/hle.cpp | 20 ++++++++++++++++---- src/core/hle/hle.h | 4 ++-- src/core/hle/kernel/thread.cpp | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 84d6c392e..609ca860d 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -52,7 +52,7 @@ void RunLoop(int tight_loop) { } HW::Update(); - if (HLE::g_reschedule) { + if (HLE::RescheduleIsPending()) { Kernel::Reschedule(); } } diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 331b1b22a..3b1369800 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -14,9 +14,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// -namespace HLE { +namespace { -bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread +bool reschedule; ///< If true, immediately reschedules the CPU to a new thread + +} + +namespace HLE { void Reschedule(const char *reason) { DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason."); @@ -29,13 +33,21 @@ void Reschedule(const char *reason) { Core::g_app_core->PrepareReschedule(); - g_reschedule = true; + reschedule = true; +} + +bool RescheduleIsPending() { + return reschedule; +} + +void DoneRescheduling() { + reschedule = false; } void Init() { Service::Init(); - g_reschedule = false; + reschedule = false; LOG_DEBUG(Kernel, "initialized OK"); } diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index e0b97797c..58dffe587 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h @@ -13,9 +13,9 @@ const Handle INVALID_HANDLE = 0; namespace HLE { -extern bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread - void Reschedule(const char *reason); +bool RescheduleIsPending(); +void DoneRescheduling(); void Init(); void Shutdown(); diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index bf32f653d..6dc95d0f1 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -483,7 +483,8 @@ void Reschedule() { Thread* cur = GetCurrentThread(); Thread* next = PopNextReadyThread(); - HLE::g_reschedule = false; + + HLE::DoneRescheduling(); // Don't bother switching to the same thread if (next == cur) From 4cb2995c6159a5c6508ea0571ffa5fc5bcd21a47 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 5 May 2016 21:34:10 -0400 Subject: [PATCH 2/2] HLE: Rename RescheduleIsPending to IsReschedulePending. --- src/core/core.cpp | 2 +- src/core/hle/hle.cpp | 2 +- src/core/hle/hle.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 609ca860d..a156682aa 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -52,7 +52,7 @@ void RunLoop(int tight_loop) { } HW::Update(); - if (HLE::RescheduleIsPending()) { + if (HLE::IsReschedulePending()) { Kernel::Reschedule(); } } diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 3b1369800..96d3ec05b 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -36,7 +36,7 @@ void Reschedule(const char *reason) { reschedule = true; } -bool RescheduleIsPending() { +bool IsReschedulePending() { return reschedule; } diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index 58dffe587..69ac0ade6 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h @@ -14,7 +14,7 @@ const Handle INVALID_HANDLE = 0; namespace HLE { void Reschedule(const char *reason); -bool RescheduleIsPending(); +bool IsReschedulePending(); void DoneRescheduling(); void Init();