diff --git a/lib.rs b/lib.rs index 590ac81bf..beba63b2d 100644 --- a/lib.rs +++ b/lib.rs @@ -4,6 +4,7 @@ #![feature(c_variadic)] #![feature(core_intrinsics)] #![feature(extern_types)] +#![cfg_attr(target_arch = "arm", feature(stdsimd))] #[cfg(not(any(feature = "bitdepth_8", feature = "bitdepth_16")))] compile_error!("No bitdepths enabled. Enable one or more of the following features: `bitdepth_8`, `bitdepth_16`"); diff --git a/src/arm/cpu.rs b/src/arm/cpu.rs index 56b7a758f..b993ba299 100644 --- a/src/arm/cpu.rs +++ b/src/arm/cpu.rs @@ -1,7 +1,6 @@ use bitflags::bitflags; -use cfg_if::cfg_if; +use std::arch; use std::ffi::c_uint; -use std::ffi::c_ulong; bitflags! { pub struct CpuFlags: c_uint { @@ -9,27 +8,18 @@ bitflags! { } } -pub const NEON_HWCAP: c_ulong = 1 << 12; - #[cold] pub unsafe fn dav1d_get_cpu_flags_arm() -> CpuFlags { let mut flags = CpuFlags::empty(); - cfg_if! { - if #[cfg(any( - target_arch = "aarch64", - target_os = "windows", - target_os = "macos" - ))] { - flags |= CpuFlags::NEON; - } else if #[cfg(target_arch = "arm")] { - if (libc::getauxval(libc::AT_HWCAP) & NEON_HWCAP) != 0 { - flags |= CpuFlags::NEON; - } - } else if #[cfg(target_os = "android")] { - // TODO: Support Android by parsing `/proc/cpuinfo` the way the original C does. - todo!("Android is not yet supported") - } + #[cfg(target_arch = "arm")] + if arch::is_arm_feature_detected!("neon") { + flags |= CpuFlags::NEON; + } + + #[cfg(target_arch = "aarch64")] + if arch::is_aarch64_feature_detected!("neon") { + flags |= CpuFlags::NEON; } flags