8#ifndef ZEPHYR_INCLUDE_SYS_ATOMIC_H_
9#define ZEPHYR_INCLUDE_SYS_ATOMIC_H_
29#if defined(CONFIG_ATOMIC_OPERATIONS_C)
32#elif defined(CONFIG_ATOMIC_OPERATIONS_ARCH)
62#define ATOMIC_INIT(i) (i)
73#define ATOMIC_PTR_INIT(p) (p)
79#define ATOMIC_BITS (sizeof(atomic_val_t) * 8)
80#define ATOMIC_MASK(bit) BIT((unsigned long)(bit) & (ATOMIC_BITS - 1U))
81#define ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / ATOMIC_BITS))
93#define ATOMIC_BITMAP_SIZE(num_bits) (1 + ((num_bits) - 1) / ATOMIC_BITS)
114#define ATOMIC_DEFINE(name, num_bits) \
115 atomic_t name[ATOMIC_BITMAP_SIZE(num_bits)]
135 return (1 & (val >> (bit & (ATOMIC_BITS - 1)))) != 0;
157 old =
atomic_and(ATOMIC_ELEM(target, bit), ~mask);
159 return (old & mask) != 0;
181 old =
atomic_or(ATOMIC_ELEM(target, bit), mask);
183 return (old & mask) != 0;
202 (void)
atomic_and(ATOMIC_ELEM(target, bit), ~mask);
221 (void)
atomic_or(ATOMIC_ELEM(target, bit), mask);
242 (void)
atomic_or(ATOMIC_ELEM(target, bit), mask);
244 (void)
atomic_and(ATOMIC_ELEM(target, bit), ~mask);
long atomic_t
Definition: atomic.h:22
atomic_t atomic_val_t
Definition: atomic.h:23
atomic_ptr_t atomic_ptr_val_t
Definition: atomic.h:25
void * atomic_ptr_t
Definition: atomic.h:24
static ALWAYS_INLINE atomic_val_t atomic_and(atomic_t *target, atomic_val_t value)
Definition: atomic_xtensa.h:111
static ALWAYS_INLINE atomic_val_t atomic_get(const atomic_t *target)
Copyright (c) 2021 Intel Corporation SPDX-License-Identifier: Apache-2.0.
Definition: atomic_xtensa.h:16
static ALWAYS_INLINE atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
Definition: atomic_xtensa.h:99
static void atomic_set_bit(atomic_t *target, int bit)
Atomically set a bit.
Definition: atomic.h:217
static bool atomic_test_bit(const atomic_t *target, int bit)
Atomically test a bit.
Definition: atomic.h:131
static void atomic_clear_bit(atomic_t *target, int bit)
Atomically clear a bit.
Definition: atomic.h:198
static bool atomic_test_and_clear_bit(atomic_t *target, int bit)
Atomically test and clear a bit.
Definition: atomic.h:152
static bool atomic_test_and_set_bit(atomic_t *target, int bit)
Atomically set a bit.
Definition: atomic.h:176
static void atomic_set_bit_to(atomic_t *target, int bit, bool val)
Atomically set a bit to a given value.
Definition: atomic.h:237