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

Update portable-atomic to 1 #139

Merged
merged 1 commit into from
Feb 20, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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]
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<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
Expand Down