From 8b77c61e7d2a8c2bc460a509d89f84701b20db50 Mon Sep 17 00:00:00 2001 From: Timon Kruiper Date: Tue, 17 May 2022 10:19:16 +0200 Subject: [PATCH] Kernel: Use AK::NeverDestroyed to store the timer class For an upcoming change to support interrupts in this driver, this class has to inherit from IRQHandler. That in turn will make this class virtual, which will then actually call the destructor of the class. We don't want this to happen, thus we have to wrap the class in a AK::NeverDestroyed. --- Kernel/Arch/aarch64/RPi/Timer.cpp | 5 +++-- Kernel/Arch/aarch64/RPi/Timer.h | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel/Arch/aarch64/RPi/Timer.cpp b/Kernel/Arch/aarch64/RPi/Timer.cpp index 02b20b2b51..1b7ae0e5f0 100644 --- a/Kernel/Arch/aarch64/RPi/Timer.cpp +++ b/Kernel/Arch/aarch64/RPi/Timer.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -35,8 +36,8 @@ Timer::Timer() Timer& Timer::the() { - static Timer instance; - return instance; + static AK::NeverDestroyed instance; + return *instance; } u64 Timer::microseconds_since_boot() diff --git a/Kernel/Arch/aarch64/RPi/Timer.h b/Kernel/Arch/aarch64/RPi/Timer.h index 7bbaca322a..59216760cf 100644 --- a/Kernel/Arch/aarch64/RPi/Timer.h +++ b/Kernel/Arch/aarch64/RPi/Timer.h @@ -14,6 +14,7 @@ struct TimerRegisters; class Timer { public: + Timer(); static Timer& the(); u64 microseconds_since_boot(); @@ -38,8 +39,6 @@ public: static u32 set_clock_rate(ClockID, u32 rate_hz, bool skip_setting_turbo = true); private: - Timer(); - TimerRegisters volatile* m_registers; };