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/sys/inotify.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/sys/inotify.rs') diff --git a/src/sys/inotify.rs b/src/sys/inotify.rs index 3f5ae22a..d6697a4a 100644 --- a/src/sys/inotify.rs +++ b/src/sys/inotify.rs @@ -36,6 +36,7 @@ use crate::unistd::read; use crate::Result; use crate::NixPath; use crate::errno::Errno; +use cfg_if::cfg_if; libc_bitflags! { /// Configuration options for [`inotify_add_watch`](fn.inotify_add_watch.html). @@ -151,16 +152,15 @@ impl Inotify { /// Returns an EINVAL error if the watch descriptor is invalid. /// /// For more information see, [inotify_rm_watch(2)](https://man7.org/linux/man-pages/man2/inotify_rm_watch.2.html). - #[cfg(target_os = "linux")] pub fn rm_watch(self, wd: WatchDescriptor) -> Result<()> { - let res = unsafe { libc::inotify_rm_watch(self.fd, wd.wd) }; - - Errno::result(res).map(drop) - } - - #[cfg(target_os = "android")] - pub fn rm_watch(self, wd: WatchDescriptor) -> Result<()> { - let res = unsafe { libc::inotify_rm_watch(self.fd, wd.wd as u32) }; + cfg_if! { + if #[cfg(target_os = "linux")] { + let arg = wd.wd; + } else if #[cfg(target_os = "android")] { + let arg = wd.wd as u32; + } + } + let res = unsafe { libc::inotify_rm_watch(self.fd, arg) }; Errno::result(res).map(drop) } -- cgit v1.2.3