From dc44e88c6c845f45f24448cc9f54939f6b31583f Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:26:34 +0200 Subject: [PATCH] Add force-generic feature flag --- .github/workflows/ci.yml | 6 +++--- Cargo.toml | 3 +++ src/lib.rs | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c5548a..514d725 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,10 +41,10 @@ jobs: - run: cargo build - run: cargo test - - run: cargo test --release - run: cargo build --no-default-features - run: cargo test --tests --no-default-features - - run: cargo test --tests --no-default-features --release --all-features + - run: cargo test --tests --no-default-features --features force-generic + - run: cargo test --tests --no-default-features --features nightly,portable-simd if: matrix.rust == 'nightly' - run: cargo bench --no-run if: matrix.rust == 'nightly' @@ -57,7 +57,7 @@ jobs: fail-fast: false matrix: target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] - flags: [--no-default-features, "", --all-features] + flags: [--no-default-features, "", --all-features, --features force-generic] exclude: # miri doesn't implement neon intrinsics. - target: aarch64-unknown-linux-gnu diff --git a/Cargo.toml b/Cargo.toml index ce62c6c..fecc95c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,9 @@ default = ["std"] std = ["hex?/std", "serde?/std", "alloc"] alloc = ["hex?/alloc", "serde?/alloc"] +# Forces generic implementation, overriding any specialized implementation (e.g. x86 or aarch64) +force-generic = [] + # Serde support. Use with `#[serde(with = "const_hex")]` serde = ["hex?/serde", "dep:serde"] diff --git a/src/lib.rs b/src/lib.rs index 1ab89f6..54b347b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,9 @@ use alloc::{string::String, vec::Vec}; // The main encoding and decoding functions. cfg_if! { - if #[cfg(feature = "portable-simd")] { + if #[cfg(feature = "force-generic")] { + use generic as imp; + } else if #[cfg(feature = "portable-simd")] { mod portable_simd; use portable_simd as imp; } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {