diff --git a/Cargo.toml b/Cargo.toml index cb9df1d..505b762 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ rust-version = "1.38" [dependencies] lock_api_crate = { package = "lock_api", version = "0.4", optional = true } -portable-atomic = { version = "0.3", optional = true, default-features = false } +portable-atomic = { version = "1", optional = true, default-features = false } [features] default = ["lock_api", "mutex", "spin_mutex", "rwlock", "once", "lazy", "barrier"] @@ -52,9 +52,14 @@ lock_api = ["lock_api_crate"] # Enables std-only features such as yield-relaxing. std = [] -# Use the portable_atomic crate to support platforms without native atomic operations -# cfg 'portable_atomic_unsafe_assume_single_core' must also be set by the final binary crate. -# This cfg is unsafe and enabling it for multicore systems is unsound. +# Use the portable_atomic crate to support platforms without native atomic operations. +# The `portable_atomic_unsafe_assume_single_core` cfg or `critical-section` feature +# of `portable-atomic` crate must also be set by the final binary crate. +# When using the cfg, note that it is unsafe and enabling it for multicore systems is unsound. +# When using the `critical-section` feature, you need to implement the critical-section +# implementation that sound for your system by implementing an unsafe trait. +# See the documentation for the `portable-atomic` crate for more information: +# https://docs.rs/portable-atomic/latest/portable_atomic/#optional-cfg portable_atomic = ["portable-atomic"] [package.metadata.docs.rs] diff --git a/README.md b/README.md index 4af6cf9..7fd3780 100644 --- a/README.md +++ b/README.md @@ -94,15 +94,21 @@ The crate comes with a few feature flags that you may wish to use. - `portable_atomic` enables usage of the `portable-atomic` crate to support platforms without native atomic operations (Cortex-M0, etc.). - The `portable_atomic_unsafe_assume_single_core` cfg flag - must also be set by the final binary crate. - This can be done by adapting the following snippet to the `.cargo/config` file: + The `portable_atomic_unsafe_assume_single_core` cfg or `critical-section` feature + of `portable-atomic` crate must also be set by the final binary crate. + + When using the cfg, this can be done by adapting the following snippet to the `.cargo/config` file: ``` [target.] rustflags = [ "--cfg", "portable_atomic_unsafe_assume_single_core" ] ``` Note that this cfg is unsafe by nature, and enabling it for multicore systems is unsound. + When using the `critical-section` feature, you need to implement the critical-section + implementation that sound for your system by implementing an unsafe trait. + See [the documentation for the `portable-atomic` crate](https://docs.rs/portable-atomic/latest/portable_atomic/#optional-cfg) + for more information. + ## Remarks It is often desirable to have a lock shared between threads. Wrapping the lock in an