Skip to content

Commit

Permalink
Add tvOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
rofferom authored and djc committed Oct 3, 2024
1 parent d126000 commit 08ee9ee
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions quinn-udp/src/unix.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "openbsd",
target_os = "solaris",
Expand Down Expand Up @@ -67,6 +68,7 @@ impl UdpSocketState {
|| cfg!(target_os = "netbsd")
|| cfg!(target_os = "macos")
|| cfg!(target_os = "ios")
|| cfg!(target_os = "tvos")
|| cfg!(target_os = "visionos")
|| cfg!(target_os = "android")
|| cfg!(target_os = "solaris")
Expand Down Expand Up @@ -133,6 +135,7 @@ impl UdpSocketState {
target_os = "freebsd",
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos"
))]
{
Expand All @@ -152,6 +155,7 @@ impl UdpSocketState {
target_os = "netbsd",
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "solaris",
))]
Expand Down Expand Up @@ -235,6 +239,7 @@ impl UdpSocketState {
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "openbsd",
target_os = "netbsd"
Expand All @@ -247,6 +252,7 @@ impl UdpSocketState {
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "openbsd",
target_os = "netbsd"
Expand Down Expand Up @@ -338,6 +344,7 @@ fn send(
#[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "openbsd",
target_os = "netbsd"
Expand All @@ -355,6 +362,7 @@ fn send(state: &UdpSocketState, io: SockRef<'_>, transmit: &Transmit<'_>) -> io:
&mut ctrl,
cfg!(target_os = "macos")
|| cfg!(target_os = "ios")
|| cfg!(target_os = "tvos")
|| cfg!(target_os = "visionos")
|| cfg!(target_os = "openbsd")
|| cfg!(target_os = "netbsd"),
Expand Down Expand Up @@ -389,6 +397,7 @@ fn send(state: &UdpSocketState, io: SockRef<'_>, transmit: &Transmit<'_>) -> io:
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "openbsd",
target_os = "solaris",
Expand Down Expand Up @@ -434,6 +443,7 @@ fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) ->
#[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "openbsd",
target_os = "solaris",
Expand Down Expand Up @@ -530,6 +540,7 @@ fn prepare_msg(
target_os = "netbsd",
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
target_os = "solaris",
))]
Expand Down Expand Up @@ -600,6 +611,7 @@ fn decode_recv(
#[allow(clippy::unnecessary_cast)] // cmsg.cmsg_len defined as size_t
if (cfg!(target_os = "macos")
|| cfg!(target_os = "ios")
|| cfg!(target_os = "tvos")
|| cfg!(target_os = "visionos"))
&& cmsg.cmsg_len as usize == libc::CMSG_LEN(mem::size_of::<u8>() as _) as usize
{
Expand All @@ -621,6 +633,7 @@ fn decode_recv(
target_os = "netbsd",
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos",
))]
(libc::IPPROTO_IP, libc::IP_RECVDSTADDR) => {
Expand Down Expand Up @@ -672,11 +685,21 @@ fn decode_recv(
}
}

#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "visionos")))]
#[cfg(not(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos"
)))]
// Chosen somewhat arbitrarily; might benefit from additional tuning.
pub(crate) const BATCH_SIZE: usize = 32;

#[cfg(any(target_os = "macos", target_os = "ios", target_os = "visionos"))]
#[cfg(any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "visionos"
))]
pub(crate) const BATCH_SIZE: usize = 1;

#[cfg(target_os = "linux")]
Expand Down

0 comments on commit 08ee9ee

Please sign in to comment.