129c32c40SBoqun Feng // SPDX-License-Identifier: GPL-2.0 229c32c40SBoqun Feng 329c32c40SBoqun Feng //! Pre-defined atomic types 429c32c40SBoqun Feng 529c32c40SBoqun Feng // SAFETY: `i32` has the same size and alignment with itself, and is round-trip transmutable to 629c32c40SBoqun Feng // itself. 729c32c40SBoqun Feng unsafe impl super::AtomicType for i32 { 829c32c40SBoqun Feng type Repr = i32; 929c32c40SBoqun Feng } 1029c32c40SBoqun Feng 11*d1320543SBoqun Feng // SAFETY: The wrapping add result of two `i32`s is a valid `i32`. 12*d1320543SBoqun Feng unsafe impl super::AtomicAdd<i32> for i32 { 13*d1320543SBoqun Feng fn rhs_into_delta(rhs: i32) -> i32 { 14*d1320543SBoqun Feng rhs 15*d1320543SBoqun Feng } 16*d1320543SBoqun Feng } 17*d1320543SBoqun Feng 1829c32c40SBoqun Feng // SAFETY: `i64` has the same size and alignment with itself, and is round-trip transmutable to 1929c32c40SBoqun Feng // itself. 2029c32c40SBoqun Feng unsafe impl super::AtomicType for i64 { 2129c32c40SBoqun Feng type Repr = i64; 2229c32c40SBoqun Feng } 23*d1320543SBoqun Feng 24*d1320543SBoqun Feng // SAFETY: The wrapping add result of two `i64`s is a valid `i64`. 25*d1320543SBoqun Feng unsafe impl super::AtomicAdd<i64> for i64 { 26*d1320543SBoqun Feng fn rhs_into_delta(rhs: i64) -> i64 { 27*d1320543SBoqun Feng rhs 28*d1320543SBoqun Feng } 29*d1320543SBoqun Feng } 30