Fix TimeSpec type.

master
Yuhao Zhou 6 years ago
parent d2f2fa3d97
commit 218bb29cf3

@ -53,20 +53,20 @@ impl TimeVal {
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub struct TimeSpec { pub struct TimeSpec {
sec: u64, sec: usize,
nsec: u64, nsec: usize,
} }
impl TimeSpec { impl TimeSpec {
pub fn to_duration(&self) -> Duration { pub fn to_duration(&self) -> Duration {
Duration::new(self.sec, self.nsec as u32) Duration::new(self.sec as u64, self.nsec as u32)
} }
pub fn get_epoch() -> Self { pub fn get_epoch() -> Self {
let usec = get_epoch_usec(); let usec = get_epoch_usec();
TimeSpec { TimeSpec {
sec: usec / USEC_PER_SEC, sec: (usec / USEC_PER_SEC) as usize,
nsec: usec % USEC_PER_SEC * NSEC_PER_USEC, nsec: (usec % USEC_PER_SEC * NSEC_PER_USEC) as usize,
} }
} }
} }

Loading…
Cancel
Save