Misc yanix fixes (#715)
* Correctly handle possibly misaligned pointers in readdir This reapplies #615, which was inadvertently reverted. * Tidy up unneeded `self::` qualifiers. * Make Dir's contents private. Also remove the `unsafe` from `impl_iter`. With `Dir`'s field being private, we can rely on the pointer being only what we've assigned to it. * Make `poll`'s timeout argument a `libc::c_int`. This clarifies that there are no subsequent conversions before calling the underlying libc API. * Use clock_gettime instead of clock_getres to get the time. * Mark FileType::from_raw as safe. It handles unknown values, so it can be marked safe.
This commit is contained in:
@@ -27,3 +27,11 @@ pub fn clock_getres(clock_id: ClockId) -> Result<libc::timespec> {
|
||||
})?;
|
||||
Ok(unsafe { timespec.assume_init() })
|
||||
}
|
||||
|
||||
pub fn clock_gettime(clock_id: ClockId) -> Result<libc::timespec> {
|
||||
let mut timespec = MaybeUninit::<libc::timespec>::uninit();
|
||||
Errno::from_success_code(unsafe {
|
||||
libc::clock_gettime(clock_id.as_raw(), timespec.as_mut_ptr())
|
||||
})?;
|
||||
Ok(unsafe { timespec.assume_init() })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user