diff --git a/src/core/core.cpp b/src/core/core.cpp index 65c73f03b..ff6da91e7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -61,6 +61,11 @@ Kernel::KernelSystem& Global() { return System::GetInstance().Kernel(); } +template <> +Core::Timing& Global() { + return System::GetInstance().CoreTiming(); +} + System::~System() = default; System::ResultStatus System::RunLoop(bool tight_loop) { diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 67fab0dae..493bb6344 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -11,8 +11,6 @@ namespace Core { -Timing* Timing::deserializing = nullptr; - // Sort by time, unless the times are the same, in which case sort by the order added to the queue bool Timing::Event::operator>(const Timing::Event& right) const { return std::tie(time, fifo_order) > std::tie(right.time, right.fifo_order); diff --git a/src/core/core_timing.h b/src/core/core_timing.h index cbe17b36b..bb34c79b0 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -28,6 +28,7 @@ #include "common/common_types.h" #include "common/logging/log.h" #include "common/threadsafe_queue.h" +#include "core/global.h" // The timing we get from the assembly is 268,111,855.956 Hz // It is possible that this number isn't just an integer because the compiler could have @@ -135,8 +136,6 @@ struct TimingEventType { }; class Timing { -private: - static Timing* deserializing; public: struct Event { @@ -165,7 +164,7 @@ public: ar& userdata; std::string name; ar >> name; - type = Timing::deserializing->RegisterEvent(name, nullptr); + type = Global().RegisterEvent(name, nullptr); } friend class boost::serialization::access; @@ -291,11 +290,9 @@ private: template void serialize(Archive& ar, const unsigned int) { // event_types set during initialization of other things - deserializing = this; ar& global_timer; ar& timers; ar& current_timer; - deserializing = nullptr; } friend class boost::serialization::access; }; diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h index 6468c0630..658e6f20c 100644 --- a/src/core/file_sys/archive_backend.h +++ b/src/core/file_sys/archive_backend.h @@ -196,7 +196,7 @@ public: } protected: - std::unique_ptr delay_generator; // TODO: Replace with virtual GetOpenDelayNs + std::unique_ptr delay_generator; private: template diff --git a/src/core/file_sys/archive_ncch.h b/src/core/file_sys/archive_ncch.h index 2d38f9a2e..76b8d4655 100644 --- a/src/core/file_sys/archive_ncch.h +++ b/src/core/file_sys/archive_ncch.h @@ -68,8 +68,8 @@ protected: Service::FS::MediaType media_type; private: - NCCHArchive() = default; // NOTE: If the public ctor has behaviour, need to replace this with - // *_construct_data + NCCHArchive() = default; + template void serialize(Archive& ar, const unsigned int) { ar& boost::serialization::base_object(*this); diff --git a/src/core/global.h b/src/core/global.h index 83bd4fc80..794d71f94 100644 --- a/src/core/global.h +++ b/src/core/global.h @@ -9,9 +9,13 @@ namespace Core { template T& Global(); -// Declare explicit specialisation to prevent im +// Declare explicit specialisation to prevent automatic instantiation class System; template <> System& Global(); +class Timing; +template <> +Timing& Global(); + } // namespace Core