atomic.h File Reference

Go to the source code of this file.

Classes

struct  atomic_t
 

Macros

#define ATOMIC_INIT(i)   �{ (i) }
 
#define atomic_read(v)   ((v)->counter)
 
#define atomic_set(v, i)   (((v)->counter) = (i))
 

Functions

static void atomic_add (int i, atomic_t *v)
 
static void atomic_sub (int i, atomic_t *v)
 
static int atomic_sub_and_test (int i, atomic_t *v)
 
static void atomic_inc (atomic_t *v)
 
static void atomic_dec (atomic_t *v)
 decrement atomic variable �* More...
 
static int atomic_dec_and_test (atomic_t *v)
 Decrement and test �*. More...
 
static int atomic_inc_and_test (atomic_t *v)
 Increment and test �*. More...
 
static int atomic_add_negative (int i, atomic_t *v)
 add and test if negative �* More...
 

Macro Definition Documentation

◆ ATOMIC_INIT

#define ATOMIC_INIT (   i)    �{ (i) }

◆ atomic_read

#define atomic_read (   v)    ((v)->counter)

�* Read atomic variable �*

Parameters
vpointer of type atomic_t �* �* Atomically reads the value of @v. �

◆ atomic_set

#define atomic_set (   v,
 
)    (((v)->counter) = (i))

�* Set atomic variable �*

Parameters
vpointer of type atomic_t �*
irequired value �

Function Documentation

◆ atomic_add()

static void atomic_add ( int  i,
atomic_t v 
)
inlinestatic

�* Add to the atomic variable �*

Parameters
iinteger value to add �*
vpointer of type atomic_t

References atomic_t::counter.

◆ atomic_add_negative()

static int atomic_add_negative ( int  i,
atomic_t v 
)
inlinestatic

add and test if negative �*

�*

Parameters
vpointer of type atomic_t �*
iinteger value to add �* �* Atomically adds @i to @v and returns true �* if the result is negative, or false when �* result is greater than or equal to zero. �

References atomic_t::counter.

◆ atomic_dec()

static void atomic_dec ( atomic_t v)
inlinestatic

decrement atomic variable �*

�*

Parameters
vpointer of type atomic_t �* �* Atomically decrements @v by 1. �Note that the guaranteed �* useful range of an atomic_t is only 24 bits. �

References atomic_t::counter.

◆ atomic_dec_and_test()

static int atomic_dec_and_test ( atomic_t v)
inlinestatic

Decrement and test �*.

�*

Parameters
vpointer of type atomic_t �* �* Atomically decrements @v by 1 and �* returns true if the result is 0, or false for all other �* cases. �

References atomic_t::counter.

◆ atomic_inc()

static void atomic_inc ( atomic_t v)
inlinestatic

�* Increment atomic variable �*

Parameters
vpointer of type atomic_t �* �* Atomically increments @v by 1. �

References atomic_t::counter.

◆ atomic_inc_and_test()

static int atomic_inc_and_test ( atomic_t v)
inlinestatic

Increment and test �*.

�*

Parameters
vpointer of type atomic_t �* �* Atomically increments @v by 1 �* and returns true if the result is zero, or false for all �* other cases. �

References atomic_t::counter.

◆ atomic_sub()

static void atomic_sub ( int  i,
atomic_t v 
)
inlinestatic

�* Subtract the atomic variable �*

Parameters
iinteger value to subtract �*
vpointer of type atomic_t �* �* Atomically subtracts @i from @v. �

References atomic_t::counter.

◆ atomic_sub_and_test()

static int atomic_sub_and_test ( int  i,
atomic_t v 
)
inlinestatic

�* Subtract value from variable and test result �*

Parameters
iinteger value to subtract �*
vpointer of type atomic_t �* �* Atomically subtracts @i from @v and returns �* true if the result is zero, or false for all �* other cases. �

References atomic_t::counter.