1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 23:12:08 +00:00

Revert "Kernel: Switch singletons to use new Singleton class"

This reverts commit f48feae0b2.
This commit is contained in:
Andreas Kling 2020-08-22 17:53:34 +02:00
parent 0addcb45b8
commit 2fd9e72264
44 changed files with 146 additions and 184 deletions

View file

@ -32,7 +32,6 @@
#include <Kernel/Time/HardwareTimer.h>
#include <Kernel/Time/PIT.h>
#include <Kernel/Time/RTC.h>
#include <Kernel/Singleton.h>
#include <Kernel/Time/TimeManagement.h>
#include <Kernel/VM/MemoryManager.h>
@ -40,11 +39,12 @@
namespace Kernel {
static auto s_the = make_singleton<TimeManagement>();
static TimeManagement* s_time_management;
TimeManagement& TimeManagement::the()
{
return *s_the;
ASSERT(s_time_management);
return *s_time_management;
}
bool TimeManagement::is_system_timer(const HardwareTimer& timer) const
@ -65,9 +65,11 @@ time_t TimeManagement::epoch_time() const
void TimeManagement::initialize()
{
ASSERT(!s_the.is_initialized());
s_the.ensure_instance();
ASSERT(!s_time_management);
if (kernel_command_line().lookup("time").value_or("modern") == "legacy")
s_time_management = new TimeManagement(false);
else
s_time_management = new TimeManagement(true);
}
time_t TimeManagement::seconds_since_boot() const
{
@ -88,9 +90,8 @@ time_t TimeManagement::boot_time() const
return RTC::boot_time();
}
TimeManagement::TimeManagement()
TimeManagement::TimeManagement(bool probe_non_legacy_hardware_timers)
{
bool probe_non_legacy_hardware_timers = !(kernel_command_line().lookup("time").value_or("modern") == "legacy");
if (ACPI::is_enabled()) {
if (!ACPI::Parser::the()->x86_specific_flags().cmos_rtc_not_present) {
RTC::initialize();
@ -116,8 +117,7 @@ TimeManagement::TimeManagement()
timeval TimeManagement::now_as_timeval()
{
auto* time_management = s_the.ptr();
return { time_management->epoch_time(), (suseconds_t)time_management->ticks_this_second() * (suseconds_t)1000 };
return { s_time_management->epoch_time(), (suseconds_t)s_time_management->ticks_this_second() * (suseconds_t)1000 };
}
Vector<HardwareTimer*> TimeManagement::scan_and_initialize_periodic_timers()