Skip to content

Commit a0874f5

Browse files
authored
cpufeatures: add support for aarch64's sm4 target feature (#972)
1 parent fd04ea5 commit a0874f5

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

cpufeatures/src/aarch64.rs

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ __expand_check_macro! {
6969
("aes", AES), // Enable AES support.
7070
("sha2", SHA2), // Enable SHA1 and SHA256 support.
7171
("sha3", SHA3), // Enable SHA512 and SHA3 support.
72+
("sm4", SM4), // Enable SM3 and SM4 support.
7273
}
7374

7475
/// Linux hardware capabilities mapped to target features.
@@ -85,6 +86,7 @@ pub mod hwcaps {
8586
pub const AES: c_ulong = libc::HWCAP_AES | libc::HWCAP_PMULL;
8687
pub const SHA2: c_ulong = libc::HWCAP_SHA2;
8788
pub const SHA3: c_ulong = libc::HWCAP_SHA3 | libc::HWCAP_SHA512;
89+
pub const SM4: c_ulong = libc::HWCAP_SM3 | libc::HWCAP_SM4;
8890
}
8991

9092
// Apple OS (macOS, iOS, watchOS, and tvOS) `check!` macro.

cpufeatures/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
//! - `sha2`*
1919
//! - `sha3`*
2020
//!
21+
//! Linux only
22+
//!
23+
//! - `sm4`*
24+
//!
2125
//! ## `loongarch64`
2226
//!
2327
//! Linux only (LoongArch64 does not support OS-independent feature detection)

cpufeatures/tests/aarch64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![cfg(target_arch = "aarch64")]
44

5-
cpufeatures::new!(armcaps, "aes", "sha2", "sha3");
5+
cpufeatures::new!(armcaps, "aes", "sha2", "sha3", "sm4");
66

77
#[test]
88
fn init() {

0 commit comments

Comments
 (0)