From f34d3d7e84a1396d4d4f07ec1434b06b1f39bb8a Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 23 Dec 2023 13:58:09 -0500 Subject: core_timing: remove user data value --- src/core/hle/kernel/k_hardware_timer.cpp | 18 ++++++++---------- src/core/hle/kernel/kernel.cpp | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/k_hardware_timer.cpp b/src/core/hle/kernel/k_hardware_timer.cpp index 8e2e40307..2a29a487c 100644 --- a/src/core/hle/kernel/k_hardware_timer.cpp +++ b/src/core/hle/kernel/k_hardware_timer.cpp @@ -10,15 +10,15 @@ namespace Kernel { void KHardwareTimer::Initialize() { // Create the timing callback to register with CoreTiming. - m_event_type = Core::Timing::CreateEvent( - "KHardwareTimer::Callback", [](std::uintptr_t timer_handle, s64, std::chrono::nanoseconds) { - reinterpret_cast(timer_handle)->DoTask(); - return std::nullopt; - }); + m_event_type = Core::Timing::CreateEvent("KHardwareTimer::Callback", + [this](s64, std::chrono::nanoseconds) { + this->DoTask(); + return std::nullopt; + }); } void KHardwareTimer::Finalize() { - m_kernel.System().CoreTiming().UnscheduleEvent(m_event_type, reinterpret_cast(this)); + m_kernel.System().CoreTiming().UnscheduleEvent(m_event_type); m_wakeup_time = std::numeric_limits::max(); m_event_type.reset(); } @@ -57,13 +57,11 @@ void KHardwareTimer::EnableInterrupt(s64 wakeup_time) { m_wakeup_time = wakeup_time; m_kernel.System().CoreTiming().ScheduleEvent(std::chrono::nanoseconds{m_wakeup_time}, - m_event_type, reinterpret_cast(this), - true); + m_event_type, true); } void KHardwareTimer::DisableInterrupt() { - m_kernel.System().CoreTiming().UnscheduleEventWithoutWait(m_event_type, - reinterpret_cast(this)); + m_kernel.System().CoreTiming().UnscheduleEventWithoutWait(m_event_type); m_wakeup_time = std::numeric_limits::max(); } diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index e479dacde..b515f6a18 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -247,7 +247,7 @@ struct KernelCore::Impl { void InitializePreemption(KernelCore& kernel) { preemption_event = Core::Timing::CreateEvent( "PreemptionCallback", - [this, &kernel](std::uintptr_t, s64 time, + [this, &kernel](s64 time, std::chrono::nanoseconds) -> std::optional { { KScopedSchedulerLock lock(kernel); -- cgit v1.2.3 From 575db0417278eef0c854900885734fd068b97430 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 23 Dec 2023 14:06:41 -0500 Subject: core_timing: use static typing for no-wait unschedule --- src/core/core_timing.cpp | 5 +++-- src/core/core_timing.h | 12 +++++++----- src/core/hle/kernel/k_hardware_timer.cpp | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 3b7b0aa45..d08c007bb 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -143,7 +143,8 @@ void CoreTiming::ScheduleLoopingEvent(std::chrono::nanoseconds start_time, event.Set(); } -void CoreTiming::UnscheduleEvent(const std::shared_ptr& event_type, bool wait) { +void CoreTiming::UnscheduleEvent(const std::shared_ptr& event_type, + UnscheduleEventType type) { { std::scoped_lock lk{basic_lock}; @@ -161,7 +162,7 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr& event_type, b } // Force any in-progress events to finish - if (wait) { + if (type == UnscheduleEventType::Wait) { std::scoped_lock lk{advance_lock}; } } diff --git a/src/core/core_timing.h b/src/core/core_timing.h index d86337cdc..d8cd599ee 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -35,6 +35,11 @@ struct EventType { const std::string name; }; +enum class UnscheduleEventType { + Wait, + NoWait, +}; + /** * This is a system to schedule events into the emulated machine's future. Time is measured * in main CPU clock cycles. @@ -98,11 +103,8 @@ public: const std::shared_ptr& event_type, bool absolute_time = false); - void UnscheduleEvent(const std::shared_ptr& event_type, bool wait = true); - - void UnscheduleEventWithoutWait(const std::shared_ptr& event_type) { - UnscheduleEvent(event_type, false); - } + void UnscheduleEvent(const std::shared_ptr& event_type, + UnscheduleEventType type = UnscheduleEventType::Wait); void AddTicks(u64 ticks_to_add); diff --git a/src/core/hle/kernel/k_hardware_timer.cpp b/src/core/hle/kernel/k_hardware_timer.cpp index 2a29a487c..4e947dd6b 100644 --- a/src/core/hle/kernel/k_hardware_timer.cpp +++ b/src/core/hle/kernel/k_hardware_timer.cpp @@ -61,7 +61,8 @@ void KHardwareTimer::EnableInterrupt(s64 wakeup_time) { } void KHardwareTimer::DisableInterrupt() { - m_kernel.System().CoreTiming().UnscheduleEventWithoutWait(m_event_type); + m_kernel.System().CoreTiming().UnscheduleEvent(m_event_type, + Core::Timing::UnscheduleEventType::NoWait); m_wakeup_time = std::numeric_limits::max(); } -- cgit v1.2.3