diff options
Diffstat (limited to 'src/core/core_timing.cpp')
| -rw-r--r-- | src/core/core_timing.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index ec9d52a08..6f716b1ca 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -7,8 +7,8 @@ #include <mutex> #include <vector> +#include "common/assert.h" #include "common/chunk_file.h" -#include "common/log.h" #include "core/arm/arm_interface.h" #include "core/core.h" @@ -33,7 +33,7 @@ struct EventType const char* name; }; -std::vector<EventType> event_types; +static std::vector<EventType> event_types; struct BaseEvent { @@ -44,32 +44,32 @@ struct BaseEvent typedef LinkedListItem<BaseEvent> Event; -Event* first; -Event* ts_first; -Event* ts_last; +static Event* first; +static Event* ts_first; +static Event* ts_last; // event pools -Event* event_pool = 0; -Event* event_ts_pool = 0; -int allocated_ts_events = 0; +static Event* event_pool = nullptr; +static Event* event_ts_pool = nullptr; +static int allocated_ts_events = 0; // Optimization to skip MoveEvents when possible. -std::atomic<bool> has_ts_events(false); +static std::atomic<bool> has_ts_events(false); int g_slice_length; -s64 global_timer; -s64 idled_cycles; -s64 last_global_time_ticks; -s64 last_global_time_us; +static s64 global_timer; +static s64 idled_cycles; +static s64 last_global_time_ticks; +static s64 last_global_time_us; static std::recursive_mutex external_event_section; // Warning: not included in save state. using AdvanceCallback = void(int cycles_executed); -AdvanceCallback* advance_callback = nullptr; -std::vector<MHzChangeCallback> mhz_change_callbacks; +static AdvanceCallback* advance_callback = nullptr; +static std::vector<MHzChangeCallback> mhz_change_callbacks; -void FireMhzChange() { +static void FireMhzChange() { for (auto callback : mhz_change_callbacks) callback(); } @@ -97,7 +97,7 @@ u64 GetGlobalTimeUs() { return last_global_time_us + us_since_last; } -Event* GetNewEvent() { +static Event* GetNewEvent() { if (!event_pool) return new Event; @@ -106,7 +106,7 @@ Event* GetNewEvent() { return event; } -Event* GetNewTsEvent() { +static Event* GetNewTsEvent() { allocated_ts_events++; if (!event_ts_pool) @@ -117,23 +117,23 @@ Event* GetNewTsEvent() { return event; } -void FreeEvent(Event* event) { +static void FreeEvent(Event* event) { event->next = event_pool; event_pool = event; } -void FreeTsEvent(Event* event) { +static void FreeTsEvent(Event* event) { event->next = event_ts_pool; event_ts_pool = event; allocated_ts_events--; } int RegisterEvent(const char* name, TimedCallback callback) { - event_types.push_back(EventType(callback, name)); + event_types.emplace_back(callback, name); return (int)event_types.size() - 1; } -void AntiCrashCallback(u64 userdata, int cycles_late) { +static void AntiCrashCallback(u64 userdata, int cycles_late) { LOG_CRITICAL(Core_Timing, "Savestate broken: an unregistered event was called."); Core::Halt("invalid timing events"); } @@ -147,7 +147,7 @@ void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callba void UnregisterAllEvents() { if (first) - PanicAlert("Cannot unregister events with events pending"); + LOG_ERROR(Core_Timing, "Cannot unregister events with events pending"); event_types.clear(); } @@ -228,7 +228,7 @@ void ClearPendingEvents() { } } -void AddEventToQueue(Event* new_event) { +static void AddEventToQueue(Event* new_event) { Event* prev_event = nullptr; Event** next_event = &first; for (;;) { @@ -459,7 +459,7 @@ void MoveEvents() { } void ForceCheck() { - int cycles_executed = g_slice_length - Core::g_app_core->down_count; + s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; global_timer += cycles_executed; // This will cause us to check for new events immediately. Core::g_app_core->down_count = 0; @@ -468,7 +468,7 @@ void ForceCheck() { } void Advance() { - int cycles_executed = g_slice_length - Core::g_app_core->down_count; + s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; global_timer += cycles_executed; Core::g_app_core->down_count = g_slice_length; @@ -504,13 +504,13 @@ void LogPendingEvents() { } void Idle(int max_idle) { - int cycles_down = Core::g_app_core->down_count; + s64 cycles_down = Core::g_app_core->down_count; if (max_idle != 0 && cycles_down > max_idle) cycles_down = max_idle; if (first && cycles_down > 0) { - int cycles_executed = g_slice_length - Core::g_app_core->down_count; - int cycles_next_event = (int)(first->time - global_timer); + s64 cycles_executed = g_slice_length - Core::g_app_core->down_count; + s64 cycles_next_event = first->time - global_timer; if (cycles_next_event < cycles_executed + cycles_down) { cycles_down = cycles_next_event - cycles_executed; @@ -535,7 +535,7 @@ std::string GetScheduledEventsSummary() { while (event) { unsigned int t = event->type; if (t >= event_types.size()) - PanicAlert("Invalid event type"); // %i", t); + LOG_ERROR(Core_Timing, "Invalid event type"); // %i", t); const char* name = event_types[event->type].name; if (!name) name = "[unknown]"; |
