Skip to content

Commit

Permalink
Add tvOS and watchOS
Browse files Browse the repository at this point in the history
Follow up to 98915ad.
  • Loading branch information
Thomasdezeeuw committed Feb 25, 2023
1 parent c45510f commit 584e8f2
Show file tree
Hide file tree
Showing 13 changed files with 309 additions and 46 deletions.
4 changes: 4 additions & 0 deletions src/interest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ impl Interest {
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
))]
pub const AIO: Interest = Interest(unsafe { NonZeroU8::new_unchecked(AIO) });

Expand Down Expand Up @@ -153,6 +155,8 @@ impl fmt::Debug for Interest {
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
))]
{
if self.is_aio() {
Expand Down
18 changes: 16 additions & 2 deletions src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
let socket = syscall!(socket(domain, socket_type, 0))?;

// Mimick `libstd` and set `SO_NOSIGPIPE` on apple systems.
#[cfg(any(target_os = "ios", target_os = "macos"))]
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
))]
if let Err(err) = syscall!(setsockopt(
socket,
libc::SOL_SOCKET,
Expand All @@ -40,7 +45,12 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
}

// Darwin doesn't have SOCK_NONBLOCK or SOCK_CLOEXEC.
#[cfg(any(target_os = "ios", target_os = "macos"))]
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
))]
{
if let Err(err) = syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK)) {
let _ = syscall!(close(socket));
Expand Down Expand Up @@ -93,6 +103,8 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "tvos",
target_os = "watchos",
))]
sin_len: 0,
};
Expand All @@ -117,6 +129,8 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "tvos",
target_os = "watchos",
))]
sin6_len: 0,
#[cfg(target_os = "illumos")]
Expand Down
9 changes: 8 additions & 1 deletion src/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ pub fn new() -> io::Result<(Sender, Receiver)> {
}
}

#[cfg(any(target_os = "ios", target_os = "macos"))]
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "watchos",
))]
unsafe {
// For platforms that don't have `pipe2(2)` we need to manually set the
// correct flags on the file descriptor.
Expand Down Expand Up @@ -195,6 +200,8 @@ pub fn new() -> io::Result<(Sender, Receiver)> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "tvos",
target_os = "watchos",
)))]
compile_error!("unsupported target for `mio::unix::pipe`");

Expand Down
Loading

0 comments on commit 584e8f2

Please sign in to comment.