@@ -247,12 +247,16 @@ macro_rules! integer_pass_through_methods {
247
247
}
248
248
249
249
// ----- `*mut T` and `AtomicPtr` -----
250
+ #[ cfg( target_has_atomic = "ptr" ) ]
250
251
impl < T > Atom for * mut T {
251
252
type Repr = Self ;
252
253
id_pack_unpack ! ( ) ;
253
254
}
254
255
256
+ #[ cfg( target_has_atomic = "ptr" ) ]
255
257
impl < T > sealed:: Sealed for * mut T { }
258
+
259
+ #[ cfg( target_has_atomic = "ptr" ) ]
256
260
impl < T > PrimitiveAtom for * mut T {
257
261
type Impl = atomic:: AtomicPtr < T > ;
258
262
pass_through_methods ! ( atomic:: AtomicPtr <T >) ;
@@ -305,19 +309,20 @@ macro_rules! impl_std_atomics {
305
309
( @int_methods $ty: ty, $non_zero_ty: ident, $impl_ty: ident, false ) => { } ;
306
310
}
307
311
308
- impl_std_atomics ! ( bool , _Dummy, AtomicBool , false ) ;
309
- impl_std_atomics ! ( u8 , NonZeroU8 , AtomicU8 , true ) ;
310
- impl_std_atomics ! ( i8 , NonZeroI8 , AtomicI8 , true ) ;
311
- impl_std_atomics ! ( u16 , NonZeroU16 , AtomicU16 , true ) ;
312
- impl_std_atomics ! ( i16 , NonZeroI16 , AtomicI16 , true ) ;
313
- impl_std_atomics ! ( u32 , NonZeroU32 , AtomicU32 , true ) ;
314
- impl_std_atomics ! ( i32 , NonZeroI32 , AtomicI32 , true ) ;
315
- impl_std_atomics ! ( u64 , NonZeroU64 , AtomicU64 , true ) ;
316
- impl_std_atomics ! ( i64 , NonZeroI64 , AtomicI64 , true ) ;
317
- impl_std_atomics ! ( usize , NonZeroUsize , AtomicUsize , true ) ;
318
- impl_std_atomics ! ( isize , NonZeroIsize , AtomicIsize , true ) ;
312
+ # [ cfg ( target_has_atomic = "8" ) ] impl_std_atomics ! ( bool , _Dummy, AtomicBool , false ) ;
313
+ # [ cfg ( target_has_atomic = "8" ) ] impl_std_atomics ! ( u8 , NonZeroU8 , AtomicU8 , true ) ;
314
+ # [ cfg ( target_has_atomic = "8" ) ] impl_std_atomics ! ( i8 , NonZeroI8 , AtomicI8 , true ) ;
315
+ # [ cfg ( target_has_atomic = "16" ) ] impl_std_atomics ! ( u16 , NonZeroU16 , AtomicU16 , true ) ;
316
+ # [ cfg ( target_has_atomic = "16" ) ] impl_std_atomics ! ( i16 , NonZeroI16 , AtomicI16 , true ) ;
317
+ # [ cfg ( target_has_atomic = "32" ) ] impl_std_atomics ! ( u32 , NonZeroU32 , AtomicU32 , true ) ;
318
+ # [ cfg ( target_has_atomic = "32" ) ] impl_std_atomics ! ( i32 , NonZeroI32 , AtomicI32 , true ) ;
319
+ # [ cfg ( target_has_atomic = "64" ) ] impl_std_atomics ! ( u64 , NonZeroU64 , AtomicU64 , true ) ;
320
+ # [ cfg ( target_has_atomic = "64" ) ] impl_std_atomics ! ( i64 , NonZeroI64 , AtomicI64 , true ) ;
321
+ # [ cfg ( target_has_atomic = "ptr" ) ] impl_std_atomics ! ( usize , NonZeroUsize , AtomicUsize , true ) ;
322
+ # [ cfg ( target_has_atomic = "ptr" ) ] impl_std_atomics ! ( isize , NonZeroIsize , AtomicIsize , true ) ;
319
323
320
324
// ----- Implementations for non-atomic primitive types ------------------------------------------
325
+ #[ cfg( target_has_atomic = "32" ) ]
321
326
impl Atom for f32 {
322
327
type Repr = u32 ;
323
328
fn pack ( self ) -> Self :: Repr {
@@ -328,6 +333,7 @@ impl Atom for f32 {
328
333
}
329
334
}
330
335
336
+ #[ cfg( target_has_atomic = "64" ) ]
331
337
impl Atom for f64 {
332
338
type Repr = u64 ;
333
339
fn pack ( self ) -> Self :: Repr {
@@ -338,6 +344,7 @@ impl Atom for f64 {
338
344
}
339
345
}
340
346
347
+ #[ cfg( target_has_atomic = "32" ) ]
341
348
impl Atom for char {
342
349
type Repr = u32 ;
343
350
fn pack ( self ) -> Self :: Repr {
@@ -362,6 +369,7 @@ impl<T: Atom> Atom for Wrapping<T> {
362
369
impl < T : AtomLogic > AtomLogic for Wrapping < T > where T :: Repr : PrimitiveAtomLogic { }
363
370
364
371
372
+ #[ cfg( target_has_atomic = "ptr" ) ]
365
373
impl < T > Atom for core:: ptr:: NonNull < T > {
366
374
type Repr = * mut T ;
367
375
fn pack ( self ) -> Self :: Repr {
@@ -373,6 +381,7 @@ impl<T> Atom for core::ptr::NonNull<T> {
373
381
}
374
382
}
375
383
384
+ #[ cfg( target_has_atomic = "ptr" ) ]
376
385
impl < T > Atom for Option < core:: ptr:: NonNull < T > > {
377
386
type Repr = * mut T ;
378
387
fn pack ( self ) -> Self :: Repr {
@@ -409,16 +418,16 @@ macro_rules! impl_option_non_zero {
409
418
} ;
410
419
}
411
420
412
- impl_option_non_zero ! ( NonZeroU8 = u8 ) ;
413
- impl_option_non_zero ! ( NonZeroI8 = i8 ) ;
414
- impl_option_non_zero ! ( NonZeroU16 = u16 ) ;
415
- impl_option_non_zero ! ( NonZeroI16 = i16 ) ;
416
- impl_option_non_zero ! ( NonZeroU32 = u32 ) ;
417
- impl_option_non_zero ! ( NonZeroI32 = i32 ) ;
418
- impl_option_non_zero ! ( NonZeroU64 = u64 ) ;
419
- impl_option_non_zero ! ( NonZeroI64 = i64 ) ;
420
- impl_option_non_zero ! ( NonZeroUsize = usize ) ;
421
- impl_option_non_zero ! ( NonZeroIsize = isize ) ;
421
+ # [ cfg ( target_has_atomic = "8" ) ] impl_option_non_zero ! ( NonZeroU8 = u8 ) ;
422
+ # [ cfg ( target_has_atomic = "8" ) ] impl_option_non_zero ! ( NonZeroI8 = i8 ) ;
423
+ # [ cfg ( target_has_atomic = "16" ) ] impl_option_non_zero ! ( NonZeroU16 = u16 ) ;
424
+ # [ cfg ( target_has_atomic = "16" ) ] impl_option_non_zero ! ( NonZeroI16 = i16 ) ;
425
+ # [ cfg ( target_has_atomic = "32" ) ] impl_option_non_zero ! ( NonZeroU32 = u32 ) ;
426
+ # [ cfg ( target_has_atomic = "32" ) ] impl_option_non_zero ! ( NonZeroI32 = i32 ) ;
427
+ # [ cfg ( target_has_atomic = "64" ) ] impl_option_non_zero ! ( NonZeroU64 = u64 ) ;
428
+ # [ cfg ( target_has_atomic = "64" ) ] impl_option_non_zero ! ( NonZeroI64 = i64 ) ;
429
+ # [ cfg ( target_has_atomic = "ptr" ) ] impl_option_non_zero ! ( NonZeroUsize = usize ) ;
430
+ # [ cfg ( target_has_atomic = "ptr" ) ] impl_option_non_zero ! ( NonZeroIsize = isize ) ;
422
431
423
432
/// This is just a dummy module to have doc tests.
424
433
///
0 commit comments