Skip to content

Commit 8e12c0c

Browse files
committedJan 3, 2022
[SOL] remove stubs for atomics
(Pseudo) atomics are now implemented in SBF anza-xyz/llvm-project#23
1 parent d75c91b commit 8e12c0c

File tree

4 files changed

+85
-193
lines changed

4 files changed

+85
-193
lines changed
 

‎library/core/src/sync/atomic.rs

Lines changed: 32 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,10 +2337,7 @@ fn strongest_failure_ordering(order: Ordering) -> Ordering {
23372337
}
23382338

23392339
#[inline]
2340-
#[cfg_attr(target_arch = "bpf", allow(unused_variables))]
2341-
#[cfg_attr(target_arch = "sbf", allow(unused_variables))]
23422340
unsafe fn atomic_store<T: Copy>(dst: *mut T, val: T, order: Ordering) {
2343-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
23442341
// SAFETY: the caller must uphold the safety contract for `atomic_store`.
23452342
unsafe {
23462343
match order {
@@ -2351,18 +2348,10 @@ unsafe fn atomic_store<T: Copy>(dst: *mut T, val: T, order: Ordering) {
23512348
AcqRel => panic!("there is no such thing as an acquire/release store"),
23522349
}
23532350
}
2354-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2355-
// SAFETY: the caller must uphold the safety contract for `atomic_store`.
2356-
unsafe {
2357-
*dst = val;
2358-
}
23592351
}
23602352

23612353
#[inline]
2362-
#[cfg_attr(target_arch = "bpf", allow(unused_variables))]
2363-
#[cfg_attr(target_arch = "sbf", allow(unused_variables))]
23642354
unsafe fn atomic_load<T: Copy>(dst: *const T, order: Ordering) -> T {
2365-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
23662355
// SAFETY: the caller must uphold the safety contract for `atomic_load`.
23672356
unsafe {
23682357
match order {
@@ -2373,19 +2362,11 @@ unsafe fn atomic_load<T: Copy>(dst: *const T, order: Ordering) -> T {
23732362
AcqRel => panic!("there is no such thing as an acquire/release load"),
23742363
}
23752364
}
2376-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2377-
// SAFETY: the caller must uphold the safety contract for `atomic_load`.
2378-
unsafe {
2379-
*dst
2380-
}
23812365
}
23822366

23832367
#[inline]
23842368
#[cfg(target_has_atomic = "8")]
2385-
#[cfg_attr(target_arch = "bpf", allow(unused_variables))]
2386-
#[cfg_attr(target_arch = "sbf", allow(unused_variables))]
23872369
unsafe fn atomic_swap<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
2388-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
23892370
// SAFETY: the caller must uphold the safety contract for `atomic_swap`.
23902371
unsafe {
23912372
match order {
@@ -2396,22 +2377,12 @@ unsafe fn atomic_swap<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
23962377
SeqCst => intrinsics::atomic_xchg(dst, val),
23972378
}
23982379
}
2399-
#[cfg(any(target_arch = "bpf" ,target_arch = "sbf"))]
2400-
// SAFETY: the caller must uphold the safety contract for `atomic_swap`.
2401-
unsafe {
2402-
let old = *dst;
2403-
*dst = val;
2404-
old
2405-
}
24062380
}
24072381

24082382
/// Returns the previous value (like __sync_fetch_and_add).
24092383
#[inline]
24102384
#[cfg(target_has_atomic = "8")]
2411-
#[cfg_attr(target_arch = "bpf", allow(unused_variables))]
2412-
#[cfg_attr(target_arch = "sbf", allow(unused_variables))]
24132385
unsafe fn atomic_add<T: Copy + crate::ops::Add<Output = T>>(dst: *mut T, val: T, order: Ordering) -> T {
2414-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
24152386
// SAFETY: the caller must uphold the safety contract for `atomic_add`.
24162387
unsafe {
24172388
match order {
@@ -2422,22 +2393,12 @@ unsafe fn atomic_add<T: Copy + crate::ops::Add<Output = T>>(dst: *mut T, val: T,
24222393
SeqCst => intrinsics::atomic_xadd(dst, val),
24232394
}
24242395
}
2425-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2426-
// SAFETY: the caller must uphold the safety contract for `atomic_add`.
2427-
unsafe {
2428-
let old = *dst;
2429-
*dst = old + val;
2430-
old
2431-
}
24322396
}
24332397

24342398
/// Returns the previous value (like __sync_fetch_and_sub).
24352399
#[inline]
24362400
#[cfg(target_has_atomic = "8")]
2437-
#[cfg_attr(target_arch = "bpf", allow(unused_variables))]
2438-
#[cfg_attr(target_arch = "sbf", allow(unused_variables))]
24392401
unsafe fn atomic_sub<T: Copy + crate::ops::Sub<Output = T>>(dst: *mut T, val: T, order: Ordering) -> T {
2440-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
24412402
// SAFETY: the caller must uphold the safety contract for `atomic_sub`.
24422403
unsafe {
24432404
match order {
@@ -2448,58 +2409,35 @@ unsafe fn atomic_sub<T: Copy + crate::ops::Sub<Output = T>>(dst: *mut T, val: T,
24482409
SeqCst => intrinsics::atomic_xsub(dst, val),
24492410
}
24502411
}
2451-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2452-
// SAFETY: the caller must uphold the safety contract for `atomic_sub`.
2453-
unsafe {
2454-
let old = *dst;
2455-
*dst = old - val;
2456-
old
2457-
}
24582412
}
24592413

24602414
#[inline]
24612415
#[cfg(target_has_atomic = "8")]
2462-
#[cfg_attr(target_arch = "bpf", allow(unused_variables))]
2463-
#[cfg_attr(target_arch = "sbf", allow(unused_variables))]
24642416
unsafe fn atomic_compare_exchange<T: Copy + crate::cmp::PartialEq>(
24652417
dst: *mut T,
24662418
old: T,
24672419
new: T,
24682420
success: Ordering,
24692421
failure: Ordering,
24702422
) -> Result<T, T> {
2471-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
2472-
{
2473-
// SAFETY: the caller must uphold the safety contract for `atomic_compare_exchange`.
2474-
let (val, ok) = unsafe {
2475-
match (success, failure) {
2476-
(Acquire, Acquire) => intrinsics::atomic_cxchg_acq(dst, old, new),
2477-
(Release, Relaxed) => intrinsics::atomic_cxchg_rel(dst, old, new),
2478-
(AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel(dst, old, new),
2479-
(Relaxed, Relaxed) => intrinsics::atomic_cxchg_relaxed(dst, old, new),
2480-
(SeqCst, SeqCst) => intrinsics::atomic_cxchg(dst, old, new),
2481-
(Acquire, Relaxed) => intrinsics::atomic_cxchg_acq_failrelaxed(dst, old, new),
2482-
(AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_failrelaxed(dst, old, new),
2483-
(SeqCst, Relaxed) => intrinsics::atomic_cxchg_failrelaxed(dst, old, new),
2484-
(SeqCst, Acquire) => intrinsics::atomic_cxchg_failacq(dst, old, new),
2485-
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
2486-
(_, Release) => panic!("there is no such thing as a release failure ordering"),
2487-
_ => panic!("a failure ordering can't be stronger than a success ordering"),
2488-
}
2489-
};
2490-
if ok { Ok(val) } else { Err(val) }
2491-
}
2492-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
24932423
// SAFETY: the caller must uphold the safety contract for `atomic_compare_exchange`.
2494-
unsafe {
2495-
let current = *dst;
2496-
if current == old {
2497-
*dst = new;
2498-
Ok(current)
2499-
} else {
2500-
Err(current)
2424+
let (val, ok) = unsafe {
2425+
match (success, failure) {
2426+
(Acquire, Acquire) => intrinsics::atomic_cxchg_acq(dst, old, new),
2427+
(Release, Relaxed) => intrinsics::atomic_cxchg_rel(dst, old, new),
2428+
(AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel(dst, old, new),
2429+
(Relaxed, Relaxed) => intrinsics::atomic_cxchg_relaxed(dst, old, new),
2430+
(SeqCst, SeqCst) => intrinsics::atomic_cxchg(dst, old, new),
2431+
(Acquire, Relaxed) => intrinsics::atomic_cxchg_acq_failrelaxed(dst, old, new),
2432+
(AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_failrelaxed(dst, old, new),
2433+
(SeqCst, Relaxed) => intrinsics::atomic_cxchg_failrelaxed(dst, old, new),
2434+
(SeqCst, Acquire) => intrinsics::atomic_cxchg_failacq(dst, old, new),
2435+
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
2436+
(_, Release) => panic!("there is no such thing as a release failure ordering"),
2437+
_ => panic!("a failure ordering can't be stronger than a success ordering"),
25012438
}
2502-
}
2439+
};
2440+
if ok { Ok(val) } else { Err(val) }
25032441
}
25042442

25052443
#[inline]
@@ -2511,38 +2449,24 @@ unsafe fn atomic_compare_exchange_weak<T: Copy + crate::cmp::PartialEq>(
25112449
_success: Ordering,
25122450
_failure: Ordering,
25132451
) -> Result<T, T> {
2514-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
2515-
{
2516-
// SAFETY: the caller must uphold the safety contract for `atomic_compare_exchange_weak`.
2517-
let (val, ok) = unsafe {
2518-
match (_success, _failure) {
2519-
(Acquire, Acquire) => intrinsics::atomic_cxchgweak_acq(dst, old, new),
2520-
(Release, Relaxed) => intrinsics::atomic_cxchgweak_rel(dst, old, new),
2521-
(AcqRel, Acquire) => intrinsics::atomic_cxchgweak_acqrel(dst, old, new),
2522-
(Relaxed, Relaxed) => intrinsics::atomic_cxchgweak_relaxed(dst, old, new),
2523-
(SeqCst, SeqCst) => intrinsics::atomic_cxchgweak(dst, old, new),
2524-
(Acquire, Relaxed) => intrinsics::atomic_cxchgweak_acq_failrelaxed(dst, old, new),
2525-
(AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_failrelaxed(dst, old, new),
2526-
(SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_failrelaxed(dst, old, new),
2527-
(SeqCst, Acquire) => intrinsics::atomic_cxchgweak_failacq(dst, old, new),
2528-
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
2529-
(_, Release) => panic!("there is no such thing as a release failure ordering"),
2530-
_ => panic!("a failure ordering can't be stronger than a success ordering"),
2531-
}
2532-
};
2533-
if ok { Ok(val) } else { Err(val) }
2534-
}
2535-
#[cfg(any(target_arch = "sbf", target_arch = "bpf"))]
25362452
// SAFETY: the caller must uphold the safety contract for `atomic_compare_exchange_weak`.
2537-
unsafe {
2538-
let current = *dst;
2539-
if current == old {
2540-
*dst = new;
2541-
Ok(current)
2542-
} else {
2543-
Err(current)
2453+
let (val, ok) = unsafe {
2454+
match (_success, _failure) {
2455+
(Acquire, Acquire) => intrinsics::atomic_cxchgweak_acq(dst, old, new),
2456+
(Release, Relaxed) => intrinsics::atomic_cxchgweak_rel(dst, old, new),
2457+
(AcqRel, Acquire) => intrinsics::atomic_cxchgweak_acqrel(dst, old, new),
2458+
(Relaxed, Relaxed) => intrinsics::atomic_cxchgweak_relaxed(dst, old, new),
2459+
(SeqCst, SeqCst) => intrinsics::atomic_cxchgweak(dst, old, new),
2460+
(Acquire, Relaxed) => intrinsics::atomic_cxchgweak_acq_failrelaxed(dst, old, new),
2461+
(AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_failrelaxed(dst, old, new),
2462+
(SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_failrelaxed(dst, old, new),
2463+
(SeqCst, Acquire) => intrinsics::atomic_cxchgweak_failacq(dst, old, new),
2464+
(_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"),
2465+
(_, Release) => panic!("there is no such thing as a release failure ordering"),
2466+
_ => panic!("a failure ordering can't be stronger than a success ordering"),
25442467
}
2545-
}
2468+
};
2469+
if ok { Ok(val) } else { Err(val) }
25462470
}
25472471

25482472
#[inline]
@@ -2609,7 +2533,6 @@ unsafe fn atomic_xor<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
26092533
#[inline]
26102534
#[cfg(target_has_atomic = "8")]
26112535
unsafe fn atomic_max<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Ordering) -> T {
2612-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
26132536
// SAFETY: the caller must uphold the safety contract for `atomic_max`
26142537
unsafe {
26152538
match _order {
@@ -2620,18 +2543,12 @@ unsafe fn atomic_max<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Ord
26202543
SeqCst => intrinsics::atomic_max(dst, val),
26212544
}
26222545
}
2623-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2624-
// SAFETY: the caller must uphold the safety contract for `atomic_max`
2625-
unsafe {
2626-
crate::cmp::max(*dst, val)
2627-
}
26282546
}
26292547

26302548
/// returns the min value (signed comparison)
26312549
#[inline]
26322550
#[cfg(target_has_atomic = "8")]
26332551
unsafe fn atomic_min<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Ordering) -> T {
2634-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
26352552
// SAFETY: the caller must uphold the safety contract for `atomic_min`
26362553
unsafe {
26372554
match _order {
@@ -2642,18 +2559,12 @@ unsafe fn atomic_min<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Ord
26422559
SeqCst => intrinsics::atomic_min(dst, val),
26432560
}
26442561
}
2645-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2646-
// SAFETY: the caller must uphold the safety contract for `atomic_min`
2647-
unsafe {
2648-
crate::cmp::min(*dst, val)
2649-
}
26502562
}
26512563

26522564
/// returns the max value (unsigned comparison)
26532565
#[inline]
26542566
#[cfg(target_has_atomic = "8")]
26552567
unsafe fn atomic_umax<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Ordering) -> T {
2656-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
26572568
// SAFETY: the caller must uphold the safety contract for `atomic_umax`
26582569
unsafe {
26592570
match _order {
@@ -2664,18 +2575,12 @@ unsafe fn atomic_umax<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Or
26642575
SeqCst => intrinsics::atomic_umax(dst, val),
26652576
}
26662577
}
2667-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2668-
// SAFETY: the caller must uphold the safety contract for `atomic_umax`
2669-
unsafe {
2670-
crate::cmp::max(*dst, val)
2671-
}
26722578
}
26732579

26742580
/// returns the min value (unsigned comparison)
26752581
#[inline]
26762582
#[cfg(target_has_atomic = "8")]
26772583
unsafe fn atomic_umin<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Ordering) -> T {
2678-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
26792584
// SAFETY: the caller must uphold the safety contract for `atomic_umin`
26802585
unsafe {
26812586
match _order {
@@ -2686,11 +2591,6 @@ unsafe fn atomic_umin<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Or
26862591
SeqCst => intrinsics::atomic_umin(dst, val),
26872592
}
26882593
}
2689-
#[cfg(any(target_arch = "bpf", target_arch = "sbf"))]
2690-
// SAFETY: the caller must uphold the safety contract for `atomic_umin`
2691-
unsafe {
2692-
crate::cmp::min(*dst, val)
2693-
}
26942594
}
26952595

26962596
/// An atomic fence.
@@ -2770,16 +2670,8 @@ unsafe fn atomic_umin<T: Copy + crate::cmp::Ord>(dst: *mut T, val: T, _order: Or
27702670
#[inline]
27712671
#[stable(feature = "rust1", since = "1.0.0")]
27722672
#[rustc_diagnostic_item = "fence"]
2773-
#[cfg_attr(any(target_arch = "bpf", target_arch = "sbf", target_arch = "wasm32"), allow(unused_variables))]
27742673
pub fn fence(order: Ordering) {
2775-
#[cfg(not(any(target_arch = "wasm32", target_arch = "bpf", target_arch = "sbf")))]
27762674
// SAFETY: using an atomic fence is safe.
2777-
// On wasm32 and SBF it looks like fences aren't implemented in LLVM yet in that
2778-
// they will cause LLVM to abort. The wasm instruction set doesn't have
2779-
// fences right now. There's discussion online about the best way for tools
2780-
// to conventionally implement fences at
2781-
// https://github.com/WebAssembly/tool-conventions/issues/59. We should
2782-
// follow that discussion and implement a solution when one comes about!
27832675
unsafe {
27842676
match order {
27852677
Acquire => intrinsics::atomic_fence_acq(),
@@ -2860,10 +2752,7 @@ pub fn fence(order: Ordering) {
28602752
#[inline]
28612753
#[stable(feature = "compiler_fences", since = "1.21.0")]
28622754
#[rustc_diagnostic_item = "compiler_fence"]
2863-
#[cfg_attr(target_arch = "bpf", allow(unused_variables))]
2864-
#[cfg_attr(target_arch = "sbf", allow(unused_variables))]
28652755
pub fn compiler_fence(order: Ordering) {
2866-
#[cfg(all(not(target_arch = "bpf"), not(target_arch = "sbf")))]
28672756
// SAFETY: using an atomic fence is safe.
28682757
unsafe {
28692758
match order {

‎library/core/tests/atomic.rs

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -127,38 +127,42 @@ fn int_max() {
127127
assert_eq!(x.load(SeqCst), 0xf731);
128128
}
129129

130-
static S_FALSE: AtomicBool = AtomicBool::new(false);
131-
static S_TRUE: AtomicBool = AtomicBool::new(true);
132-
static S_INT: AtomicIsize = AtomicIsize::new(0);
133-
static S_UINT: AtomicUsize = AtomicUsize::new(0);
134-
135-
#[test]
136-
fn static_init() {
137-
// Note that we're not really testing the mutability here but it's important
138-
// on Android at the moment (#49775)
139-
assert!(!S_FALSE.swap(true, SeqCst));
140-
assert!(S_TRUE.swap(false, SeqCst));
141-
assert!(S_INT.fetch_add(1, SeqCst) == 0);
142-
assert!(S_UINT.fetch_add(1, SeqCst) == 0);
130+
// SBF does not support mustable static data
131+
#[cfg(not(any(target_arch = "bpf", target_arch = "sbf")))]
132+
mod statik {
133+
use super::*;
134+
135+
static S_FALSE: AtomicBool = AtomicBool::new(false);
136+
static S_TRUE: AtomicBool = AtomicBool::new(true);
137+
static S_INT: AtomicIsize = AtomicIsize::new(0);
138+
static S_UINT: AtomicUsize = AtomicUsize::new(0);
139+
140+
#[test]
141+
fn static_init() {
142+
// Note that we're not really testing the mutability here but it's important
143+
// on Android at the moment (#49775)
144+
assert!(!S_FALSE.swap(true, SeqCst));
145+
assert!(S_TRUE.swap(false, SeqCst));
146+
assert!(S_INT.fetch_add(1, SeqCst) == 0);
147+
assert!(S_UINT.fetch_add(1, SeqCst) == 0);
148+
}
143149
}
144150

145151
#[test]
146152
fn atomic_access_bool() {
147-
static mut ATOMIC: AtomicBool = AtomicBool::new(false);
148-
149-
unsafe {
150-
assert_eq!(*ATOMIC.get_mut(), false);
151-
ATOMIC.store(true, SeqCst);
152-
assert_eq!(*ATOMIC.get_mut(), true);
153-
ATOMIC.fetch_or(false, SeqCst);
154-
assert_eq!(*ATOMIC.get_mut(), true);
155-
ATOMIC.fetch_and(false, SeqCst);
156-
assert_eq!(*ATOMIC.get_mut(), false);
157-
ATOMIC.fetch_nand(true, SeqCst);
158-
assert_eq!(*ATOMIC.get_mut(), true);
159-
ATOMIC.fetch_xor(true, SeqCst);
160-
assert_eq!(*ATOMIC.get_mut(), false);
161-
}
153+
let mut atomic: AtomicBool = AtomicBool::new(false);
154+
155+
assert_eq!(*atomic.get_mut(), false);
156+
atomic.store(true, SeqCst);
157+
assert_eq!(*atomic.get_mut(), true);
158+
atomic.fetch_or(false, SeqCst);
159+
assert_eq!(*atomic.get_mut(), true);
160+
atomic.fetch_and(false, SeqCst);
161+
assert_eq!(*atomic.get_mut(), false);
162+
atomic.fetch_nand(true, SeqCst);
163+
assert_eq!(*atomic.get_mut(), true);
164+
atomic.fetch_xor(true, SeqCst);
165+
assert_eq!(*atomic.get_mut(), false);
162166
}
163167

164168
#[test]
@@ -199,24 +203,24 @@ fn atomic_alignment() {
199203
fn atomic_compare_exchange() {
200204
use Ordering::*;
201205

202-
static ATOMIC: AtomicIsize = AtomicIsize::new(0);
203-
204-
ATOMIC.compare_exchange(0, 1, Relaxed, Relaxed).ok();
205-
ATOMIC.compare_exchange(0, 1, Acquire, Relaxed).ok();
206-
ATOMIC.compare_exchange(0, 1, Release, Relaxed).ok();
207-
ATOMIC.compare_exchange(0, 1, AcqRel, Relaxed).ok();
208-
ATOMIC.compare_exchange(0, 1, SeqCst, Relaxed).ok();
209-
ATOMIC.compare_exchange(0, 1, Acquire, Acquire).ok();
210-
ATOMIC.compare_exchange(0, 1, AcqRel, Acquire).ok();
211-
ATOMIC.compare_exchange(0, 1, SeqCst, Acquire).ok();
212-
ATOMIC.compare_exchange(0, 1, SeqCst, SeqCst).ok();
213-
ATOMIC.compare_exchange_weak(0, 1, Relaxed, Relaxed).ok();
214-
ATOMIC.compare_exchange_weak(0, 1, Acquire, Relaxed).ok();
215-
ATOMIC.compare_exchange_weak(0, 1, Release, Relaxed).ok();
216-
ATOMIC.compare_exchange_weak(0, 1, AcqRel, Relaxed).ok();
217-
ATOMIC.compare_exchange_weak(0, 1, SeqCst, Relaxed).ok();
218-
ATOMIC.compare_exchange_weak(0, 1, Acquire, Acquire).ok();
219-
ATOMIC.compare_exchange_weak(0, 1, AcqRel, Acquire).ok();
220-
ATOMIC.compare_exchange_weak(0, 1, SeqCst, Acquire).ok();
221-
ATOMIC.compare_exchange_weak(0, 1, SeqCst, SeqCst).ok();
206+
let atomic: AtomicIsize = AtomicIsize::new(0);
207+
208+
atomic.compare_exchange(0, 1, Relaxed, Relaxed).ok();
209+
atomic.compare_exchange(0, 1, Acquire, Relaxed).ok();
210+
atomic.compare_exchange(0, 1, Release, Relaxed).ok();
211+
atomic.compare_exchange(0, 1, AcqRel, Relaxed).ok();
212+
atomic.compare_exchange(0, 1, SeqCst, Relaxed).ok();
213+
atomic.compare_exchange(0, 1, Acquire, Acquire).ok();
214+
atomic.compare_exchange(0, 1, AcqRel, Acquire).ok();
215+
atomic.compare_exchange(0, 1, SeqCst, Acquire).ok();
216+
atomic.compare_exchange(0, 1, SeqCst, SeqCst).ok();
217+
atomic.compare_exchange_weak(0, 1, Relaxed, Relaxed).ok();
218+
atomic.compare_exchange_weak(0, 1, Acquire, Relaxed).ok();
219+
atomic.compare_exchange_weak(0, 1, Release, Relaxed).ok();
220+
atomic.compare_exchange_weak(0, 1, AcqRel, Relaxed).ok();
221+
atomic.compare_exchange_weak(0, 1, SeqCst, Relaxed).ok();
222+
atomic.compare_exchange_weak(0, 1, Acquire, Acquire).ok();
223+
atomic.compare_exchange_weak(0, 1, AcqRel, Acquire).ok();
224+
atomic.compare_exchange_weak(0, 1, SeqCst, Acquire).ok();
225+
atomic.compare_exchange_weak(0, 1, SeqCst, SeqCst).ok();
222226
}

‎library/core/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ mod alloc;
7979
mod any;
8080
mod array;
8181
mod ascii;
82-
#[cfg(not(any(target_arch = "bpf", target_arch = "sbf")))]
8382
mod atomic;
8483
mod bool;
8584
mod cell;

‎src/llvm-project

0 commit comments

Comments
 (0)
Please sign in to comment.