xref: /linux/rust/kernel/sync/atomic/predefine.rs (revision d132054360baf0d127a463bbf853e43dd6eb0dd9)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 //! Pre-defined atomic types
4 
5 // SAFETY: `i32` has the same size and alignment with itself, and is round-trip transmutable to
6 // itself.
7 unsafe impl super::AtomicType for i32 {
8     type Repr = i32;
9 }
10 
11 // SAFETY: The wrapping add result of two `i32`s is a valid `i32`.
12 unsafe impl super::AtomicAdd<i32> for i32 {
13     fn rhs_into_delta(rhs: i32) -> i32 {
14         rhs
15     }
16 }
17 
18 // SAFETY: `i64` has the same size and alignment with itself, and is round-trip transmutable to
19 // itself.
20 unsafe impl super::AtomicType for i64 {
21     type Repr = i64;
22 }
23 
24 // SAFETY: The wrapping add result of two `i64`s is a valid `i64`.
25 unsafe impl super::AtomicAdd<i64> for i64 {
26     fn rhs_into_delta(rhs: i64) -> i64 {
27         rhs
28     }
29 }
30