@@ -212,40 +212,44 @@ fn ptr_bitops_tagging() {
212212 assert_eq ! ( atom. load( SeqCst ) , ptr) ;
213213}
214214
215- static S_FALSE : AtomicBool = AtomicBool :: new ( false ) ;
216- static S_TRUE : AtomicBool = AtomicBool :: new ( true ) ;
217- static S_INT : AtomicIsize = AtomicIsize :: new ( 0 ) ;
218- static S_UINT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
219-
220- #[ test]
221- fn static_init ( ) {
222- // Note that we're not really testing the mutability here but it's important
223- // on Android at the moment (#49775)
224- assert ! ( !S_FALSE . swap( true , SeqCst ) ) ;
225- assert ! ( S_TRUE . swap( false , SeqCst ) ) ;
226- assert ! ( S_INT . fetch_add( 1 , SeqCst ) == 0 ) ;
227- assert ! ( S_UINT . fetch_add( 1 , SeqCst ) == 0 ) ;
215+ // SBF does not support mustable static data
216+ #[ cfg( not( any( target_arch = "bpf" , target_arch = "sbf" ) ) ) ]
217+ mod statik {
218+ use super :: * ;
219+
220+ static S_FALSE : AtomicBool = AtomicBool :: new ( false ) ;
221+ static S_TRUE : AtomicBool = AtomicBool :: new ( true ) ;
222+ static S_INT : AtomicIsize = AtomicIsize :: new ( 0 ) ;
223+ static S_UINT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
224+
225+ #[ test]
226+ fn static_init ( ) {
227+ // Note that we're not really testing the mutability here but it's important
228+ // on Android at the moment (#49775)
229+ assert ! ( !S_FALSE . swap( true , SeqCst ) ) ;
230+ assert ! ( S_TRUE . swap( false , SeqCst ) ) ;
231+ assert ! ( S_INT . fetch_add( 1 , SeqCst ) == 0 ) ;
232+ assert ! ( S_UINT . fetch_add( 1 , SeqCst ) == 0 ) ;
233+ }
228234}
229235
230236#[ test]
231237// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
232238#[ allow( static_mut_refs) ]
233239fn atomic_access_bool ( ) {
234- static mut ATOMIC : AtomicBool = AtomicBool :: new ( false ) ;
235-
236- unsafe {
237- assert_eq ! ( * ATOMIC . get_mut( ) , false ) ;
238- ATOMIC . store ( true , SeqCst ) ;
239- assert_eq ! ( * ATOMIC . get_mut( ) , true ) ;
240- ATOMIC . fetch_or ( false , SeqCst ) ;
241- assert_eq ! ( * ATOMIC . get_mut( ) , true ) ;
242- ATOMIC . fetch_and ( false , SeqCst ) ;
243- assert_eq ! ( * ATOMIC . get_mut( ) , false ) ;
244- ATOMIC . fetch_nand ( true , SeqCst ) ;
245- assert_eq ! ( * ATOMIC . get_mut( ) , true ) ;
246- ATOMIC . fetch_xor ( true , SeqCst ) ;
247- assert_eq ! ( * ATOMIC . get_mut( ) , false ) ;
248- }
240+ let mut atomic: AtomicBool = AtomicBool :: new ( false ) ;
241+
242+ assert_eq ! ( * atomic. get_mut( ) , false ) ;
243+ atomic. store ( true , SeqCst ) ;
244+ assert_eq ! ( * atomic. get_mut( ) , true ) ;
245+ atomic. fetch_or ( false , SeqCst ) ;
246+ assert_eq ! ( * atomic. get_mut( ) , true ) ;
247+ atomic. fetch_and ( false , SeqCst ) ;
248+ assert_eq ! ( * atomic. get_mut( ) , false ) ;
249+ atomic. fetch_nand ( true , SeqCst ) ;
250+ assert_eq ! ( * atomic. get_mut( ) , true ) ;
251+ atomic. fetch_xor ( true , SeqCst ) ;
252+ assert_eq ! ( * atomic. get_mut( ) , false ) ;
249253}
250254
251255#[ test]
@@ -286,26 +290,26 @@ fn atomic_alignment() {
286290fn atomic_compare_exchange ( ) {
287291 use Ordering :: * ;
288292
289- static ATOMIC : AtomicIsize = AtomicIsize :: new ( 0 ) ;
290-
291- ATOMIC . compare_exchange ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
292- ATOMIC . compare_exchange ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
293- ATOMIC . compare_exchange ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
294- ATOMIC . compare_exchange ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
295- ATOMIC . compare_exchange ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
296- ATOMIC . compare_exchange ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
297- ATOMIC . compare_exchange ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
298- ATOMIC . compare_exchange ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
299- ATOMIC . compare_exchange ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
300- ATOMIC . compare_exchange_weak ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
301- ATOMIC . compare_exchange_weak ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
302- ATOMIC . compare_exchange_weak ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
303- ATOMIC . compare_exchange_weak ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
304- ATOMIC . compare_exchange_weak ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
305- ATOMIC . compare_exchange_weak ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
306- ATOMIC . compare_exchange_weak ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
307- ATOMIC . compare_exchange_weak ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
308- ATOMIC . compare_exchange_weak ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
293+ let atomic : AtomicIsize = AtomicIsize :: new ( 0 ) ;
294+
295+ atomic . compare_exchange ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
296+ atomic . compare_exchange ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
297+ atomic . compare_exchange ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
298+ atomic . compare_exchange ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
299+ atomic . compare_exchange ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
300+ atomic . compare_exchange ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
301+ atomic . compare_exchange ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
302+ atomic . compare_exchange ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
303+ atomic . compare_exchange ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
304+ atomic . compare_exchange_weak ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
305+ atomic . compare_exchange_weak ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
306+ atomic . compare_exchange_weak ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
307+ atomic . compare_exchange_weak ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
308+ atomic . compare_exchange_weak ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
309+ atomic . compare_exchange_weak ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
310+ atomic . compare_exchange_weak ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
311+ atomic . compare_exchange_weak ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
312+ atomic . compare_exchange_weak ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
309313}
310314
311315/* FIXME(#110395)
0 commit comments