Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from linkmauve/use-libc
sha1, sha2: Use libc for AArch64 consts too
- Loading branch information
Showing
4 changed files
with
6 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
// TODO: Import those from libc, see https://github.com/rust-lang/libc/pull/1638 | ||
const AT_HWCAP: u64 = 16; | ||
const HWCAP_SHA1: u64 = 32; | ||
use libc::{getauxval, AT_HWCAP, HWCAP_SHA1}; | ||
|
||
#[inline(always)] | ||
pub fn sha1_supported() -> bool { | ||
let hwcaps: u64 = unsafe { ::libc::getauxval(AT_HWCAP) }; | ||
let hwcaps: u64 = unsafe { getauxval(AT_HWCAP) }; | ||
(hwcaps & HWCAP_SHA1) != 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
// TODO: Import those from libc, see https://github.com/rust-lang/libc/pull/1638 | ||
const AT_HWCAP: u64 = 16; | ||
const HWCAP_SHA2: u64 = 64; | ||
use libc::{getauxval, AT_HWCAP, HWCAP_SHA2}; | ||
|
||
#[inline(always)] | ||
pub fn sha2_supported() -> bool { | ||
let hwcaps: u64 = unsafe { ::libc::getauxval(AT_HWCAP) }; | ||
let hwcaps: u64 = unsafe { getauxval(AT_HWCAP) }; | ||
(hwcaps & HWCAP_SHA2) != 0 | ||
} |