From 732b398c4bfeab79b11eef9ca4d7be5e5fef6fa2 Mon Sep 17 00:00:00 2001 From: Janrupf Date: Tue, 9 Aug 2022 23:49:42 +0200 Subject: [PATCH] Add proper cfg to LOWEST_FD in unix selector --- src/sys/unix/selector/mod.rs | 65 +++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/src/sys/unix/selector/mod.rs b/src/sys/unix/selector/mod.rs index f1c19a9b7..ef5947164 100644 --- a/src/sys/unix/selector/mod.rs +++ b/src/sys/unix/selector/mod.rs @@ -1,14 +1,3 @@ -#[cfg(all( - any( - target_os = "android", - target_os = "illumos", - target_os = "linux", - target_os = "redox", - ), - not(feature = "force-old-poll") -))] -mod epoll; - #[cfg(all( any( target_os = "android", @@ -19,7 +8,6 @@ mod epoll; not(feature = "force-old-poll") ))] pub(crate) use self::epoll::{event, Event, Events, Selector}; - #[cfg(all( any( target_os = "dragonfly", @@ -31,37 +19,47 @@ pub(crate) use self::epoll::{event, Event, Events, Selector}; ), not(feature = "force-old-poll") ))] -mod kqueue; - -#[cfg(all( - any( +pub(crate) use self::kqueue::{event, Event, Events, Selector}; +#[cfg(any( + not(any( + target_os = "android", + target_os = "illumos", + target_os = "linux", + target_os = "redox", target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd" - ), - not(feature = "force-old-poll") + )), + feature = "force-old-poll" ))] -pub(crate) use self::kqueue::{event, Event, Events, Selector}; +pub(crate) use self::poll::{event, Event, Events, Selector}; -#[cfg(any( - not(any( +#[cfg(all( + any( target_os = "android", target_os = "illumos", target_os = "linux", target_os = "redox", + ), + not(feature = "force-old-poll") +))] +mod epoll; + +#[cfg(all( + any( target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd" - )), - feature = "force-old-poll" + ), + not(feature = "force-old-poll") ))] -mod poll; +mod kqueue; #[cfg(any( not(any( @@ -78,7 +76,7 @@ mod poll; )), feature = "force-old-poll" ))] -pub(crate) use self::poll::{event, Event, Events, Selector}; +mod poll; /// Lowest file descriptor used in `Selector::try_clone`. /// @@ -88,5 +86,20 @@ pub(crate) use self::poll::{event, Event, Events, Selector}; /// blindly assume this to be true, which means using any one of those a select /// could result in some interesting and unexpected errors. Avoid that by using /// an fd that doesn't have a pre-determined usage. -#[cfg(not(feature = "force-old-poll"))] +#[cfg(all( + unix, + any( + target_os = "android", + target_os = "illumos", + target_os = "linux", + target_os = "redox", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd" + ), + not(feature = "force-old-poll") +))] const LOWEST_FD: libc::c_int = 3;