Skip to content

Support for portable-atomic #35

@peku33

Description

@peku33

Hi, I would like to achieve AtomicRefCell-like behavior on no_std target without CAS support (lots of baseline MCUs like cortex-m0, avr, baseline risc-v). While current implementation is generally no_std friendly, these platforms do not support operations like fetch_add and fetch_sub and compilation fails.

There is a portable-atomic crate ( https://lib.rs/crates/portable-atomic ) (25M monthly downloads) that fills missing CAS operations using platform-dependent implementation (eg. uses CAS where available, uses critical-section where not).

I would like to extend atomic_refcell crate to allow using portable-atomic, based on feature flag (so base implementation will remain unchanged). I would like to ask, whether you are willing to accept a PR adding such functionality and what are your requirements.

My idea was to:

  • add portable-atomic feature to this crate, make it disabled by default
  • add portable-atomic optional dependency, based on this feature, using library-style features (none)
  • replace imports with portable-atomic types, based on feature flag
  • bump release version
  • adjust docs

Let me know whether this plan looks fine and whether you are open to accept such change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions