1
2
3#ifndef _LINUX_ATOMIC_H
4#define _LINUX_ATOMIC_H
5#include <linux/types.h>
6
7#include <asm/atomic.h>
8#include <asm/barrier.h>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#define atomic_cond_read_acquire(v, c) smp_cond_load_acquire(&(v)->counter, (c))
29#define atomic_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c))
30
31#define atomic64_cond_read_acquire(v, c) smp_cond_load_acquire(&(v)->counter, (c))
32#define atomic64_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c))
33
34
35
36
37
38
39
40
41
42#ifndef __atomic_acquire_fence
43#define __atomic_acquire_fence smp_mb__after_atomic
44#endif
45
46#ifndef __atomic_release_fence
47#define __atomic_release_fence smp_mb__before_atomic
48#endif
49
50#ifndef __atomic_pre_full_fence
51#define __atomic_pre_full_fence smp_mb__before_atomic
52#endif
53
54#ifndef __atomic_post_full_fence
55#define __atomic_post_full_fence smp_mb__after_atomic
56#endif
57
58#define __atomic_op_acquire(op, args...) \
59({ \
60 typeof(op##_relaxed(args)) __ret = op##_relaxed(args); \
61 __atomic_acquire_fence(); \
62 __ret; \
63})
64
65#define __atomic_op_release(op, args...) \
66({ \
67 __atomic_release_fence(); \
68 op##_relaxed(args); \
69})
70
71#define __atomic_op_fence(op, args...) \
72({ \
73 typeof(op##_relaxed(args)) __ret; \
74 __atomic_pre_full_fence(); \
75 __ret = op##_relaxed(args); \
76 __atomic_post_full_fence(); \
77 __ret; \
78})
79
80#include <linux/atomic-arch-fallback.h>
81#include <asm-generic/atomic-instrumented.h>
82
83#include <asm-generic/atomic-long.h>
84
85#endif
86