Skip to content

Commit

Permalink
Add support for Apple visionOS
Browse files Browse the repository at this point in the history
Co-authored-by: Quentin Perez <[email protected]>
  • Loading branch information
Thomasdezeeuw and QuentinPerez committed Jun 10, 2024
1 parent 5200f6c commit 3334d1b
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/interest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl Interest {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
pub const AIO: Interest = Interest(unsafe { NonZeroU8::new_unchecked(AIO) });
Expand Down Expand Up @@ -163,6 +164,7 @@ impl fmt::Debug for Interest {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
{
Expand Down
4 changes: 4 additions & 0 deletions src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
if let Err(err) = syscall!(setsockopt(
Expand All @@ -53,6 +54,7 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
target_os = "espidf",
target_os = "vita",
Expand Down Expand Up @@ -116,6 +118,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
target_os = "netbsd",
target_os = "openbsd",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
target_os = "espidf",
target_os = "vita",
Expand Down Expand Up @@ -149,6 +152,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
target_os = "netbsd",
target_os = "openbsd",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
target_os = "espidf",
target_os = "vita",
Expand Down
2 changes: 2 additions & 0 deletions src/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
target_os = "espidf",
target_os = "nto",
Expand Down Expand Up @@ -68,6 +69,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
target_os = "openbsd",
target_os = "redox",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
target_os = "espidf",
target_os = "solaris",
Expand Down
42 changes: 42 additions & 0 deletions src/sys/unix/selector/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Filter = libc::c_short;
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
type Filter = i16;
Expand All @@ -37,6 +38,7 @@ type Flags = libc::c_ushort;
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
type Flags = u16;
Expand Down Expand Up @@ -212,6 +214,7 @@ impl Selector {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
pub fn setup_waker(&self, token: Token) -> io::Result<()> {
Expand Down Expand Up @@ -239,6 +242,7 @@ impl Selector {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
pub fn wake(&self, token: Token) -> io::Result<()> {
Expand Down Expand Up @@ -369,6 +373,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
// Used by the `Awakener`. On platforms that use `eventfd` or a unix
Expand All @@ -382,6 +387,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
)))]
{
Expand Down Expand Up @@ -422,6 +428,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
{
Expand All @@ -433,6 +440,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
)))]
{
Expand Down Expand Up @@ -471,6 +479,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::EVFILT_FS,
Expand All @@ -482,6 +491,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::EVFILT_USER,
Expand All @@ -495,13 +505,15 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::EVFILT_MACHPORT,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::EVFILT_VM,
Expand Down Expand Up @@ -532,20 +544,23 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::EV_FLAG0,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::EV_POLL,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::EV_OOBAND,
Expand All @@ -566,6 +581,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::NOTE_TRIGGER,
Expand All @@ -575,6 +591,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::NOTE_FFNOP,
Expand All @@ -584,6 +601,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::NOTE_FFAND,
Expand All @@ -593,6 +611,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::NOTE_FFOR,
Expand All @@ -602,6 +621,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::NOTE_FFCOPY,
Expand All @@ -611,6 +631,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::NOTE_FFCTRLMASK,
Expand All @@ -620,6 +641,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos",
))]
libc::NOTE_FFLAGSMASK,
Expand All @@ -634,6 +656,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_EXTEND,
Expand All @@ -645,6 +668,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_NONE,
Expand All @@ -657,20 +681,23 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_SIGNAL,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_EXITSTATUS,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_EXIT_DETAIL,
Expand Down Expand Up @@ -701,55 +728,63 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_EXIT_DETAIL_MASK,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_EXIT_DECRYPTFAIL,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_EXIT_MEMORY,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_EXIT_CSERROR,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_VM_PRESSURE,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_VM_PRESSURE_TERMINATE,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_VM_PRESSURE_SUDDEN_TERMINATE,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_VM_ERROR,
Expand All @@ -758,6 +793,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_SECONDS,
Expand All @@ -768,6 +804,7 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_USECONDS,
Expand All @@ -776,34 +813,39 @@ pub mod event {
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_NSECONDS,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_ABSOLUTE,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_LEEWAY,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_CRITICAL,
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "tvos",
target_os = "visionos",
target_os = "watchos"
))]
libc::NOTE_BACKGROUND,
Expand Down
Loading

0 comments on commit 3334d1b

Please sign in to comment.