1 //! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html 2 3 use crate::unix::header::sys_time::{gettimeofday ,timeval, timezone}; 4 5 #[repr(C)] 6 #[derive(Default)] 7 pub struct timeb { 8 pub time: ::time_t, 9 pub millitm: ::c_ushort, 10 pub timezone: ::c_short, 11 pub dstflag: ::c_short, 12 } 13 14 #[no_mangle] 15 pub unsafe extern "C" fn ftime(tp: *mut timeb) -> ::c_int { 16 let mut tv = timeval::default(); 17 let mut tz = timezone::default(); 18 if gettimeofday(&mut tv, &mut tz) < 0 { 19 return -1; 20 } 21 22 (*tp).time = tv.tv_sec; 23 (*tp).millitm = (tv.tv_usec / 1000) as ::c_ushort; 24 (*tp).timezone = tz.tz_minuteswest as ::c_short; 25 (*tp).dstflag = tz.tz_dsttime as ::c_short; 26 27 0 28 } 29