Skip to content

Commit

Permalink
src/lib.rs: make this build on big-endian aarch64.
Browse files Browse the repository at this point in the history
Do this by avoiding trying to use neon / SIMD on big-endian aarch64.
Neon intrinsics are problematical on big-endian targets, ref.
rust-lang/stdarch#1484
  • Loading branch information
he32 committed Oct 2, 2024
1 parent e6c7318 commit 0430800
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ mod integer_simd;
feature = "runtime-dispatch-simd",
any(target_arch = "x86", target_arch = "x86_64")
),
target_arch = "aarch64",
all(
target_arch = "aarch64",
target_endian = "little"
),
target_arch = "wasm32",
feature = "generic-simd"
))]
Expand Down Expand Up @@ -93,7 +96,11 @@ pub fn count(haystack: &[u8], needle: u8) -> usize {
}
}
}
#[cfg(all(target_arch = "aarch64", not(feature = "generic_simd")))]
#[cfg(all(
target_arch = "aarch64",
target_endian = "little",
not(feature = "generic_simd")
))]
{
unsafe {
return simd::aarch64::chunk_count(haystack, needle);
Expand Down Expand Up @@ -155,7 +162,11 @@ pub fn num_chars(utf8_chars: &[u8]) -> usize {
}
}
}
#[cfg(all(target_arch = "aarch64", not(feature = "generic_simd")))]
#[cfg(all(
target_arch = "aarch64",
target_endian = "little",
not(feature = "generic_simd")
))]
{
unsafe {
return simd::aarch64::chunk_num_chars(utf8_chars);
Expand Down

0 comments on commit 0430800

Please sign in to comment.