Skip to content

Commit

Permalink
Support running inside miri
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun authored and oconnor663 committed Mar 10, 2024
1 parent 8fc3618 commit e6e7f27
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/platform.rs
Expand Up @@ -56,6 +56,11 @@ pub enum Platform {
impl Platform {
#[allow(unreachable_code)]
pub fn detect() -> Self {
#[cfg(miri)]
{
return Platform::Portable;
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
#[cfg(blake3_avx512_ffi)]
Expand Down Expand Up @@ -329,6 +334,10 @@ impl Platform {
#[inline(always)]
#[allow(unreachable_code)]
pub fn avx512_detected() -> bool {
if cfg!(miri) {
return false;
}

// A testing-only short-circuit.
if cfg!(feature = "no_avx512") {
return false;
Expand All @@ -352,6 +361,10 @@ pub fn avx512_detected() -> bool {
#[inline(always)]
#[allow(unreachable_code)]
pub fn avx2_detected() -> bool {
if cfg!(miri) {
return false;
}

// A testing-only short-circuit.
if cfg!(feature = "no_avx2") {
return false;
Expand All @@ -375,6 +388,10 @@ pub fn avx2_detected() -> bool {
#[inline(always)]
#[allow(unreachable_code)]
pub fn sse41_detected() -> bool {
if cfg!(miri) {
return false;
}

// A testing-only short-circuit.
if cfg!(feature = "no_sse41") {
return false;
Expand All @@ -398,6 +415,10 @@ pub fn sse41_detected() -> bool {
#[inline(always)]
#[allow(unreachable_code)]
pub fn sse2_detected() -> bool {
if cfg!(miri) {
return false;
}

// A testing-only short-circuit.
if cfg!(feature = "no_sse2") {
return false;
Expand Down

0 comments on commit e6e7f27

Please sign in to comment.