Skip to content

Commit 33ff403

Browse files
authored
Merge pull request #33 from jfrimmel/portable-atomics-docu
Add explanation of supported hardware
2 parents a539d61 + 597c004 commit 33ff403

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,24 @@ A note to users on systems with advanced memory features like MMUs and MPUs:
6868
Use a proper memory allocator for that use case (one that supports paging, etc.).
6969
However, if you need dynamic memory before enabling the MMU, this crate certainly is an option.
7070

71+
# Platform support
72+
73+
This crate does not use any platform-specific features (e.g. an MMU or specific instructions), except for the requirement for a atomic compare-and-swap-instruction (CAS), which is widely available.
74+
Therefore this crate works out-of-the-box on most architectures.
75+
76+
Some platforms however don't provide such an instruction (e.g. `thumbv6m-none-eabi` or the RISC-V OpenTitan) or totally lack atomic instructions (e.g. AVR) due to only a single-core nature.
77+
On those platforms, where the CAS instruction is not available, one can use the workaround, that [`spin`][spin-docs] use: you can enable the `portable_atomic`-feature in your `Cargo.toml`, like this:
78+
```toml
79+
[dependencies.emballoc]
80+
version = "*" # replace with current version from crates.io
81+
features = ["portable_atomic"]
82+
```
83+
This enables the use of the `portable_atomic` instead of the `core`-atomics.
84+
This is safe on any platform.
85+
86+
To actually enable atomics support on platforms without hardware support, the `--cfg portable_atomic_unsafe_assume_single_core`-option needs to be explicitly enabled when compiling.
87+
For more details see the [documentation of `spin`][spin-docs].
88+
7189
# Minimum supported Rust version
7290

7391
This crate has a stability guarantee about the compiler version supported.
@@ -85,3 +103,4 @@ at your option.
85103

86104
[docu-testing]: https://docs.rs/emballoc/latest/emballoc/#testing
87105
[gist_hosted-test]: https://gist.github.com/jfrimmel/61943f9879adfbe760a78efa17a0ecaa
106+
[spin-docs]: https://crates.io/crates/spin#Feature_flags

0 commit comments

Comments
 (0)