Skip to content

Commit

Permalink
Fix kqueue on platforms where C's long is i32
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed May 19, 2019
1 parent 1b68512 commit 87d7241
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sys/unix/kqueue.rs
Expand Up @@ -74,7 +74,11 @@ impl Selector {
) -> io::Result<bool> {
let timeout = timeout.map(|to| libc::timespec {
tv_sec: cmp::min(to.as_secs(), time_t::max_value() as u64) as time_t,
tv_nsec: libc::c_long::from(to.subsec_nanos()),
// `Duration::subsec_nanos` is guaranteed to be less than one
// billion (the number of nanoseconds in a second), making the
// cast to i32 safe. The cast itself is needed for platforms
// where C's long is only 32 bits.
tv_nsec: libc::c_long::from(to.subsec_nanos() as i32),
});
let timeout = timeout
.as_ref()
Expand Down

0 comments on commit 87d7241

Please sign in to comment.