Skip to content

Commit 970e088

Browse files
committed
Use cfg(target_has_atomic) on no-std targets
1 parent 5e35c12 commit 970e088

File tree

24 files changed

+89
-333
lines changed

24 files changed

+89
-333
lines changed

.github/workflows/ci.yml

-36
Original file line numberDiff line numberDiff line change
@@ -230,42 +230,6 @@ jobs:
230230
--workspace --exclude futures-test \
231231
--features unstable --ignore-unknown-features
232232
233-
# When this job failed, run ci/no_atomic_cas.sh and commit result changes.
234-
codegen:
235-
runs-on: ubuntu-latest
236-
permissions:
237-
contents: write
238-
pull-requests: write
239-
steps:
240-
- uses: actions/checkout@v4
241-
- name: Install Rust
242-
run: rustup update nightly && rustup default nightly
243-
- run: ci/no_atomic_cas.sh
244-
- run: git add -N . && git diff --exit-code
245-
if: github.repository_owner != 'rust-lang' || github.event_name != 'schedule'
246-
- id: diff
247-
run: |
248-
git config user.name "Taiki Endo"
249-
git config user.email "[email protected]"
250-
git add -N .
251-
if ! git diff --exit-code; then
252-
git add .
253-
git commit -m "Update no_atomic_cas.rs"
254-
echo "::set-output name=success::false"
255-
fi
256-
if: github.repository_owner == 'rust-lang' && github.event_name == 'schedule'
257-
- uses: peter-evans/create-pull-request@v5
258-
with:
259-
title: Update no_atomic_cas.rs
260-
body: |
261-
Auto-generated by [create-pull-request][1]
262-
[Please close and immediately reopen this pull request to run CI.][2]
263-
264-
[1]: https://github.com/peter-evans/create-pull-request
265-
[2]: https://github.com/peter-evans/create-pull-request/blob/HEAD/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs
266-
branch: update-no-atomic-cas-rs
267-
if: github.repository_owner == 'rust-lang' && github.event_name == 'schedule' && steps.diff.outputs.success == 'false'
268-
269233
miri:
270234
name: cargo miri test
271235
runs-on: ubuntu-latest

ci/no_atomic_cas.sh

-31
This file was deleted.

futures-channel/build.rs

-41
This file was deleted.

futures-channel/no_atomic_cas.rs

-1
This file was deleted.

futures-channel/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@
2929
#![allow(clippy::arc_with_non_send_sync)] // false positive https://github.com/rust-lang/rust-clippy/issues/11076
3030
#![allow(clippy::needless_pass_by_ref_mut)]
3131

32-
#[cfg(not(futures_no_atomic_cas))]
32+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
3333
#[cfg(feature = "alloc")]
3434
extern crate alloc;
3535

36-
#[cfg(not(futures_no_atomic_cas))]
36+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
3737
#[cfg(feature = "alloc")]
3838
mod lock;
39-
#[cfg(not(futures_no_atomic_cas))]
39+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
4040
#[cfg(feature = "std")]
4141
pub mod mpsc;
42-
#[cfg(not(futures_no_atomic_cas))]
42+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
4343
#[cfg(feature = "alloc")]
4444
pub mod oneshot;

futures-core/build.rs

-41
This file was deleted.

futures-core/no_atomic_cas.rs

-1
This file was deleted.
+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#[cfg(any(not(futures_no_atomic_cas), feature = "portable-atomic"))]
1+
#[cfg_attr(target_os = "none", cfg(any(target_has_atomic = "ptr", feature = "portable-atomic")))]
22
mod atomic_waker;
3-
#[cfg(any(not(futures_no_atomic_cas), feature = "portable-atomic"))]
3+
#[cfg_attr(
4+
target_os = "none",
5+
cfg(any(target_has_atomic = "ptr", feature = "portable-atomic"))
6+
)]
47
pub use self::atomic_waker::AtomicWaker;

futures-task/build.rs

-41
This file was deleted.

futures-task/no_atomic_cas.rs

-1
This file was deleted.

futures-task/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ extern crate alloc;
1818
mod spawn;
1919
pub use crate::spawn::{LocalSpawn, Spawn, SpawnError};
2020

21-
#[cfg(not(futures_no_atomic_cas))]
21+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
2222
#[cfg(feature = "alloc")]
2323
mod arc_wake;
24-
#[cfg(not(futures_no_atomic_cas))]
24+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
2525
#[cfg(feature = "alloc")]
2626
pub use crate::arc_wake::ArcWake;
2727

28-
#[cfg(not(futures_no_atomic_cas))]
28+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
2929
#[cfg(feature = "alloc")]
3030
mod waker;
31-
#[cfg(not(futures_no_atomic_cas))]
31+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
3232
#[cfg(feature = "alloc")]
3333
pub use crate::waker::waker;
3434

35-
#[cfg(not(futures_no_atomic_cas))]
35+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
3636
#[cfg(feature = "alloc")]
3737
mod waker_ref;
38-
#[cfg(not(futures_no_atomic_cas))]
38+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
3939
#[cfg(feature = "alloc")]
4040
pub use crate::waker_ref::{waker_ref, WakerRef};
4141

futures-task/src/spawn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ mod if_alloc {
168168
}
169169
}
170170

171-
#[cfg(not(futures_no_atomic_cas))]
171+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
172172
impl<Sp: ?Sized + Spawn> Spawn for alloc::sync::Arc<Sp> {
173173
fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError> {
174174
(**self).spawn_obj(future)
@@ -179,7 +179,7 @@ mod if_alloc {
179179
}
180180
}
181181

182-
#[cfg(not(futures_no_atomic_cas))]
182+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
183183
impl<Sp: ?Sized + LocalSpawn> LocalSpawn for alloc::sync::Arc<Sp> {
184184
fn spawn_local_obj(&self, future: LocalFutureObj<'static, ()>) -> Result<(), SpawnError> {
185185
(**self).spawn_local_obj(future)

futures-util/build.rs

-41
This file was deleted.

futures-util/no_atomic_cas.rs

-1
This file was deleted.

futures-util/src/future/join_all.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use core::task::{Context, Poll};
1212

1313
use super::{assert_future, MaybeDone};
1414

15-
#[cfg(not(futures_no_atomic_cas))]
15+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
1616
use crate::stream::{Collect, FuturesOrdered, StreamExt};
1717

1818
pub(crate) fn iter_pin_mut<T>(slice: Pin<&mut [T]>) -> impl Iterator<Item = Pin<&mut T>> {
@@ -31,7 +31,7 @@ where
3131
kind: JoinAllKind<F>,
3232
}
3333

34-
#[cfg(not(futures_no_atomic_cas))]
34+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
3535
pub(crate) const SMALL: usize = 30;
3636

3737
enum JoinAllKind<F>
@@ -41,7 +41,7 @@ where
4141
Small {
4242
elems: Pin<Box<[MaybeDone<F>]>>,
4343
},
44-
#[cfg(not(futures_no_atomic_cas))]
44+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
4545
Big {
4646
fut: Collect<FuturesOrdered<F>, Vec<F::Output>>,
4747
},
@@ -57,7 +57,7 @@ where
5757
JoinAllKind::Small { ref elems } => {
5858
f.debug_struct("JoinAll").field("elems", elems).finish()
5959
}
60-
#[cfg(not(futures_no_atomic_cas))]
60+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
6161
JoinAllKind::Big { ref fut, .. } => fmt::Debug::fmt(fut, f),
6262
}
6363
}
@@ -106,15 +106,16 @@ where
106106
{
107107
let iter = iter.into_iter();
108108

109-
#[cfg(futures_no_atomic_cas)]
109+
#[cfg(target_os = "none")]
110+
#[cfg_attr(target_os = "none", cfg(not(target_has_atomic = "ptr")))]
110111
{
111112
let kind =
112113
JoinAllKind::Small { elems: iter.map(MaybeDone::Future).collect::<Box<[_]>>().into() };
113114

114115
assert_future::<Vec<<I::Item as Future>::Output>, _>(JoinAll { kind })
115116
}
116117

117-
#[cfg(not(futures_no_atomic_cas))]
118+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
118119
{
119120
let kind = match iter.size_hint().1 {
120121
Some(max) if max <= SMALL => JoinAllKind::Small {
@@ -153,7 +154,7 @@ where
153154
Poll::Pending
154155
}
155156
}
156-
#[cfg(not(futures_no_atomic_cas))]
157+
#[cfg_attr(target_os = "none", cfg(target_has_atomic = "ptr"))]
157158
JoinAllKind::Big { fut } => Pin::new(fut).poll(cx),
158159
}
159160
}

0 commit comments

Comments
 (0)