Remove uses of mem::uninitialized in std::sys::cloudabi
Usages still appear in cloudabi tests and in the reentrant mutex implementation
This commit is contained in:
parent
e649e90344
commit
e1e0df8a49
@ -273,6 +273,7 @@
|
||||
#![feature(link_args)]
|
||||
#![feature(linkage)]
|
||||
#![feature(maybe_uninit_ref)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(mem_take)]
|
||||
#![feature(needs_panic_runtime)]
|
||||
#![feature(never_type)]
|
||||
|
@ -79,16 +79,21 @@ impl Condvar {
|
||||
},
|
||||
..mem::zeroed()
|
||||
};
|
||||
let mut event: abi::event = mem::uninitialized();
|
||||
let mut nevents: usize = mem::uninitialized();
|
||||
let ret = abi::poll(&subscription, &mut event, 1, &mut nevents);
|
||||
let mut event: mem::MaybeUninit<abi::event> = mem::MaybeUninit::uninit();
|
||||
let mut nevents: mem::MaybeUninit<usize> = mem::MaybeUninit::uninit();
|
||||
let ret = abi::poll(
|
||||
&subscription,
|
||||
event.as_mut_ptr(),
|
||||
1,
|
||||
nevents.get_mut()
|
||||
);
|
||||
assert_eq!(
|
||||
ret,
|
||||
abi::errno::SUCCESS,
|
||||
"Failed to wait on condition variable"
|
||||
);
|
||||
assert_eq!(
|
||||
event.error,
|
||||
event.assume_init().error,
|
||||
abi::errno::SUCCESS,
|
||||
"Failed to wait on condition variable"
|
||||
);
|
||||
@ -131,21 +136,27 @@ impl Condvar {
|
||||
..mem::zeroed()
|
||||
},
|
||||
];
|
||||
let mut events: [abi::event; 2] = mem::uninitialized();
|
||||
let mut nevents: usize = mem::uninitialized();
|
||||
let ret = abi::poll(subscriptions.as_ptr(), events.as_mut_ptr(), 2, &mut nevents);
|
||||
let mut events: [mem::MaybeUninit<abi::event>; 2] = [mem::MaybeUninit::uninit(); 2];
|
||||
let mut nevents: mem::MaybeUninit<usize> = mem::MaybeUninit::uninit();
|
||||
let ret = abi::poll(
|
||||
subscriptions.as_ptr(),
|
||||
mem::MaybeUninit::first_ptr_mut(&mut events),
|
||||
2,
|
||||
nevents.get_mut()
|
||||
);
|
||||
assert_eq!(
|
||||
ret,
|
||||
abi::errno::SUCCESS,
|
||||
"Failed to wait on condition variable"
|
||||
);
|
||||
let nevents = nevents.assume_init();
|
||||
for i in 0..nevents {
|
||||
assert_eq!(
|
||||
events[i].error,
|
||||
events[i].assume_init().error,
|
||||
abi::errno::SUCCESS,
|
||||
"Failed to wait on condition variable"
|
||||
);
|
||||
if events[i].type_ == abi::eventtype::CONDVAR {
|
||||
if events[i].assume_init().type_ == abi::eventtype::CONDVAR {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,11 @@ pub use libc::strlen;
|
||||
|
||||
pub fn hashmap_random_keys() -> (u64, u64) {
|
||||
unsafe {
|
||||
let mut v = mem::uninitialized();
|
||||
libc::arc4random_buf(&mut v as *mut _ as *mut libc::c_void, mem::size_of_val(&v));
|
||||
v
|
||||
let mut v: mem::MaybeUninit<(u64, u64)> = mem::MaybeUninit::uninit();
|
||||
libc::arc4random_buf(
|
||||
v.as_mut_ptr() as *mut libc::c_void,
|
||||
mem::size_of_val(v.get_ref())
|
||||
);
|
||||
v.assume_init()
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ pub fn checked_dur2intervals(dur: &Duration) -> Option<abi::timestamp> {
|
||||
impl Instant {
|
||||
pub fn now() -> Instant {
|
||||
unsafe {
|
||||
let mut t = mem::uninitialized();
|
||||
let ret = abi::clock_time_get(abi::clockid::MONOTONIC, 0, &mut t);
|
||||
let mut t: mem::MaybeUninit<abi::timestamp> = mem::MaybeUninit::uninit();
|
||||
let ret = abi::clock_time_get(abi::clockid::MONOTONIC, 0, t.get_mut());
|
||||
assert_eq!(ret, abi::errno::SUCCESS);
|
||||
Instant { t }
|
||||
}
|
||||
@ -59,8 +59,8 @@ pub struct SystemTime {
|
||||
impl SystemTime {
|
||||
pub fn now() -> SystemTime {
|
||||
unsafe {
|
||||
let mut t = mem::uninitialized();
|
||||
let ret = abi::clock_time_get(abi::clockid::REALTIME, 0, &mut t);
|
||||
let mut t: mem::MaybeUninit<abi::timestamp> = mem::MaybeUninit::uninit();
|
||||
let ret = abi::clock_time_get(abi::clockid::REALTIME, 0, t.get_mut());
|
||||
assert_eq!(ret, abi::errno::SUCCESS);
|
||||
SystemTime { t }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user