Skip to content

Commit edc3f23

Browse files
makotokatognzlbg
authored andcommitted
Add CRC32 detection to arm32
armv8 has 32-bit mode, but it can use crc32 instruction sets even if 32-bit.
1 parent 6a016c7 commit edc3f23

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

crates/std_detect/src/detect/arch/arm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ features! {
1414
/// ARM Advanced SIMD (NEON) - Aarch32
1515
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] pmull: "pmull";
1616
/// Polynomial Multiply
17+
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
18+
/// CRC32 (Cyclic Redundancy Check)
1719
}

crates/std_detect/src/detect/os/linux/arm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ pub(crate) fn detect_features() -> cache::Initializer {
1515

1616
// The values are part of the platform-specific [asm/hwcap.h][hwcap]
1717
//
18-
// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h
18+
// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm/include/uapi/asm/hwcap.h
1919
if let Ok(auxv) = auxvec::auxv() {
2020
enable_feature(&mut value, Feature::neon, bit::test(auxv.hwcap, 12));
2121
enable_feature(&mut value, Feature::pmull, bit::test(auxv.hwcap2, 1));
22+
enable_feature(&mut value, Feature::crc, bit::test(auxv.hwcap2, 4));
2223
return value;
2324
}
2425

@@ -29,6 +30,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
2930
c.field("Features").has("neon") && !has_broken_neon(&c),
3031
);
3132
enable_feature(&mut value, Feature::pmull, c.field("Features").has("pmull"));
33+
enable_feature(&mut value, Feature::crc, c.field("Features").has("crc32"));
3234
return value;
3335
}
3436
value

crates/std_detect/tests/cpu-detection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn all() {
2424
fn arm_linux() {
2525
println!("neon: {}", is_arm_feature_detected!("neon"));
2626
println!("pmull: {}", is_arm_feature_detected!("pmull"));
27+
println!("crc: {}", is_arm_feature_detected!("crc"));
2728
}
2829

2930
#[test]

0 commit comments

Comments
 (0)