From 7145cd2d5b7b77a15ce3ca8c19b3e62e9374ac8f Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sat, 14 Sep 2024 16:03:01 +0200 Subject: [PATCH] Add support for visionOS (#217) --- README.md | 2 +- examples/wait-signal.rs | 15 +++------------ src/kqueue.rs | 12 +++--------- src/lib.rs | 17 ++++------------- src/os.rs | 5 +---- tests/other_modes.rs | 10 ++-------- tests/precision.rs | 10 ++-------- 7 files changed, 16 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index fab575d..840c6ad 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Portable interface to epoll, kqueue, event ports, and IOCP. Supported platforms: - [epoll](https://en.wikipedia.org/wiki/Epoll): Linux, Android, RedoxOS -- [kqueue](https://en.wikipedia.org/wiki/Kqueue): macOS, iOS, tvOS, watchOS, FreeBSD, NetBSD, OpenBSD, +- [kqueue](https://en.wikipedia.org/wiki/Kqueue): macOS, iOS, tvOS, watchOS, visionOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD - [event ports](https://illumos.org/man/port_create): illumos, Solaris - [poll](https://en.wikipedia.org/wiki/Poll_(Unix)): VxWorks, Fuchsia, HermitOS, other Unix systems diff --git a/examples/wait-signal.rs b/examples/wait-signal.rs index 92cb55b..3692447 100644 --- a/examples/wait-signal.rs +++ b/examples/wait-signal.rs @@ -1,9 +1,6 @@ #[cfg(all( any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", @@ -43,10 +40,7 @@ mod example { #[cfg(all( any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", @@ -60,10 +54,7 @@ fn main() { #[cfg(not(all( any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", diff --git a/src/kqueue.rs b/src/kqueue.rs index 30bdaf9..860bc5a 100644 --- a/src/kqueue.rs +++ b/src/kqueue.rs @@ -1,4 +1,4 @@ -//! Bindings to kqueue (macOS, iOS, tvOS, watchOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD). +//! Bindings to kqueue (macOS, iOS, tvOS, watchOS, visionOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD). use std::collections::HashSet; use std::io; @@ -397,10 +397,7 @@ pub(crate) fn mode_to_flags(mode: PollMode) -> kqueue::EventFlags { #[cfg(any( target_os = "freebsd", target_os = "dragonfly", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", ))] mod notify { use super::Poller; @@ -480,10 +477,7 @@ mod notify { #[cfg(not(any( target_os = "freebsd", target_os = "dragonfly", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", )))] mod notify { use super::Poller; diff --git a/src/lib.rs b/src/lib.rs index da77a01..21f77fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ //! //! Supported platforms: //! - [epoll](https://en.wikipedia.org/wiki/Epoll): Linux, Android, RedoxOS -//! - [kqueue](https://en.wikipedia.org/wiki/Kqueue): macOS, iOS, tvOS, watchOS, FreeBSD, NetBSD, OpenBSD, +//! - [kqueue](https://en.wikipedia.org/wiki/Kqueue): macOS, iOS, tvOS, watchOS, visionOS, FreeBSD, NetBSD, OpenBSD, //! DragonFly BSD //! - [event ports](https://illumos.org/man/port_create): illumos, Solaris //! - [poll](https://en.wikipedia.org/wiki/Poll_(Unix)): VxWorks, Fuchsia, HermitOS, other Unix systems @@ -94,10 +94,7 @@ cfg_if! { mod port; use port as sys; } else if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", @@ -968,10 +965,7 @@ impl fmt::Debug for Events { target_os = "android", target_os = "illumos", target_os = "solaris", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", @@ -986,10 +980,7 @@ impl fmt::Debug for Events { target_os = "android", target_os = "illumos", target_os = "solaris", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", diff --git a/src/os.rs b/src/os.rs index 1d58bfa..35f5d1a 100644 --- a/src/os.rs +++ b/src/os.rs @@ -2,10 +2,7 @@ #[cfg(all( any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", diff --git a/tests/other_modes.rs b/tests/other_modes.rs index 407e42b..c3cf79f 100644 --- a/tests/other_modes.rs +++ b/tests/other_modes.rs @@ -113,10 +113,7 @@ fn edge_triggered() { any( target_os = "linux", target_os = "android", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", @@ -209,10 +206,7 @@ fn edge_oneshot_triggered() { any( target_os = "linux", target_os = "android", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", diff --git a/tests/precision.rs b/tests/precision.rs index 1776fa8..c87709d 100644 --- a/tests/precision.rs +++ b/tests/precision.rs @@ -26,10 +26,7 @@ fn below_ms() -> io::Result<()> { any( target_os = "linux", target_os = "android", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", ), not(polling_test_poll_backend) @@ -64,10 +61,7 @@ fn above_ms() -> io::Result<()> { target_os = "android", target_os = "illumos", target_os = "solaris", - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", + target_vendor = "apple", target_os = "freebsd", ), not(polling_test_poll_backend)