Add ISA flag detection for s390x (#4101)

Adds support for s390x to check_compatible_with_isa_flag,
which fixes running the test suite on z15 and later.
This commit is contained in:
Ulrich Weigand
2022-05-05 18:26:19 +02:00
committed by GitHub
parent 7fdc616368
commit e1f7b50a12

View File

@@ -390,7 +390,8 @@ impl Engine {
} }
} }
let enabled; #[allow(unused_assignments)]
let mut enabled = None;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
{ {
@@ -403,6 +404,24 @@ impl Engine {
}; };
} }
// There is no is_s390x_feature_detected macro yet, so for now
// we use getauxval from the libc crate directly.
#[cfg(all(target_arch = "s390x", target_os = "linux"))]
{
let v = unsafe { libc::getauxval(libc::AT_HWCAP) };
const HWCAP_S390X_VXRS_EXT2: libc::c_ulong = 32768;
enabled = match flag {
// There is no separate HWCAP bit for mie2, so assume
// that any machine with vxrs_ext2 also has mie2.
"has_vxrs_ext2" | "has_mie2" => Some((v & HWCAP_S390X_VXRS_EXT2) != 0),
// fall through to the very bottom to indicate that support is
// not enabled to test whether this feature is enabled on the
// host.
_ => None,
}
}
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
{ {
enabled = match flag { enabled = match flag {
@@ -429,11 +448,6 @@ impl Engine {
}; };
} }
#[cfg(not(any(target_arch = "aarch64", target_arch = "x86_64")))]
{
enabled = None;
}
match enabled { match enabled {
Some(true) => return Ok(()), Some(true) => return Ok(()),
Some(false) => { Some(false) => {