Skip to content

Commit

Permalink
Add ppoll()
Browse files Browse the repository at this point in the history
  • Loading branch information
Susurrus committed Feb 23, 2017
1 parent 2bb718c commit be77188
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/poll.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use std;
use std::time::Duration;

use libc;
use {Errno, Result};

Expand Down Expand Up @@ -47,3 +50,19 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result<libc::c_int> {

Errno::result(res)
}

pub fn ppoll(fds: &mut [PollFd], timeout: Duration) -> Result<libc::c_int> {

let timeout = libc::timespec {
tv_sec: timeout.as_secs() as libc::time_t,
tv_nsec: timeout.subsec_nanos() as libc::c_long,
};

let res = unsafe {
libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd,
fds.len() as libc::nfds_t,
&timeout as *const libc::timespec,
std::ptr::null())
};
Errno::result(res)
}

0 comments on commit be77188

Please sign in to comment.