Utility functions for atomic access

Detailed Description

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)
{
// No need to use atomic access in IRQ handlers, if other IRQ handlers
// never touch global_counter: At the beginning and at the end of every
// ISR a memory barrier is in place, so that at the end of the ISR the
// memory will be in a state as if all memory accesses within the ISR
// took place in sequential order.
//
// Extra detail only RIOT kernel hackers need to know: If all ISRs
// accessing the same variable cannot interrupt each other, atomic
// access is still not needed. (Currently only PendSV on ARM can be
// interrupted by other IRQs with RIOTs default IRQ priorities. If
// application developers modifies those, they can be assumed to know
// what they are doing - or to happily face the consequences otherwise.)
global_counter++;
}
void called_by_thread_a(void) {
if (atomic_load_u32(&global_counter) > THRESHOLD) {
on_threshold_reached();
atomic_store_u32(&global_counter, 0);
}
}
void called_by_thread_b(void) {
atomic_add_u32(&global_counter, 42);
}

Motivation

There are some reasons why these functions might be chosen over the C11 Atomic Operations Library in some advanced use cases:

Guarantees

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:

// All the user header boilerplate
#define HAS_ATOMIC_LOAD_U8
static inline uint8_t atomic_load_u8(const uint8_t *var)
{
return __atomic_load_1(var, __ATOMIC_SEQ_CST);
}
#define HAS_ATOMIC_STORE_U8
static inline void atomic_store_u8(uint8_t *dest, uint8_t val)
{
__atomic_store_1(dest, val, __ATOMIC_SEQ_CST);
}

Note: The semi_atomic_*() family of functions is always provided using atomic_*() functions in the cheapest way possible.

Files

file  atomic_utils.h
 API of the utility functions for atomic accesses.
 

Data Structures

struct  atomic_bit_u8_t
 Type specifying a bit in an uint8_t More...
 
struct  atomic_bit_u16_t
 Type specifying a bit in an uint16_t More...
 
struct  atomic_bit_u32_t
 Type specifying a bit in an uint32_t More...
 
struct  atomic_bit_u64_t
 Type specifying a bit in an uint64_t More...
 

Macros

#define CONCAT(a, b)   a ## b
 Concatenate two tokens.
 
#define CONCAT4(a, b, c, d)   a ## b ## c ## d
 Concatenate four tokens.
 
#define ATOMIC_LOAD_IMPL(name, type)
 Generates a static inline function implementing atomic_load_u<width>() More...
 
#define ATOMIC_STORE_IMPL(name, type)
 Generates a static inline function implementing atomic_store_u<width>() More...
 
#define ATOMIC_FETCH_OP_IMPL(opname, op, name, type)
 Generates a static inline function implementing atomic_fecth_<op>_u<width>() More...
 

Atomic Loads

static uint8_t atomic_load_u8 (const uint8_t *var)
 Load an uint8_t atomically. More...
 
static uint16_t atomic_load_u16 (const uint16_t *var)
 Load an uint16_t atomically. More...
 
static uint32_t atomic_load_u32 (const uint32_t *var)
 Load an uint32_t atomically. More...
 
static uint64_t atomic_load_u64 (const uint64_t *var)
 Load an uint64_t atomically. More...
 

Atomic Stores

static void atomic_store_u8 (uint8_t *dest, uint8_t val)
 Store an uint8_t atomically. More...
 
static void atomic_store_u16 (uint16_t *dest, uint16_t val)
 Store an uint16_t atomically. More...
 
static void atomic_store_u32 (uint32_t *dest, uint32_t val)
 Store an uint32_t atomically. More...
 
static void atomic_store_u64 (uint64_t *dest, uint64_t val)
 Store an uint64_t atomically. More...
 

Atomic In-Place Addition

static void atomic_fetch_add_u8 (uint8_t *dest, uint8_t summand)
 Atomically add a value onto a given value. More...
 
static void atomic_fetch_add_u16 (uint16_t *dest, uint16_t summand)
 Atomically add a value onto a given value. More...
 
static void atomic_fetch_add_u32 (uint32_t *dest, uint32_t summand)
 Atomically add a value onto a given value. More...
 
static void atomic_fetch_add_u64 (uint64_t *dest, uint64_t summand)
 Atomically add a value onto a given value. More...
 

Atomic In-Place Subtraction

static void atomic_fetch_sub_u8 (uint8_t *dest, uint8_t subtrahend)
 Atomically subtract a value from a given value. More...
 
static void atomic_fetch_sub_u16 (uint16_t *dest, uint16_t subtrahend)
 Atomically subtract a value from a given value. More...
 
static void atomic_fetch_sub_u32 (uint32_t *dest, uint32_t subtrahend)
 Atomically subtract a value from a given value. More...
 
static void atomic_fetch_sub_u64 (uint64_t *dest, uint64_t subtrahend)
 Atomically subtract a value from a given value. More...
 

Atomic In-Place Bitwise OR

static void atomic_fetch_or_u8 (uint8_t *dest, uint8_t val)
 Atomic version of *dest |= val More...
 
static void atomic_fetch_or_u16 (uint16_t *dest, uint16_t val)
 Atomic version of *dest |= val More...
 
static void atomic_fetch_or_u32 (uint32_t *dest, uint32_t val)
 Atomic version of *dest |= val More...
 
static void atomic_fetch_or_u64 (uint64_t *dest, uint64_t val)
 Atomic version of *dest |= val More...
 

Atomic In-Place Bitwise XOR

static void atomic_fetch_xor_u8 (uint8_t *dest, uint8_t val)
 Atomic version of *dest ^= val More...
 
static void atomic_fetch_xor_u16 (uint16_t *dest, uint16_t val)
 Atomic version of *dest ^= val More...
 
static void atomic_fetch_xor_u32 (uint32_t *dest, uint32_t val)
 Atomic version of *dest ^= val More...
 
static void atomic_fetch_xor_u64 (uint64_t *dest, uint64_t val)
 Atomic version of *dest ^= val More...
 

Atomic In-Place Bitwise AND

static void atomic_fetch_and_u8 (uint8_t *dest, uint8_t val)
 Atomic version of *dest &= val More...
 
static void atomic_fetch_and_u16 (uint16_t *dest, uint16_t val)
 Atomic version of *dest &= val More...
 
static void atomic_fetch_and_u32 (uint32_t *dest, uint32_t val)
 Atomic version of *dest &= val More...
 
static void atomic_fetch_and_u64 (uint64_t *dest, uint64_t val)
 Atomic version of *dest &= val More...
 

Helper Functions to Handle Atomic Bit References

static atomic_bit_u8_t atomic_bit_u8 (uint8_t *dest, uint8_t bit)
 Create a reference to a bit in an uint8_t More...
 
static atomic_bit_u16_t atomic_bit_u16 (uint16_t *dest, uint8_t bit)
 Create a reference to a bit in an uint16_t More...
 
static atomic_bit_u32_t atomic_bit_u32 (uint32_t *dest, uint8_t bit)
 Create a reference to a bit in an uint32_t More...
 
static atomic_bit_u64_t atomic_bit_u64 (uint64_t *dest, uint8_t bit)
 Create a reference to a bit in an uint64_t More...
 

Atomic Bit Setting

static void atomic_set_bit_u8 (atomic_bit_u8_t bit)
 Atomic version of *dest |= (1 << bit) More...
 
static void atomic_set_bit_u16 (atomic_bit_u16_t bit)
 Atomic version of *dest |= (1 << bit) More...
 
static void atomic_set_bit_u32 (atomic_bit_u32_t bit)
 Atomic version of *dest |= (1 << bit) More...
 
static void atomic_set_bit_u64 (atomic_bit_u64_t bit)
 Atomic version of *dest |= (1 << bit) More...
 

Atomic Bit Clearing

static void atomic_clear_bit_u8 (atomic_bit_u8_t bit)
 Atomic version of *dest &= ~(1 << bit) More...
 
static void atomic_clear_bit_u16 (atomic_bit_u16_t bit)
 Atomic version of *dest &= ~(1 << bit) More...
 
static void atomic_clear_bit_u32 (atomic_bit_u32_t bit)
 Atomic version of *dest &= ~(1 << bit) More...
 
static void atomic_clear_bit_u64 (atomic_bit_u64_t bit)
 Atomic version of *dest &= ~(1 << bit) More...
 

Semi-Atomic In-Place Addition

static void semi_atomic_fetch_add_u8 (uint8_t *dest, uint8_t summand)
 Semi-atomically add a value onto a given value. More...
 
static void semi_atomic_fetch_add_u16 (uint16_t *dest, uint16_t summand)
 Semi-atomically add a value onto a given value. More...
 
static void semi_atomic_fetch_add_u32 (uint32_t *dest, uint32_t summand)
 Semi-atomically add a value onto a given value. More...
 
static void semi_atomic_fetch_add_u64 (uint64_t *dest, uint64_t summand)
 Semi-atomically add a value onto a given value. More...
 

Semi-Atomic In-Place Subtraction

static void semi_atomic_fetch_sub_u8 (uint8_t *dest, uint8_t subtrahend)
 Semi-atomically subtract a value from a given value. More...
 
static void semi_atomic_fetch_sub_u16 (uint16_t *dest, uint16_t subtrahend)
 Semi-atomically subtract a value from a given value. More...
 
static void semi_atomic_fetch_sub_u32 (uint32_t *dest, uint32_t subtrahend)
 Semi-atomically subtract a value from a given value. More...
 
static void semi_atomic_fetch_sub_u64 (uint64_t *dest, uint64_t subtrahend)
 Semi-atomically subtract a value from a given value. More...
 

Semi-atomic In-Place Bitwise OR

static void semi_atomic_fetch_or_u8 (uint8_t *dest, uint8_t val)
 Semi-atomic version of *dest |= val More...
 
static void semi_atomic_fetch_or_u16 (uint16_t *dest, uint16_t val)
 Semi-atomic version of *dest |= val More...
 
static void semi_atomic_fetch_or_u32 (uint32_t *dest, uint32_t val)
 Semi-atomic version of *dest |= val More...
 
static void semi_atomic_fetch_or_u64 (uint64_t *dest, uint64_t val)
 Semi-atomic version of *dest |= val More...
 

Semi-Atomic In-Place Bitwise XOR

static void semi_atomic_fetch_xor_u8 (uint8_t *dest, uint8_t val)
 Semi-atomic version of *dest ^= val More...
 
static void semi_atomic_fetch_xor_u16 (uint16_t *dest, uint16_t val)
 Semi-atomic version of *dest ^= val More...
 
static void semi_atomic_fetch_xor_u32 (uint32_t *dest, uint32_t val)
 Semi-atomic version of *dest ^= val More...
 
static void semi_atomic_fetch_xor_u64 (uint64_t *dest, uint64_t val)
 Semi-atomic version of *dest ^= val More...
 

Semi-Atomic In-Place Bitwise AND

static void semi_atomic_fetch_and_u8 (uint8_t *dest, uint8_t val)
 Semi-atomic version of *dest &= val More...
 
static void semi_atomic_fetch_and_u16 (uint16_t *dest, uint16_t val)
 Semi-atomic version of *dest &= val More...
 
static void semi_atomic_fetch_and_u32 (uint32_t *dest, uint32_t val)
 Semi-atomic version of *dest &= val More...
 
static void semi_atomic_fetch_and_u64 (uint64_t *dest, uint64_t val)
 Semi-atomic version of *dest &= val More...
 

Macro Definition Documentation

◆ ATOMIC_FETCH_OP_IMPL

#define ATOMIC_FETCH_OP_IMPL (   opname,
  op,
  name,
  type 
)
Value:
static inline void CONCAT4(atomic_fetch_, opname, _, name)(type *dest, \
type val) \
{ \
unsigned state = irq_disable(); \
/* dest can be register allocated, hence the memory barrier of \
* irq_disable() and irq_restore() may not apply here. Using volatile \
* ensures that the compiler allocates it in memory and that the \
* memory access is not optimized out. */ \
volatile type *tmp = dest; \
*tmp = *tmp op val; \
irq_restore(state); \
}

Generates a static inline function implementing atomic_fecth_<op>_u<width>()

Parameters
opnameName of the operator in op, e.g. "and" for +
opOperator to implement atomically, e.g. +
nameName of the variable type, e.g. "u8"
typeVariable type, e.g. uint8_t

Definition at line 775 of file atomic_utils.h.

◆ ATOMIC_LOAD_IMPL

#define ATOMIC_LOAD_IMPL (   name,
  type 
)
Value:
static inline type CONCAT(atomic_load_, name)(const type *var) \
{ \
unsigned state = irq_disable(); \
/* var can be register allocated, hence the memory barrier of \
* irq_disable() and irq_restore() may not apply here. Using volatile \
* ensures that the compiler allocates it in memory and that the \
* memory access is not optimized out. */ \
type result = *((const volatile type *)var); \
irq_restore(state); \
return result; \
}

Generates a static inline function implementing atomic_load_u<width>()

Parameters
nameName of the variable type, e.g. "u8"
typeVariable type, e.g. uint8_t

Definition at line 714 of file atomic_utils.h.

◆ ATOMIC_STORE_IMPL

#define ATOMIC_STORE_IMPL (   name,
  type 
)
Value:
static inline void CONCAT(atomic_store_, name)(type *dest, type val) \
{ \
unsigned state = irq_disable(); \
/* dest can be register allocated, hence the memory barrier of \
* irq_disable() and irq_restore() may not apply here. Using volatile \
* ensures that the compiler allocates it in memory and that the \
* memory access is not optimized out. */ \
*((volatile type *)dest) = val; \
irq_restore(state); \
}

Generates a static inline function implementing atomic_store_u<width>()

Parameters
nameName of the variable type, e.g. "u8"
typeVariable type, e.g. uint8_t

Definition at line 744 of file atomic_utils.h.

Function Documentation

◆ atomic_bit_u16()

static atomic_bit_u16_t atomic_bit_u16 ( uint16_t *  dest,
uint8_t  bit 
)
inlinestatic

Create a reference to a bit in an uint16_t

Parameters
[in]destMemory containing the bit
[in]bitBit number (0 refers to the least significant)

Definition at line 857 of file atomic_utils.h.

◆ atomic_bit_u32()

static atomic_bit_u32_t atomic_bit_u32 ( uint32_t *  dest,
uint8_t  bit 
)
inlinestatic

Create a reference to a bit in an uint32_t

Parameters
[in]destMemory containing the bit
[in]bitBit number (0 refers to the least significant)

Definition at line 862 of file atomic_utils.h.

◆ atomic_bit_u64()

static atomic_bit_u64_t atomic_bit_u64 ( uint64_t *  dest,
uint8_t  bit 
)
inlinestatic

Create a reference to a bit in an uint64_t

Parameters
[in]destMemory containing the bit
[in]bitBit number (0 refers to the least significant)

Definition at line 867 of file atomic_utils.h.

◆ atomic_bit_u8()

static atomic_bit_u8_t atomic_bit_u8 ( uint8_t *  dest,
uint8_t  bit 
)
inlinestatic

Create a reference to a bit in an uint8_t

Parameters
[in]destMemory containing the bit
[in]bitBit number (0 refers to the least significant)

Definition at line 852 of file atomic_utils.h.

◆ atomic_clear_bit_u16()

static void atomic_clear_bit_u16 ( atomic_bit_u16_t  bit)
inlinestatic

Atomic version of *dest &= ~(1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 892 of file atomic_utils.h.

◆ atomic_clear_bit_u32()

static void atomic_clear_bit_u32 ( atomic_bit_u32_t  bit)
inlinestatic

Atomic version of *dest &= ~(1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 896 of file atomic_utils.h.

◆ atomic_clear_bit_u64()

static void atomic_clear_bit_u64 ( atomic_bit_u64_t  bit)
inlinestatic

Atomic version of *dest &= ~(1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 900 of file atomic_utils.h.

◆ atomic_clear_bit_u8()

static void atomic_clear_bit_u8 ( atomic_bit_u8_t  bit)
inlinestatic

Atomic version of *dest &= ~(1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 888 of file atomic_utils.h.

◆ atomic_fetch_add_u16()

static void atomic_fetch_add_u16 ( uint16_t *  dest,
uint16_t  summand 
)
inlinestatic

Atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value atomically in-place
[in]summandValue to add onto dest

◆ atomic_fetch_add_u32()

static void atomic_fetch_add_u32 ( uint32_t *  dest,
uint32_t  summand 
)
inlinestatic

Atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value atomically in-place
[in]summandValue to add onto dest

◆ atomic_fetch_add_u64()

static void atomic_fetch_add_u64 ( uint64_t *  dest,
uint64_t  summand 
)
inlinestatic

Atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value atomically in-place
[in]summandValue to add onto dest

◆ atomic_fetch_add_u8()

static void atomic_fetch_add_u8 ( uint8_t *  dest,
uint8_t  summand 
)
inlinestatic

Atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value atomically in-place
[in]summandValue to add onto dest

◆ atomic_fetch_and_u16()

static void atomic_fetch_and_u16 ( uint16_t *  dest,
uint16_t  val 
)
inlinestatic

Atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

◆ atomic_fetch_and_u32()

static void atomic_fetch_and_u32 ( uint32_t *  dest,
uint32_t  val 
)
inlinestatic

Atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

◆ atomic_fetch_and_u64()

static void atomic_fetch_and_u64 ( uint64_t *  dest,
uint64_t  val 
)
inlinestatic

Atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

◆ atomic_fetch_and_u8()

static void atomic_fetch_and_u8 ( uint8_t *  dest,
uint8_t  val 
)
inlinestatic

Atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

◆ atomic_fetch_or_u16()

static void atomic_fetch_or_u16 ( uint16_t *  dest,
uint16_t  val 
)
inlinestatic

Atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

◆ atomic_fetch_or_u32()

static void atomic_fetch_or_u32 ( uint32_t *  dest,
uint32_t  val 
)
inlinestatic

Atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

◆ atomic_fetch_or_u64()

static void atomic_fetch_or_u64 ( uint64_t *  dest,
uint64_t  val 
)
inlinestatic

Atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

◆ atomic_fetch_or_u8()

static void atomic_fetch_or_u8 ( uint8_t *  dest,
uint8_t  val 
)
inlinestatic

Atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

◆ atomic_fetch_sub_u16()

static void atomic_fetch_sub_u16 ( uint16_t *  dest,
uint16_t  subtrahend 
)
inlinestatic

Atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value atomically in-place
[in]subtrahendValue to subtract from dest

◆ atomic_fetch_sub_u32()

static void atomic_fetch_sub_u32 ( uint32_t *  dest,
uint32_t  subtrahend 
)
inlinestatic

Atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value atomically in-place
[in]subtrahendValue to subtract from dest

◆ atomic_fetch_sub_u64()

static void atomic_fetch_sub_u64 ( uint64_t *  dest,
uint64_t  subtrahend 
)
inlinestatic

Atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value atomically in-place
[in]subtrahendValue to subtract from dest

◆ atomic_fetch_sub_u8()

static void atomic_fetch_sub_u8 ( uint8_t *  dest,
uint8_t  subtrahend 
)
inlinestatic

Atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value atomically in-place
[in]subtrahendValue to subtract from dest

◆ atomic_fetch_xor_u16()

static void atomic_fetch_xor_u16 ( uint16_t *  dest,
uint16_t  val 
)
inlinestatic

Atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

◆ atomic_fetch_xor_u32()

static void atomic_fetch_xor_u32 ( uint32_t *  dest,
uint32_t  val 
)
inlinestatic

Atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

◆ atomic_fetch_xor_u64()

static void atomic_fetch_xor_u64 ( uint64_t *  dest,
uint64_t  val 
)
inlinestatic

Atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

◆ atomic_fetch_xor_u8()

static void atomic_fetch_xor_u8 ( uint8_t *  dest,
uint8_t  val 
)
inlinestatic

Atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

◆ atomic_load_u16()

static uint16_t atomic_load_u16 ( const uint16_t *  var)
inlinestatic

Load an uint16_t atomically.

Parameters
[in]varVariable to load atomically
Returns
The value stored in var

◆ atomic_load_u32()

static uint32_t atomic_load_u32 ( const uint32_t *  var)
inlinestatic

Load an uint32_t atomically.

Parameters
[in]varVariable to load atomically
Returns
The value stored in var

◆ atomic_load_u64()

static uint64_t atomic_load_u64 ( const uint64_t *  var)
inlinestatic

Load an uint64_t atomically.

Parameters
[in]varVariable to load atomically
Returns
The value stored in var

◆ atomic_load_u8()

static uint8_t atomic_load_u8 ( const uint8_t *  var)
inlinestatic

Load an uint8_t atomically.

Parameters
[in]varVariable to load atomically
Returns
The value stored in var

◆ atomic_set_bit_u16()

static void atomic_set_bit_u16 ( atomic_bit_u16_t  bit)
inlinestatic

Atomic version of *dest |= (1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 876 of file atomic_utils.h.

◆ atomic_set_bit_u32()

static void atomic_set_bit_u32 ( atomic_bit_u32_t  bit)
inlinestatic

Atomic version of *dest |= (1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 880 of file atomic_utils.h.

◆ atomic_set_bit_u64()

static void atomic_set_bit_u64 ( atomic_bit_u64_t  bit)
inlinestatic

Atomic version of *dest |= (1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 884 of file atomic_utils.h.

◆ atomic_set_bit_u8()

static void atomic_set_bit_u8 ( atomic_bit_u8_t  bit)
inlinestatic

Atomic version of *dest |= (1 << bit)

Parameters
[in,out]bitbit to set

Definition at line 872 of file atomic_utils.h.

◆ atomic_store_u16()

static void atomic_store_u16 ( uint16_t *  dest,
uint16_t  val 
)
inlinestatic

Store an uint16_t atomically.

Parameters
[out]destLocation to atomically write the new value to
[in]valValue to write

◆ atomic_store_u32()

static void atomic_store_u32 ( uint32_t *  dest,
uint32_t  val 
)
inlinestatic

Store an uint32_t atomically.

Parameters
[out]destLocation to atomically write the new value to
[in]valValue to write

◆ atomic_store_u64()

static void atomic_store_u64 ( uint64_t *  dest,
uint64_t  val 
)
inlinestatic

Store an uint64_t atomically.

Parameters
[out]destLocation to atomically write the new value to
[in]valValue to write

◆ atomic_store_u8()

static void atomic_store_u8 ( uint8_t *  dest,
uint8_t  val 
)
inlinestatic

Store an uint8_t atomically.

Parameters
[out]destLocation to atomically write the new value to
[in]valValue to write

◆ semi_atomic_fetch_add_u16()

static void semi_atomic_fetch_add_u16 ( uint16_t *  dest,
uint16_t  summand 
)
inlinestatic

Semi-atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value semi-atomically in-place
[in]summandValue to add onto dest

Definition at line 930 of file atomic_utils.h.

◆ semi_atomic_fetch_add_u32()

static void semi_atomic_fetch_add_u32 ( uint32_t *  dest,
uint32_t  summand 
)
inlinestatic

Semi-atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value semi-atomically in-place
[in]summandValue to add onto dest

Definition at line 940 of file atomic_utils.h.

◆ semi_atomic_fetch_add_u64()

static void semi_atomic_fetch_add_u64 ( uint64_t *  dest,
uint64_t  summand 
)
inlinestatic

Semi-atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value semi-atomically in-place
[in]summandValue to add onto dest

Definition at line 950 of file atomic_utils.h.

◆ semi_atomic_fetch_add_u8()

static void semi_atomic_fetch_add_u8 ( uint8_t *  dest,
uint8_t  summand 
)
inlinestatic

Semi-atomically add a value onto a given value.

Parameters
[in,out]destAdd summand onto this value semi-atomically in-place
[in]summandValue to add onto dest

Definition at line 920 of file atomic_utils.h.

◆ semi_atomic_fetch_and_u16()

static void semi_atomic_fetch_and_u16 ( uint16_t *  dest,
uint16_t  val 
)
inlinestatic

Semi-atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

Definition at line 1094 of file atomic_utils.h.

◆ semi_atomic_fetch_and_u32()

static void semi_atomic_fetch_and_u32 ( uint32_t *  dest,
uint32_t  val 
)
inlinestatic

Semi-atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

Definition at line 1104 of file atomic_utils.h.

◆ semi_atomic_fetch_and_u64()

static void semi_atomic_fetch_and_u64 ( uint64_t *  dest,
uint64_t  val 
)
inlinestatic

Semi-atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

Definition at line 1114 of file atomic_utils.h.

◆ semi_atomic_fetch_and_u8()

static void semi_atomic_fetch_and_u8 ( uint8_t *  dest,
uint8_t  val 
)
inlinestatic

Semi-atomic version of *dest &= val

Parameters
[in,out]destReplace this value with the result of *dest & val
[in]valValue to bitwise and into dest in-place

Definition at line 1084 of file atomic_utils.h.

◆ semi_atomic_fetch_or_u16()

static void semi_atomic_fetch_or_u16 ( uint16_t *  dest,
uint16_t  val 
)
inlinestatic

Semi-atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

Definition at line 1012 of file atomic_utils.h.

◆ semi_atomic_fetch_or_u32()

static void semi_atomic_fetch_or_u32 ( uint32_t *  dest,
uint32_t  val 
)
inlinestatic

Semi-atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

Definition at line 1022 of file atomic_utils.h.

◆ semi_atomic_fetch_or_u64()

static void semi_atomic_fetch_or_u64 ( uint64_t *  dest,
uint64_t  val 
)
inlinestatic

Semi-atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

Definition at line 1032 of file atomic_utils.h.

◆ semi_atomic_fetch_or_u8()

static void semi_atomic_fetch_or_u8 ( uint8_t *  dest,
uint8_t  val 
)
inlinestatic

Semi-atomic version of *dest |= val

Parameters
[in,out]destReplace this value with the result of *dest | val
[in]valValue to bitwise or into dest in-place

Definition at line 1002 of file atomic_utils.h.

◆ semi_atomic_fetch_sub_u16()

static void semi_atomic_fetch_sub_u16 ( uint16_t *  dest,
uint16_t  subtrahend 
)
inlinestatic

Semi-atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value semi-atomically in-place
[in]subtrahendValue to subtract from dest

Definition at line 971 of file atomic_utils.h.

◆ semi_atomic_fetch_sub_u32()

static void semi_atomic_fetch_sub_u32 ( uint32_t *  dest,
uint32_t  subtrahend 
)
inlinestatic

Semi-atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value semi-atomically in-place
[in]subtrahendValue to subtract from dest

Definition at line 981 of file atomic_utils.h.

◆ semi_atomic_fetch_sub_u64()

static void semi_atomic_fetch_sub_u64 ( uint64_t *  dest,
uint64_t  subtrahend 
)
inlinestatic

Semi-atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value semi-atomically in-place
[in]subtrahendValue to subtract from dest

Definition at line 991 of file atomic_utils.h.

◆ semi_atomic_fetch_sub_u8()

static void semi_atomic_fetch_sub_u8 ( uint8_t *  dest,
uint8_t  subtrahend 
)
inlinestatic

Semi-atomically subtract a value from a given value.

Parameters
[in,out]destSubtract subtrahend from this value semi-atomically in-place
[in]subtrahendValue to subtract from dest

Definition at line 961 of file atomic_utils.h.

◆ semi_atomic_fetch_xor_u16()

static void semi_atomic_fetch_xor_u16 ( uint16_t *  dest,
uint16_t  val 
)
inlinestatic

Semi-atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

Definition at line 1053 of file atomic_utils.h.

◆ semi_atomic_fetch_xor_u32()

static void semi_atomic_fetch_xor_u32 ( uint32_t *  dest,
uint32_t  val 
)
inlinestatic

Semi-atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

Definition at line 1063 of file atomic_utils.h.

◆ semi_atomic_fetch_xor_u64()

static void semi_atomic_fetch_xor_u64 ( uint64_t *  dest,
uint64_t  val 
)
inlinestatic

Semi-atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

Definition at line 1073 of file atomic_utils.h.

◆ semi_atomic_fetch_xor_u8()

static void semi_atomic_fetch_xor_u8 ( uint8_t *  dest,
uint8_t  val 
)
inlinestatic

Semi-atomic version of *dest ^= val

Parameters
[in,out]destReplace this value with the result of *dest ^ val
[in]valValue to bitwise xor into dest in-place

Definition at line 1043 of file atomic_utils.h.

atomic_store_u32
static void atomic_store_u32(uint32_t *dest, uint32_t val)
Store an uint32_t atomically.
irq_disable
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
lua_riot_builtin_c::name
const char * name
Definition: lua_builtin.h:61
atomic_store_u8
static void atomic_store_u8(uint8_t *dest, uint8_t val)
Store an uint8_t atomically.
atomic_load_u32
static uint32_t atomic_load_u32(const uint32_t *var)
Load an uint32_t atomically.
CONCAT
#define CONCAT(a, b)
Concatenate two tokens.
Definition: atomic_utils.h:700
CONCAT4
#define CONCAT4(a, b, c, d)
Concatenate four tokens.
Definition: atomic_utils.h:705
atomic_load_u8
static uint8_t atomic_load_u8(const uint8_t *var)
Load an uint8_t atomically.