embassy-rs / atomic-polyfill Goto Github PK
View Code? Open in Web Editor NEW⚠️ DEPRECATED ⚠️ -- use `portable-atomic` instead.
License: Apache License 2.0
⚠️ DEPRECATED ⚠️ -- use `portable-atomic` instead.
License: Apache License 2.0
Currently this crate doesn't make available deprecated items in polyfilled mode. This includes:
compare_and_swap
method on all atomic typesATOMIC_XX_INIT
constsspin_loop_hint
functionTo me this doesn't seem a big deal because if you're migrating some code from core::sync::atomic
to atomic_polyfill
you're already doing modifications,
OTOH it might be annoying to have code that compiles in non-polyfilled mode and fails in polyfilled mode. If we aim to be a complete drop-in replacement maybe deprecated items should be available too...
Thoughts?
Does this crate have an MSRV policy? I doubt that it's any recent version of Rust (since it just re-exports core
primitives or redefines them using relatively low-level types), but it would be nice to know for when users want to include it in their projects.
This crate is required because shared-bus
0.2.3 now depends on it.
at 09:24:22 ❯ cargo build
Compiling atomic-polyfill v0.1.6
Compiling robotica-remote-rust v0.22.8 (/home/brian/tree/personal/robotica-remote-rust)
error[E0432]: unresolved import `core::sync::atomic::AtomicU64`
--> /home/brian/.cargo/registry/src/github.com-1ecc6299db9ec823/atomic-polyfill-0.1.6/src/lib.rs:8:17
|
8 | pub use core::sync::atomic::$atomic_type;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `AtomicU64` in `sync::atomic`
...
195 | atomic_int!(u64, AtomicU64, u64_native, u64_cas, u64_full);
| ----------------------------------------------------------
| | |
| | help: a similar name exists in the module: `AtomicU8`
| in this macro invocation
|
= note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `core::sync::atomic::AtomicI64`
--> /home/brian/.cargo/registry/src/github.com-1ecc6299db9ec823/atomic-polyfill-0.1.6/src/lib.rs:8:17
|
8 | pub use core::sync::atomic::$atomic_type;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `AtomicI64` in `sync::atomic`
...
200 | atomic_int!(i64, AtomicI64, i64_native, i64_cas, i64_full);
| ----------------------------------------------------------
| | |
| | help: a similar name exists in the module: `AtomicI8`
| in this macro invocation
|
= note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0432`.
error: could not compile `atomic-polyfill` due to 2 previous errors
I am currently working on a project on an MSP430 and embassy-executor appears to require an implementation of atomic-polyfill
for this target. I can cook up a patched version on a fork and submit a PR. Creating this issue to track.
The compile-time features in the crate are fairly granular, but in build.rs
they are more coarse.
In practice, this means that platforms such as AVR can't express that they natively support some
atomic operations on small-width integer types, but need polyfills on larger ones to the build process.
Would you be open to a patch that makes the built-in tuning in build.rs
a bit more granular?
I'd like to use this in a crate that also uses Arc
. Theoretically, it should be possible to also re-export/re-implement the Arc
and Weak
types using this crate. Maybe lock it behind an alloc
feature for targets without an allocator available.
I can implement this PR myself.
AtomicPtr and AtomicBool don't implement Debug, contrary to their std equivalent.
I was unable to compile the latest release or latest master using nightly. In order to get it to compile successfully, I had to bring in the master version of critical-section
instead of 0.2.7.
jeremy@jeremy-desktop:~/apechem/atomic-polyfill$ cargo +nightly build --target avr-unknown-gnu-atmega328 -Z build-std=core --release
Compiling critical-section v0.2.7
Compiling atomic-polyfill v0.1.8 (/home/jeremy/apechem/atomic-polyfill)
error: cannot find macro `llvm_asm` in this scope
--> /home/jeremy/.cargo/registry/src/github.com-1ecc6299db9ec823/critical-section-0.2.7/src/lib.rs:127:13
|
127 | llvm_asm!(
| ^^^^^^^^
error: cannot find macro `llvm_asm` in this scope
--> /home/jeremy/.cargo/registry/src/github.com-1ecc6299db9ec823/critical-section-0.2.7/src/lib.rs:139:17
|
139 | llvm_asm!("sei" :::: "volatile");
| ^^^^^^^^
error[E0635]: unknown feature `llvm_asm`
--> /home/jeremy/.cargo/registry/src/github.com-1ecc6299db9ec823/critical-section-0.2.7/src/lib.rs:3:42
|
3 | #![cfg_attr(target_arch = "avr", feature(llvm_asm))]
| ^^^^^^^^
For more information about this error, try `rustc --explain E0635`.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.