Skip to content

Commit 0ed3231

Browse files
committed
#[cfg(target_has_atomic_cas)] -> #[cfg(target_has_atomic = "cas")]
1 parent bbf688a commit 0ed3231

File tree

8 files changed

+34
-33
lines changed

8 files changed

+34
-33
lines changed

src/liballoc/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
#![feature(box_patterns)]
8787
#![feature(box_syntax)]
8888
#![feature(cfg_target_has_atomic)]
89-
#![cfg_attr(not(stage0), feature(cfg_target_has_atomic_cas))]
9089
#![feature(coerce_unsized)]
9190
#![feature(collections_range)]
9291
#![feature(const_fn)]
@@ -163,8 +162,10 @@ mod boxed {
163162
#[cfg(test)]
164163
mod boxed_test;
165164
pub mod collections;
166-
#[cfg_attr(stage0, cfg(target_has_atomic = "ptr"))]
167-
#[cfg_attr(not(stage0), cfg(all(target_has_atomic = "ptr", target_has_atomic_cas)))]
165+
#[cfg(any(
166+
all(stage0, target_has_atomic = "ptr"),
167+
all(not(stage0), target_has_atomic = "ptr", target_has_atomic = "cas")
168+
))]
168169
pub mod sync;
169170
pub mod rc;
170171
pub mod raw_vec;

src/liballoc/task.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
1313
pub use core::task::*;
1414

15-
#[cfg_attr(stage0, cfg(target_has_atomic = "ptr"))]
16-
#[cfg_attr(not(stage0), cfg(all(target_has_atomic = "ptr", target_has_atomic_cas)))]
15+
#[cfg(any(
16+
all(stage0, target_has_atomic = "ptr"),
17+
all(not(stage0), target_has_atomic = "ptr", target_has_atomic = "cas")
18+
))]
1719
pub use self::if_arc::*;
1820

19-
#[cfg_attr(stage0, cfg(target_has_atomic = "ptr"))]
20-
#[cfg_attr(not(stage0), cfg(all(target_has_atomic = "ptr", target_has_atomic_cas)))]
21+
#[cfg(any(
22+
all(stage0, target_has_atomic = "ptr"),
23+
all(not(stage0), target_has_atomic = "ptr", target_has_atomic = "cas")
24+
))]
2125
mod if_arc {
2226
use super::*;
2327
use core::marker::PhantomData;
@@ -49,8 +53,10 @@ mod if_arc {
4953
}
5054
}
5155

52-
#[cfg_attr(stage0, cfg(target_has_atomic = "ptr"))]
53-
#[cfg_attr(not(stage0), cfg(all(target_has_atomic = "ptr", target_has_atomic_cas)))]
56+
#[cfg(any(
57+
all(stage0, target_has_atomic = "ptr"),
58+
all(not(stage0), target_has_atomic = "ptr", target_has_atomic = "cas")
59+
))]
5460
struct ArcWrapped<T>(PhantomData<T>);
5561

5662
unsafe impl<T: Wake + 'static> UnsafeWake for ArcWrapped<T> {

src/libcore/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
#![feature(associated_type_defaults)]
8080
#![feature(attr_literals)]
8181
#![feature(cfg_target_has_atomic)]
82-
#![cfg_attr(not(stage0), feature(cfg_target_has_atomic_cas))]
8382
#![feature(concat_idents)]
8483
#![feature(const_fn)]
8584
#![feature(const_int_ops)]

src/libcore/sync/atomic.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl AtomicBool {
371371
/// ```
372372
#[inline]
373373
#[stable(feature = "rust1", since = "1.0.0")]
374-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
374+
#[cfg(any(stage0, target_has_atomic = "cas"))]
375375
pub fn swap(&self, val: bool, order: Ordering) -> bool {
376376
unsafe { atomic_swap(self.v.get(), val as u8, order) != 0 }
377377
}
@@ -402,7 +402,7 @@ impl AtomicBool {
402402
/// ```
403403
#[inline]
404404
#[stable(feature = "rust1", since = "1.0.0")]
405-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
405+
#[cfg(any(stage0, target_has_atomic = "cas"))]
406406
pub fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> bool {
407407
match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) {
408408
Ok(x) => x,
@@ -448,7 +448,7 @@ impl AtomicBool {
448448
/// ```
449449
#[inline]
450450
#[stable(feature = "extended_compare_and_swap", since = "1.10.0")]
451-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
451+
#[cfg(any(stage0, target_has_atomic = "cas"))]
452452
pub fn compare_exchange(&self,
453453
current: bool,
454454
new: bool,
@@ -540,7 +540,7 @@ impl AtomicBool {
540540
/// ```
541541
#[inline]
542542
#[stable(feature = "rust1", since = "1.0.0")]
543-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
543+
#[cfg(any(stage0, target_has_atomic = "cas"))]
544544
pub fn fetch_and(&self, val: bool, order: Ordering) -> bool {
545545
unsafe { atomic_and(self.v.get(), val as u8, order) != 0 }
546546
}
@@ -572,7 +572,7 @@ impl AtomicBool {
572572
/// ```
573573
#[inline]
574574
#[stable(feature = "rust1", since = "1.0.0")]
575-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
575+
#[cfg(any(stage0, target_has_atomic = "cas"))]
576576
pub fn fetch_nand(&self, val: bool, order: Ordering) -> bool {
577577
// We can't use atomic_nand here because it can result in a bool with
578578
// an invalid value. This happens because the atomic operation is done
@@ -615,7 +615,7 @@ impl AtomicBool {
615615
/// ```
616616
#[inline]
617617
#[stable(feature = "rust1", since = "1.0.0")]
618-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
618+
#[cfg(any(stage0, target_has_atomic = "cas"))]
619619
pub fn fetch_or(&self, val: bool, order: Ordering) -> bool {
620620
unsafe { atomic_or(self.v.get(), val as u8, order) != 0 }
621621
}
@@ -646,7 +646,7 @@ impl AtomicBool {
646646
/// ```
647647
#[inline]
648648
#[stable(feature = "rust1", since = "1.0.0")]
649-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
649+
#[cfg(any(stage0, target_has_atomic = "cas"))]
650650
pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool {
651651
unsafe { atomic_xor(self.v.get(), val as u8, order) != 0 }
652652
}
@@ -793,7 +793,7 @@ impl<T> AtomicPtr<T> {
793793
/// ```
794794
#[inline]
795795
#[stable(feature = "rust1", since = "1.0.0")]
796-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
796+
#[cfg(any(stage0, target_has_atomic = "cas"))]
797797
pub fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T {
798798
unsafe { atomic_swap(self.p.get() as *mut usize, ptr as usize, order) as *mut T }
799799
}
@@ -823,7 +823,7 @@ impl<T> AtomicPtr<T> {
823823
/// ```
824824
#[inline]
825825
#[stable(feature = "rust1", since = "1.0.0")]
826-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
826+
#[cfg(any(stage0, target_has_atomic = "cas"))]
827827
pub fn compare_and_swap(&self, current: *mut T, new: *mut T, order: Ordering) -> *mut T {
828828
match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) {
829829
Ok(x) => x,
@@ -862,7 +862,7 @@ impl<T> AtomicPtr<T> {
862862
/// ```
863863
#[inline]
864864
#[stable(feature = "extended_compare_and_swap", since = "1.10.0")]
865-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
865+
#[cfg(any(stage0, target_has_atomic = "cas"))]
866866
pub fn compare_exchange(&self,
867867
current: *mut T,
868868
new: *mut T,
@@ -1148,7 +1148,7 @@ assert_eq!(some_var.swap(10, Ordering::Relaxed), 5);
11481148
```"),
11491149
#[inline]
11501150
#[$stable]
1151-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
1151+
#[cfg(any(stage0, target_has_atomic = "cas"))]
11521152
pub fn swap(&self, val: $int_type, order: Ordering) -> $int_type {
11531153
unsafe { atomic_swap(self.v.get(), val, order) }
11541154
}
@@ -1181,7 +1181,7 @@ assert_eq!(some_var.load(Ordering::Relaxed), 10);
11811181
```"),
11821182
#[inline]
11831183
#[$stable]
1184-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
1184+
#[cfg(any(stage0, target_has_atomic = "cas"))]
11851185
pub fn compare_and_swap(&self,
11861186
current: $int_type,
11871187
new: $int_type,
@@ -1235,7 +1235,7 @@ assert_eq!(some_var.load(Ordering::Relaxed), 10);
12351235
```"),
12361236
#[inline]
12371237
#[$stable_cxchg]
1238-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
1238+
#[cfg(any(stage0, target_has_atomic = "cas"))]
12391239
pub fn compare_exchange(&self,
12401240
current: $int_type,
12411241
new: $int_type,
@@ -1690,7 +1690,7 @@ atomic_int!{
16901690
}
16911691

16921692
#[inline]
1693-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
1693+
#[cfg(any(stage0, target_has_atomic = "cas"))]
16941694
fn strongest_failure_ordering(order: Ordering) -> Ordering {
16951695
match order {
16961696
Release => Relaxed,
@@ -1727,7 +1727,7 @@ unsafe fn atomic_load<T>(dst: *const T, order: Ordering) -> T {
17271727
}
17281728

17291729
#[inline]
1730-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
1730+
#[cfg(any(stage0, target_has_atomic = "cas"))]
17311731
unsafe fn atomic_swap<T>(dst: *mut T, val: T, order: Ordering) -> T {
17321732
match order {
17331733
Acquire => intrinsics::atomic_xchg_acq(dst, val),
@@ -1766,7 +1766,7 @@ unsafe fn atomic_sub<T>(dst: *mut T, val: T, order: Ordering) -> T {
17661766
}
17671767

17681768
#[inline]
1769-
#[cfg_attr(not(stage0), cfg(target_has_atomic_cas))]
1769+
#[cfg(any(stage0, target_has_atomic = "cas"))]
17701770
unsafe fn atomic_compare_exchange<T>(dst: *mut T,
17711771
old: T,
17721772
new: T,

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
14081408
}
14091409
}
14101410
if atomic_cas {
1411-
ret.insert((Symbol::intern("target_has_atomic_cas"), None));
1411+
ret.insert((Symbol::intern("target_has_atomic"), Some(Symbol::intern("cas"))));
14121412
}
14131413
if sess.opts.debug_assertions {
14141414
ret.insert((Symbol::intern("debug_assertions"), None));

src/librustc_target/spec/msp430_none_elf.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ pub fn target() -> TargetResult {
3737
// There are no atomic CAS instructions available in the MSP430
3838
// instruction set
3939
max_atomic_width: Some(16),
40-
4140
atomic_cas: false,
4241

4342
// Because these devices have very little resources having an

src/librustc_target/spec/thumbv6m_none_eabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn target() -> TargetResult {
2929
// The ARMv6-M architecture doesn't support unaligned loads/stores so we disable them
3030
// with +strict-align.
3131
features: "+strict-align".to_string(),
32-
// There are no atomic instructions available in the instruction set of the ARMv6-M
32+
// There are no atomic CAS instructions available in the instruction set of the ARMv6-M
3333
// architecture
3434
atomic_cas: false,
3535
.. super::thumb_base::opts()

src/libsyntax/feature_gate.rs

-4
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,6 @@ declare_features! (
479479

480480
// Allows async and await syntax
481481
(active, async_await, "1.28.0", Some(50547), None),
482-
483-
// Allows async and await syntax
484-
(active, cfg_target_has_atomic_cas, "1.28.0", Some(0), None),
485482
);
486483

487484
declare_features! (
@@ -1102,7 +1099,6 @@ const GATED_CFGS: &[(&str, &str, fn(&Features) -> bool)] = &[
11021099
("target_vendor", "cfg_target_vendor", cfg_fn!(cfg_target_vendor)),
11031100
("target_thread_local", "cfg_target_thread_local", cfg_fn!(cfg_target_thread_local)),
11041101
("target_has_atomic", "cfg_target_has_atomic", cfg_fn!(cfg_target_has_atomic)),
1105-
("target_has_atomic_cas", "cfg_target_has_atomic_cas", cfg_fn!(cfg_target_has_atomic_cas)),
11061102
];
11071103

11081104
#[derive(Debug, Eq, PartialEq)]

0 commit comments

Comments
 (0)