blob: 4748990f1243db043166ff3ba1b9f055c11b509f [file] [log] [blame]
Eric Biederman8ca8d762003-04-22 19:02:15 +00001#ifndef SMP_ATOMIC_H
2#define SMP_ATOMIC_H
3
Eric Biederman2c018fb2003-07-21 20:13:45 +00004#ifdef CONFIG_SMP
Eric Biederman8ca8d762003-04-22 19:02:15 +00005#include <arch/smp/atomic.h>
6#else
7
8typedef struct { int counter; } atomic_t;
9#define ATOMIC_INIT(i) { (i) }
10
11/**
12 * atomic_read - read atomic variable
13 * @v: pointer of type atomic_t
14 *
15 * Atomically reads the value of @v. Note that the guaranteed
16 * useful range of an atomic_t is only 24 bits.
17 */
18#define atomic_read(v) ((v)->counter)
19
20/**
21 * atomic_set - set atomic variable
22 * @v: pointer of type atomic_t
23 * @i: required value
24 *
25 * Atomically sets the value of @v to @i. Note that the guaranteed
26 * useful range of an atomic_t is only 24 bits.
27 */
28#define atomic_set(v,i) (((v)->counter) = (i))
29
30
31/**
32 * atomic_inc - increment atomic variable
33 * @v: pointer of type atomic_t
34 *
35 * Atomically increments @v by 1. Note that the guaranteed
36 * useful range of an atomic_t is only 24 bits.
37 */
38#define atomic_inc(v) (((v)->counter)++)
39
40
41/**
42 * atomic_dec - decrement atomic variable
43 * @v: pointer of type atomic_t
44 *
45 * Atomically decrements @v by 1. Note that the guaranteed
46 * useful range of an atomic_t is only 24 bits.
47 */
48#define atomic_dec(v) (((v)->counter)--)
49
50
Eric Biederman2c018fb2003-07-21 20:13:45 +000051#endif /* CONFIG_SMP */
Eric Biederman8ca8d762003-04-22 19:02:15 +000052
53#endif /* SMP_ATOMIC_H */