atomic_utils.h File Reference

API of the utility functions for atomic accesses. More...

Detailed Description

API of the utility functions for atomic accesses.

Author
Marian Buschsieweke maria.nosp@m.n.bu.nosp@m.schsi.nosp@m.ewek.nosp@m.e@ovg.nosp@m.u.de

Definition in file atomic_utils.h.

#include <stdint.h>
#include "irq.h"
#include "atomic_utils_arch.h"
+ Include dependency graph for atomic_utils.h:

Go to the source code of this file.

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...