From 2c6e4ce0ad367f63d2203b6a21e1cf244f344efb Mon Sep 17 00:00:00 2001 From: David Marcec Date: Sat, 21 Sep 2019 19:35:01 +1000 Subject: Deglobalize System: Time --- src/core/hle/service/time/interface.cpp | 4 ++-- src/core/hle/service/time/interface.h | 2 +- src/core/hle/service/time/time.cpp | 25 +++++++++++++++---------- src/core/hle/service/time/time.h | 4 +++- 4 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/time/interface.cpp b/src/core/hle/service/time/interface.cpp index 1030185e0..9565e7de5 100644 --- a/src/core/hle/service/time/interface.cpp +++ b/src/core/hle/service/time/interface.cpp @@ -7,8 +7,8 @@ namespace Service::Time { Time::Time(std::shared_ptr time, std::shared_ptr shared_memory, - const char* name) - : Module::Interface(std::move(time), std::move(shared_memory), name) { + Core::System& system, const char* name) + : Module::Interface(std::move(time), std::move(shared_memory), system, name) { // clang-format off static const FunctionInfo functions[] = { {0, &Time::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, diff --git a/src/core/hle/service/time/interface.h b/src/core/hle/service/time/interface.h index bdf0883e2..5c63a07f4 100644 --- a/src/core/hle/service/time/interface.h +++ b/src/core/hle/service/time/interface.h @@ -13,7 +13,7 @@ class SharedMemory; class Time final : public Module::Interface { public: explicit Time(std::shared_ptr time, std::shared_ptr shared_memory, - const char* name); + Core::System& system, const char* name); ~Time() override; }; diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index ae6446204..1b9ab8401 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -126,8 +126,8 @@ private: class ISteadyClock final : public ServiceFramework { public: - ISteadyClock(std::shared_ptr shared_memory) - : ServiceFramework("ISteadyClock"), shared_memory(shared_memory) { + ISteadyClock(std::shared_ptr shared_memory, Core::System& system) + : ServiceFramework("ISteadyClock"), shared_memory(shared_memory), system(system) { static const FunctionInfo functions[] = { {0, &ISteadyClock::GetCurrentTimePoint, "GetCurrentTimePoint"}, }; @@ -150,12 +150,13 @@ private: } SteadyClockTimePoint GetCurrentTimePoint() const { - const auto& core_timing = Core::System::GetInstance().CoreTiming(); + const auto& core_timing = system.CoreTiming(); const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks()); return {static_cast(ms.count() / 1000), {}}; } std::shared_ptr shared_memory; + Core::System& system; }; class ITimeZoneService final : public ServiceFramework { @@ -290,7 +291,7 @@ void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface(shared_memory); + rb.PushIpcInterface(shared_memory, system); } void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { @@ -325,7 +326,7 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { return; } - const auto& core_timing = Core::System::GetInstance().CoreTiming(); + const auto& core_timing = system.CoreTiming(); const auto ms = Core::Timing::CyclesToMs(core_timing.GetTicks()); const SteadyClockTimePoint steady_clock_time_point{static_cast(ms.count() / 1000), {}}; @@ -407,8 +408,10 @@ void Module::Interface::SetStandardUserSystemClockAutomaticCorrectionEnabled( } Module::Interface::Interface(std::shared_ptr time, - std::shared_ptr shared_memory, const char* name) - : ServiceFramework(name), time(std::move(time)), shared_memory(std::move(shared_memory)) {} + std::shared_ptr shared_memory, Core::System& system, + const char* name) + : ServiceFramework(name), time(std::move(time)), shared_memory(std::move(shared_memory)), + system(system) {} Module::Interface::~Interface() = default; @@ -416,9 +419,11 @@ void InstallInterfaces(Core::System& system) { auto time = std::make_shared(); auto shared_mem = std::make_shared(system); - std::make_shared