diff --git a/src/header/mod.rs b/src/header/mod.rs index 2760b38f87..09596767a6 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -55,6 +55,7 @@ pub mod sys_socket; pub mod sys_stat; pub mod sys_statvfs; pub mod sys_time; +#[deprecated] pub mod sys_timeb; //pub mod sys_times; pub mod arch_aarch64_user; diff --git a/src/header/sys_timeb/mod.rs b/src/header/sys_timeb/mod.rs index c1e434bcd4..57c11e1c2b 100644 --- a/src/header/sys_timeb/mod.rs +++ b/src/header/sys_timeb/mod.rs @@ -1,10 +1,21 @@ -//! sys/time implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/systime.h.html +//! `sys/timeb.h` implementation. +//! +//! See . +//! +//! # Deprecation +//! The `ftime()` function was marked as legacy in the Open Group Base +//! Specifications Issue 6, and the entire `sys/timeb.h` header was removed in +//! Issue 7. + +// TODO: set this for entire crate when possible +#![deny(unsafe_op_in_unsafe_fn)] use crate::{ header::sys_time::{gettimeofday, timeval, timezone}, platform::types::*, }; +/// See . #[repr(C)] #[derive(Default)] pub struct timeb { @@ -14,18 +25,21 @@ pub struct timeb { pub dstflag: c_short, } +/// See . #[no_mangle] pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int { + let tp_mut = unsafe { &mut *tp }; + let mut tv = timeval::default(); let mut tz = timezone::default(); - if gettimeofday(&mut tv, &mut tz) < 0 { + if unsafe { gettimeofday(&mut tv, &mut tz) } < 0 { return -1; } - (*tp).time = tv.tv_sec; - (*tp).millitm = (tv.tv_usec / 1000) as c_ushort; - (*tp).timezone = tz.tz_minuteswest as c_short; - (*tp).dstflag = tz.tz_dsttime as c_short; + tp_mut.time = tv.tv_sec; + tp_mut.millitm = (tv.tv_usec / 1000) as c_ushort; + tp_mut.timezone = tz.tz_minuteswest as c_short; + tp_mut.dstflag = tz.tz_dsttime as c_short; 0 }