Skip to content

Commit 32a22ef

Browse files
committed
Change has_atomic_cas to no_atomic_cas to implement a workaround for the first problem
1 parent 665c32e commit 32a22ef

File tree

13 files changed

+52
-32
lines changed

13 files changed

+52
-32
lines changed

futures-channel/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ fn main() {
1616
}
1717
};
1818

19-
if cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
20-
println!("cargo:rustc-cfg=has_atomic_cas");
19+
// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows to
20+
// treat `cfg(target_has_atomic = "ptr")` as true when the build script
21+
// doesn't run. This is needed for compatibility with non-cargo build
22+
// systems that don't run build scripts.
23+
if !cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
24+
println!("cargo:rustc-cfg=no_atomic_cas");
2125
}
2226
println!("cargo:rerun-if-changed=build.rs");
2327
}

futures-channel/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
macro_rules! cfg_target_has_atomic {
2424
($($item:item)*) => {$(
25-
#[cfg(has_atomic_cas)]
25+
#[cfg(not(no_atomic_cas))]
2626
$item
2727
)*};
2828
}

futures-core/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ fn main() {
1616
}
1717
};
1818

19-
if cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
20-
println!("cargo:rustc-cfg=has_atomic_cas");
19+
// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows to
20+
// treat `cfg(target_has_atomic = "ptr")` as true when the build script
21+
// doesn't run. This is needed for compatibility with non-cargo build
22+
// systems that don't run build scripts.
23+
if !cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
24+
println!("cargo:rustc-cfg=no_atomic_cas");
2125
}
2226
println!("cargo:rerun-if-changed=build.rs");
2327
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(has_atomic_cas)]
1+
#[cfg(not(no_atomic_cas))]
22
mod atomic_waker;
3-
#[cfg(has_atomic_cas)]
3+
#[cfg(not(no_atomic_cas))]
44
pub use self::atomic_waker::AtomicWaker;

futures-task/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ fn main() {
1616
}
1717
};
1818

19-
if cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
20-
println!("cargo:rustc-cfg=has_atomic_cas");
19+
// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows to
20+
// treat `cfg(target_has_atomic = "ptr")` as true when the build script
21+
// doesn't run. This is needed for compatibility with non-cargo build
22+
// systems that don't run build scripts.
23+
if !cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
24+
println!("cargo:rustc-cfg=no_atomic_cas");
2125
}
2226
println!("cargo:rerun-if-changed=build.rs");
2327
}

futures-task/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern crate alloc;
1919

2020
macro_rules! cfg_target_has_atomic {
2121
($($item:item)*) => {$(
22-
#[cfg(has_atomic_cas)]
22+
#[cfg(not(no_atomic_cas))]
2323
$item
2424
)*};
2525
}

futures-util/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ fn main() {
1616
}
1717
};
1818

19-
if cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
20-
println!("cargo:rustc-cfg=has_atomic_cas");
19+
// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows to
20+
// treat `cfg(target_has_atomic = "ptr")` as true when the build script
21+
// doesn't run. This is needed for compatibility with non-cargo build
22+
// systems that don't run build scripts.
23+
if !cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
24+
println!("cargo:rustc-cfg=no_atomic_cas");
2125
}
2226
println!("cargo:rerun-if-changed=build.rs");
2327
}

futures-util/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub mod __private {
5757

5858
macro_rules! cfg_target_has_atomic {
5959
($($item:item)*) => {$(
60-
#[cfg(has_atomic_cas)]
60+
#[cfg(not(no_atomic_cas))]
6161
$item
6262
)*};
6363
}

futures-util/src/stream/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ pub use self::stream::ReadyChunks;
3131
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
3232
pub use self::stream::Forward;
3333

34-
#[cfg(has_atomic_cas)]
34+
#[cfg(not(no_atomic_cas))]
3535
#[cfg(feature = "alloc")]
3636
pub use self::stream::{BufferUnordered, Buffered, ForEachConcurrent};
3737

38-
#[cfg(has_atomic_cas)]
38+
#[cfg(not(no_atomic_cas))]
3939
#[cfg(feature = "sink")]
4040
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
4141
#[cfg(feature = "alloc")]
@@ -53,7 +53,7 @@ pub use self::try_stream::{
5353
#[cfg(feature = "std")]
5454
pub use self::try_stream::IntoAsyncRead;
5555

56-
#[cfg(has_atomic_cas)]
56+
#[cfg(not(no_atomic_cas))]
5757
#[cfg(feature = "alloc")]
5858
pub use self::try_stream::{TryBufferUnordered, TryBuffered, TryForEachConcurrent};
5959

futures-util/src/stream/stream/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ pub trait StreamExt: Stream {
917917
/// fut.await;
918918
/// # })
919919
/// ```
920-
#[cfg(has_atomic_cas)]
920+
#[cfg(not(no_atomic_cas))]
921921
#[cfg(feature = "alloc")]
922922
fn for_each_concurrent<Fut, F>(
923923
self,
@@ -1140,7 +1140,7 @@ pub trait StreamExt: Stream {
11401140
///
11411141
/// This method is only available when the `std` or `alloc` feature of this
11421142
/// library is activated, and it is activated by default.
1143-
#[cfg(has_atomic_cas)]
1143+
#[cfg(not(no_atomic_cas))]
11441144
#[cfg(feature = "alloc")]
11451145
fn buffered(self, n: usize) -> Buffered<Self>
11461146
where
@@ -1185,7 +1185,7 @@ pub trait StreamExt: Stream {
11851185
/// assert_eq!(buffered.next().await, None);
11861186
/// # Ok::<(), i32>(()) }).unwrap();
11871187
/// ```
1188-
#[cfg(has_atomic_cas)]
1188+
#[cfg(not(no_atomic_cas))]
11891189
#[cfg(feature = "alloc")]
11901190
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
11911191
where
@@ -1349,7 +1349,7 @@ pub trait StreamExt: Stream {
13491349
/// library is activated, and it is activated by default.
13501350
#[cfg(feature = "sink")]
13511351
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
1352-
#[cfg(has_atomic_cas)]
1352+
#[cfg(not(no_atomic_cas))]
13531353
#[cfg(feature = "alloc")]
13541354
fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
13551355
where

futures-util/src/stream/try_stream/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ pub trait TryStreamExt: TryStream {
515515
/// assert_eq!(Err(oneshot::Canceled), fut.await);
516516
/// # })
517517
/// ```
518-
#[cfg(has_atomic_cas)]
518+
#[cfg(not(no_atomic_cas))]
519519
#[cfg(feature = "alloc")]
520520
fn try_for_each_concurrent<Fut, F>(
521521
self,
@@ -836,7 +836,7 @@ pub trait TryStreamExt: TryStream {
836836
/// assert_eq!(buffered.next().await, Some(Err("error in the stream")));
837837
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
838838
/// ```
839-
#[cfg(has_atomic_cas)]
839+
#[cfg(not(no_atomic_cas))]
840840
#[cfg(feature = "alloc")]
841841
fn try_buffer_unordered(self, n: usize) -> TryBufferUnordered<Self>
842842
where
@@ -912,7 +912,7 @@ pub trait TryStreamExt: TryStream {
912912
/// assert_eq!(buffered.next().await, Some(Err("error in the stream")));
913913
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
914914
/// ```
915-
#[cfg(has_atomic_cas)]
915+
#[cfg(not(no_atomic_cas))]
916916
#[cfg(feature = "alloc")]
917917
fn try_buffered(self, n: usize) -> TryBuffered<Self>
918918
where

futures/build.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ fn main() {
1616
}
1717
};
1818

19-
if cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
20-
println!("cargo:rustc-cfg=has_atomic_cas");
19+
// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows to
20+
// treat `cfg(target_has_atomic = "ptr")` as true when the build script
21+
// doesn't run. This is needed for compatibility with non-cargo build
22+
// systems that don't run build scripts.
23+
if !cfg.probe_expression("core::sync::atomic::AtomicPtr::<()>::compare_exchange") {
24+
println!("cargo:rustc-cfg=no_atomic_cas");
2125
}
2226
println!("cargo:rerun-if-changed=build.rs");
2327
}

futures/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub use futures_util::{pending, poll, join, try_join, select_biased}; // Async-a
125125
#[cfg(feature = "async-await")]
126126
pub use futures_util::select;
127127

128-
#[cfg(has_atomic_cas)]
128+
#[cfg(not(no_atomic_cas))]
129129
#[cfg(feature = "alloc")]
130130
pub mod channel {
131131
//! Cross-task communication.
@@ -286,7 +286,7 @@ pub mod future {
286286
select_ok, SelectOk,
287287
};
288288

289-
#[cfg(has_atomic_cas)]
289+
#[cfg(not(no_atomic_cas))]
290290
#[cfg(feature = "alloc")]
291291
pub use futures_util::future::{
292292
abortable, Abortable, AbortHandle, AbortRegistration, Aborted,
@@ -347,7 +347,7 @@ pub mod io {
347347
pub use futures_util::io::WriteAllVectored;
348348
}
349349

350-
#[cfg(has_atomic_cas)]
350+
#[cfg(not(no_atomic_cas))]
351351
#[cfg(feature = "alloc")]
352352
pub mod lock {
353353
//! Futures-powered synchronization primitives.
@@ -473,7 +473,7 @@ pub mod stream {
473473
Chunks, ReadyChunks,
474474
};
475475

476-
#[cfg(has_atomic_cas)]
476+
#[cfg(not(no_atomic_cas))]
477477
#[cfg(feature = "alloc")]
478478
pub use futures_util::stream::{
479479
FuturesOrdered,
@@ -492,7 +492,7 @@ pub mod stream {
492492
CatchUnwind,
493493
};
494494

495-
#[cfg(has_atomic_cas)]
495+
#[cfg(not(no_atomic_cas))]
496496
#[cfg(feature = "alloc")]
497497
pub use futures_util::stream::{
498498
// For TryStreamExt:
@@ -531,11 +531,11 @@ pub mod task {
531531
#[cfg(feature = "alloc")]
532532
pub use futures_util::task::{SpawnExt, LocalSpawnExt};
533533

534-
#[cfg(has_atomic_cas)]
534+
#[cfg(not(no_atomic_cas))]
535535
#[cfg(feature = "alloc")]
536536
pub use futures_util::task::{waker, waker_ref, WakerRef, ArcWake};
537537

538-
#[cfg(has_atomic_cas)]
538+
#[cfg(not(no_atomic_cas))]
539539
pub use futures_util::task::AtomicWaker;
540540
}
541541

0 commit comments

Comments
 (0)