From 5f5b7d4d7a76575673b57e685c13ba2c52c4183e Mon Sep 17 00:00:00 2001 From: Vincent Dagonneau Date: Thu, 19 Mar 2020 11:40:53 +0100 Subject: feature-gate most Nix functions Using features reduces build time and size for consumer crates. By default all features are enabled. --- src/poll.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/poll.rs') diff --git a/src/poll.rs b/src/poll.rs index 8556c1bb..5b181526 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -1,8 +1,4 @@ //! Wait for events to trigger on specific file descriptors -#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] -use crate::sys::time::TimeSpec; -#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] -use crate::sys::signal::SigSet; use std::os::unix::io::{AsRawFd, RawFd}; use crate::Result; @@ -81,15 +77,19 @@ libc_bitflags! { POLLOUT; /// Equivalent to [`POLLIN`](constant.POLLIN.html) #[cfg(not(target_os = "redox"))] + #[cfg_attr(docsrs, doc(cfg(all())))] POLLRDNORM; #[cfg(not(target_os = "redox"))] + #[cfg_attr(docsrs, doc(cfg(all())))] /// Equivalent to [`POLLOUT`](constant.POLLOUT.html) POLLWRNORM; /// Priority band data can be read (generally unused on Linux). #[cfg(not(target_os = "redox"))] + #[cfg_attr(docsrs, doc(cfg(all())))] POLLRDBAND; /// Priority data may be written. #[cfg(not(target_os = "redox"))] + #[cfg_attr(docsrs, doc(cfg(all())))] POLLWRBAND; /// Error condition (only returned in /// [`PollFd::revents`](struct.PollFd.html#method.revents); @@ -142,6 +142,8 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result { Errno::result(res) } +feature! { +#![feature = "signal"] /// `ppoll()` allows an application to safely wait until either a file /// descriptor becomes ready or until a signal is caught. /// ([`poll(2)`](https://man7.org/linux/man-pages/man2/poll.2.html)) @@ -151,7 +153,12 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result { /// specify `None` as `timeout` (it is like `timeout = -1` for `poll`). /// #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] -pub fn ppoll(fds: &mut [PollFd], timeout: Option, sigmask: SigSet) -> Result { +pub fn ppoll( + fds: &mut [PollFd], + timeout: Option, + sigmask: crate::sys::signal::SigSet + ) -> Result +{ let timeout = timeout.as_ref().map_or(core::ptr::null(), |r| r.as_ref()); let res = unsafe { libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd, @@ -161,3 +168,4 @@ pub fn ppoll(fds: &mut [PollFd], timeout: Option, sigmask: SigSet) -> }; Errno::result(res) } +} -- cgit v1.2.3