From 6d8f625f5512168796321133730d341d2741536b Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 9 Jun 2024 15:42:39 +0200 Subject: [PATCH 1/2] Add support for Apple visionOS Co-authored-by: Quentin Perez --- src/interest.rs | 2 ++ src/sys/unix/net.rs | 4 ++++ src/sys/unix/pipe.rs | 2 ++ src/sys/unix/selector/kqueue.rs | 42 +++++++++++++++++++++++++++++++++ src/sys/unix/selector/mod.rs | 2 ++ src/sys/unix/tcp.rs | 1 + src/sys/unix/uds/listener.rs | 2 ++ src/sys/unix/uds/mod.rs | 2 ++ src/sys/unix/waker.rs | 4 ++++ tests/interest.rs | 1 + tests/tcp_stream.rs | 2 ++ tests/unix_stream.rs | 3 +++ tests/util/mod.rs | 2 ++ 13 files changed, 69 insertions(+) diff --git a/src/interest.rs b/src/interest.rs index 2bab78690..bac01fce7 100644 --- a/src/interest.rs +++ b/src/interest.rs @@ -38,6 +38,7 @@ impl Interest { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] pub const AIO: Interest = Interest(unsafe { NonZeroU8::new_unchecked(AIO) }); @@ -163,6 +164,7 @@ impl fmt::Debug for Interest { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] { diff --git a/src/sys/unix/net.rs b/src/sys/unix/net.rs index 5a473bd2d..0298d0b38 100644 --- a/src/sys/unix/net.rs +++ b/src/sys/unix/net.rs @@ -35,6 +35,7 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] if let Err(err) = syscall!(setsockopt( @@ -53,6 +54,7 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", @@ -116,6 +118,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_ target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", @@ -149,6 +152,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_ target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", diff --git a/src/sys/unix/pipe.rs b/src/sys/unix/pipe.rs index c44106a29..51d01f592 100644 --- a/src/sys/unix/pipe.rs +++ b/src/sys/unix/pipe.rs @@ -31,6 +31,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "nto", @@ -68,6 +69,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> { target_os = "openbsd", target_os = "redox", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "solaris", diff --git a/src/sys/unix/selector/kqueue.rs b/src/sys/unix/selector/kqueue.rs index 8e5e41025..3da4dc112 100644 --- a/src/sys/unix/selector/kqueue.rs +++ b/src/sys/unix/selector/kqueue.rs @@ -24,6 +24,7 @@ type Filter = libc::c_short; target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] type Filter = i16; @@ -37,6 +38,7 @@ type Flags = libc::c_ushort; target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] type Flags = u16; @@ -213,6 +215,7 @@ impl Selector { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] pub fn setup_waker(&self, token: Token) -> io::Result<()> { @@ -239,6 +242,7 @@ impl Selector { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] pub fn wake(&self, token: Token) -> io::Result<()> { @@ -376,6 +380,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] // Used by the `Awakener`. On platforms that use `eventfd` or a unix @@ -389,6 +394,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" )))] { @@ -429,6 +435,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] { @@ -440,6 +447,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", )))] { @@ -478,6 +486,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::EVFILT_FS, @@ -489,6 +498,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::EVFILT_USER, @@ -502,6 +512,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::EVFILT_MACHPORT, @@ -509,6 +520,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::EVFILT_VM, @@ -539,6 +551,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::EV_FLAG0, @@ -546,6 +559,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::EV_POLL, @@ -553,6 +567,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::EV_OOBAND, @@ -573,6 +588,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::NOTE_TRIGGER, @@ -582,6 +598,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::NOTE_FFNOP, @@ -591,6 +608,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::NOTE_FFAND, @@ -600,6 +618,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::NOTE_FFOR, @@ -609,6 +628,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::NOTE_FFCOPY, @@ -618,6 +638,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::NOTE_FFCTRLMASK, @@ -627,6 +648,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::NOTE_FFLAGSMASK, @@ -641,6 +663,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_EXTEND, @@ -652,6 +675,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_NONE, @@ -664,6 +688,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_SIGNAL, @@ -671,6 +696,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_EXITSTATUS, @@ -678,6 +704,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_EXIT_DETAIL, @@ -708,6 +735,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_EXIT_DETAIL_MASK, @@ -715,6 +743,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_EXIT_DECRYPTFAIL, @@ -722,6 +751,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_EXIT_MEMORY, @@ -729,6 +759,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_EXIT_CSERROR, @@ -736,6 +767,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_VM_PRESSURE, @@ -743,6 +775,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_VM_PRESSURE_TERMINATE, @@ -750,6 +783,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_VM_PRESSURE_SUDDEN_TERMINATE, @@ -757,6 +791,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_VM_ERROR, @@ -765,6 +800,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_SECONDS, @@ -775,6 +811,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_USECONDS, @@ -783,6 +820,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_NSECONDS, @@ -790,6 +828,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_ABSOLUTE, @@ -797,6 +836,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_LEEWAY, @@ -804,6 +844,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_CRITICAL, @@ -811,6 +852,7 @@ pub mod event { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos" ))] libc::NOTE_BACKGROUND, diff --git a/src/sys/unix/selector/mod.rs b/src/sys/unix/selector/mod.rs index b712b742d..86fcfe973 100644 --- a/src/sys/unix/selector/mod.rs +++ b/src/sys/unix/selector/mod.rs @@ -59,6 +59,7 @@ cfg_io_source! { target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ) ))] @@ -74,6 +75,7 @@ mod kqueue; target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ), ))] diff --git a/src/sys/unix/tcp.rs b/src/sys/unix/tcp.rs index d1396aa01..8f9eaa488 100644 --- a/src/sys/unix/tcp.rs +++ b/src/sys/unix/tcp.rs @@ -91,6 +91,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, target_os = "macos", target_os = "redox", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", diff --git a/src/sys/unix/uds/listener.rs b/src/sys/unix/uds/listener.rs index 444e3f98a..e9eb313eb 100644 --- a/src/sys/unix/uds/listener.rs +++ b/src/sys/unix/uds/listener.rs @@ -40,6 +40,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "netbsd", target_os = "redox", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", @@ -66,6 +67,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "netbsd", target_os = "redox", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", diff --git a/src/sys/unix/uds/mod.rs b/src/sys/unix/uds/mod.rs index 42508612b..b6479c747 100644 --- a/src/sys/unix/uds/mod.rs +++ b/src/sys/unix/uds/mod.rs @@ -90,6 +90,7 @@ where target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", @@ -111,6 +112,7 @@ where target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", target_os = "espidf", target_os = "vita", diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index fd8565800..f32a60eef 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -7,6 +7,7 @@ target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ) )), @@ -65,6 +66,7 @@ mod fdbased { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ) )), @@ -180,6 +182,7 @@ pub(crate) use self::eventfd::WakerInternal; target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ) ))] @@ -221,6 +224,7 @@ mod kqueue { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ) ))] diff --git a/tests/interest.rs b/tests/interest.rs index f477d59c3..cc59eec4c 100644 --- a/tests/interest.rs +++ b/tests/interest.rs @@ -31,6 +31,7 @@ fn fmt_debug() { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] { diff --git a/tests/tcp_stream.rs b/tests/tcp_stream.rs index b307a2ad6..71388d216 100644 --- a/tests/tcp_stream.rs +++ b/tests/tcp_stream.rs @@ -298,6 +298,7 @@ fn shutdown_read() { target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] { @@ -388,6 +389,7 @@ fn shutdown_both() { target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] { diff --git a/tests/unix_stream.rs b/tests/unix_stream.rs index 87cfbd111..a501bae97 100644 --- a/tests/unix_stream.rs +++ b/tests/unix_stream.rs @@ -231,6 +231,7 @@ fn unix_stream_shutdown_read() { target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] { @@ -280,6 +281,7 @@ fn unix_stream_shutdown_write() { target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] expect_events( @@ -346,6 +348,7 @@ fn unix_stream_shutdown_both() { target_os = "netbsd", target_os = "openbsd", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] { diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 7a192d9b0..8bccc5ed1 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -253,6 +253,7 @@ pub fn set_linger_zero(socket: &TcpStream) { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", ))] libc::SO_LINGER_SEC, @@ -260,6 +261,7 @@ pub fn set_linger_zero(socket: &TcpStream) { target_os = "ios", target_os = "macos", target_os = "tvos", + target_os = "visionos", target_os = "watchos", )))] libc::SO_LINGER, From 6ee3919078506277eb3ba6768da98469eb863cd0 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 9 Jun 2024 15:48:10 +0200 Subject: [PATCH 2/2] Add visionOS to CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5aa58b1d4..50b0ba9b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -142,7 +142,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["aarch64-apple-ios", "aarch64-apple-tvos", "aarch64-unknown-openbsd", "arm64_32-apple-watchos", "armv7-sony-vita-newlibeabihf", "sparcv9-sun-solaris", "x86_64-pc-solaris", "x86_64-unknown-dragonfly", "x86_64-unknown-openbsd"] + target: ["aarch64-apple-ios", "aarch64-apple-tvos", "aarch64-apple-visionos", "aarch64-unknown-openbsd", "arm64_32-apple-watchos", "armv7-sony-vita-newlibeabihf", "sparcv9-sun-solaris", "x86_64-pc-solaris", "x86_64-unknown-dragonfly", "x86_64-unknown-openbsd"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly