Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apple visionOS support #503

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Targets available via Rustup that are supported.
# NOTE: keep in sync with the CI and docs.rs targets.
TARGETS ?= "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"
TARGETS ?= "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"

test:
cargo test --all-features
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ impl TcpKeepalive {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand All @@ -530,6 +531,7 @@ impl TcpKeepalive {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand Down Expand Up @@ -558,6 +560,7 @@ impl TcpKeepalive {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand All @@ -576,6 +579,7 @@ impl TcpKeepalive {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand Down
3 changes: 3 additions & 0 deletions src/sockaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ impl From<SocketAddrV4> for SockAddr {
target_os = "haiku",
target_os = "hermit",
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "netbsd",
target_os = "nto",
Expand Down Expand Up @@ -334,6 +335,7 @@ impl From<SocketAddrV6> for SockAddr {
target_os = "haiku",
target_os = "hermit",
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "netbsd",
target_os = "nto",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> {
// On Apple platforms set `NOSIGPIPE`.
#[cfg(any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand Down Expand Up @@ -1947,6 +1948,7 @@ impl Socket {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand All @@ -1965,6 +1967,7 @@ impl Socket {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand Down Expand Up @@ -1994,6 +1997,7 @@ impl Socket {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand All @@ -2012,6 +2016,7 @@ impl Socket {
target_os = "fuchsia",
target_os = "illumos",
target_os = "ios",
target_os = "visionos",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
Expand Down
34 changes: 34 additions & 0 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -160,13 +164,15 @@ 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",
)))]
pub(crate) use libc::SO_LINGER;
#[cfg(any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand Down Expand Up @@ -200,6 +206,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",
Expand All @@ -215,6 +222,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",
Expand All @@ -234,6 +242,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",
Expand All @@ -248,6 +257,7 @@ pub(crate) type Bool = c_int;

#[cfg(any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "nto",
target_os = "tvos",
Expand All @@ -257,6 +267,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",
Expand All @@ -282,6 +293,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",
Expand All @@ -298,6 +310,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",
Expand Down Expand Up @@ -337,6 +350,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",
Expand Down Expand Up @@ -1227,6 +1241,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",
Expand Down Expand Up @@ -1455,6 +1470,7 @@ impl crate::Socket {
#[cfg_attr(
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos"
Expand Down Expand Up @@ -1491,6 +1507,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -1502,6 +1519,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -1514,6 +1532,7 @@ impl crate::Socket {

#[cfg(any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand Down Expand Up @@ -1950,6 +1969,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -1961,6 +1981,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -1986,6 +2007,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -1997,6 +2019,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2022,6 +2045,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2033,6 +2057,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2053,6 +2078,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2064,6 +2090,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2081,6 +2108,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2092,6 +2120,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2112,6 +2141,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand All @@ -2123,6 +2153,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand Down Expand Up @@ -2446,6 +2477,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",
Expand All @@ -2461,6 +2493,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",
Expand All @@ -2484,6 +2517,7 @@ impl crate::Socket {
feature = "all",
any(
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
Expand Down