summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.cpp2
-rw-r--r--src/core/arm/unicorn/arm_unicorn.cpp2
-rw-r--r--src/core/core_timing.cpp15
-rw-r--r--src/core/core_timing.h2
-rw-r--r--src/core/cpu_core_manager.cpp4
5 files changed, 12 insertions, 13 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp
index 4d2e99ed0..700c4afff 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic.cpp
@@ -116,7 +116,7 @@ public:
num_interpreted_instructions = 0;
}
u64 GetTicksRemaining() override {
- return std::max<s64>(parent.system.CoreTiming().GetDowncount(), 0LL);
+ return std::max(parent.system.CoreTiming().GetDowncount(), s64{0});
}
u64 GetCNTPCT() override {
return Timing::CpuCyclesToClockCycles(parent.system.CoreTiming().GetTicks());
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp
index 3f91b06d4..d4f41bfc1 100644
--- a/src/core/arm/unicorn/arm_unicorn.cpp
+++ b/src/core/arm/unicorn/arm_unicorn.cpp
@@ -156,7 +156,7 @@ void ARM_Unicorn::Run() {
if (GDBStub::IsServerEnabled()) {
ExecuteInstructions(std::max(4000000, 0));
} else {
- ExecuteInstructions(std::max<s64>(system.CoreTiming().GetDowncount(), 0LL));
+ ExecuteInstructions(std::max(system.CoreTiming().GetDowncount(), s64{0}));
}
}
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 3ca265b4f..780c6843a 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -38,10 +38,8 @@ CoreTiming::CoreTiming() = default;
CoreTiming::~CoreTiming() = default;
void CoreTiming::Initialize() {
- for (std::size_t core = 0; core < num_cpu_cores; core++) {
- downcounts[core] = MAX_SLICE_LENGTH;
- time_slice[core] = MAX_SLICE_LENGTH;
- }
+ downcounts.fill(MAX_SLICE_LENGTH);
+ time_slice.fill(MAX_SLICE_LENGTH);
slice_length = MAX_SLICE_LENGTH;
global_timer = 0;
idled_cycles = 0;
@@ -162,17 +160,17 @@ std::optional<u64> CoreTiming::NextAvailableCore(const s64 needed_ticks) const {
if (time_slice[next_context] >= needed_ticks) {
return {next_context};
} else if (time_slice[next_context] >= 0) {
- return {};
+ return std::nullopt;
}
next_context = (next_context + 1) % num_cpu_cores;
}
- return {};
+ return std::nullopt;
}
void CoreTiming::Advance() {
std::unique_lock<std::mutex> guard(inner_mutex);
- const int cycles_executed = accumulated_ticks;
+ const u64 cycles_executed = accumulated_ticks;
time_slice[current_context] = std::max<s64>(0, time_slice[current_context] - accumulated_ticks);
global_timer += cycles_executed;
@@ -191,7 +189,8 @@ void CoreTiming::Advance() {
// Still events left (scheduled in the future)
if (!event_queue.empty()) {
- s64 needed_ticks = std::min<s64>(event_queue.front().time - global_timer, MAX_SLICE_LENGTH);
+ const s64 needed_ticks =
+ std::min<s64>(event_queue.front().time - global_timer, MAX_SLICE_LENGTH);
const auto next_core = NextAvailableCore(needed_ticks);
if (next_core) {
downcounts[*next_core] = needed_ticks;
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index 8bba45beb..3bb88c810 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -113,7 +113,7 @@ public:
current_context = new_context;
}
- bool CurrentContextCanRun() const {
+ bool CanCurrentContextRun() const {
return time_slice[current_context] > 0;
}
diff --git a/src/core/cpu_core_manager.cpp b/src/core/cpu_core_manager.cpp
index e022e6a60..16b384076 100644
--- a/src/core/cpu_core_manager.cpp
+++ b/src/core/cpu_core_manager.cpp
@@ -130,10 +130,10 @@ void CpuCoreManager::RunLoop(bool tight_loop) {
keep_running = false;
for (active_core = 0; active_core < NUM_CPU_CORES; ++active_core) {
core_timing.SwitchContext(active_core);
- if (core_timing.CurrentContextCanRun()) {
+ if (core_timing.CanCurrentContextRun()) {
cores[active_core]->RunLoop(tight_loop);
}
- keep_running |= core_timing.CurrentContextCanRun();
+ keep_running |= core_timing.CanCurrentContextRun();
}
} while (keep_running);