Commit 86d51bc3 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

s390/atomic: implement atomic_sub_return() with atomic_add_return()

Get rid of the own atomic_sub_return() implementation. Otherwise we can't
make use of the interlocked-access facility 1 instructions for
atomic_sub_return(), since there is no "load and subtract" instruction
available.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent fcd05b50
...@@ -60,11 +60,7 @@ static inline int atomic_add_return(int i, atomic_t *v) ...@@ -60,11 +60,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
#define atomic_inc(_v) atomic_add_return(1, _v) #define atomic_inc(_v) atomic_add_return(1, _v)
#define atomic_inc_return(_v) atomic_add_return(1, _v) #define atomic_inc_return(_v) atomic_add_return(1, _v)
#define atomic_inc_and_test(_v) (atomic_add_return(1, _v) == 0) #define atomic_inc_and_test(_v) (atomic_add_return(1, _v) == 0)
#define atomic_sub_return(_i, _v) atomic_add_return(-(int)(_i), _v)
static inline int atomic_sub_return(int i, atomic_t *v)
{
return __CS_LOOP(v, i, "sr");
}
#define atomic_sub(_i, _v) atomic_sub_return(_i, _v) #define atomic_sub(_i, _v) atomic_sub_return(_i, _v)
#define atomic_sub_and_test(_i, _v) (atomic_sub_return(_i, _v) == 0) #define atomic_sub_and_test(_i, _v) (atomic_sub_return(_i, _v) == 0)
#define atomic_dec(_v) atomic_sub_return(1, _v) #define atomic_dec(_v) atomic_sub_return(1, _v)
...@@ -152,11 +148,6 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v) ...@@ -152,11 +148,6 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
return __CSG_LOOP(v, i, "agr"); return __CSG_LOOP(v, i, "agr");
} }
static inline long long atomic64_sub_return(long long i, atomic64_t *v)
{
return __CSG_LOOP(v, i, "sgr");
}
static inline void atomic64_clear_mask(unsigned long mask, atomic64_t *v) static inline void atomic64_clear_mask(unsigned long mask, atomic64_t *v)
{ {
__CSG_LOOP(v, ~mask, "ngr"); __CSG_LOOP(v, ~mask, "ngr");
...@@ -248,17 +239,6 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v) ...@@ -248,17 +239,6 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
return new; return new;
} }
static inline long long atomic64_sub_return(long long i, atomic64_t *v)
{
long long old, new;
do {
old = atomic64_read(v);
new = old - i;
} while (atomic64_cmpxchg(v, old, new) != old);
return new;
}
static inline void atomic64_set_mask(unsigned long long mask, atomic64_t *v) static inline void atomic64_set_mask(unsigned long long mask, atomic64_t *v)
{ {
long long old, new; long long old, new;
...@@ -319,6 +299,7 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v) ...@@ -319,6 +299,7 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
#define atomic64_inc(_v) atomic64_add_return(1, _v) #define atomic64_inc(_v) atomic64_add_return(1, _v)
#define atomic64_inc_return(_v) atomic64_add_return(1, _v) #define atomic64_inc_return(_v) atomic64_add_return(1, _v)
#define atomic64_inc_and_test(_v) (atomic64_add_return(1, _v) == 0) #define atomic64_inc_and_test(_v) (atomic64_add_return(1, _v) == 0)
#define atomic64_sub_return(_i, _v) atomic64_add_return(-(long long)(_i), _v)
#define atomic64_sub(_i, _v) atomic64_sub_return(_i, _v) #define atomic64_sub(_i, _v) atomic64_sub_return(_i, _v)
#define atomic64_sub_and_test(_i, _v) (atomic64_sub_return(_i, _v) == 0) #define atomic64_sub_and_test(_i, _v) (atomic64_sub_return(_i, _v) == 0)
#define atomic64_dec(_v) atomic64_sub_return(1, _v) #define atomic64_dec(_v) atomic64_sub_return(1, _v)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment