Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use target_has_atomic instead of the atomic_f64 feature #14

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ jobs:
- uses: hecrj/setup-rust-action@v2
with:
rust-version: ${{ matrix.rust }}
- run: cargo test --verbose --workspace --all-features
- run: cargo test --verbose --workspace --no-default-features
- run: cargo test --verbose --workspace --all-features
env:
RUSTFLAGS: "--cfg force_disable_atomic64"
RUSTDOCFLAGS: "--cfg force_disable_atomic64"
- run: cargo test --verbose --workspace

cross-test:
name: Test on ${{ matrix.target }} (using cross)
Expand All @@ -52,8 +47,7 @@ jobs:
- uses: actions/checkout@v4
- uses: hecrj/setup-rust-action@v2
- run: cargo install cross
- run: cross test --verbose --target=${{ matrix.target }} --no-default-features
- run: cross test --verbose --target=${{ matrix.target }} --all-features
- run: cross test --verbose --target=${{ matrix.target }}

check:
name: Check warnings
Expand All @@ -64,7 +58,6 @@ jobs:
- uses: actions/checkout@v4
- uses: hecrj/setup-rust-action@v2
- run: cargo check --workspace --all-targets --verbose
- run: cargo check --workspace --all-targets --verbose --no-default-features

rustfmt:
name: Verify code formatting
Expand Down
2 changes: 1 addition & 1 deletion src/atomic_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use core::sync::atomic::{
/// See the module documentation for [core::sync::atomic] for information about
/// the portability of various atomics (this one is mostly as portable as
/// [`AtomicU64`](core::sync::atomic::AtomicU64), with the caveat that we
/// additionally that the platform support 64-bit floats).
/// additionally require that the platform support 64-bit floats).
///
/// # Example
///
Expand Down
29 changes: 5 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,9 @@
//! [`AtomicU32`]: core::sync::atomic::AtomicU32
//! [`AtomicU64`]: core::sync::atomic::AtomicU64
//!
//! Not every architecture has 64-bit atomics. As a result [`AtomicF64`] is
//! behind an on-by-default feature flag, called `atomic_f64`, and is explicitly
//! disabled on platforms known not to have 64-bit atomics (32-bit MIPs and
//! PowerPC targets).
//!
//! Because it's on-by-default, it's possible it will be enabled by accident. If
//! you're the person compiling the end-result (invoking `cargo build`), and
//! some crate has done this (e.g. you can't simply add
//! `default-features=false`) to a `Cargo.toml` line, you can override feature
//! selection and force-disable `AtomicF64` using the `force_disable_atomic64`
//! cfg (that is, by adding `RUSTFLAGS="--cfg=force_disable_atomic64"`).
//!
//! Let me know if you have to do this though, and I'll make consideration for
//! your target the way I have for MIPs and PowerPC.
//! Some architectures do not support 64-bit atomics, so [`AtomicF64`] is not
//! available on such architectures. Examples include 32-bit PowerPC, MIPS, and
//! Arm M-Profile.
//!
//! # Potential Use Cases
//!
Expand Down Expand Up @@ -81,18 +70,10 @@
mod atomic_f32;
pub use atomic_f32::AtomicF32;

#[cfg(all(
feature = "atomic_f64",
target_has_atomic = "64",
not(force_disable_atomic64),
))]
#[cfg(target_has_atomic = "64")]
mod atomic_f64;

#[cfg(all(
feature = "atomic_f64",
target_has_atomic = "64",
not(force_disable_atomic64),
))]
#[cfg(target_has_atomic = "64")]
pub use atomic_f64::AtomicF64;

use core::sync::atomic::Ordering;
Expand Down
7 changes: 1 addition & 6 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ fn test_serde_f32() {
);
}

#[cfg(all(
feature = "serde",
feature = "atomic_f64",
target_has_atomic = "64",
not(force_disable_atomic64),
))]
#[cfg(all(feature = "serde", target_has_atomic = "64"))]
#[test]
fn test_serde_f64() {
serde_test::assert_tokens(
Expand Down