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 tvOS and watchOS #1658

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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