Skip to content

Commit 246cace

Browse files
taiki-ezesterer
authored andcommitted
Update portable-atomic to 1 (mvdnes#139)
1 parent 3f1fbb6 commit 246cace

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Cargo.toml

+9-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rust-version = "1.38"
1414

1515
[dependencies]
1616
lock_api_crate = { package = "lock_api", version = "0.4", optional = true }
17-
portable-atomic = { version = "0.3", optional = true, default-features = false }
17+
portable-atomic = { version = "1", optional = true, default-features = false }
1818

1919
[features]
2020
default = ["lock_api", "mutex", "spin_mutex", "rwlock", "once", "lazy", "barrier"]
@@ -52,9 +52,14 @@ lock_api = ["lock_api_crate"]
5252
# Enables std-only features such as yield-relaxing.
5353
std = []
5454

55-
# Use the portable_atomic crate to support platforms without native atomic operations
56-
# cfg 'portable_atomic_unsafe_assume_single_core' must also be set by the final binary crate.
57-
# This cfg is unsafe and enabling it for multicore systems is unsound.
55+
# Use the portable_atomic crate to support platforms without native atomic operations.
56+
# The `portable_atomic_unsafe_assume_single_core` cfg or `critical-section` feature
57+
# of `portable-atomic` crate must also be set by the final binary crate.
58+
# When using the cfg, note that it is unsafe and enabling it for multicore systems is unsound.
59+
# When using the `critical-section` feature, you need to implement the critical-section
60+
# implementation that sound for your system by implementing an unsafe trait.
61+
# See the documentation for the `portable-atomic` crate for more information:
62+
# https://docs.rs/portable-atomic/latest/portable_atomic/#optional-cfg
5863
portable_atomic = ["portable-atomic"]
5964

6065
[package.metadata.docs.rs]

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,21 @@ The crate comes with a few feature flags that you may wish to use.
9494

9595
- `portable_atomic` enables usage of the `portable-atomic` crate
9696
to support platforms without native atomic operations (Cortex-M0, etc.).
97-
The `portable_atomic_unsafe_assume_single_core` cfg flag
98-
must also be set by the final binary crate.
99-
This can be done by adapting the following snippet to the `.cargo/config` file:
97+
The `portable_atomic_unsafe_assume_single_core` cfg or `critical-section` feature
98+
of `portable-atomic` crate must also be set by the final binary crate.
99+
100+
When using the cfg, this can be done by adapting the following snippet to the `.cargo/config` file:
100101
```
101102
[target.<target>]
102103
rustflags = [ "--cfg", "portable_atomic_unsafe_assume_single_core" ]
103104
```
104105
Note that this cfg is unsafe by nature, and enabling it for multicore systems is unsound.
105106

107+
When using the `critical-section` feature, you need to implement the critical-section
108+
implementation that sound for your system by implementing an unsafe trait.
109+
See [the documentation for the `portable-atomic` crate](https://docs.rs/portable-atomic/latest/portable_atomic/#optional-cfg)
110+
for more information.
111+
106112
## Remarks
107113

108114
It is often desirable to have a lock shared between threads. Wrapping the lock in an

0 commit comments

Comments
 (0)