Skip to content

Commit

Permalink
Auto merge of #520 - Susurrus:master, r=fiveop
Browse files Browse the repository at this point in the history
Add ppoll()

This will currently fail CI, as the necessary changes haven't hit libc yet. That is tracked in rust-lang/libc#537. This does build on my computer using the changes tracked on that PR, so I'd appreciate any visual review of this code as it should be "done".

I also wanted to get this submitted so hopefully it'd be in the queue for the 0.8 release.
  • Loading branch information
homu committed Feb 26, 2017
2 parents 4ab234c + 5d4967e commit d4d790e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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
- `::nix::sys::termios::{cfgetispeed, cfsetispeed, cfgetospeed, cfsetospeed}`
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;
#[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)
}

0 comments on commit d4d790e

Please sign in to comment.