diff options
author | Vincent Dagonneau <vincentdagonneau@gmail.com> | 2020-03-19 11:40:53 +0100 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2021-12-20 18:47:16 -0700 |
commit | 5f5b7d4d7a76575673b57e685c13ba2c52c4183e (patch) | |
tree | 75b45fc8b1b70750783e89069bc4d90810c500fe /src/sys/inotify.rs | |
parent | d1c6fed481638405b0a87e5b7eecf82ce89b2268 (diff) | |
download | nix-5f5b7d4d7a76575673b57e685c13ba2c52c4183e.zip |
feature-gate most Nix functions
Using features reduces build time and size for consumer crates. By
default all features are enabled.
Diffstat (limited to 'src/sys/inotify.rs')
-rw-r--r-- | src/sys/inotify.rs | 18 |
1 files changed, 9 insertions, 9 deletions
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) } |