Skip to content

Commit 6159ead

Browse files
committed
Invert use_target_has_atomic cfg
This way, a build system that does not want to run Cargo build scripts can build serde without any cfgs defined, and get the most modern feature set.
1 parent 692ac99 commit 6159ead

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

serde/build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ fn main() {
9595
// Whitelist of archs that support std::sync::atomic module. Ideally we
9696
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
9797
// Instead this is based on rustc's compiler/rustc_target/src/spec/*.rs.
98-
if minor >= 60 {
99-
println!("cargo:rustc-cfg=use_target_has_atomic");
100-
} else {
98+
if minor < 60 {
99+
println!("cargo:rustc-cfg=no_target_has_atomic");
101100
let has_atomic64 = target.starts_with("x86_64")
102101
|| target.starts_with("i686")
103102
|| target.starts_with("aarch64")

serde/src/de/impls.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,7 +2660,7 @@ where
26602660
}
26612661
}
26622662

2663-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic)))]
2663+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
26642664
macro_rules! atomic_impl {
26652665
($($ty:ident)*) => {
26662666
$(
@@ -2676,7 +2676,7 @@ macro_rules! atomic_impl {
26762676
};
26772677
}
26782678

2679-
#[cfg(all(feature = "std", use_target_has_atomic))]
2679+
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
26802680
macro_rules! atomic_impl {
26812681
($($ty:ident $size:expr),*) => {
26822682
$(
@@ -2693,19 +2693,19 @@ macro_rules! atomic_impl {
26932693
};
26942694
}
26952695

2696-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic)))]
2696+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
26972697
atomic_impl! {
26982698
AtomicBool
26992699
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
27002700
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
27012701
}
27022702

2703-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic64)))]
2703+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic64)))]
27042704
atomic_impl! {
27052705
AtomicI64 AtomicU64
27062706
}
27072707

2708-
#[cfg(all(feature = "std", use_target_has_atomic))]
2708+
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
27092709
atomic_impl! {
27102710
AtomicBool "8",
27112711
AtomicI8 "8",

serde/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,25 +236,25 @@ mod lib {
236236
#[cfg(not(no_range_inclusive))]
237237
pub use self::core::ops::RangeInclusive;
238238

239-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic)))]
239+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
240240
pub use std::sync::atomic::{
241241
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8,
242242
AtomicUsize, Ordering,
243243
};
244-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic64)))]
244+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic64)))]
245245
pub use std::sync::atomic::{AtomicI64, AtomicU64};
246246

247-
#[cfg(all(feature = "std", use_target_has_atomic))]
247+
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
248248
pub use std::sync::atomic::Ordering;
249-
#[cfg(all(feature = "std", use_target_has_atomic, target_has_atomic = "8"))]
249+
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "8"))]
250250
pub use std::sync::atomic::{AtomicBool, AtomicI8, AtomicU8};
251-
#[cfg(all(feature = "std", use_target_has_atomic, target_has_atomic = "16"))]
251+
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "16"))]
252252
pub use std::sync::atomic::{AtomicI16, AtomicU16};
253-
#[cfg(all(feature = "std", use_target_has_atomic, target_has_atomic = "32"))]
253+
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "32"))]
254254
pub use std::sync::atomic::{AtomicI32, AtomicU32};
255-
#[cfg(all(feature = "std", use_target_has_atomic, target_has_atomic = "64"))]
255+
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "64"))]
256256
pub use std::sync::atomic::{AtomicI64, AtomicU64};
257-
#[cfg(all(feature = "std", use_target_has_atomic, target_has_atomic = "ptr"))]
257+
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "ptr"))]
258258
pub use std::sync::atomic::{AtomicIsize, AtomicUsize};
259259

260260
#[cfg(any(feature = "std", not(no_core_duration)))]

serde/src/ser/impls.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ where
945945

946946
////////////////////////////////////////////////////////////////////////////////
947947

948-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic)))]
948+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
949949
macro_rules! atomic_impl {
950950
($($ty:ident)*) => {
951951
$(
@@ -962,7 +962,7 @@ macro_rules! atomic_impl {
962962
}
963963
}
964964

965-
#[cfg(all(feature = "std", use_target_has_atomic))]
965+
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
966966
macro_rules! atomic_impl {
967967
($($ty:ident $size:expr),*) => {
968968
$(
@@ -980,19 +980,19 @@ macro_rules! atomic_impl {
980980
}
981981
}
982982

983-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic)))]
983+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
984984
atomic_impl! {
985985
AtomicBool
986986
AtomicI8 AtomicI16 AtomicI32 AtomicIsize
987987
AtomicU8 AtomicU16 AtomicU32 AtomicUsize
988988
}
989989

990-
#[cfg(all(feature = "std", not(use_target_has_atomic), not(no_std_atomic64)))]
990+
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic64)))]
991991
atomic_impl! {
992992
AtomicI64 AtomicU64
993993
}
994994

995-
#[cfg(all(feature = "std", use_target_has_atomic))]
995+
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
996996
atomic_impl! {
997997
AtomicBool "8",
998998
AtomicI8 "8",

0 commit comments

Comments
 (0)