Skip to content

Commit be77188

Browse files
committed
Add ppoll()
1 parent 2bb718c commit be77188

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/poll.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std;
2+
use std::time::Duration;
3+
14
use libc;
25
use {Errno, Result};
36

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

4851
Errno::result(res)
4952
}
53+
54+
pub fn ppoll(fds: &mut [PollFd], timeout: Duration) -> Result<libc::c_int> {
55+
56+
let timeout = libc::timespec {
57+
tv_sec: timeout.as_secs() as libc::time_t,
58+
tv_nsec: timeout.subsec_nanos() as libc::c_long,
59+
};
60+
61+
let res = unsafe {
62+
libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd,
63+
fds.len() as libc::nfds_t,
64+
&timeout as *const libc::timespec,
65+
std::ptr::null())
66+
};
67+
Errno::result(res)
68+
}

0 commit comments

Comments
 (0)