summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2017-02-26 22:14:50 +0900
committerHomu <homu@barosl.com>2017-02-26 22:14:50 +0900
commitd4d790ed8de851e42696ead049339dae4dfb77f2 (patch)
tree97865587c5373f87072e81283abcdcce49aac043
parent4ab234cd67249d8e74256079435187df6ef1a418 (diff)
parent5d4967ee9af8b2feeffd18534eef433066ad36c5 (diff)
downloadnix-d4d790ed8de851e42696ead049339dae4dfb77f2.zip
Auto merge of #520 - Susurrus:master, r=fiveop
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.
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/poll.rs18
2 files changed, 20 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb3aeedb..fd7bb095 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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}`
diff --git a/src/poll.rs b/src/poll.rs
index 72988d8c..8a3de5f1 100644
--- a/src/poll.rs
+++ b/src/poll.rs
@@ -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};
@@ -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)
+}