Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ppoll() #520

Merged
merged 1 commit into from
Feb 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#508](https://github.com/nix-rust/nix/pull/508))
- Fixed the style of many bitflags and use `libc` in more places.
([#503](https://github.com/nix-rust/nix/pull/503))
- Added `ppoll` in `::nix::poll`
([#520](https://github.com/nix-rust/nix/pull/520))

### Changed
- `epoll_ctl` now could accept None as argument `event`
Expand Down
18 changes: 18 additions & 0 deletions src/poll.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#[cfg(any(target_os = "linux", target_os = "android"))]
use sys::time::TimeSpec;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to conditional include this and SigSet. This is why the build fails on macos.

#[cfg(any(target_os = "linux", target_os = "android"))]
use sys::signal::SigSet;

use libc;
use {Errno, Result};

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

Errno::result(res)
}

#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn ppoll(fds: &mut [PollFd], timeout: TimeSpec, sigmask: SigSet) -> Result<libc::c_int> {


let res = unsafe {
libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd,
fds.len() as libc::nfds_t,
timeout.as_ref(),
sigmask.as_ref())
};
Errno::result(res)
}