This modules adds some utility functions to perform atomic accesses.
More...
This modules adds some utility functions to perform atomic accesses.
Usage
The atomic utilitys allow atomic access to regular variables.
uint32_t global_counter;
void irq_handler(void)
{
global_counter++;
}
void called_by_thread_a(void) {
on_threshold_reached();
}
}
void called_by_thread_b(void) {
atomic_add_u32(&global_counter, 42);
}
static uint32_t atomic_load_u32(const volatile uint32_t *var)
Load an uint32_t atomically.
static void atomic_store_u32(volatile uint32_t *dest, uint32_t val)
Store an uint32_t atomically.
Motivation
There are some reasons why these functions might be chosen over the C11 Atomic Operations Library in some advanced use cases:
- The functions allow mixing of atomic and non-atomic accesses. E.g. while IRQs are disabled anyway, even plain accesses cannot be interrupted but are often more efficient.
- On platforms not supporting lock-free access, a library call is generated instead. The fallback implementation used here is more efficient in terms of both CPU instructions and ROM size.
- On platforms where some operations can be implemented lock free while others can't, at least LLVM will use the library call even for those accesses that can be implemented lock-free. This is because without assuming how the library call implements atomic access for the other functions, mixing library calls and lock free accesses could result in data corruption. But this implementation resorts to disabling IRQs when lock-free implementations are not possible, which mixes well with lock-free accesses. Thus, additional overhead for atomic accesses is only spent where needed.
- In some cases the fallback implementation performs better than the lock free implementation. E.g. if a specific platform has an atomic compare and swap instruction, this could be used to perform a read-modify-write in a loop until the value initially read was not changed in between. Just disabling IRQs to implement an atomic read-modify-write operation is likely more efficient. C11 atomics will however always use the lock free implementation (if such exists), assuming that this is more efficient. This assumption was made with desktop class hardware in mind, but is not generally true for bare metal targets. These function allow to optimize for the actual hardware RIOT is running on.
- This library provides "semi-atomic" read-modify-write operations, which are useful when at most one thread is ever writing to memory. In that case, only the write part of the read-modify-write operation needs to be performed in an atomic fashion in order for the reading threads to perceive atomic updates of the variable. This is significantly cheaper than atomic read-modify-write operations for many platforms
Guarantees
- Every utility function here acts as a barrier for code reordering regarding
- For the
atomic_*()
family of functions: The whole operation will be done in an non-interruptible fashion
- For the
semi_atomic_*()
family of functions: The write part of the operation is done atomically. If at most one thread is ever performing changes to a variable using the semi_atomic_()
functions, those changes will appear as if they were atomic to all other threads.
Porting to new CPUs
At the bare minimum, create an empty atomic_utils_arch.h
file. This will result in the fallback implementations being used.
To expose lock-free atomic operations, add an implementation to the atomic_utils_arch.h
file and disable the fallback implementation by defining HAS_<FN_NAME_ALL_CAPS>
, where <FN_NAME_ALL_CAPS>
is the name of the function provided in all upper case. E.g. most platforms will be able to provide lock-free reads and writes up to their word size and can expose this as follows for GCC:
#define HAS_ATOMIC_LOAD_U8
{
return __atomic_load_1(var, __ATOMIC_SEQ_CST);
}
#define HAS_ATOMIC_STORE_U8
{
__atomic_store_1(dest, val, __ATOMIC_SEQ_CST);
}
static void atomic_store_u8(volatile uint8_t *dest, uint8_t val)
Store an uint8_t atomically.
static uint8_t atomic_load_u8(const volatile uint8_t *var)
Load an uint8_t atomically.
Note: The semi_atomic_*()
family of functions is always provided using atomic_*()
functions in the cheapest way possible.
|
#define | ATOMIC_LOAD_IMPL(name, type) |
| Generates a static inline function implementing atomic_load_u<width>()
|
|
#define | ATOMIC_STORE_IMPL(name, type) |
| Generates a static inline function implementing atomic_store_u<width>()
|
|
#define | ATOMIC_FETCH_OP_IMPL(opname, op, name, type) |
| Generates a static inline function implementing atomic_fecth_<op>_u<width>()
|
|
|
static uint8_t | atomic_fetch_add_u8 (volatile uint8_t *dest, uint8_t summand) |
| Atomically add a value onto a given value.
|
|
static uint16_t | atomic_fetch_add_u16 (volatile uint16_t *dest, uint16_t summand) |
| Atomically add a value onto a given value.
|
|
static uint32_t | atomic_fetch_add_u32 (volatile uint32_t *dest, uint32_t summand) |
| Atomically add a value onto a given value.
|
|
static uint64_t | atomic_fetch_add_u64 (volatile uint64_t *dest, uint64_t summand) |
| Atomically add a value onto a given value.
|
|
|
static uint8_t | atomic_fetch_sub_u8 (volatile uint8_t *dest, uint8_t subtrahend) |
| Atomically subtract a value from a given value.
|
|
static uint16_t | atomic_fetch_sub_u16 (volatile uint16_t *dest, uint16_t subtrahend) |
| Atomically subtract a value from a given value.
|
|
static uint32_t | atomic_fetch_sub_u32 (volatile uint32_t *dest, uint32_t subtrahend) |
| Atomically subtract a value from a given value.
|
|
static uint64_t | atomic_fetch_sub_u64 (volatile uint64_t *dest, uint64_t subtrahend) |
| Atomically subtract a value from a given value.
|
|
|
static uint8_t | atomic_fetch_or_u8 (volatile uint8_t *dest, uint8_t val) |
| Atomic version of *dest |= val
|
|
static uint16_t | atomic_fetch_or_u16 (volatile uint16_t *dest, uint16_t val) |
| Atomic version of *dest |= val
|
|
static uint32_t | atomic_fetch_or_u32 (volatile uint32_t *dest, uint32_t val) |
| Atomic version of *dest |= val
|
|
static uint64_t | atomic_fetch_or_u64 (volatile uint64_t *dest, uint64_t val) |
| Atomic version of *dest |= val
|
|
|
static uint8_t | atomic_fetch_xor_u8 (volatile uint8_t *dest, uint8_t val) |
| Atomic version of *dest ^= val
|
|
static uint16_t | atomic_fetch_xor_u16 (volatile uint16_t *dest, uint16_t val) |
| Atomic version of *dest ^= val
|
|
static uint32_t | atomic_fetch_xor_u32 (volatile uint32_t *dest, uint32_t val) |
| Atomic version of *dest ^= val
|
|
static uint64_t | atomic_fetch_xor_u64 (volatile uint64_t *dest, uint64_t val) |
| Atomic version of *dest ^= val
|
|
|
static uint8_t | atomic_fetch_and_u8 (volatile uint8_t *dest, uint8_t val) |
| Atomic version of *dest &= val
|
|
static uint16_t | atomic_fetch_and_u16 (volatile uint16_t *dest, uint16_t val) |
| Atomic version of *dest &= val
|
|
static uint32_t | atomic_fetch_and_u32 (volatile uint32_t *dest, uint32_t val) |
| Atomic version of *dest &= val
|
|
static uint64_t | atomic_fetch_and_u64 (volatile uint64_t *dest, uint64_t val) |
| Atomic version of *dest &= val
|
|
|
static uint8_t | semi_atomic_fetch_add_u8 (volatile uint8_t *dest, uint8_t summand) |
| Semi-atomically add a value onto a given value.
|
|
static uint16_t | semi_atomic_fetch_add_u16 (volatile uint16_t *dest, uint16_t summand) |
| Semi-atomically add a value onto a given value.
|
|
static uint32_t | semi_atomic_fetch_add_u32 (volatile uint32_t *dest, uint32_t summand) |
| Semi-atomically add a value onto a given value.
|
|
static uint64_t | semi_atomic_fetch_add_u64 (volatile uint64_t *dest, uint64_t summand) |
| Semi-atomically add a value onto a given value.
|
|
|
static uint8_t | semi_atomic_fetch_sub_u8 (volatile uint8_t *dest, uint8_t subtrahend) |
| Semi-atomically subtract a value from a given value.
|
|
static uint16_t | semi_atomic_fetch_sub_u16 (volatile uint16_t *dest, uint16_t subtrahend) |
| Semi-atomically subtract a value from a given value.
|
|
static uint32_t | semi_atomic_fetch_sub_u32 (volatile uint32_t *dest, uint32_t subtrahend) |
| Semi-atomically subtract a value from a given value.
|
|
static uint64_t | semi_atomic_fetch_sub_u64 (volatile uint64_t *dest, uint64_t subtrahend) |
| Semi-atomically subtract a value from a given value.
|
|
◆ ATOMIC_FETCH_OP_IMPL
#define ATOMIC_FETCH_OP_IMPL |
( |
|
opname, |
|
|
|
op, |
|
|
|
name, |
|
|
|
type |
|
) |
| |
Value: static inline type
CONCAT4(atomic_fetch_, opname, _, name) \
(volatile type *dest, type val) \
{ \
const type result = *dest; \
*dest = result op val; \
irq_restore(state); \
return result; \
}
#define CONCAT4(a, b, c, d)
Concatenate the tokens a , b , c , and d.
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
Generates a static inline function implementing atomic_fecth_<op>_u<width>()
- Parameters
-
opname | Name of the operator in op , e.g. "and" for + |
op | Operator to implement atomically, e.g. + |
name | Name of the variable type, e.g. "u8" |
type | Variable type, e.g. uint8_t |
Definition at line 920 of file atomic_utils.h.
◆ ATOMIC_LOAD_IMPL
#define ATOMIC_LOAD_IMPL |
( |
|
name, |
|
|
|
type |
|
) |
| |
Value: static inline type
CONCAT(atomic_load_, name)(
const volatile type *var) \
{ \
type result = *var; \
irq_restore(state); \
return result; \
}
#define CONCAT(a, b)
Concatenate the tokens a and b.
Generates a static inline function implementing atomic_load_u<width>()
- Parameters
-
name | Name of the variable type, e.g. "u8" |
type | Variable type, e.g. uint8_t |
Definition at line 860 of file atomic_utils.h.
◆ ATOMIC_STORE_IMPL
#define ATOMIC_STORE_IMPL |
( |
|
name, |
|
|
|
type |
|
) |
| |
Value: static inline void CONCAT(atomic_store_, name) \
(volatile type *dest, type val) \
{ \
*dest = val; \
irq_restore(state); \
}
Generates a static inline function implementing atomic_store_u<width>()
- Parameters
-
name | Name of the variable type, e.g. "u8" |
type | Variable type, e.g. uint8_t |
Definition at line 889 of file atomic_utils.h.
◆ atomic_bit_u16()
static atomic_bit_u16_t atomic_bit_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Create a reference to a bit in an uint16_t
- Parameters
-
[in] | dest | Memory containing the bit |
[in] | bit | Bit number (0 refers to the least significant) |
Definition at line 1003 of file atomic_utils.h.
◆ atomic_bit_u32()
static atomic_bit_u32_t atomic_bit_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Create a reference to a bit in an uint32_t
- Parameters
-
[in] | dest | Memory containing the bit |
[in] | bit | Bit number (0 refers to the least significant) |
Definition at line 1009 of file atomic_utils.h.
◆ atomic_bit_u64()
static atomic_bit_u64_t atomic_bit_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Create a reference to a bit in an uint64_t
- Parameters
-
[in] | dest | Memory containing the bit |
[in] | bit | Bit number (0 refers to the least significant) |
Definition at line 1015 of file atomic_utils.h.
◆ atomic_bit_u8()
static atomic_bit_u8_t atomic_bit_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Create a reference to a bit in an uint8_t
- Parameters
-
[in] | dest | Memory containing the bit |
[in] | bit | Bit number (0 refers to the least significant) |
Definition at line 997 of file atomic_utils.h.
◆ atomic_clear_bit_u16()
Atomic version of *dest &= ~(1 << bit)
- Parameters
-
Definition at line 1041 of file atomic_utils.h.
◆ atomic_clear_bit_u32()
Atomic version of *dest &= ~(1 << bit)
- Parameters
-
Definition at line 1045 of file atomic_utils.h.
◆ atomic_clear_bit_u64()
Atomic version of *dest &= ~(1 << bit)
- Parameters
-
Definition at line 1049 of file atomic_utils.h.
◆ atomic_clear_bit_u8()
Atomic version of *dest &= ~(1 << bit)
- Parameters
-
Definition at line 1037 of file atomic_utils.h.
◆ atomic_fetch_add_u16()
static uint16_t atomic_fetch_add_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
summand |
|
) |
| |
|
inlinestatic |
Atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_add_u32()
static uint32_t atomic_fetch_add_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
summand |
|
) |
| |
|
inlinestatic |
Atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_add_u64()
static uint64_t atomic_fetch_add_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
summand |
|
) |
| |
|
inlinestatic |
Atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_add_u8()
static uint8_t atomic_fetch_add_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
summand |
|
) |
| |
|
inlinestatic |
Atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_and_u16()
static uint16_t atomic_fetch_and_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_and_u32()
static uint32_t atomic_fetch_and_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_and_u64()
static uint64_t atomic_fetch_and_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_and_u8()
static uint8_t atomic_fetch_and_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_or_u16()
static uint16_t atomic_fetch_or_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_or_u32()
static uint32_t atomic_fetch_or_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_or_u64()
static uint64_t atomic_fetch_or_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_or_u8()
static uint8_t atomic_fetch_or_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_sub_u16()
static uint16_t atomic_fetch_sub_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_sub_u32()
static uint32_t atomic_fetch_sub_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_sub_u64()
static uint64_t atomic_fetch_sub_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_sub_u8()
static uint8_t atomic_fetch_sub_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
◆ atomic_fetch_xor_u16()
static uint16_t atomic_fetch_xor_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_xor_u32()
static uint32_t atomic_fetch_xor_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_xor_u64()
static uint64_t atomic_fetch_xor_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_fetch_xor_u8()
static uint8_t atomic_fetch_xor_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
val |
|
) |
| |
|
inlinestatic |
Atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
◆ atomic_load_kernel_pid()
Load an kernel_pid_t
atomically.
- Parameters
-
[in] | var | Variable to load atomically |
- Returns
- The value stored in
var
Definition at line 275 of file atomic_utils.h.
◆ atomic_load_ptr()
static void * atomic_load_ptr |
( |
void ** |
ptr_addr | ) |
|
|
inlinestatic |
Load an void *
atomically.
- Parameters
-
[in] | ptr_addr | Address to the pointer to load |
- Returns
- Value of the loaded pointer
Definition at line 266 of file atomic_utils.h.
◆ atomic_load_u16()
static uint16_t atomic_load_u16 |
( |
const volatile uint16_t * |
var | ) |
|
|
inlinestatic |
Load an uint16_t
atomically.
- Parameters
-
[in] | var | Variable to load atomically |
- Returns
- The value stored in
var
◆ atomic_load_u32()
static uint32_t atomic_load_u32 |
( |
const volatile uint32_t * |
var | ) |
|
|
inlinestatic |
Load an uint32_t
atomically.
- Parameters
-
[in] | var | Variable to load atomically |
- Returns
- The value stored in
var
◆ atomic_load_u64()
static uint64_t atomic_load_u64 |
( |
const volatile uint64_t * |
var | ) |
|
|
inlinestatic |
Load an uint64_t
atomically.
- Parameters
-
[in] | var | Variable to load atomically |
- Returns
- The value stored in
var
◆ atomic_load_u8()
static uint8_t atomic_load_u8 |
( |
const volatile uint8_t * |
var | ) |
|
|
inlinestatic |
Load an uint8_t
atomically.
- Parameters
-
[in] | var | Variable to load atomically |
- Returns
- The value stored in
var
◆ atomic_load_uintptr()
static uintptr_t atomic_load_uintptr |
( |
const volatile uintptr_t * |
var | ) |
|
|
inlinestatic |
Load an uintptr_t
atomically.
- Parameters
-
[in] | var | Variable to load atomically |
- Returns
- The value stored in
var
Definition at line 249 of file atomic_utils.h.
◆ atomic_set_bit_u16()
Atomic version of *dest |= (1 << bit)
- Parameters
-
Definition at line 1025 of file atomic_utils.h.
◆ atomic_set_bit_u32()
Atomic version of *dest |= (1 << bit)
- Parameters
-
Definition at line 1029 of file atomic_utils.h.
◆ atomic_set_bit_u64()
Atomic version of *dest |= (1 << bit)
- Parameters
-
Definition at line 1033 of file atomic_utils.h.
◆ atomic_set_bit_u8()
Atomic version of *dest |= (1 << bit)
- Parameters
-
Definition at line 1021 of file atomic_utils.h.
◆ atomic_store_kernel_pid()
Store an kernel_pid_t
atomically.
- Parameters
-
[out] | dest | Location to atomically write the new value to |
[in] | val | Value to write |
Definition at line 343 of file atomic_utils.h.
◆ atomic_store_ptr()
static void atomic_store_ptr |
( |
void ** |
dest, |
|
|
const void * |
val |
|
) |
| |
|
inlinestatic |
Store an void *
atomically.
- Parameters
-
[out] | dest | Location to atomically write the new value to |
[in] | val | Value to write |
Definition at line 334 of file atomic_utils.h.
◆ atomic_store_u16()
static void atomic_store_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
val |
|
) |
| |
|
inlinestatic |
Store an uint16_t
atomically.
- Parameters
-
[out] | dest | Location to atomically write the new value to |
[in] | val | Value to write |
◆ atomic_store_u32()
static void atomic_store_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
val |
|
) |
| |
|
inlinestatic |
Store an uint32_t
atomically.
- Parameters
-
[out] | dest | Location to atomically write the new value to |
[in] | val | Value to write |
◆ atomic_store_u64()
static void atomic_store_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
val |
|
) |
| |
|
inlinestatic |
Store an uint64_t
atomically.
- Parameters
-
[out] | dest | Location to atomically write the new value to |
[in] | val | Value to write |
◆ atomic_store_u8()
static void atomic_store_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
val |
|
) |
| |
|
inlinestatic |
Store an uint8_t
atomically.
- Parameters
-
[out] | dest | Location to atomically write the new value to |
[in] | val | Value to write |
◆ atomic_store_uintptr()
static void atomic_store_uintptr |
( |
volatile uintptr_t * |
dest, |
|
|
uintptr_t |
val |
|
) |
| |
|
inlinestatic |
Store an uintptr_t
atomically.
- Parameters
-
[out] | dest | Location to atomically write the new value to |
[in] | val | Value to write |
Definition at line 316 of file atomic_utils.h.
◆ semi_atomic_fetch_add_u16()
static uint16_t semi_atomic_fetch_add_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
summand |
|
) |
| |
|
inlinestatic |
Semi-atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value semi-atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
Definition at line 1085 of file atomic_utils.h.
◆ semi_atomic_fetch_add_u32()
static uint32_t semi_atomic_fetch_add_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
summand |
|
) |
| |
|
inlinestatic |
Semi-atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value semi-atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
Definition at line 1101 of file atomic_utils.h.
◆ semi_atomic_fetch_add_u64()
static uint64_t semi_atomic_fetch_add_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
summand |
|
) |
| |
|
inlinestatic |
Semi-atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value semi-atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
Definition at line 1117 of file atomic_utils.h.
◆ semi_atomic_fetch_add_u8()
static uint8_t semi_atomic_fetch_add_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
summand |
|
) |
| |
|
inlinestatic |
Semi-atomically add a value onto a given value.
- Parameters
-
[in,out] | dest | Add summand onto this value semi-atomically in-place |
[in] | summand | Value to add onto dest |
- Returns
- The value previously stored
dest
Definition at line 1069 of file atomic_utils.h.
◆ semi_atomic_fetch_and_u16()
static uint16_t semi_atomic_fetch_and_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1343 of file atomic_utils.h.
◆ semi_atomic_fetch_and_u32()
static uint32_t semi_atomic_fetch_and_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1359 of file atomic_utils.h.
◆ semi_atomic_fetch_and_u64()
static uint64_t semi_atomic_fetch_and_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1375 of file atomic_utils.h.
◆ semi_atomic_fetch_and_u8()
static uint8_t semi_atomic_fetch_and_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest &= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest & val |
[in] | val | Value to bitwise and into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1327 of file atomic_utils.h.
◆ semi_atomic_fetch_or_u16()
static uint16_t semi_atomic_fetch_or_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1213 of file atomic_utils.h.
◆ semi_atomic_fetch_or_u32()
static uint32_t semi_atomic_fetch_or_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1229 of file atomic_utils.h.
◆ semi_atomic_fetch_or_u64()
static uint64_t semi_atomic_fetch_or_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1245 of file atomic_utils.h.
◆ semi_atomic_fetch_or_u8()
static uint8_t semi_atomic_fetch_or_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest |= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest | val |
[in] | val | Value to bitwise or into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1197 of file atomic_utils.h.
◆ semi_atomic_fetch_sub_u16()
static uint16_t semi_atomic_fetch_sub_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Semi-atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value semi-atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
Definition at line 1148 of file atomic_utils.h.
◆ semi_atomic_fetch_sub_u32()
static uint32_t semi_atomic_fetch_sub_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Semi-atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value semi-atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
Definition at line 1164 of file atomic_utils.h.
◆ semi_atomic_fetch_sub_u64()
static uint64_t semi_atomic_fetch_sub_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Semi-atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value semi-atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
Definition at line 1180 of file atomic_utils.h.
◆ semi_atomic_fetch_sub_u8()
static uint8_t semi_atomic_fetch_sub_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
subtrahend |
|
) |
| |
|
inlinestatic |
Semi-atomically subtract a value from a given value.
- Parameters
-
[in,out] | dest | Subtract subtrahend from this value semi-atomically in-place |
[in] | subtrahend | Value to subtract from dest |
- Returns
- The value previously stored
dest
Definition at line 1132 of file atomic_utils.h.
◆ semi_atomic_fetch_xor_u16()
static uint16_t semi_atomic_fetch_xor_u16 |
( |
volatile uint16_t * |
dest, |
|
|
uint16_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1278 of file atomic_utils.h.
◆ semi_atomic_fetch_xor_u32()
static uint32_t semi_atomic_fetch_xor_u32 |
( |
volatile uint32_t * |
dest, |
|
|
uint32_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1294 of file atomic_utils.h.
◆ semi_atomic_fetch_xor_u64()
static uint64_t semi_atomic_fetch_xor_u64 |
( |
volatile uint64_t * |
dest, |
|
|
uint64_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1310 of file atomic_utils.h.
◆ semi_atomic_fetch_xor_u8()
static uint8_t semi_atomic_fetch_xor_u8 |
( |
volatile uint8_t * |
dest, |
|
|
uint8_t |
val |
|
) |
| |
|
inlinestatic |
Semi-atomic version of *dest ^= val
- Parameters
-
[in,out] | dest | Replace this value with the result of *dest ^ val |
[in] | val | Value to bitwise xor into dest in-place |
- Returns
- The value previously stored
dest
Definition at line 1262 of file atomic_utils.h.