Skip to content

Commit

Permalink
Add Apple visionOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinPerez committed Apr 10, 2024
1 parent 7240849 commit 3824fb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ mod c {
if target_os != "ios"
&& target_os != "watchos"
&& target_os != "tvos"
&& target_os != "visionos"
&& (target_vendor != "apple" || target_arch != "x86")
{
sources.extend(&[
Expand Down Expand Up @@ -364,6 +365,7 @@ mod c {

if target_arch == "arm"
&& target_os != "ios"
&& target_os != "visionos"
&& target_os != "watchos"
&& target_os != "tvos"
&& target_env != "msvc"
Expand Down
28 changes: 14 additions & 14 deletions src/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
use core::intrinsics;

// iOS symbols have a leading underscore.
#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", target_os = "visionos"))]
macro_rules! bl {
($func:literal) => {
concat!("bl _", $func)
};
}
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
macro_rules! bl {
($func:literal) => {
concat!("bl ", $func)
Expand Down Expand Up @@ -89,13 +89,13 @@ intrinsics! {
// FIXME: The `*4` and `*8` variants should be defined as aliases.

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) {
crate::mem::memcpy(dest, src, n);
}

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) {
// We are guaranteed 4-alignment, so accessing at u32 is okay.
let mut dest = dest as *mut u32;
Expand All @@ -113,38 +113,38 @@ intrinsics! {
}

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) {
__aeabi_memcpy4(dest, src, n);
}

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) {
crate::mem::memmove(dest, src, n);
}

#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
#[cfg(not(any(target_os = "ios", target_os = "visionos", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) {
__aeabi_memmove(dest, src, n);
}

#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
#[cfg(not(any(target_os = "ios", target_os = "visionos", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) {
__aeabi_memmove(dest, src, n);
}

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) {
// Note the different argument order
crate::mem::memset(dest, c, n);
}

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) {
let mut dest = dest as *mut u32;
let mut n = n;
Expand All @@ -162,25 +162,25 @@ intrinsics! {
}

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) {
__aeabi_memset4(dest, n, c);
}

#[weak]
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_os = "visionos")))]
pub unsafe extern "aapcs" fn __aeabi_memclr(dest: *mut u8, n: usize) {
__aeabi_memset(dest, n, 0);
}

#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
#[cfg(not(any(target_os = "ios", target_os = "visionos", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
__aeabi_memset4(dest, n, 0);
}

#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
#[cfg(not(any(target_os = "ios", target_os = "visionos", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
__aeabi_memset4(dest, n, 0);
}
Expand Down

0 comments on commit 3824fb5

Please sign in to comment.