diff --git a/src/sys/event.rs b/src/sys/event.rs index f53e0dfdad..28f1e1a1e4 100644 --- a/src/sys/event.rs +++ b/src/sys/event.rs @@ -78,12 +78,7 @@ impl Kqueue { } } -#[cfg(any( - target_os = "dragonfly", - target_os = "freebsd", - apple_targets, - target_os = "openbsd" -))] +#[cfg(any(freebsdlike, apple_targets, target_os = "openbsd"))] type type_of_udata = *mut libc::c_void; #[cfg(target_os = "netbsd")] type type_of_udata = intptr_t; @@ -108,9 +103,7 @@ libc_enum! { /// Takes a descriptor as the identifier, and returns whenever one of /// the specified exceptional conditions has occurred on the descriptor. EVFILT_EXCEPT, - #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", - apple_targets))] + #[cfg(any(freebsdlike, apple_targets))] /// Establishes a file system monitor. EVFILT_FS, #[cfg(target_os = "freebsd")] @@ -142,9 +135,7 @@ libc_enum! { EVFILT_SIGNAL, /// Establishes a timer and notifies when the timer expires. EVFILT_TIMER, - #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", - apple_targets))] + #[cfg(any(freebsdlike, apple_targets))] /// Notifies only when explicitly requested by the user. EVFILT_USER, #[cfg(apple_targets)] @@ -159,12 +150,7 @@ libc_enum! { impl TryFrom } -#[cfg(any( - target_os = "dragonfly", - target_os = "freebsd", - apple_targets, - target_os = "openbsd" -))] +#[cfg(any(freebsdlike, apple_targets, target_os = "openbsd"))] #[doc(hidden)] pub type type_of_event_flag = u16; #[cfg(target_os = "netbsd")] @@ -244,34 +230,22 @@ libc_bitflags!( NOTE_EXITSTATUS; #[allow(missing_docs)] NOTE_EXTEND; - #[cfg(any(apple_targets, - target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(any(apple_targets, freebsdlike))] #[allow(missing_docs)] NOTE_FFAND; - #[cfg(any(apple_targets, - target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(any(apple_targets, freebsdlike))] #[allow(missing_docs)] NOTE_FFCOPY; - #[cfg(any(apple_targets, - target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(any(apple_targets, freebsdlike))] #[allow(missing_docs)] NOTE_FFCTRLMASK; - #[cfg(any(apple_targets, - target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(any(apple_targets, freebsdlike))] #[allow(missing_docs)] NOTE_FFLAGSMASK; - #[cfg(any(apple_targets, - target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(any(apple_targets, freebsdlike))] #[allow(missing_docs)] NOTE_FFNOP; - #[cfg(any(apple_targets, - target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(any(apple_targets, freebsdlike))] #[allow(missing_docs)] NOTE_FFOR; #[allow(missing_docs)] @@ -314,9 +288,7 @@ libc_bitflags!( NOTE_TRACK; #[allow(missing_docs)] NOTE_TRACKERR; - #[cfg(any(apple_targets, - target_os = "freebsd", - target_os = "dragonfly"))] + #[cfg(any(apple_targets, freebsdlike))] #[allow(missing_docs)] NOTE_TRIGGER; #[cfg(target_os = "openbsd")] @@ -434,12 +406,7 @@ pub fn kevent( kq.kevent(changelist, eventlist, Some(timeout)) } -#[cfg(any( - apple_targets, - target_os = "freebsd", - target_os = "dragonfly", - target_os = "openbsd" -))] +#[cfg(any(apple_targets, freebsdlike, target_os = "openbsd"))] type type_of_nchanges = c_int; #[cfg(target_os = "netbsd")] type type_of_nchanges = size_t; diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 199587f557..6247ea4e17 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -57,7 +57,7 @@ libc_bitflags! { /// The mapping is not backed by any file. MAP_ANONYMOUS; /// Put the mapping into the first 2GB of the process address space. - #[cfg(any(all(any(target_os = "android", target_os = "linux"), + #[cfg(any(all(linux_android, any(target_arch = "x86", target_arch = "x86_64")), all(target_os = "linux", target_env = "musl", any(target_arch = "x86", target_arch = "x86_64")), all(target_os = "freebsd", target_pointer_width = "64")))] @@ -140,7 +140,7 @@ libc_bitflags! { #[cfg(any(freebsdlike, target_os = "netbsd", target_os = "openbsd"))] MAP_HASSEMAPHORE; /// Region grows down, like a stack. - #[cfg(any(target_os = "android", freebsdlike, target_os = "linux", target_os = "openbsd"))] + #[cfg(any(linux_android, freebsdlike, target_os = "openbsd"))] MAP_STACK; /// Pages in this mapping are not retained in the kernel's memory cache. #[cfg(apple_targets)] diff --git a/src/sys/mod.rs b/src/sys/mod.rs index 28ccd1ba2d..c29d5ce376 100644 --- a/src/sys/mod.rs +++ b/src/sys/mod.rs @@ -1,7 +1,6 @@ //! Mostly platform-specific functionality #[cfg(any( - target_os = "dragonfly", - target_os = "freebsd", + freebsdlike, all(target_os = "linux", not(target_env = "uclibc")), apple_targets, target_os = "netbsd" @@ -32,19 +31,13 @@ feature! { pub mod fanotify; } -#[cfg(any( - bsd, - target_os = "android", - target_os = "linux", - target_os = "redox", - target_os = "illumos", -))] +#[cfg(any(bsd, linux_android, target_os = "redox", target_os = "illumos"))] #[cfg(feature = "ioctl")] #[cfg_attr(docsrs, doc(cfg(feature = "ioctl")))] #[macro_use] pub mod ioctl; -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] +#[cfg(any(linux_android, target_os = "freebsd"))] feature! { #![feature = "fs"] pub mod memfd; @@ -74,10 +67,8 @@ feature! { } #[cfg(any( - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", + linux_android, + freebsdlike, target_os = "macos", target_os = "netbsd", target_os = "openbsd" @@ -116,15 +107,7 @@ feature! { pub mod select; } -#[cfg(any( - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - apple_targets, - target_os = "linux", - target_os = "solaris", - target_os = "illumos", -))] +#[cfg(any(linux_android, freebsdlike, apple_targets, solarish))] feature! { #![feature = "zerocopy"] pub mod sendfile; @@ -151,14 +134,7 @@ feature! { pub mod stat; } -#[cfg(any( - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", - apple_targets, - target_os = "linux", - target_os = "openbsd" -))] +#[cfg(any(linux_android, freebsdlike, apple_targets, target_os = "openbsd"))] feature! { #![feature = "fs"] pub mod statfs; diff --git a/src/sys/resource.rs b/src/sys/resource.rs index 6b518b7af5..14f3e14c21 100644 --- a/src/sys/resource.rs +++ b/src/sys/resource.rs @@ -75,10 +75,9 @@ libc_enum! { RLIMIT_LOCKS, #[cfg(any( - target_os = "android", + linux_android, target_os = "freebsd", target_os = "openbsd", - target_os = "linux", target_os = "netbsd" ))] /// The maximum size (in bytes) which a process may lock into memory @@ -96,11 +95,10 @@ libc_enum! { RLIMIT_NICE, #[cfg(any( - target_os = "android", + linux_android, target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", - target_os = "linux", target_os = "aix", ))] /// The maximum number of simultaneous processes for this user id. @@ -111,11 +109,10 @@ libc_enum! { /// create. RLIMIT_NPTS, - #[cfg(any(target_os = "android", + #[cfg(any(linux_android, target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", - target_os = "linux", target_os = "aix", ))] /// When there is memory pressure and swap is available, prioritize diff --git a/src/sys/sendfile.rs b/src/sys/sendfile.rs index 546664cf2e..ced85d48e8 100644 --- a/src/sys/sendfile.rs +++ b/src/sys/sendfile.rs @@ -22,12 +22,7 @@ use crate::Result; /// /// For more information, see [the sendfile(2) man page.](https://man7.org/linux/man-pages/man2/sendfile.2.html) for Linux, /// see [the sendfile(2) man page.](https://docs.oracle.com/cd/E88353_01/html/E37843/sendfile-3c.html) for Solaris. -#[cfg(any( - target_os = "android", - target_os = "linux", - target_os = "solaris", - target_os = "illumos", -))] +#[cfg(any(linux_android, solarish))] pub fn sendfile( out_fd: F1, in_fd: F2, @@ -82,9 +77,7 @@ pub fn sendfile64( } cfg_if! { - if #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", - apple_targets,))] { + if #[cfg(any(freebsdlike, apple_targets))] { use std::io::IoSlice; #[derive(Clone, Debug)] diff --git a/src/sys/signal.rs b/src/sys/signal.rs index 8ef2b95243..3156848c48 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -65,8 +65,8 @@ libc_enum! { /// Software termination signal from kill SIGTERM, /// Stack fault (obsolete) - #[cfg(all(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux"), + #[cfg(all(any(linux_android, target_os = "emscripten", + target_os = "fuchsia"), not(any(target_arch = "mips", target_arch = "mips32r6", target_arch = "mips64", @@ -100,22 +100,20 @@ libc_enum! { /// Input/output possible signal #[cfg(not(target_os = "haiku"))] SIGIO, - #[cfg(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", - target_os = "aix"))] + #[cfg(any(linux_android, target_os = "emscripten", + target_os = "fuchsia", target_os = "aix"))] /// Power failure imminent. SIGPWR, /// Bad system call SIGSYS, - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", + #[cfg(not(any(linux_android, target_os = "emscripten", + target_os = "fuchsia", target_os = "redox", target_os = "haiku")))] /// Emulator trap SIGEMT, - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", - target_os = "redox", target_os = "haiku", - target_os = "aix")))] + #[cfg(not(any(linux_android, target_os = "emscripten", + target_os = "fuchsia", target_os = "redox", + target_os = "haiku", target_os = "aix")))] /// Information request SIGINFO, } @@ -144,10 +142,9 @@ impl FromStr for Signal { "SIGTERM" => Signal::SIGTERM, #[cfg(all( any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux" ), not(any( target_arch = "mips", @@ -173,27 +170,24 @@ impl FromStr for Signal { #[cfg(not(target_os = "haiku"))] "SIGIO" => Signal::SIGIO, #[cfg(any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux" ))] "SIGPWR" => Signal::SIGPWR, "SIGSYS" => Signal::SIGSYS, #[cfg(not(any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux", target_os = "redox", target_os = "haiku" )))] "SIGEMT" => Signal::SIGEMT, #[cfg(not(any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux", target_os = "redox", target_os = "aix", target_os = "haiku" @@ -230,10 +224,9 @@ impl Signal { Signal::SIGTERM => "SIGTERM", #[cfg(all( any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux" ), not(any( target_arch = "mips", @@ -259,28 +252,25 @@ impl Signal { #[cfg(not(target_os = "haiku"))] Signal::SIGIO => "SIGIO", #[cfg(any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", target_os = "aix", - target_os = "linux" ))] Signal::SIGPWR => "SIGPWR", Signal::SIGSYS => "SIGSYS", #[cfg(not(any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux", target_os = "redox", target_os = "haiku" )))] Signal::SIGEMT => "SIGEMT", #[cfg(not(any( - target_os = "android", + linux_android, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux", target_os = "redox", target_os = "aix", target_os = "haiku" @@ -324,12 +314,7 @@ const SIGNALS: [Signal; 28] = [ SIGPROF, SIGWINCH, SIGSYS, ]; #[cfg(all( - any( - target_os = "linux", - target_os = "android", - target_os = "emscripten", - target_os = "fuchsia" - ), + any(linux_android, target_os = "emscripten", target_os = "fuchsia"), not(any( target_arch = "mips", target_arch = "mips32r6", @@ -346,12 +331,7 @@ const SIGNALS: [Signal; 31] = [ SIGVTALRM, SIGPROF, SIGWINCH, SIGIO, SIGPWR, SIGSYS, ]; #[cfg(all( - any( - target_os = "linux", - target_os = "android", - target_os = "emscripten", - target_os = "fuchsia" - ), + any(linux_android, target_os = "emscripten", target_os = "fuchsia"), any( target_arch = "mips", target_arch = "mips32r6", @@ -376,8 +356,7 @@ const SIGNALS: [Signal; 30] = [ SIGVTALRM, SIGPROF, SIGXCPU, SIGXFSZ, SIGTRAP, ]; #[cfg(not(any( - target_os = "linux", - target_os = "android", + linux_android, target_os = "fuchsia", target_os = "emscripten", target_os = "aix",