@@ -212,38 +212,42 @@ fn ptr_bitops_tagging() {
212
212
assert_eq ! ( atom. load( SeqCst ) , ptr) ;
213
213
}
214
214
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
+ }
228
234
}
229
235
230
236
#[ test]
231
237
fn atomic_access_bool ( ) {
232
- static mut ATOMIC : AtomicBool = AtomicBool :: new ( false ) ;
233
-
234
- unsafe {
235
- assert_eq ! ( * ATOMIC . get_mut( ) , false ) ;
236
- ATOMIC . store ( true , SeqCst ) ;
237
- assert_eq ! ( * ATOMIC . get_mut( ) , true ) ;
238
- ATOMIC . fetch_or ( false , SeqCst ) ;
239
- assert_eq ! ( * ATOMIC . get_mut( ) , true ) ;
240
- ATOMIC . fetch_and ( false , SeqCst ) ;
241
- assert_eq ! ( * ATOMIC . get_mut( ) , false ) ;
242
- ATOMIC . fetch_nand ( true , SeqCst ) ;
243
- assert_eq ! ( * ATOMIC . get_mut( ) , true ) ;
244
- ATOMIC . fetch_xor ( true , SeqCst ) ;
245
- assert_eq ! ( * ATOMIC . get_mut( ) , false ) ;
246
- }
238
+ let mut atomic: AtomicBool = AtomicBool :: new ( false ) ;
239
+
240
+ assert_eq ! ( * atomic. get_mut( ) , false ) ;
241
+ atomic. store ( true , SeqCst ) ;
242
+ assert_eq ! ( * atomic. get_mut( ) , true ) ;
243
+ atomic. fetch_or ( false , SeqCst ) ;
244
+ assert_eq ! ( * atomic. get_mut( ) , true ) ;
245
+ atomic. fetch_and ( false , SeqCst ) ;
246
+ assert_eq ! ( * atomic. get_mut( ) , false ) ;
247
+ atomic. fetch_nand ( true , SeqCst ) ;
248
+ assert_eq ! ( * atomic. get_mut( ) , true ) ;
249
+ atomic. fetch_xor ( true , SeqCst ) ;
250
+ assert_eq ! ( * atomic. get_mut( ) , false ) ;
247
251
}
248
252
249
253
#[ test]
@@ -284,26 +288,26 @@ fn atomic_alignment() {
284
288
fn atomic_compare_exchange ( ) {
285
289
use Ordering :: * ;
286
290
287
- static ATOMIC : AtomicIsize = AtomicIsize :: new ( 0 ) ;
288
-
289
- ATOMIC . compare_exchange ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
290
- ATOMIC . compare_exchange ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
291
- ATOMIC . compare_exchange ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
292
- ATOMIC . compare_exchange ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
293
- ATOMIC . compare_exchange ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
294
- ATOMIC . compare_exchange ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
295
- ATOMIC . compare_exchange ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
296
- ATOMIC . compare_exchange ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
297
- ATOMIC . compare_exchange ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
298
- ATOMIC . compare_exchange_weak ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
299
- ATOMIC . compare_exchange_weak ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
300
- ATOMIC . compare_exchange_weak ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
301
- ATOMIC . compare_exchange_weak ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
302
- ATOMIC . compare_exchange_weak ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
303
- ATOMIC . compare_exchange_weak ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
304
- ATOMIC . compare_exchange_weak ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
305
- ATOMIC . compare_exchange_weak ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
306
- ATOMIC . compare_exchange_weak ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
291
+ let atomic : AtomicIsize = AtomicIsize :: new ( 0 ) ;
292
+
293
+ atomic . compare_exchange ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
294
+ atomic . compare_exchange ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
295
+ atomic . compare_exchange ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
296
+ atomic . compare_exchange ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
297
+ atomic . compare_exchange ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
298
+ atomic . compare_exchange ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
299
+ atomic . compare_exchange ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
300
+ atomic . compare_exchange ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
301
+ atomic . compare_exchange ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
302
+ atomic . compare_exchange_weak ( 0 , 1 , Relaxed , Relaxed ) . ok ( ) ;
303
+ atomic . compare_exchange_weak ( 0 , 1 , Acquire , Relaxed ) . ok ( ) ;
304
+ atomic . compare_exchange_weak ( 0 , 1 , Release , Relaxed ) . ok ( ) ;
305
+ atomic . compare_exchange_weak ( 0 , 1 , AcqRel , Relaxed ) . ok ( ) ;
306
+ atomic . compare_exchange_weak ( 0 , 1 , SeqCst , Relaxed ) . ok ( ) ;
307
+ atomic . compare_exchange_weak ( 0 , 1 , Acquire , Acquire ) . ok ( ) ;
308
+ atomic . compare_exchange_weak ( 0 , 1 , AcqRel , Acquire ) . ok ( ) ;
309
+ atomic . compare_exchange_weak ( 0 , 1 , SeqCst , Acquire ) . ok ( ) ;
310
+ atomic . compare_exchange_weak ( 0 , 1 , SeqCst , SeqCst ) . ok ( ) ;
307
311
}
308
312
309
313
/* FIXME(#110395)
0 commit comments