0001
0002
0003 #ifndef _LINUX_ATOMIC_H
0004 #define _LINUX_ATOMIC_H
0005 #include <linux/types.h>
0006
0007 #include <asm/atomic.h>
0008 #include <asm/barrier.h>
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #define atomic_cond_read_acquire(v, c) smp_cond_load_acquire(&(v)->counter, (c))
0029 #define atomic_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c))
0030
0031 #define atomic64_cond_read_acquire(v, c) smp_cond_load_acquire(&(v)->counter, (c))
0032 #define atomic64_cond_read_relaxed(v, c) smp_cond_load_relaxed(&(v)->counter, (c))
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 #ifndef __atomic_acquire_fence
0043 #define __atomic_acquire_fence smp_mb__after_atomic
0044 #endif
0045
0046 #ifndef __atomic_release_fence
0047 #define __atomic_release_fence smp_mb__before_atomic
0048 #endif
0049
0050 #ifndef __atomic_pre_full_fence
0051 #define __atomic_pre_full_fence smp_mb__before_atomic
0052 #endif
0053
0054 #ifndef __atomic_post_full_fence
0055 #define __atomic_post_full_fence smp_mb__after_atomic
0056 #endif
0057
0058 #define __atomic_op_acquire(op, args...) \
0059 ({ \
0060 typeof(op##_relaxed(args)) __ret = op##_relaxed(args); \
0061 __atomic_acquire_fence(); \
0062 __ret; \
0063 })
0064
0065 #define __atomic_op_release(op, args...) \
0066 ({ \
0067 __atomic_release_fence(); \
0068 op##_relaxed(args); \
0069 })
0070
0071 #define __atomic_op_fence(op, args...) \
0072 ({ \
0073 typeof(op##_relaxed(args)) __ret; \
0074 __atomic_pre_full_fence(); \
0075 __ret = op##_relaxed(args); \
0076 __atomic_post_full_fence(); \
0077 __ret; \
0078 })
0079
0080 #include <linux/atomic/atomic-arch-fallback.h>
0081 #include <linux/atomic/atomic-long.h>
0082 #include <linux/atomic/atomic-instrumented.h>
0083
0084 #endif