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

fix AVR support by using atomic-polyfill #124

Merged
merged 3 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 @@ -36,6 +36,9 @@ runtime-rng = ["getrandom"]
# If this is disabled and runtime-rng 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 @@ getrandom = { version = "0.2.3", optional = true }
const-random = { version = "0.1.12", optional = true }
serde = { version = "1.0.117", optional = true }
cfg-if = "1.0"
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 = ["unstable", "alloc"] }
once_cell = { version = "1.13.1", default-features = false, features = ["unstable", "alloc"] }

[dev-dependencies]
no-panic = "0.1.10"
Expand Down
7 changes: 6 additions & 1 deletion src/random_state.rs
Expand Up @@ -23,8 +23,13 @@ cfg_if::cfg_if! {
}
}

#[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};
use core::any::{Any, TypeId};
use core::fmt;
use core::hash::BuildHasher;
Expand Down