-
Notifications
You must be signed in to change notification settings - Fork 341
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 AtomicCell<u64> on targets with target_has_atomic less than 64 #286
Conversation
src/sync/atomic.rs
Outdated
// `#[cfg(target_has_atomic = "64")]`. | ||
// Refs: https://github.com/rust-lang/rust/tree/master/src/librustc_target | ||
cfg_if::cfg_if! { | ||
if #[cfg(not(any(target_arch = "arm", target_arch = "mips", target_arch = "powerpc")))] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many target_arch = "arm"
targets are target_has_atomic = "64"
, but only some targets seems different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc #48 Should we support these targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would definitely support arm-linux-androideabi
, I'm hard pressed to find a deployment target with armv5
that is relevant for async-std.
CI failure seems due to the fact that I enabled the test. |
2b036b2
to
72167f0
Compare
2352bff
to
bade3b7
Compare
This PR needs another rebase. |
bbd761b
to
83487da
Compare
83487da
to
d6c5377
Compare
This PR should not have changed the behavior on macOS, but this test failed on macOS on CI... But I couldn't reproduce this locally. |
Would it be better to name it as something else rather than AtomicU64? Rust atomics are guaranteed to be layout-wise identical to their corresponding integer type, so naming it as AtomicU64 may incorrectly represent that. Also: std::sync::Mutex is too heavy to protect just an integer. It'd be better to have a spinlock instead. |
I don't intend to make these implementations public, so I don't think it's a problem. However, if #355 is merged, we may need to consider this.
I agree. And another advantage of this is |
Another thought, would it make sense to do similar thing as crossbeam's AtomicCell which uses a global Mutex instead? This can guarantee layout compatibility with u64, as well as a const new fn. |
45484e9
to
cb197e8
Compare
1d7d149
to
4dbd49b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, wanted to click "request changes"
I think it needs a new release of crossbeam-utils including crossbeam-rs/crossbeam#437. So filed crossbeam-rs/crossbeam#444. |
@taiki-e New versions of crossbeam have been published now. |
e9abb0c
to
745cf87
Compare
looks like ci failure is #286 (comment). |
@taiki-e Can you try rebasing/merging with the master branch to see if that helps? |
b48511f
to
a80d6ae
Compare
Updated. It seems to succeed on the existing targets (linux,macos,windows), but fails on the newly added targets. |
Rebasing this is almost trivial (just remove the Cargo.toml changes). It then applies cleanly and makes async-std work on MIPS and other platforms. |
Hmm, still a test mentioned in #286 (comment) is failed on the newly added targets. |
Why was this closed? It still does not compile on MIPS. |
I found this PR today while trying to cross compile |
I thought this PR was going to pass, so I closed it first…… |
Closed because inactive |
Closes #141
cc #48
Related: tokio-rs/tokio#1538