]> git.proxmox.com Git - rustc.git/blob - vendor/sha-1/src/compress/aarch64.rs
New upstream version 1.49.0~beta.4+dfsg1
[rustc.git] / vendor / sha-1 / src / compress / aarch64.rs
1 #![cfg(feature = "asm-aarch64")]
2 use libc::{getauxval, AT_HWCAP, HWCAP_SHA1};
3
4 fn sha1_supported() -> bool {
5 #[allow(unsafe_code)]
6 let hwcaps: u64 = unsafe { getauxval(AT_HWCAP) };
7 (hwcaps & HWCAP_SHA1) != 0
8 }
9
10 pub fn compress(state: &mut [u32; 5], blocks: &[u8; 64]) {
11 // TODO: Replace this platform-specific call with is_aarch64_feature_detected!("sha1") once
12 // that macro is stabilised and https://github.com/rust-lang/rfcs/pull/2725 is implemented
13 // to let us use it on no_std.
14 if sha1_supported() {
15 for block in blocks {
16 sha1_asm::compress(state, block);
17 }
18 } else {
19 super::soft::compress(state, blocks);
20 }
21 }