]>
git.proxmox.com Git - rustc.git/blob - library/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs
1 //! Run-time feature detection for PowerPC on Linux.
4 use crate::detect
::{cache, Feature}
;
6 /// Try to read the features from the auxiliary vector, and if that fails, try
7 /// to read them from /proc/cpuinfo.
8 pub(crate) fn detect_features() -> cache
::Initializer
{
9 let mut value
= cache
::Initializer
::default();
10 let enable_feature
= |value
: &mut cache
::Initializer
, f
, enable
| {
16 // The values are part of the platform-specific [asm/cputable.h][cputable]
18 // [cputable]: https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/cputable.h
19 if let Ok(auxv
) = auxvec
::auxv() {
20 // note: the PowerPC values are the mask to do the test (instead of the
21 // index of the bit to test like in ARM and Aarch64)
22 enable_feature(&mut value
, Feature
::altivec
, auxv
.hwcap
& 0x10000000 != 0);
23 enable_feature(&mut value
, Feature
::vsx
, auxv
.hwcap
& 0x00000080 != 0);
24 enable_feature(&mut value
, Feature
::power8
, auxv
.hwcap2
& 0x80000000 != 0);
28 // PowerPC's /proc/cpuinfo lacks a proper Feature field,
29 // but `altivec` support is indicated in the `cpu` field.
30 #[cfg(feature = "std_detect_file_io")]
31 if let Ok(c
) = super::cpuinfo
::CpuInfo
::new() {
32 enable_feature(&mut value
, Feature
::altivec
, c
.field("cpu").has("altivec"));