Skip to content

Commit 9bd0e95

Browse files
committed
Add tvOS and watchOS
Follow up to 98915ad.
1 parent c45510f commit 9bd0e95

File tree

13 files changed

+314
-51
lines changed

13 files changed

+314
-51
lines changed

src/interest.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ impl Interest {
3737
target_os = "freebsd",
3838
target_os = "ios",
3939
target_os = "macos",
40+
target_os = "tvos",
41+
target_os = "watchos",
4042
))]
4143
pub const AIO: Interest = Interest(unsafe { NonZeroU8::new_unchecked(AIO) });
4244

@@ -153,6 +155,8 @@ impl fmt::Debug for Interest {
153155
target_os = "freebsd",
154156
target_os = "ios",
155157
target_os = "macos",
158+
target_os = "tvos",
159+
target_os = "watchos",
156160
))]
157161
{
158162
if self.is_aio() {

src/sys/unix/net.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
2727
let socket = syscall!(socket(domain, socket_type, 0))?;
2828

2929
// Mimick `libstd` and set `SO_NOSIGPIPE` on apple systems.
30-
#[cfg(any(target_os = "ios", target_os = "macos"))]
30+
#[cfg(any(
31+
target_os = "ios",
32+
target_os = "macos",
33+
target_os = "tvos",
34+
target_os = "watchos",
35+
))]
3136
if let Err(err) = syscall!(setsockopt(
3237
socket,
3338
libc::SOL_SOCKET,
@@ -40,7 +45,12 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
4045
}
4146

4247
// Darwin doesn't have SOCK_NONBLOCK or SOCK_CLOEXEC.
43-
#[cfg(any(target_os = "ios", target_os = "macos"))]
48+
#[cfg(any(
49+
target_os = "ios",
50+
target_os = "macos",
51+
target_os = "tvos",
52+
target_os = "watchos",
53+
))]
4454
{
4555
if let Err(err) = syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK)) {
4656
let _ = syscall!(close(socket));
@@ -93,6 +103,8 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
93103
target_os = "macos",
94104
target_os = "netbsd",
95105
target_os = "openbsd",
106+
target_os = "tvos",
107+
target_os = "watchos",
96108
))]
97109
sin_len: 0,
98110
};
@@ -117,6 +129,8 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
117129
target_os = "macos",
118130
target_os = "netbsd",
119131
target_os = "openbsd",
132+
target_os = "tvos",
133+
target_os = "watchos",
120134
))]
121135
sin6_len: 0,
122136
#[cfg(target_os = "illumos")]

src/sys/unix/pipe.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ pub fn new() -> io::Result<(Sender, Receiver)> {
163163
}
164164
}
165165

166-
#[cfg(any(target_os = "ios", target_os = "macos"))]
166+
#[cfg(any(
167+
target_os = "ios",
168+
target_os = "macos",
169+
target_os = "tvos",
170+
target_os = "watchos",
171+
))]
167172
unsafe {
168173
// For platforms that don't have `pipe2(2)` we need to manually set the
169174
// correct flags on the file descriptor.
@@ -195,6 +200,8 @@ pub fn new() -> io::Result<(Sender, Receiver)> {
195200
target_os = "netbsd",
196201
target_os = "openbsd",
197202
target_os = "redox",
203+
target_os = "tvos",
204+
target_os = "watchos",
198205
)))]
199206
compile_error!("unsupported target for `mio::unix::pipe`");
200207

0 commit comments

Comments
 (0)