about summary refs log tree commit diff
path: root/library/stdarch/crates/std_detect
diff options
context:
space:
mode:
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>2019-11-30 15:16:19 +0900
committergnzlbg <gnzlbg@users.noreply.github.com>2019-12-02 19:23:05 +0100
commitcca9a86637c3307f2d25c9e63567b726b1612c0a (patch)
treed50846bf71b8d1db53fbf2c7ee3d46f4b6b69775 /library/stdarch/crates/std_detect
parent7c56404f1a3270c7a0f1bab31444cb0316e9307d (diff)
downloadrust-cca9a86637c3307f2d25c9e63567b726b1612c0a.tar.gz
rust-cca9a86637c3307f2d25c9e63567b726b1612c0a.zip
Add CRC32 detection to arm32
armv8 has 32-bit mode, but it can use crc32 instruction sets even if 32-bit.
Diffstat (limited to 'library/stdarch/crates/std_detect')
-rw-r--r--library/stdarch/crates/std_detect/src/detect/arch/arm.rs2
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs4
-rw-r--r--library/stdarch/crates/std_detect/tests/cpu-detection.rs1
3 files changed, 6 insertions, 1 deletions
diff --git a/library/stdarch/crates/std_detect/src/detect/arch/arm.rs b/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
index 02bf654945d..96978b70098 100644
--- a/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
+++ b/library/stdarch/crates/std_detect/src/detect/arch/arm.rs
@@ -14,4 +14,6 @@ features! {
     /// ARM Advanced SIMD (NEON) - Aarch32
     @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
     /// Polynomial Multiply
+    @FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
+    /// CRC32 (Cyclic Redundancy Check)
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs b/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs
index a1b28dad70f..f55bc30b849 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs
@@ -15,10 +15,11 @@ pub(crate) fn detect_features() -> cache::Initializer {
 
     // The values are part of the platform-specific [asm/hwcap.h][hwcap]
     //
-    // [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h
+    // [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm/include/uapi/asm/hwcap.h
     if let Ok(auxv) = auxvec::auxv() {
         enable_feature(&mut value, Feature::neon, bit::test(auxv.hwcap, 12));
         enable_feature(&mut value, Feature::pmull, bit::test(auxv.hwcap2, 1));
+        enable_feature(&mut value, Feature::crc, bit::test(auxv.hwcap2, 4));
         return value;
     }
 
@@ -29,6 +30,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
             c.field("Features").has("neon") && !has_broken_neon(&c),
         );
         enable_feature(&mut value, Feature::pmull, c.field("Features").has("pmull"));
+        enable_feature(&mut value, Feature::crc, c.field("Features").has("crc32"));
         return value;
     }
     value
diff --git a/library/stdarch/crates/std_detect/tests/cpu-detection.rs b/library/stdarch/crates/std_detect/tests/cpu-detection.rs
index d441f4e1eff..7beb8a491a4 100644
--- a/library/stdarch/crates/std_detect/tests/cpu-detection.rs
+++ b/library/stdarch/crates/std_detect/tests/cpu-detection.rs
@@ -24,6 +24,7 @@ fn all() {
 fn arm_linux() {
     println!("neon: {}", is_arm_feature_detected!("neon"));
     println!("pmull: {}", is_arm_feature_detected!("pmull"));
+    println!("crc: {}", is_arm_feature_detected!("crc"));
 }
 
 #[test]