diff --git a/src/device/events.rs b/src/device/events.rs index 7979b64e..82d3a2f1 100644 --- a/src/device/events.rs +++ b/src/device/events.rs @@ -95,7 +95,7 @@ fn set_next_event(device: &mut device::Device) { pub fn translate_events(device: &mut device::Device, old_count: u64, new_count: u64) { for i in device.cpu.events.iter_mut() { if i.enabled { - i.count = i.count.wrapping_sub(old_count).wrapping_add(new_count); + i.count = new_count + i.count.saturating_sub(old_count); } } set_next_event(device);