72 static_assert(__atomic_always_lock_free(
sizeof(T), 0),
"atomic is not lock-free for the given type T");
76 explicit atomic(T value) : _value(value) {}
83 return __atomic_load_n(&_value, __ATOMIC_SEQ_CST);
89 inline void store(T value)
91 __atomic_store(&_value, &value, __ATOMIC_SEQ_CST);
98 inline T fetch_add(T num)
100 return __atomic_fetch_add(&_value, num, __ATOMIC_SEQ_CST);
107 inline T fetch_sub(T num)
109 return __atomic_fetch_sub(&_value, num, __ATOMIC_SEQ_CST);
116 inline T fetch_and(T num)
118 return __atomic_fetch_and(&_value, num, __ATOMIC_SEQ_CST);
125 inline T fetch_xor(T num)
127 return __atomic_fetch_xor(&_value, num, __ATOMIC_SEQ_CST);
134 inline T fetch_or(T num)
136 return __atomic_fetch_or(&_value, num, __ATOMIC_SEQ_CST);
143 inline T fetch_nand(T num)
145 return __atomic_fetch_nand(&_value, num, __ATOMIC_SEQ_CST);
156 inline bool compare_exchange(T *expected, T num)
158 return __atomic_compare_exchange(&_value, expected, num,
false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
165 using atomic_int = atomic<int>;
166 using atomic_int32_t = atomic<int32_t>;
167 using atomic_bool = atomic<bool>;
Definition: px4_nuttx_impl.cpp:44