Skip to content

Commit

Permalink
Expose cfg(futures_no_atomic_cas) as unstable public API
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Apr 23, 2021
1 parent 2b5d082 commit 0457c51
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 47 deletions.
27 changes: 19 additions & 8 deletions futures-channel/build.rs
Expand Up @@ -2,9 +2,20 @@ use std::env;

include!("no_atomic_cas.rs");

// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `futures_no_atomic_cas`
// Assume the target does not have atomic CAS (compare-and-swap).
// The target that does not have atomic CAS is usually detected
// automatically by the build script, but you may need to enable it
// manually when building for custom targets or using non-cargo build
// systems that don't run the build script.
//
// With the exceptions mentioned above, the rustc-cfg strings below are
// *not* public API. Please let us know by opening a GitHub issue if your build
// environment requires some way to enable these cfgs other than by executing
// our build script.
fn main() {
let target = match env::var("TARGET") {
Ok(target) => target,
Expand All @@ -18,12 +29,12 @@ fn main() {
}
};

// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows
// treating `cfg(target_has_atomic = "ptr")` as true when the build script
// doesn't run. This is needed for compatibility with non-cargo build
// systems that don't run build scripts.
// Note that this is `no_*`, not `has_*`. This allows treating
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
println!("cargo:rustc-cfg=no_atomic_cas");
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

println!("cargo:rerun-if-changed=no_atomic_cas.rs");
Expand Down
2 changes: 1 addition & 1 deletion futures-channel/src/lib.rs
Expand Up @@ -20,7 +20,7 @@

macro_rules! cfg_target_has_atomic {
($($item:item)*) => {$(
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
$item
)*};
}
Expand Down
27 changes: 19 additions & 8 deletions futures-core/build.rs
Expand Up @@ -2,9 +2,20 @@ use std::env;

include!("no_atomic_cas.rs");

// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `futures_no_atomic_cas`
// Assume the target does not have atomic CAS (compare-and-swap).
// The target that does not have atomic CAS is usually detected
// automatically by the build script, but you may need to enable it
// manually when building for custom targets or using non-cargo build
// systems that don't run the build script.
//
// With the exceptions mentioned above, the rustc-cfg strings below are
// *not* public API. Please let us know by opening a GitHub issue if your build
// environment requires some way to enable these cfgs other than by executing
// our build script.
fn main() {
let target = match env::var("TARGET") {
Ok(target) => target,
Expand All @@ -18,12 +29,12 @@ fn main() {
}
};

// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows
// treating `cfg(target_has_atomic = "ptr")` as true when the build script
// doesn't run. This is needed for compatibility with non-cargo build
// systems that don't run build scripts.
// Note that this is `no_*`, not `has_*`. This allows treating
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
println!("cargo:rustc-cfg=no_atomic_cas");
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

println!("cargo:rerun-if-changed=no_atomic_cas.rs");
Expand Down
4 changes: 2 additions & 2 deletions futures-core/src/task/__internal/mod.rs
@@ -1,4 +1,4 @@
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
mod atomic_waker;
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
pub use self::atomic_waker::AtomicWaker;
27 changes: 19 additions & 8 deletions futures-task/build.rs
Expand Up @@ -2,9 +2,20 @@ use std::env;

include!("no_atomic_cas.rs");

// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `futures_no_atomic_cas`
// Assume the target does not have atomic CAS (compare-and-swap).
// The target that does not have atomic CAS is usually detected
// automatically by the build script, but you may need to enable it
// manually when building for custom targets or using non-cargo build
// systems that don't run the build script.
//
// With the exceptions mentioned above, the rustc-cfg strings below are
// *not* public API. Please let us know by opening a GitHub issue if your build
// environment requires some way to enable these cfgs other than by executing
// our build script.
fn main() {
let target = match env::var("TARGET") {
Ok(target) => target,
Expand All @@ -18,12 +29,12 @@ fn main() {
}
};

// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows
// treating `cfg(target_has_atomic = "ptr")` as true when the build script
// doesn't run. This is needed for compatibility with non-cargo build
// systems that don't run build scripts.
// Note that this is `no_*`, not `has_*`. This allows treating
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
println!("cargo:rustc-cfg=no_atomic_cas");
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

println!("cargo:rerun-if-changed=no_atomic_cas.rs");
Expand Down
2 changes: 1 addition & 1 deletion futures-task/src/lib.rs
Expand Up @@ -12,7 +12,7 @@ extern crate alloc;

macro_rules! cfg_target_has_atomic {
($($item:item)*) => {$(
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
$item
)*};
}
Expand Down
27 changes: 19 additions & 8 deletions futures-util/build.rs
Expand Up @@ -2,9 +2,20 @@ use std::env;

include!("no_atomic_cas.rs");

// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `futures_no_atomic_cas`
// Assume the target does not have atomic CAS (compare-and-swap).
// The target that does not have atomic CAS is usually detected
// automatically by the build script, but you may need to enable it
// manually when building for custom targets or using non-cargo build
// systems that don't run the build script.
//
// With the exceptions mentioned above, the rustc-cfg strings below are
// *not* public API. Please let us know by opening a GitHub issue if your build
// environment requires some way to enable these cfgs other than by executing
// our build script.
fn main() {
let target = match env::var("TARGET") {
Ok(target) => target,
Expand All @@ -18,12 +29,12 @@ fn main() {
}
};

// Note that this is `no_atomic_cas`, not `has_atomic_cas`. This allows
// treating `cfg(target_has_atomic = "ptr")` as true when the build script
// doesn't run. This is needed for compatibility with non-cargo build
// systems that don't run build scripts.
// Note that this is `no_*`, not `has_*`. This allows treating
// `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
// run. This is needed for compatibility with non-cargo build systems that
// don't run the build script.
if NO_ATOMIC_CAS_TARGETS.contains(&&*target) {
println!("cargo:rustc-cfg=no_atomic_cas");
println!("cargo:rustc-cfg=futures_no_atomic_cas");
}

println!("cargo:rerun-if-changed=no_atomic_cas.rs");
Expand Down
2 changes: 1 addition & 1 deletion futures-util/src/lib.rs
Expand Up @@ -49,7 +49,7 @@ pub mod __private {

macro_rules! cfg_target_has_atomic {
($($item:item)*) => {$(
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
$item
)*};
}
Expand Down
6 changes: 3 additions & 3 deletions futures-util/src/stream/mod.rs
Expand Up @@ -37,11 +37,11 @@ pub use self::stream::ReadyChunks;
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
pub use self::stream::Forward;

#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
pub use self::stream::{BufferUnordered, Buffered, ForEachConcurrent, TryForEachConcurrent};

#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "sink")]
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
#[cfg(feature = "alloc")]
Expand All @@ -59,7 +59,7 @@ pub use self::try_stream::{
#[cfg(feature = "std")]
pub use self::try_stream::IntoAsyncRead;

#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
pub use self::try_stream::{TryBufferUnordered, TryBuffered};

Expand Down
10 changes: 5 additions & 5 deletions futures-util/src/stream/stream/mod.rs
Expand Up @@ -933,7 +933,7 @@ pub trait StreamExt: Stream {
/// fut.await;
/// # })
/// ```
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
fn for_each_concurrent<Fut, F>(
self,
Expand Down Expand Up @@ -1066,7 +1066,7 @@ pub trait StreamExt: Stream {
/// assert_eq!(Err(oneshot::Canceled), fut.await);
/// # })
/// ```
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
fn try_for_each_concurrent<Fut, F, E>(
self,
Expand Down Expand Up @@ -1293,7 +1293,7 @@ pub trait StreamExt: Stream {
/// # Panics
///
/// This method will panic if `n` is zero.
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
fn buffered(self, n: usize) -> Buffered<Self>
where
Expand Down Expand Up @@ -1342,7 +1342,7 @@ pub trait StreamExt: Stream {
/// assert_eq!(buffered.next().await, None);
/// # Ok::<(), i32>(()) }).unwrap();
/// ```
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
where
Expand Down Expand Up @@ -1509,7 +1509,7 @@ pub trait StreamExt: Stream {
/// library is activated, and it is activated by default.
#[cfg(feature = "sink")]
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
where
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/stream/try_stream/mod.rs
Expand Up @@ -684,7 +684,7 @@ pub trait TryStreamExt: TryStream {
/// assert_eq!(buffered.next().await, Some(Err("error in the stream")));
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
fn try_buffer_unordered(self, n: usize) -> TryBufferUnordered<Self>
where
Expand Down Expand Up @@ -760,7 +760,7 @@ pub trait TryStreamExt: TryStream {
/// assert_eq!(buffered.next().await, Some(Err("error in the stream")));
/// # Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
/// ```
#[cfg(not(no_atomic_cas))]
#[cfg(not(futures_no_atomic_cas))]
#[cfg(feature = "alloc")]
fn try_buffered(self, n: usize) -> TryBuffered<Self>
where
Expand Down

0 comments on commit 0457c51

Please sign in to comment.