coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
atomic.h
Go to the documentation of this file.
1 #ifndef SMP_ATOMIC_H
2 #define SMP_ATOMIC_H
3 
4 #if CONFIG(SMP)
5 #include <arch/smp/atomic.h>
6 #else
7 
8 typedef struct { int counter; } atomic_t;
9 #define ATOMIC_INIT(i) { (i) }
10 
11 /**
12  * @file include/smp/atomic.h
13  */
14 
15 /**
16  * atomic_read - read atomic variable
17  * @param v: pointer of type atomic_t
18  *
19  * Atomically reads the value of v. Note that the guaranteed
20  * useful range of an atomic_t is only 24 bits.
21  */
22 #define atomic_read(v) ((v)->counter)
23 
24 /**
25  * atomic_set - set atomic variable
26  * @param v: pointer of type atomic_t
27  * @param i: required value
28  *
29  * Atomically sets the value of v to i. Note that the guaranteed
30  * useful range of an atomic_t is only 24 bits.
31  */
32 #define atomic_set(v, i) (((v)->counter) = (i))
33 
34 /**
35  * atomic_inc - increment atomic variable
36  * @param v: pointer of type atomic_t
37  *
38  * Atomically increments v by 1. Note that the guaranteed
39  * useful range of an atomic_t is only 24 bits.
40  */
41 #define atomic_inc(v) (((v)->counter)++)
42 
43 /**
44  * atomic_dec - decrement atomic variable
45  * @param v: pointer of type atomic_t
46  *
47  * Atomically decrements v by 1. Note that the guaranteed
48  * useful range of an atomic_t is only 24 bits.
49  */
50 #define atomic_dec(v) (((v)->counter)--)
51 
52 #endif /* CONFIG_SMP */
53 
54 #endif /* SMP_ATOMIC_H */
Definition: atomic.h:8
int counter
Definition: atomic.h:8