]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | //! Run-time feature detection for ARM on FreeBSD |
2 | ||
3 | use crate::detect::{Feature, cache}; | |
4 | use super::{auxvec}; | |
5 | ||
6 | /// Performs run-time feature detection. | |
7 | #[inline] | |
8 | pub fn check_for(x: Feature) -> bool { | |
9 | cache::test(x as u32, detect_features) | |
10 | } | |
11 | ||
12 | /// Try to read the features from the auxiliary vector | |
13 | fn detect_features() -> cache::Initializer { | |
14 | let mut value = cache::Initializer::default(); | |
15 | let enable_feature = |value: &mut cache::Initializer, f, enable| { | |
16 | if enable { | |
17 | value.set(f as u32); | |
18 | } | |
19 | }; | |
20 | ||
21 | if let Ok(auxv) = auxvec::auxv() { | |
22 | enable_feature(&mut value, Feature::neon, auxv.hwcap & 0x00001000 != 0); | |
23 | enable_feature(&mut value, Feature::pmull, auxv.hwcap2 & 0x00000002 != 0); | |
24 | return value; | |
25 | } | |
26 | value | |
27 | } |