:: commit e5d96fbb91b48e7f1d06820b7cd7596c382c5d20

Mintsuki <mintsuki@protonmail.com> — 2026-02-22 16:10

parents: 4dca52e001

sys/cpu: Fix integer truncation in stall()

diff --git a/common/sys/cpu.h b/common/sys/cpu.h
index 8c4cf51e..e6099053 100644
--- a/common/sys/cpu.h
+++ b/common/sys/cpu.h
@@ -420,7 +420,7 @@ static inline void stall(uint64_t us) {
         return;
     }
 #endif
-    uint64_t ticks = tsc_freq / 1000000 * us;
+    uint64_t ticks = tsc_freq * us / 1000000;
     uint64_t next_stop = rdtsc() + ticks;
     while (rdtsc() < next_stop);
 }
tab: 248 wrap: offon