diff --git a/src/fcntl.rs b/src/fcntl.rs index e4f0417b7a..5853b62f12 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -22,11 +22,7 @@ use std::os::unix::io::RawFd; all(target_os = "freebsd", target_arch = "x86_64"), ))] use std::path::PathBuf; -#[cfg(any( - target_os = "android", - target_os = "freebsd", - target_os = "linux" -))] +#[cfg(any(linux_android, target_os = "freebsd"))] use std::{ os::unix::io::{AsFd, AsRawFd}, ptr, @@ -36,8 +32,7 @@ use std::{ use crate::{sys::stat::Mode, NixPath, Result}; #[cfg(any( - target_os = "linux", - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", target_os = "wasi", @@ -81,10 +76,11 @@ libc_bitflags!( /// Open the file in append-only mode. O_APPEND; /// Generate a signal when input or output becomes possible. - #[cfg(not(any(target_os = "aix", - target_os = "illumos", - target_os = "solaris", - target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "aix", + target_os = "haiku" + )))] O_ASYNC; /// Closes the file descriptor once an `execve` call is made. /// @@ -93,19 +89,18 @@ libc_bitflags!( /// Create the file if it does not exist. O_CREAT; /// Try to minimize cache effects of the I/O for this file. - #[cfg(any(target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd"))] + #[cfg(any( + freebsdlike, + linux_android, + target_os = "netbsd" + ))] O_DIRECT; /// If the specified path isn't a directory, fail. #[cfg(not(solarish))] O_DIRECTORY; /// Implicitly follow each `write()` with an `fdatasync()`. - #[cfg(any(target_os = "android", + #[cfg(any(linux_android, apple_targets, - target_os = "linux", target_os = "netbsd", target_os = "openbsd"))] O_DSYNC; @@ -144,7 +139,7 @@ libc_bitflags!( /// Obtain a file descriptor for low-level access. /// /// The file itself is not opened and other file operations will fail. - #[cfg(any(target_os = "android", target_os = "linux", target_os = "redox"))] + #[cfg(any(linux_android, target_os = "redox"))] O_PATH; /// Only allow reading. /// @@ -184,7 +179,7 @@ libc_bitflags!( /// Computes the raw fd consumed by a function of the form `*at`. #[cfg(any( all(feature = "fs", not(target_os = "redox")), - all(feature = "process", any(target_os = "android", target_os = "linux")), + all(feature = "process", linux_android), all(feature = "fanotify", target_os = "linux") ))] pub(crate) fn at_rawfd(fd: Option) -> raw::c_int { @@ -346,8 +341,7 @@ fn inner_readlink( ) } #[cfg(not(any( - target_os = "android", - target_os = "linux", + linux_android, target_os = "redox" )))] Some(dirfd) => super::sys::stat::fstatat( @@ -406,7 +400,7 @@ pub fn readlinkat( } } -#[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))] +#[cfg(any(linux_android, target_os = "freebsd"))] #[cfg(feature = "fs")] libc_bitflags!( /// Additional flags for file sealing, which allows for limiting operations on a file. @@ -460,14 +454,12 @@ pub enum FcntlArg<'a> { #[cfg(linux_android)] F_OFD_GETLK(&'a mut libc::flock), #[cfg(any( - target_os = "android", - target_os = "linux", + linux_android, target_os = "freebsd" ))] F_ADD_SEALS(SealFlag), #[cfg(any( - target_os = "android", - target_os = "linux", + linux_android, target_os = "freebsd" ))] F_GET_SEALS, @@ -530,16 +522,14 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result { #[cfg(linux_android)] F_OFD_GETLK(flock) => libc::fcntl(fd, libc::F_OFD_GETLK, flock), #[cfg(any( - target_os = "android", - target_os = "linux", + linux_android, target_os = "freebsd" ))] F_ADD_SEALS(flag) => { libc::fcntl(fd, libc::F_ADD_SEALS, flag.bits()) } #[cfg(any( - target_os = "android", - target_os = "linux", + linux_android, target_os = "freebsd" ))] F_GET_SEALS => libc::fcntl(fd, libc::F_GET_SEALS), @@ -672,7 +662,7 @@ feature! { // Note: FreeBSD defines the offset argument as "off_t". Linux and Android // define it as "loff_t". But on both OSes, on all supported platforms, those // are 64 bits. So Nix uses i64 to make the docs simple and consistent. -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] +#[cfg(any(linux_android, target_os = "freebsd"))] pub fn copy_file_range( fd_in: Fd1, off_in: Option<&mut i64>, @@ -960,8 +950,7 @@ pub fn fspacectl_all( } #[cfg(any( - target_os = "linux", - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", target_os = "wasi", @@ -1008,13 +997,11 @@ mod posix_fadvise { } #[cfg(any( - target_os = "linux", - target_os = "android", - target_os = "dragonfly", + linux_android, + freebsdlike, target_os = "emscripten", target_os = "fuchsia", target_os = "wasi", - target_os = "freebsd" ))] pub fn posix_fallocate( fd: RawFd, diff --git a/src/features.rs b/src/features.rs index a623d2d533..b528773d10 100644 --- a/src/features.rs +++ b/src/features.rs @@ -98,8 +98,7 @@ mod os { } #[cfg(any( - target_os = "dragonfly", // Since ??? - target_os = "freebsd", // Since 10.0 + freebsdlike, // FreeBSD since 10.0 DragonFlyBSD since ??? target_os = "illumos", // Since ??? target_os = "netbsd", // Since 6.0 target_os = "openbsd", // Since 5.7 diff --git a/src/ifaddrs.rs b/src/ifaddrs.rs index e90b26d012..58cbfec9eb 100644 --- a/src/ifaddrs.rs +++ b/src/ifaddrs.rs @@ -33,7 +33,7 @@ pub struct InterfaceAddress { } cfg_if! { - if #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] { + if #[cfg(any(linux_android, target_os = "emscripten", target_os = "fuchsia"))] { fn get_ifu_from_sockaddr(info: &libc::ifaddrs) -> *const libc::sockaddr { info.ifa_ifu } diff --git a/src/lib.rs b/src/lib.rs index ed9d67b7fe..0d4416926f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,9 +123,8 @@ pub mod fcntl; feature! { #![feature = "net"] - #[cfg(any(target_os = "android", + #[cfg(any(linux_android, bsd, - target_os = "linux", target_os = "illumos"))] #[deny(missing_docs)] pub mod ifaddrs; @@ -143,12 +142,7 @@ feature! { #![feature = "mount"] pub mod mount; } -#[cfg(any( - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd" -))] +#[cfg(any(freebsdlike, target_os = "linux", target_os = "netbsd"))] feature! { #![feature = "mqueue"] pub mod mqueue; diff --git a/src/poll.rs b/src/poll.rs index 46ee26ae09..0ad9f40d3b 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -224,7 +224,7 @@ feature! { /// so in that case `ppoll` differs from `poll` only in the precision of the /// timeout argument. /// -#[cfg(any(target_os = "android", freebsdlike, target_os = "linux"))] +#[cfg(any(linux_android, freebsdlike))] pub fn ppoll( fds: &mut [PollFd], timeout: Option, diff --git a/src/sched.rs b/src/sched.rs index bafbfa0bd8..d76d5581d1 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -152,20 +152,10 @@ mod sched_linux_like { } } -#[cfg(any( - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux" -))] +#[cfg(any(linux_android, freebsdlike))] pub use self::sched_affinity::*; -#[cfg(any( - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux" -))] +#[cfg(any(linux_android, freebsdlike))] mod sched_affinity { use crate::errno::Errno; use crate::unistd::Pid; diff --git a/src/time.rs b/src/time.rs index 6e8aac6ac1..b4b0f07eb7 100644 --- a/src/time.rs +++ b/src/time.rs @@ -22,11 +22,7 @@ impl ClockId { feature! { #![feature = "process"] /// Returns `ClockId` of a `pid` CPU-time clock - #[cfg(any( - freebsdlike, - linux_android, - target_os = "emscripten", - ))] + #[cfg(any(freebsdlike, linux_android, target_os = "emscripten"))] pub fn pid_cpu_clock_id(pid: Pid) -> Result { clock_getcpuclockid(pid) }