Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.DS_Store
.git
.vscode
/scripts
44 changes: 40 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,42 @@ rustversion = "1.0"
indexmap = { version = ">=2.11.0, <2.12.0", optional = true }

# no_std support
# spin is always required for no_std builds (feature detection synchronization)
spin = { version = "0.10.0", default-features = false, features = ["once", "rwlock", "mutex", "spin_mutex"] }
# spin is optional - only needed on architectures with SIMD (for feature detection)
# or when cache feature is enabled
spin = { version = "0.10.0", default-features = false, features = [
"once",
"rwlock",
"mutex",
"spin_mutex",
], optional = true }
# hashbrown is only needed when caching is enabled in no_std
hashbrown = { version = "0.16.0", optional = true }

# Target-specific dependencies: spin is needed for feature detection on SIMD-capable architectures
[target.'cfg(target_arch = "aarch64")'.dependencies]
spin = { version = "0.10.0", default-features = false, features = [
"once",
"rwlock",
"mutex",
"spin_mutex",
] }

[target.'cfg(target_arch = "x86")'.dependencies]
spin = { version = "0.10.0", default-features = false, features = [
"once",
"rwlock",
"mutex",
"spin_mutex",
] }

[target.'cfg(target_arch = "x86_64")'.dependencies]
spin = { version = "0.10.0", default-features = false, features = [
"once",
"rwlock",
"mutex",
"spin_mutex",
] }

[dev-dependencies]
criterion = "0.7"
cbindgen = "0.29"
Expand Down Expand Up @@ -80,11 +111,16 @@ default = ["std", "panic-handler", "ffi"]
std = ["alloc"] # std implies alloc is available
alloc = ["digest"] # marker feature for heap allocation support
panic-handler = [] # Provides panic handler for no_std library checks (disable in binaries)
ffi = [] # C/C++ compatible dynamic/static library, planned to become optional in the next MAJOR version (v2) to reduce overhead
ffi = [
] # C/C++ compatible dynamic/static library, planned to become optional in the next MAJOR version (v2) to reduce overhead

# optional features
cli = ["std"] # command line interface binaries (checksum, arch-check, get-custom-params)
cache = ["alloc", "hashbrown"] # no_std caching requires alloc + hashbrown HashMap
cache = [
"alloc",
"hashbrown",
"spin",
] # no_std caching requires alloc + hashbrown HashMap + spin for synchronization

# the features below are deprecated, aren't in use, and will be removed in the next MAJOR version (v2)
vpclmulqdq = [] # deprecated, VPCLMULQDQ stabilized in Rust 1.89.0
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ ifeq ($(UNAME_S),Linux)
POST_INSTALL := ldconfig
else ifeq ($(UNAME_S),Darwin)
DESTDIR ?=
# on macOS, there's not really a default location, so require DESTDIR
ifeq ($(DESTDIR),)
$(error On macOS, DESTDIR must be set for installation. Common locations include /usr/local or /opt/homebrew)
endif
LIB_EXTENSION := dylib
STATIC_LIB_EXTENSION := a
INSTALL_LIB_DIR := /lib
Expand Down Expand Up @@ -96,6 +92,16 @@ uninstall: print-paths
ldconfig; \
fi

# Run all code quality checks
.PHONY: check
check:
cargo fmt --all
cargo check --workspace --all-targets --all-features
cargo clippy --workspace --all-targets --all-features --fix --allow-dirty -- -D warnings
# cargo deny check all
# RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --all-features
# cargo audit

# Clean build artifacts
.PHONY: clean
clean:
Expand Down
4 changes: 3 additions & 1 deletion src/arch/x86_64/avx512_vpclmulqdq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl Simd512 {
))
}

#[cfg(feature = "std")]
#[inline]
#[target_feature(enable = "avx512f")]
unsafe fn extract_u64s(&self) -> [u64; 8] {
Expand Down Expand Up @@ -93,6 +94,7 @@ impl Simd512 {
Self(_mm512_xor_si512(self.0, other.0))
}

#[cfg(feature = "std")]
#[inline]
#[target_feature(enable = "avx512f")]
#[allow(unused)]
Expand Down Expand Up @@ -382,7 +384,7 @@ unsafe fn reflect_bytes512(reflector: &Reflector512, data: Simd512) -> Simd512 {
// pre-compute the reverse indices for 512-bit shuffling
#[rustversion::since(1.89)]
static REVERSE_INDICES_512: __m512i =
unsafe { std::mem::transmute([7u64, 6u64, 5u64, 4u64, 3u64, 2u64, 1u64, 0u64]) };
unsafe { core::mem::transmute([7u64, 6u64, 5u64, 4u64, 3u64, 2u64, 1u64, 0u64]) };

// Implement a 512-bit byte shuffle function
#[rustversion::since(1.89)]
Expand Down
5 changes: 4 additions & 1 deletion src/crc32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
pub mod algorithm;
pub mod consts;

#[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(all(
feature = "std",
any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")
))]
pub(crate) mod fusion;
Loading