2 * @ingroup adf_os_public
3 * @file adf_os_atomic.h
4 * This file abstracts an atomic counter.
7 #ifndef _ADF_OS_ATOMIC_H
8 #define _ADF_OS_ATOMIC_H
10 #include <adf_os_atomic_pvt.h>
12 * @brief Atomic type of variable.
13 * Use this when you want a simple resource counter etc. which is atomic
14 * across multiple CPU's. These maybe slower than usual counters on some
15 * platforms/OS'es, so use them with caution.
17 typedef __adf_os_atomic_t adf_os_atomic_t;
20 * @brief Initialize an atomic type variable
21 * @param[in] v a pointer to an opaque atomic variable
24 adf_os_atomic_init(adf_os_atomic_t *v)
26 __adf_os_atomic_init(v);
30 * @brief Read the value of an atomic variable.
31 * @param[in] v a pointer to an opaque atomic variable
33 * @return the current value of the variable
35 static inline a_uint32_t
36 adf_os_atomic_read(adf_os_atomic_t *v)
38 return (__adf_os_atomic_read(v));
42 * @brief Increment the value of an atomic variable.
43 * @param[in] v a pointer to an opaque atomic variable
46 adf_os_atomic_inc(adf_os_atomic_t *v)
48 return (__adf_os_atomic_inc(v));
52 * @brief Decrement the value of an atomic variable.
53 * @param v a pointer to an opaque atomic variable
56 adf_os_atomic_dec(adf_os_atomic_t *v)
58 return (__adf_os_atomic_dec(v));