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

Use portable-atomic crate on no-std target #4

Merged
merged 2 commits into from
Aug 3, 2022
Merged

Use portable-atomic crate on no-std target #4

merged 2 commits into from
Aug 3, 2022

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Feb 24, 2022

This allows removing volatile read/write hack on targets do not support atomic load/store.

atomic-memcpy/src/lib.rs

Lines 832 to 834 in 6a2a8f6

// HACK: Using volatile read/write instead of atomic load/store on single-threaded platforms where
// LLVM does not support atomic is normally considered to be an okay workaround.
// <https://github.com/rust-lang/compiler-builtins/commit/e0187f17dbcbf9dc026d379b2af8d866300596a5>

refs: portable-atomic

@taiki-e taiki-e force-pushed the portable-atomic branch 3 times, most recently from 3a3998c to 47f48be Compare February 26, 2022 10:18
@taiki-e taiki-e force-pushed the portable-atomic branch 3 times, most recently from a52b3de to de3c320 Compare March 11, 2022 16:03
@taiki-e taiki-e marked this pull request as ready for review March 12, 2022 18:26
@taiki-e taiki-e force-pushed the portable-atomic branch 3 times, most recently from 7978009 to de303c3 Compare June 12, 2022 14:30
@taiki-e
Copy link
Owner Author

taiki-e commented Aug 3, 2022

This will reduce performance somewhat for types with smaller alignments, but considering that the current one is technically UB, that atomic load/store support will be added in LLVM on these platforms, and that after the standard library supports it, portable-atomic's version detection can handle them, tend to merge this.

Users who need the same codegen as before can set up an unsafe cfg atomic_memcpy_unsafe_volatile as before.

@taiki-e
Copy link
Owner Author

taiki-e commented Aug 3, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 3, 2022

Build succeeded:

@bors bors bot merged commit ea0d6c0 into main Aug 3, 2022
@bors bors bot deleted the portable-atomic branch August 3, 2022 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant