Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch ahash 0.7.x to support AVR using atomic-polyfill #125

Merged
merged 2 commits into from Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.toml
Expand Up @@ -33,6 +33,9 @@ std = []
# If this is disabled and gerrandom is unavailable constant keys are used.
compile-time-rng = ["const-random"]

# in case this is being used on an architecture lacking core::sync::atomic::AtomicUsize and friends
atomic-polyfill = [ "dep:atomic-polyfill", "once_cell/atomic-polyfill"]

[[bench]]
name = "ahash"
path = "tests/bench.rs"
Expand Down Expand Up @@ -72,9 +75,10 @@ serde = { version = "1.0.117", optional = true }
[target.'cfg(not(any(target_os = "linux", target_os = "android", target_os = "windows", target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly", target_os = "solaris", target_os = "illumos", target_os = "fuchsia", target_os = "redox", target_os = "cloudabi", target_os = "haiku", target_os = "vxworks", target_os = "emscripten", target_os = "wasi")))'.dependencies]
const-random = { version = "0.1.12", optional = true }
serde = { version = "1.0.117", optional = true }
atomic-polyfill = { version="1.0.1", optional=true}

[target.'cfg(not(all(target_arch = "arm", target_os = "none")))'.dependencies]
once_cell = { version = "1.8", default-features = false, features = ["alloc"] }
once_cell = { version = "1.13.1", default-features = false, features = ["alloc"] }

[dev-dependencies]
no-panic = "0.1.10"
Expand Down
7 changes: 6 additions & 1 deletion src/random_state.rs
Expand Up @@ -29,8 +29,13 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std as alloc;

#[cfg(feature = "atomic-polyfill")]
use atomic_polyfill as atomic;
#[cfg(not(feature = "atomic-polyfill"))]
use core::sync::atomic;

use alloc::boxed::Box;
use core::sync::atomic::{AtomicUsize, Ordering};
use atomic::{AtomicUsize, Ordering};
#[cfg(not(all(target_arch = "arm", target_os = "none")))]
use once_cell::race::OnceBox;

Expand Down