From 4c2dcc1f87f0ebabff80fc6eff18f6e74600be51 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Wed, 29 May 2024 18:50:37 -0400 Subject: [PATCH 1/4] added visionos support --- .github/workflows/main.yml | 2 +- src/lib.rs | 4 ++++ src/sockaddr.rs | 3 +++ src/socket.rs | 5 +++++ src/sys/unix.rs | 34 ++++++++++++++++++++++++++++++++++ tests/socket.rs | 13 +++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d83a0e5..82999a9a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] + target: ["aarch64-apple-ios", "aarch64-apple-visionos", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable diff --git a/src/lib.rs b/src/lib.rs index c3161d63..8f593163 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -515,6 +515,7 @@ impl TcpKeepalive { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -531,6 +532,7 @@ impl TcpKeepalive { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -559,6 +561,7 @@ impl TcpKeepalive { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -577,6 +580,7 @@ impl TcpKeepalive { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", diff --git a/src/sockaddr.rs b/src/sockaddr.rs index 2f4b40ed..c80dccf3 100644 --- a/src/sockaddr.rs +++ b/src/sockaddr.rs @@ -291,6 +291,7 @@ impl From for SockAddr { target_os = "haiku", target_os = "hermit", target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "nto", @@ -334,6 +335,7 @@ impl From for SockAddr { target_os = "haiku", target_os = "hermit", target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "nto", @@ -358,6 +360,7 @@ impl fmt::Debug for SockAddr { target_os = "haiku", target_os = "hermit", target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "nto", diff --git a/src/socket.rs b/src/socket.rs index 19f269cf..86d61de7 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -801,6 +801,7 @@ fn set_common_flags(socket: Socket) -> io::Result { // On Apple platforms set `NOSIGPIPE`. #[cfg(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1978,6 +1979,7 @@ impl Socket { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -1996,6 +1998,7 @@ impl Socket { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -2025,6 +2028,7 @@ impl Socket { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -2043,6 +2047,7 @@ impl Socket { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 51ef4a5d..3a898bc3 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -18,6 +18,7 @@ use std::net::{Ipv4Addr, Ipv6Addr}; feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -31,6 +32,7 @@ use std::num::NonZeroU32; target_os = "android", target_os = "freebsd", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "tvos", @@ -46,6 +48,7 @@ use std::os::unix::ffi::OsStrExt; target_os = "android", target_os = "freebsd", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "tvos", @@ -63,6 +66,7 @@ use std::{io, slice}; #[cfg(not(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -160,6 +164,7 @@ pub(crate) use libc::IP_RECVTOS; pub(crate) use libc::IP_TOS; #[cfg(not(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -167,6 +172,7 @@ pub(crate) use libc::IP_TOS; pub(crate) use libc::SO_LINGER; #[cfg(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -202,6 +208,7 @@ pub(crate) use libc::{ target_os = "haiku", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "nto", @@ -217,6 +224,7 @@ pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP}; target_os = "haiku", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "openbsd", @@ -236,6 +244,7 @@ pub(crate) use libc::{ target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -250,6 +259,7 @@ pub(crate) type Bool = c_int; #[cfg(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "nto", target_os = "tvos", @@ -259,6 +269,7 @@ use libc::TCP_KEEPALIVE as KEEPALIVE_TIME; #[cfg(not(any( target_os = "haiku", target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "nto", target_os = "openbsd", @@ -284,6 +295,7 @@ macro_rules! syscall { /// Maximum size of a buffer passed to system call like `recv` and `send`. #[cfg(not(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -300,6 +312,7 @@ const MAX_BUF_LEN: usize = ssize_t::MAX as usize; // both platforms. #[cfg(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -339,6 +352,7 @@ type IovLen = usize; target_os = "hurd", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "netbsd", target_os = "nto", @@ -1234,6 +1248,7 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res target_os = "hurd", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -1462,6 +1477,7 @@ impl crate::Socket { #[cfg_attr( any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos" @@ -1498,6 +1514,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1509,6 +1526,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1521,6 +1539,7 @@ impl crate::Socket { #[cfg(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1957,6 +1976,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1968,6 +1988,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1993,6 +2014,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2004,6 +2026,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2029,6 +2052,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2040,6 +2064,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2060,6 +2085,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2071,6 +2097,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2088,6 +2115,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2099,6 +2127,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2119,6 +2148,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2130,6 +2160,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -2453,6 +2484,7 @@ impl crate::Socket { target_os = "android", target_os = "freebsd", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "tvos", @@ -2468,6 +2500,7 @@ impl crate::Socket { target_os = "android", target_os = "freebsd", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "tvos", @@ -2491,6 +2524,7 @@ impl crate::Socket { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", diff --git a/tests/socket.rs b/tests/socket.rs index 89b79f5f..e8c72e26 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -5,6 +5,7 @@ target_os = "android", target_os = "freebsd", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "tvos", @@ -29,6 +30,7 @@ use std::net::{Ipv6Addr, SocketAddrV6}; target_os = "android", target_os = "freebsd", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "tvos", @@ -225,6 +227,7 @@ fn assert_common_flags(socket: &Socket, expected: bool) { assert_close_on_exec(socket, expected); #[cfg(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -416,6 +419,7 @@ where feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -436,6 +440,7 @@ fn set_nosigpipe() { /// Assert that `SO_NOSIGPIPE` is set on `socket`. #[cfg(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -864,6 +869,7 @@ fn tcp_keepalive() { target_os = "freebsd", target_os = "fuchsia", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -881,6 +887,7 @@ fn tcp_keepalive() { target_os = "freebsd", target_os = "fuchsia", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -908,6 +915,7 @@ fn tcp_keepalive() { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -929,6 +937,7 @@ fn tcp_keepalive() { target_os = "fuchsia", target_os = "illumos", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "netbsd", @@ -977,6 +986,7 @@ fn device() { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1022,6 +1032,7 @@ fn device() { feature = "all", any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", @@ -1069,6 +1080,7 @@ fn device_v6() { target_os = "android", target_os = "freebsd", target_os = "ios", + target_os = "visionos", target_os = "linux", target_os = "macos", target_os = "tvos", @@ -1226,6 +1238,7 @@ fn r#type() { unix, not(any( target_os = "ios", + target_os = "visionos", target_os = "macos", target_os = "tvos", target_os = "watchos", From 2f30556eaf9e6dbd19243c798dcfaad59b02063d Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Tue, 4 Jun 2024 10:47:08 -0400 Subject: [PATCH 2/4] moved visionos to nightly branches in CI --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 82999a9a..28cdcfc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["aarch64-apple-ios", "aarch64-apple-visionos", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] + target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -71,7 +71,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["armv7-sony-vita-newlibeabihf", "i686-unknown-hurd-gnu"] + target: ["aarch64-apple-visionos", "armv7-sony-vita-newlibeabihf", "i686-unknown-hurd-gnu"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly @@ -97,7 +97,7 @@ jobs: target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature. + - uses: dtolnay/rust-toolchain@stable # NOTE: need nightly for `doc_cfg` feature. with: targets: ${{ matrix.target }} - name: Check docs for docs.rs @@ -108,7 +108,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["armv7-sony-vita-newlibeabihf", "i686-unknown-hurd-gnu"] + target: ["aarch64-apple-visionos", "armv7-sony-vita-newlibeabihf", "i686-unknown-hurd-gnu"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature. From 27fd5a6b25e0ceb0312089ca7682396ed00198ea Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Tue, 4 Jun 2024 10:52:59 -0400 Subject: [PATCH 3/4] fixed nightly branch on CI for the docs --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28cdcfc1..502a3677 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -97,7 +97,7 @@ jobs: target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable # NOTE: need nightly for `doc_cfg` feature. + - uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature. with: targets: ${{ matrix.target }} - name: Check docs for docs.rs From 22b965fa27b571599d2734208efecf41dc3db966 Mon Sep 17 00:00:00 2001 From: Eugene Hauptmann Date: Tue, 4 Jun 2024 10:57:16 -0400 Subject: [PATCH 4/4] removed freebsd support --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 502a3677..b536de1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] + target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -94,7 +94,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] + target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature.