summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2018-07-18 18:55:58 -0700
committerGravatar GitHub2018-07-18 18:55:58 -0700
commit49b0966003caeaafe2f5455d06b16175f02686fb (patch)
tree141c8d3c09f9eca021dddedb17cdc3cc6607a19a /src/core
parentMerge pull request #680 from bunnei/fix-swizz (diff)
parentcore: Make System's default constructor private (diff)
downloadyuzu-49b0966003caeaafe2f5455d06b16175f02686fb.tar.gz
yuzu-49b0966003caeaafe2f5455d06b16175f02686fb.tar.xz
yuzu-49b0966003caeaafe2f5455d06b16175f02686fb.zip
Merge pull request #687 from lioncash/instance
core: Don't construct instance of Core::System, just to access its live instance
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.cpp4
-rw-r--r--src/core/core.h2
-rw-r--r--src/core/hle/kernel/thread.cpp12
3 files changed, 11 insertions, 7 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 82db5cccf..9bd9f4bd9 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -26,11 +26,13 @@ namespace Core {
26 26
27/*static*/ System System::s_instance; 27/*static*/ System System::s_instance;
28 28
29System::System() = default;
30
29System::~System() = default; 31System::~System() = default;
30 32
31/// Runs a CPU core while the system is powered on 33/// Runs a CPU core while the system is powered on
32static void RunCpuCore(std::shared_ptr<Cpu> cpu_state) { 34static void RunCpuCore(std::shared_ptr<Cpu> cpu_state) {
33 while (Core::System().GetInstance().IsPoweredOn()) { 35 while (Core::System::GetInstance().IsPoweredOn()) {
34 cpu_state->RunLoop(true); 36 cpu_state->RunLoop(true);
35 } 37 }
36} 38}
diff --git a/src/core/core.h b/src/core/core.h
index f90f085ad..c6f69f001 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -168,6 +168,8 @@ public:
168 } 168 }
169 169
170private: 170private:
171 System();
172
171 /// Returns the currently running CPU core 173 /// Returns the currently running CPU core
172 Cpu& CurrentCpuCore(); 174 Cpu& CurrentCpuCore();
173 175
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 9a9746585..0b3c66428 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -165,7 +165,7 @@ void Thread::CancelWakeupTimer() {
165static boost::optional<s32> GetNextProcessorId(u64 mask) { 165static boost::optional<s32> GetNextProcessorId(u64 mask) {
166 for (s32 index = 0; index < Core::NUM_CPU_CORES; ++index) { 166 for (s32 index = 0; index < Core::NUM_CPU_CORES; ++index) {
167 if (mask & (1ULL << index)) { 167 if (mask & (1ULL << index)) {
168 if (!Core::System().GetInstance().Scheduler(index)->GetCurrentThread()) { 168 if (!Core::System::GetInstance().Scheduler(index)->GetCurrentThread()) {
169 // Core is enabled and not running any threads, use this one 169 // Core is enabled and not running any threads, use this one
170 return index; 170 return index;
171 } 171 }
@@ -215,14 +215,14 @@ void Thread::ResumeFromWait() {
215 new_processor_id = processor_id; 215 new_processor_id = processor_id;
216 } 216 }
217 if (ideal_core != -1 && 217 if (ideal_core != -1 &&
218 Core::System().GetInstance().Scheduler(ideal_core)->GetCurrentThread() == nullptr) { 218 Core::System::GetInstance().Scheduler(ideal_core)->GetCurrentThread() == nullptr) {
219 new_processor_id = ideal_core; 219 new_processor_id = ideal_core;
220 } 220 }
221 221
222 ASSERT(*new_processor_id < 4); 222 ASSERT(*new_processor_id < 4);
223 223
224 // Add thread to new core's scheduler 224 // Add thread to new core's scheduler
225 auto& next_scheduler = Core::System().GetInstance().Scheduler(*new_processor_id); 225 auto& next_scheduler = Core::System::GetInstance().Scheduler(*new_processor_id);
226 226
227 if (*new_processor_id != processor_id) { 227 if (*new_processor_id != processor_id) {
228 // Remove thread from previous core's scheduler 228 // Remove thread from previous core's scheduler
@@ -325,7 +325,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
325 thread->name = std::move(name); 325 thread->name = std::move(name);
326 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap(); 326 thread->callback_handle = wakeup_callback_handle_table.Create(thread).Unwrap();
327 thread->owner_process = owner_process; 327 thread->owner_process = owner_process;
328 thread->scheduler = Core::System().GetInstance().Scheduler(processor_id); 328 thread->scheduler = Core::System::GetInstance().Scheduler(processor_id);
329 thread->scheduler->AddThread(thread, priority); 329 thread->scheduler->AddThread(thread, priority);
330 330
331 // Find the next available TLS index, and mark it as used 331 // Find the next available TLS index, and mark it as used
@@ -481,14 +481,14 @@ void Thread::ChangeCore(u32 core, u64 mask) {
481 new_processor_id = processor_id; 481 new_processor_id = processor_id;
482 } 482 }
483 if (ideal_core != -1 && 483 if (ideal_core != -1 &&
484 Core::System().GetInstance().Scheduler(ideal_core)->GetCurrentThread() == nullptr) { 484 Core::System::GetInstance().Scheduler(ideal_core)->GetCurrentThread() == nullptr) {
485 new_processor_id = ideal_core; 485 new_processor_id = ideal_core;
486 } 486 }
487 487
488 ASSERT(*new_processor_id < 4); 488 ASSERT(*new_processor_id < 4);
489 489
490 // Add thread to new core's scheduler 490 // Add thread to new core's scheduler
491 auto& next_scheduler = Core::System().GetInstance().Scheduler(*new_processor_id); 491 auto& next_scheduler = Core::System::GetInstance().Scheduler(*new_processor_id);
492 492
493 if (*new_processor_id != processor_id) { 493 if (*new_processor_id != processor_id) {
494 // Remove thread from previous core's scheduler 494 // Remove thread from previous core's scheduler