diff options
Diffstat (limited to 'arch/tile/include/asm/atomic.h')
-rw-r--r-- | arch/tile/include/asm/atomic.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/tile/include/asm/atomic.h b/arch/tile/include/asm/atomic.h index e71387ab20ca..d385eaadece7 100644 --- a/arch/tile/include/asm/atomic.h +++ b/arch/tile/include/asm/atomic.h | |||
@@ -114,6 +114,32 @@ static inline int atomic_read(const atomic_t *v) | |||
114 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) | 114 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * atomic_xchg - atomically exchange contents of memory with a new value | ||
118 | * @v: pointer of type atomic_t | ||
119 | * @i: integer value to store in memory | ||
120 | * | ||
121 | * Atomically sets @v to @i and returns old @v | ||
122 | */ | ||
123 | static inline int atomic_xchg(atomic_t *v, int n) | ||
124 | { | ||
125 | return xchg(&v->counter, n); | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * atomic_cmpxchg - atomically exchange contents of memory if it matches | ||
130 | * @v: pointer of type atomic_t | ||
131 | * @o: old value that memory should have | ||
132 | * @n: new value to write to memory if it matches | ||
133 | * | ||
134 | * Atomically checks if @v holds @o and replaces it with @n if so. | ||
135 | * Returns the old value at @v. | ||
136 | */ | ||
137 | static inline int atomic_cmpxchg(atomic_t *v, int o, int n) | ||
138 | { | ||
139 | return cmpxchg(&v->counter, o, n); | ||
140 | } | ||
141 | |||
142 | /** | ||
117 | * atomic_add_negative - add and test if negative | 143 | * atomic_add_negative - add and test if negative |
118 | * @v: pointer of type atomic_t | 144 | * @v: pointer of type atomic_t |
119 | * @i: integer value to add | 145 | * @i: integer value to add |
@@ -133,6 +159,32 @@ static inline int atomic_read(const atomic_t *v) | |||
133 | 159 | ||
134 | #ifndef __ASSEMBLY__ | 160 | #ifndef __ASSEMBLY__ |
135 | 161 | ||
162 | /** | ||
163 | * atomic64_xchg - atomically exchange contents of memory with a new value | ||
164 | * @v: pointer of type atomic64_t | ||
165 | * @i: integer value to store in memory | ||
166 | * | ||
167 | * Atomically sets @v to @i and returns old @v | ||
168 | */ | ||
169 | static inline u64 atomic64_xchg(atomic64_t *v, u64 n) | ||
170 | { | ||
171 | return xchg64(&v->counter, n); | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * atomic64_cmpxchg - atomically exchange contents of memory if it matches | ||
176 | * @v: pointer of type atomic64_t | ||
177 | * @o: old value that memory should have | ||
178 | * @n: new value to write to memory if it matches | ||
179 | * | ||
180 | * Atomically checks if @v holds @o and replaces it with @n if so. | ||
181 | * Returns the old value at @v. | ||
182 | */ | ||
183 | static inline u64 atomic64_cmpxchg(atomic64_t *v, u64 o, u64 n) | ||
184 | { | ||
185 | return cmpxchg64(&v->counter, o, n); | ||
186 | } | ||
187 | |||
136 | static inline long long atomic64_dec_if_positive(atomic64_t *v) | 188 | static inline long long atomic64_dec_if_positive(atomic64_t *v) |
137 | { | 189 | { |
138 | long long c, old, dec; | 190 | long long c, old, dec; |