Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
Macros | |
#define | ATOMIC_INIT(i) (i) |
Initialize an atomic variable. | |
#define | ATOMIC_PTR_INIT(p) (p) |
Initialize an atomic pointer variable. | |
#define | ATOMIC_BITMAP_SIZE(num_bits) (ROUND_UP(num_bits, ATOMIC_BITS) / ATOMIC_BITS) |
This macro computes the number of atomic variables necessary to represent a bitmap with num_bits. | |
#define | ATOMIC_DEFINE(name, num_bits) atomic_t name[ATOMIC_BITMAP_SIZE(num_bits)] |
Define an array of atomic variables. | |
Functions | |
static bool | atomic_test_bit (const atomic_t *target, int bit) |
Atomically test a bit. | |
static bool | atomic_test_and_clear_bit (atomic_t *target, int bit) |
Atomically test and clear a bit. | |
static bool | atomic_test_and_set_bit (atomic_t *target, int bit) |
Atomically set a bit. | |
static void | atomic_clear_bit (atomic_t *target, int bit) |
Atomically clear a bit. | |
static void | atomic_set_bit (atomic_t *target, int bit) |
Atomically set a bit. | |
static void | atomic_set_bit_to (atomic_t *target, int bit, bool val) |
Atomically set a bit to a given value. | |
bool | atomic_cas (atomic_t *target, atomic_val_t old_value, atomic_val_t new_value) |
Atomic compare-and-set. | |
bool | atomic_ptr_cas (atomic_ptr_t *target, atomic_ptr_val_t old_value, atomic_ptr_val_t new_value) |
Atomic compare-and-set with pointer values. | |
atomic_val_t | atomic_add (atomic_t *target, atomic_val_t value) |
Atomic addition. | |
atomic_val_t | atomic_sub (atomic_t *target, atomic_val_t value) |
Atomic subtraction. | |
atomic_val_t | atomic_inc (atomic_t *target) |
Atomic increment. | |
atomic_val_t | atomic_dec (atomic_t *target) |
Atomic decrement. | |
atomic_val_t | atomic_get (const atomic_t *target) |
Atomic get. | |
atomic_ptr_val_t | atomic_ptr_get (const atomic_ptr_t *target) |
Atomic get a pointer value. | |
atomic_val_t | atomic_set (atomic_t *target, atomic_val_t value) |
Atomic get-and-set. | |
atomic_ptr_val_t | atomic_ptr_set (atomic_ptr_t *target, atomic_ptr_val_t value) |
Atomic get-and-set for pointer values. | |
atomic_val_t | atomic_clear (atomic_t *target) |
Atomic clear. | |
atomic_ptr_val_t | atomic_ptr_clear (atomic_ptr_t *target) |
Atomic clear of a pointer value. | |
atomic_val_t | atomic_or (atomic_t *target, atomic_val_t value) |
Atomic bitwise inclusive OR. | |
atomic_val_t | atomic_xor (atomic_t *target, atomic_val_t value) |
Atomic bitwise exclusive OR (XOR). | |
atomic_val_t | atomic_and (atomic_t *target, atomic_val_t value) |
Atomic bitwise AND. | |
atomic_val_t | atomic_nand (atomic_t *target, atomic_val_t value) |
Atomic bitwise NAND. | |
#define ATOMIC_BITMAP_SIZE | ( | num_bits | ) | (ROUND_UP(num_bits, ATOMIC_BITS) / ATOMIC_BITS) |
#include <zephyr/sys/atomic.h>
This macro computes the number of atomic variables necessary to represent a bitmap with num_bits.
num_bits | Number of bits. |
#define ATOMIC_DEFINE | ( | name, | |
num_bits | |||
) | atomic_t name[ATOMIC_BITMAP_SIZE(num_bits)] |
#include <zephyr/sys/atomic.h>
Define an array of atomic variables.
This macro defines an array of atomic variables containing at least num_bits bits.
name | Name of array of atomic variables. |
num_bits | Number of bits needed. |
#define ATOMIC_INIT | ( | i | ) | (i) |
#include <zephyr/sys/atomic.h>
Initialize an atomic variable.
This macro can be used to initialize an atomic variable. For example,
i | Value to assign to atomic variable. |
#define ATOMIC_PTR_INIT | ( | p | ) | (p) |
#include <zephyr/sys/atomic.h>
Initialize an atomic pointer variable.
This macro can be used to initialize an atomic pointer variable. For example,
p | Pointer value to assign to atomic pointer variable. |
atomic_val_t atomic_add | ( | atomic_t * | target, |
atomic_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic addition.
This routine performs an atomic addition on target.
target | Address of atomic variable. |
value | Value to add. |
atomic_val_t atomic_and | ( | atomic_t * | target, |
atomic_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic bitwise AND.
This routine atomically sets target to the bitwise AND of target and value.
target | Address of atomic variable. |
value | Value to AND. |
bool atomic_cas | ( | atomic_t * | target, |
atomic_val_t | old_value, | ||
atomic_val_t | new_value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic compare-and-set.
This routine performs an atomic compare-and-set on target. If the current value of target equals old_value, target is set to new_value. If the current value of target does not equal old_value, target is left unchanged.
target | Address of atomic variable. |
old_value | Original value to compare against. |
new_value | New value to store. |
atomic_val_t atomic_clear | ( | atomic_t * | target | ) |
#include <zephyr/sys/atomic.h>
Atomic clear.
This routine atomically sets target to zero and returns its previous value. (Hence, it is equivalent to atomic_set(target, 0).)
target | Address of atomic variable. |
|
inlinestatic |
#include <zephyr/sys/atomic.h>
Atomically clear a bit.
Atomically clear bit number bit of target. The target may be a single atomic variable or an array of them.
target | Address of atomic variable or array. |
bit | Bit number (starting from 0). |
atomic_val_t atomic_dec | ( | atomic_t * | target | ) |
#include <zephyr/sys/atomic.h>
Atomic decrement.
This routine performs an atomic decrement by 1 on target.
target | Address of atomic variable. |
atomic_val_t atomic_get | ( | const atomic_t * | target | ) |
#include <zephyr/sys/atomic.h>
Atomic get.
This routine performs an atomic read on target.
target | Address of atomic variable. |
atomic_val_t atomic_inc | ( | atomic_t * | target | ) |
#include <zephyr/sys/atomic.h>
Atomic increment.
This routine performs an atomic increment by 1 on target.
target | Address of atomic variable. |
atomic_val_t atomic_nand | ( | atomic_t * | target, |
atomic_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic bitwise NAND.
This routine atomically sets target to the bitwise NAND of target and value. (This operation is equivalent to target = ~(target & value).)
target | Address of atomic variable. |
value | Value to NAND. |
atomic_val_t atomic_or | ( | atomic_t * | target, |
atomic_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic bitwise inclusive OR.
This routine atomically sets target to the bitwise inclusive OR of target and value.
target | Address of atomic variable. |
value | Value to OR. |
bool atomic_ptr_cas | ( | atomic_ptr_t * | target, |
atomic_ptr_val_t | old_value, | ||
atomic_ptr_val_t | new_value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic compare-and-set with pointer values.
This routine performs an atomic compare-and-set on target. If the current value of target equals old_value, target is set to new_value. If the current value of target does not equal old_value, target is left unchanged.
target | Address of atomic variable. |
old_value | Original value to compare against. |
new_value | New value to store. |
atomic_ptr_val_t atomic_ptr_clear | ( | atomic_ptr_t * | target | ) |
#include <zephyr/sys/atomic.h>
Atomic clear of a pointer value.
This routine atomically sets target to zero and returns its previous value. (Hence, it is equivalent to atomic_set(target, 0).)
target | Address of atomic variable. |
atomic_ptr_val_t atomic_ptr_get | ( | const atomic_ptr_t * | target | ) |
#include <zephyr/sys/atomic.h>
Atomic get a pointer value.
This routine performs an atomic read on target.
target | Address of pointer variable. |
atomic_ptr_val_t atomic_ptr_set | ( | atomic_ptr_t * | target, |
atomic_ptr_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic get-and-set for pointer values.
This routine atomically sets target to value and returns the previous value of target.
target | Address of atomic variable. |
value | Value to write to target. |
atomic_val_t atomic_set | ( | atomic_t * | target, |
atomic_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic get-and-set.
This routine atomically sets target to value and returns the previous value of target.
target | Address of atomic variable. |
value | Value to write to target. |
|
inlinestatic |
#include <zephyr/sys/atomic.h>
Atomically set a bit.
Atomically set bit number bit of target. The target may be a single atomic variable or an array of them.
target | Address of atomic variable or array. |
bit | Bit number (starting from 0). |
#include <zephyr/sys/atomic.h>
Atomically set a bit to a given value.
Atomically set bit number bit of target to value val. The target may be a single atomic variable or an array of them.
target | Address of atomic variable or array. |
bit | Bit number (starting from 0). |
val | true for 1, false for 0. |
atomic_val_t atomic_sub | ( | atomic_t * | target, |
atomic_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic subtraction.
This routine performs an atomic subtraction on target.
target | Address of atomic variable. |
value | Value to subtract. |
#include <zephyr/sys/atomic.h>
Atomically test and clear a bit.
Atomically clear bit number bit of target and return its old value. The target may be a single atomic variable or an array of them.
target | Address of atomic variable or array. |
bit | Bit number (starting from 0). |
#include <zephyr/sys/atomic.h>
Atomically set a bit.
Atomically set bit number bit of target and return its old value. The target may be a single atomic variable or an array of them.
target | Address of atomic variable or array. |
bit | Bit number (starting from 0). |
#include <zephyr/sys/atomic.h>
Atomically test a bit.
This routine tests whether bit number bit of target is set or not. The target may be a single atomic variable or an array of them.
target | Address of atomic variable or array. |
bit | Bit number (starting from 0). |
atomic_val_t atomic_xor | ( | atomic_t * | target, |
atomic_val_t | value | ||
) |
#include <zephyr/sys/atomic.h>
Atomic bitwise exclusive OR (XOR).
This routine atomically sets target to the bitwise exclusive OR (XOR) of target and value.
target | Address of atomic variable. |
value | Value to XOR |