use common::{callbacks::FnCall, Opaque};
use crate::bindings::{
- self, qemu_clock_get_ns, timer_del, timer_init_full, timer_mod, QEMUClockType,
+ self, qemu_clock_get_ns, timer_del, timer_expire_time_ns, timer_init_full, timer_mod,
+ timer_mod_ns, QEMUClockType,
};
/// A safe wrapper around [`bindings::QEMUTimer`].
}
}
+ pub fn expire_time_ns(&self) -> Option<i64> {
+ // SAFETY: the only way to obtain a Timer safely is via methods that
+ // take a Pin<&mut Self>, therefore the timer is pinned
+ let ret = unsafe { timer_expire_time_ns(self.as_ptr()) };
+ i64::try_from(ret).ok()
+ }
+
+ pub fn modify_ns(&self, expire_time: u64) {
+ // SAFETY: the only way to obtain a Timer safely is via methods that
+ // take a Pin<&mut Self>, therefore the timer is pinned
+ unsafe { timer_mod_ns(self.as_mut_ptr(), expire_time.try_into().unwrap()) }
+ }
+
pub fn modify(&self, expire_time: u64) {
// SAFETY: the only way to obtain a Timer safely is via methods that
// take a Pin<&mut Self>, therefore the timer is pinned