Skip to content

Commit 6b6449b

Browse files
committed
Remove cfg_target_has_atomic! macro (#2439)
1 parent fc080d1 commit 6b6449b

File tree

17 files changed

+184
-202
lines changed

17 files changed

+184
-202
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ jobs:
248248
steps:
249249
- uses: actions/checkout@v2
250250
- name: Install Rust
251-
run: rustup update stable && rustup default stable
252-
- run: tools/fmt.sh
251+
run: rustup update stable
252+
- run: cargo fmt --all -- --check
253253

254254
docs:
255255
name: cargo doc

ci/no_atomic_cas.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Update the list of targets that do not support atomic CAS operations.
4+
#
5+
# Usage:
6+
# ./ci/no_atomic_cas.sh
7+
38
set -euo pipefail
49
IFS=$'\n\t'
510

futures-channel/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include!("no_atomic_cas.rs");
88
// and outside of the normal semver guarantees:
99
//
1010
// - `futures_no_atomic_cas`
11-
// Assume the target does not have atomic CAS (compare-and-swap).
11+
// Assume the target does *not* support atomic CAS operations.
1212
// This is usually detected automatically by the build script, but you may
1313
// need to enable it manually when building for custom targets or using
1414
// non-cargo build systems that don't run the build script.

futures-channel/src/lib.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,16 @@
1818
#![warn(clippy::all)]
1919
#![doc(test(attr(deny(warnings), allow(dead_code, unused_assignments, unused_variables))))]
2020

21-
macro_rules! cfg_target_has_atomic {
22-
($($item:item)*) => {$(
23-
#[cfg(not(futures_no_atomic_cas))]
24-
$item
25-
)*};
26-
}
21+
#[cfg(not(futures_no_atomic_cas))]
22+
#[cfg(feature = "alloc")]
23+
extern crate alloc;
2724

28-
cfg_target_has_atomic! {
29-
#[cfg(feature = "alloc")]
30-
extern crate alloc;
31-
32-
#[cfg(feature = "alloc")]
33-
mod lock;
34-
#[cfg(feature = "std")]
35-
pub mod mpsc;
36-
#[cfg(feature = "alloc")]
37-
pub mod oneshot;
38-
}
25+
#[cfg(not(futures_no_atomic_cas))]
26+
#[cfg(feature = "alloc")]
27+
mod lock;
28+
#[cfg(not(futures_no_atomic_cas))]
29+
#[cfg(feature = "std")]
30+
pub mod mpsc;
31+
#[cfg(not(futures_no_atomic_cas))]
32+
#[cfg(feature = "alloc")]
33+
pub mod oneshot;

futures-core/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include!("no_atomic_cas.rs");
88
// and outside of the normal semver guarantees:
99
//
1010
// - `futures_no_atomic_cas`
11-
// Assume the target does not have atomic CAS (compare-and-swap).
11+
// Assume the target does *not* support atomic CAS operations.
1212
// This is usually detected automatically by the build script, but you may
1313
// need to enable it manually when building for custom targets or using
1414
// non-cargo build systems that don't run the build script.

futures-task/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include!("no_atomic_cas.rs");
88
// and outside of the normal semver guarantees:
99
//
1010
// - `futures_no_atomic_cas`
11-
// Assume the target does not have atomic CAS (compare-and-swap).
11+
// Assume the target does *not* support atomic CAS operations.
1212
// This is usually detected automatically by the build script, but you may
1313
// need to enable it manually when building for custom targets or using
1414
// non-cargo build systems that don't run the build script.

futures-task/src/lib.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,29 @@
1010
#[cfg(feature = "alloc")]
1111
extern crate alloc;
1212

13-
macro_rules! cfg_target_has_atomic {
14-
($($item:item)*) => {$(
15-
#[cfg(not(futures_no_atomic_cas))]
16-
$item
17-
)*};
18-
}
19-
2013
mod spawn;
2114
pub use crate::spawn::{LocalSpawn, Spawn, SpawnError};
2215

23-
cfg_target_has_atomic! {
24-
#[cfg(feature = "alloc")]
25-
mod arc_wake;
26-
#[cfg(feature = "alloc")]
27-
pub use crate::arc_wake::ArcWake;
28-
29-
#[cfg(feature = "alloc")]
30-
mod waker;
31-
#[cfg(feature = "alloc")]
32-
pub use crate::waker::waker;
33-
34-
#[cfg(feature = "alloc")]
35-
mod waker_ref;
36-
#[cfg(feature = "alloc")]
37-
pub use crate::waker_ref::{waker_ref, WakerRef};
38-
}
16+
#[cfg(not(futures_no_atomic_cas))]
17+
#[cfg(feature = "alloc")]
18+
mod arc_wake;
19+
#[cfg(not(futures_no_atomic_cas))]
20+
#[cfg(feature = "alloc")]
21+
pub use crate::arc_wake::ArcWake;
22+
23+
#[cfg(not(futures_no_atomic_cas))]
24+
#[cfg(feature = "alloc")]
25+
mod waker;
26+
#[cfg(not(futures_no_atomic_cas))]
27+
#[cfg(feature = "alloc")]
28+
pub use crate::waker::waker;
29+
30+
#[cfg(not(futures_no_atomic_cas))]
31+
#[cfg(feature = "alloc")]
32+
mod waker_ref;
33+
#[cfg(not(futures_no_atomic_cas))]
34+
#[cfg(feature = "alloc")]
35+
pub use crate::waker_ref::{waker_ref, WakerRef};
3936

4037
mod future_obj;
4138
pub use crate::future_obj::{FutureObj, LocalFutureObj, UnsafeFutureObj};

futures-task/src/spawn.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,25 @@ mod if_alloc {
168168
}
169169
}
170170

171-
cfg_target_has_atomic! {
172-
use alloc::{ sync::Arc };
173-
174-
impl<Sp: ?Sized + Spawn> Spawn for Arc<Sp> {
175-
fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError> {
176-
(**self).spawn_obj(future)
177-
}
171+
#[cfg(not(futures_no_atomic_cas))]
172+
impl<Sp: ?Sized + Spawn> Spawn for alloc::sync::Arc<Sp> {
173+
fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError> {
174+
(**self).spawn_obj(future)
175+
}
178176

179-
fn status(&self) -> Result<(), SpawnError> {
180-
(**self).status()
181-
}
177+
fn status(&self) -> Result<(), SpawnError> {
178+
(**self).status()
182179
}
180+
}
183181

184-
impl<Sp: ?Sized + LocalSpawn> LocalSpawn for Arc<Sp> {
185-
fn spawn_local_obj(&self, future: LocalFutureObj<'static, ()>) -> Result<(), SpawnError> {
186-
(**self).spawn_local_obj(future)
187-
}
182+
#[cfg(not(futures_no_atomic_cas))]
183+
impl<Sp: ?Sized + LocalSpawn> LocalSpawn for alloc::sync::Arc<Sp> {
184+
fn spawn_local_obj(&self, future: LocalFutureObj<'static, ()>) -> Result<(), SpawnError> {
185+
(**self).spawn_local_obj(future)
186+
}
188187

189-
fn status_local(&self) -> Result<(), SpawnError> {
190-
(**self).status_local()
191-
}
188+
fn status_local(&self) -> Result<(), SpawnError> {
189+
(**self).status_local()
192190
}
193191
}
194192
}

futures-util/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include!("no_atomic_cas.rs");
99
// and outside of the normal semver guarantees:
1010
//
1111
// - `futures_no_atomic_cas`
12-
// Assume the target does not have atomic CAS (compare-and-swap).
12+
// Assume the target does *not* support atomic CAS operations.
1313
// This is usually detected automatically by the build script, but you may
1414
// need to enable it manually when building for custom targets or using
1515
// non-cargo build systems that don't run the build script.

futures-util/src/future/mod.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,15 @@ pub use self::select_ok::{select_ok, SelectOk};
108108
mod either;
109109
pub use self::either::Either;
110110

111-
cfg_target_has_atomic! {
112-
#[cfg(feature = "alloc")]
113-
mod abortable;
114-
#[cfg(feature = "alloc")]
115-
pub use crate::abortable::{Abortable, AbortHandle, AbortRegistration, Aborted};
116-
#[cfg(feature = "alloc")]
117-
pub use abortable::abortable;
118-
}
111+
#[cfg(not(futures_no_atomic_cas))]
112+
#[cfg(feature = "alloc")]
113+
mod abortable;
114+
#[cfg(not(futures_no_atomic_cas))]
115+
#[cfg(feature = "alloc")]
116+
pub use crate::abortable::{AbortHandle, AbortRegistration, Abortable, Aborted};
117+
#[cfg(not(futures_no_atomic_cas))]
118+
#[cfg(feature = "alloc")]
119+
pub use abortable::abortable;
119120

120121
// Just a helper function to ensure the futures we're returning all have the
121122
// right implementations.

0 commit comments

Comments
 (0)