#atomic #macro #generate #attributes #atomic-xxx

macro atomic_macro

Attribute macros for generating AtomicXXX

2 releases

0.1.1 Jan 19, 2022
0.1.0 Jan 19, 2022

#259 in #atomic

Custom license

7KB
83 lines

atomic_macro

Usage

#[atomic_macro::atomic(32)]
struct SomeStruct {
    field_one: u8,
    field_two: u16,
}
impl From<u32> for SomeStruct {
    fn from(value: u32) -> Self {
        ...
    }
}
impl From<SomeStruct> for u32 {
    fn from(value: SomeStruct) -> Self {
        ...
    }
}

Generates

enum AtomicSomeStruct(AtomicU32);
impl AtomicSomeStruct {
    fn load(&self, order: Ordering) -> SomeStruct;
    fn store(&self, val: SomeStruct, order: Ordering);
    ...
}

Dependencies

~1.5MB
~37K SLoC