Skip to content

Commit

Permalink
add no-std compatible aarch64 constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
srijs committed Feb 12, 2024
1 parent 3580338 commit aef4670
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/specialized/aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
use std::arch::aarch64 as arch;
use core::arch::aarch64 as arch;

#[derive(Clone)]
pub struct State {
state: u32,
}

impl State {
#[cfg(not(feature = "std"))]
pub fn new(state: u32) -> Option<Self> {
if cfg!(target_feature = "crc") {
// SAFETY: The conditions above ensure that all
// required instructions are supported by the CPU.
Some(Self { state })
} else {
None
}
}

#[cfg(feature = "std")]
pub fn new(state: u32) -> Option<Self> {
if std::arch::is_aarch64_feature_detected!("crc") {
// SAFETY: The conditions above ensure that all
Expand Down

0 comments on commit aef4670

Please sign in to comment.