Skip to content

Commit 0430800

Browse files
committed
src/lib.rs: make this build on big-endian aarch64.
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
1 parent e6c7318 commit 0430800

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/lib.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ mod integer_simd;
5050
feature = "runtime-dispatch-simd",
5151
any(target_arch = "x86", target_arch = "x86_64")
5252
),
53-
target_arch = "aarch64",
53+
all(
54+
target_arch = "aarch64",
55+
target_endian = "little"
56+
),
5457
target_arch = "wasm32",
5558
feature = "generic-simd"
5659
))]
@@ -93,7 +96,11 @@ pub fn count(haystack: &[u8], needle: u8) -> usize {
9396
}
9497
}
9598
}
96-
#[cfg(all(target_arch = "aarch64", not(feature = "generic_simd")))]
99+
#[cfg(all(
100+
target_arch = "aarch64",
101+
target_endian = "little",
102+
not(feature = "generic_simd")
103+
))]
97104
{
98105
unsafe {
99106
return simd::aarch64::chunk_count(haystack, needle);
@@ -155,7 +162,11 @@ pub fn num_chars(utf8_chars: &[u8]) -> usize {
155162
}
156163
}
157164
}
158-
#[cfg(all(target_arch = "aarch64", not(feature = "generic_simd")))]
165+
#[cfg(all(
166+
target_arch = "aarch64",
167+
target_endian = "little",
168+
not(feature = "generic_simd")
169+
))]
159170
{
160171
unsafe {
161172
return simd::aarch64::chunk_num_chars(utf8_chars);

0 commit comments

Comments
 (0)