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:
Dan Gohman
2019-12-16 13:34:22 -08:00
committed by GitHub
parent e21016f773
commit c2ba419409
11 changed files with 40 additions and 26 deletions

View File

@@ -35,7 +35,7 @@ impl PollFd {
}
}
pub fn poll(fds: &mut [PollFd], timeout: i32) -> Result<usize> {
pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result<usize> {
Errno::from_result(unsafe {
libc::poll(
fds.as_mut_ptr() as *mut libc::pollfd,