pub enum AtomicClass {
Bool,
Int {
bytes: u64,
signed: bool,
},
Float {
bytes: u64,
},
Ptr,
FnPtr,
}Expand description
What kind of Rust atomic an object is reached through.
The width comes from the C type’s size, so long is an AtomicI64 on an
LP64 target and an AtomicI32 on an ILP32 one; the
data-model check is what makes that assumption safe.
Variants§
Bool
_Bool, which is AtomicBool — a Rust bool may only ever hold 0 or
1, so it may not be reached through an integer atomic.
Int
An integer (or enum) of bytes bytes: AtomicI8 … AtomicU64.
Float
float or double, reached through the integer atomic of the same
width and to_bits/from_bits.
Ptr
An object pointer, which is AtomicPtr.
FnPtr
A function pointer, which is also an AtomicPtr — but whose C value
is an Option<unsafe extern "C" fn(…)> in Rust rather than a raw
pointer, so the two ends of every operation are a transmute instead
of a cast.
That transmute is sound because an Option<fn> is pointer-sized with
the null pointer as its None niche, which is exactly the
representation C gives a function pointer that may be null. Arithmetic
is not: C has none on a function pointer, and neither has this.