Skip to content

Commit 2c2dde2

Browse files
committed
Change has_atomic_cas to no_atomic_cas to implement a workaround for the first problem
1 parent d7ad23a commit 2c2dde2

File tree

12 files changed

+45
-25
lines changed

12 files changed

+45
-25
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
20+
// treating `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
@@ -21,7 +21,7 @@
2121

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

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
20+
// treating `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
20+
// treating `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
@@ -13,7 +13,7 @@ extern crate alloc;
1313

1414
macro_rules! cfg_target_has_atomic {
1515
($($item:item)*) => {$(
16-
#[cfg(has_atomic_cas)]
16+
#[cfg(not(no_atomic_cas))]
1717
$item
1818
)*};
1919
}

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
20+
// treating `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
@@ -54,7 +54,7 @@ pub mod __private {
5454

5555
macro_rules! cfg_target_has_atomic {
5656
($($item:item)*) => {$(
57-
#[cfg(has_atomic_cas)]
57+
#[cfg(not(no_atomic_cas))]
5858
$item
5959
)*};
6060
}

futures-util/src/stream/mod.rs

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

39-
#[cfg(has_atomic_cas)]
39+
#[cfg(not(no_atomic_cas))]
4040
#[cfg(feature = "alloc")]
4141
pub use self::stream::{BufferUnordered, Buffered, ForEachConcurrent};
4242

43-
#[cfg(has_atomic_cas)]
43+
#[cfg(not(no_atomic_cas))]
4444
#[cfg(feature = "sink")]
4545
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
4646
#[cfg(feature = "alloc")]
@@ -58,7 +58,7 @@ pub use self::try_stream::{
5858
#[cfg(feature = "std")]
5959
pub use self::try_stream::IntoAsyncRead;
6060

61-
#[cfg(has_atomic_cas)]
61+
#[cfg(not(no_atomic_cas))]
6262
#[cfg(feature = "alloc")]
6363
pub use self::try_stream::{TryBufferUnordered, TryBuffered, TryForEachConcurrent};
6464

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
20+
// treating `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
}

0 commit comments

Comments
 (0)