Use Out for out-pointer in ftime()
This commit is contained in:
committed by
Jeremy Soller
parent
b6ff0f89f7
commit
9eddd8a73e
@@ -7,17 +7,15 @@
|
||||
//! Specifications Issue 6, and the entire `sys/timeb.h` header was removed in
|
||||
//! Issue 7.
|
||||
|
||||
use core::ptr::NonNull;
|
||||
|
||||
#[allow(deprecated)]
|
||||
use crate::header::sys_time::gettimeofday;
|
||||
use crate::{
|
||||
header::{sys_select::timeval, sys_time::timezone},
|
||||
out::Out,
|
||||
platform::types::{c_int, c_short, c_ushort, time_t},
|
||||
};
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/timeb.h.html>.
|
||||
#[deprecated]
|
||||
#[repr(C)]
|
||||
#[derive(Default)]
|
||||
pub struct timeb {
|
||||
@@ -30,14 +28,13 @@ pub struct timeb {
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/009695399/functions/ftime.html>.
|
||||
///
|
||||
/// # Safety
|
||||
/// The caller must ensure that `tp` is convertible to a `&mut
|
||||
/// MaybeUninit<timeb>`.
|
||||
#[deprecated]
|
||||
/// The caller must ensure that `tp` is convertible to an [`Out<timeb>`].
|
||||
#[allow(deprecated)]
|
||||
#[deprecated]
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int {
|
||||
// SAFETY: the caller is required to ensure that the pointer is valid.
|
||||
let tp_maybe_uninit = unsafe { NonNull::new_unchecked(tp).as_uninit_mut() };
|
||||
let mut tp_out = unsafe { Out::nonnull(tp) };
|
||||
|
||||
let mut tv = timeval::default();
|
||||
let mut tz = timezone::default();
|
||||
@@ -53,7 +50,7 @@ pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int {
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
tp_maybe_uninit.write(timeb {
|
||||
tp_out.write(timeb {
|
||||
time: tv.tv_sec,
|
||||
millitm: (tv.tv_usec / 1000) as c_ushort,
|
||||
timezone: tz.tz_minuteswest as c_short,
|
||||
|
||||
Reference in New Issue
Block a user