From 67aef22b8049ac9e5994f98dfb704b119593630d Mon Sep 17 00:00:00 2001 From: Georges Palauqui Date: Sat, 14 Sep 2024 10:47:25 +0200 Subject: [PATCH 1/2] add support for defmt log using a new feature --- Cargo.toml | 7 ++++++- src/decode.rs | 1 + src/error.rs | 1 + src/lib.rs | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c6dfe97..4fae222 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,17 +17,22 @@ exclude = [ ] [dependencies] +defmt = { version = "0.3", optional = true } serde = { version = "1.0", default-features = false, optional = true } [features] default = ["std", "serde"] std = ["alloc", "serde?/std"] -alloc = [] +alloc = ["defmt?/alloc"] serde = ["dep:serde", "alloc"] +defmt-03 = ["dep:defmt"] [target.'cfg(not(feature = "alloc"))'.dependencies] heapless = { version = "0.8" } +[target.'cfg(not(feature = "alloc"))'.features] +defmt-03 = ["dep:defmt", "heapless/defmt-03"] + [dev-dependencies] criterion = "0.5" rustc-hex = "1.0" diff --git a/src/decode.rs b/src/decode.rs index be8ea59..0e2af54 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -140,6 +140,7 @@ pub unsafe fn hex_check_sse(src: &[u8]) -> bool { } #[derive(Eq, PartialEq)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub enum CheckCase { None, Lower, diff --git a/src/error.rs b/src/error.rs index 00d5a70..5930c10 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,5 @@ #[derive(Clone, Copy, PartialEq)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub enum Error { InvalidChar, InvalidLength(usize), diff --git a/src/lib.rs b/src/lib.rs index aa54d2e..008af39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,7 @@ pub use crate::encode::hex_to; pub use crate::decode::{hex_check_sse, hex_check_sse_with_case}; #[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "defmt-03", derive(defmt::Format))] pub(crate) enum Vectorization { None = 0, SSE41 = 1, From e31a4f14799846a9aba70fc799a1cd5546da8b42 Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Mon, 16 Sep 2024 12:51:53 +1000 Subject: [PATCH 2/2] check bit 28 for avx support --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index aa54d2e..7a89a1a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,7 @@ fn vectorization_support_no_cache_x86() -> Vectorization { let have_xsave = (proc_info_ecx >> 26) & 1 == 1; let have_osxsave = (proc_info_ecx >> 27) & 1 == 1; - let have_avx = (proc_info_ecx >> 27) & 1 == 1; + let have_avx = (proc_info_ecx >> 28) & 1 == 1; if have_xsave && have_osxsave && have_avx { // # Safety: We checked that the processor supports xsave if unsafe { avx2_support_no_cache_x86() } {