From 700334753d9160e717479504ea39250b45ed0fe8 Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Sat, 27 Jul 2024 09:52:12 +0300 Subject: [PATCH] cellMic: Fix potential overflow --- rpcs3/Emu/Cell/Modules/cellMic.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMic.cpp b/rpcs3/Emu/Cell/Modules/cellMic.cpp index df2bca2762..7f3c987231 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMic.cpp @@ -73,14 +73,13 @@ void mic_context::operator()() // Timestep in microseconds constexpr u64 TIMESTEP = 256ull * 1'000'000ull / 48000ull; u64 timeout = 0; - u32 oldvalue = 0; while (thread_ctrl::state() != thread_state::aborting) { if (timeout != 0) { - thread_ctrl::wait_on(wakey, oldvalue, timeout); - oldvalue = wakey; + thread_ctrl::wait_on(wakey, 0, timeout); + wakey.store(0); } std::lock_guard lock(mutex); @@ -124,7 +123,7 @@ void mic_context::operator()() void mic_context::wake_up() { - wakey++; + wakey.store(1); wakey.notify_one(); }