]> git.proxmox.com Git - rustc.git/blame - src/tools/rustfmt/tests/source/cfg_if/detect/os/freebsd/arm.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / rustfmt / tests / source / cfg_if / detect / os / freebsd / arm.rs
CommitLineData
f20569fa
XL
1//! Run-time feature detection for ARM on FreeBSD
2
3use crate::detect::{Feature, cache};
4use super::{auxvec};
5
6/// Performs run-time feature detection.
7#[inline]
8pub 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
13fn 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}