mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 10:16:41 +00:00
ppc: Add atomic_dec_return()
Borrowed from Linux kernel. travis-ci: success for series starting with [1/2] ppc: Add atomic_dec_return() Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
6c7eb2ee99
commit
994d9d4ea6
1 changed files with 20 additions and 0 deletions
|
|
@ -107,6 +107,26 @@ static __inline__ void atomic_dec(atomic_t *v)
|
|||
: "cc", "xer");
|
||||
}
|
||||
|
||||
static __inline__ int atomic_sub_return(int a, atomic_t *v)
|
||||
{
|
||||
int t;
|
||||
|
||||
__asm__ __volatile__(
|
||||
" \nLWSYNC\n"
|
||||
"1: lwarx %0,0,%2 # atomic_sub_return\n\
|
||||
subf %0,%1,%0\n"
|
||||
" stwcx. %0,0,%2 \n\
|
||||
bne- 1b"
|
||||
" \nsync\n"
|
||||
: "=&r" (t)
|
||||
: "r" (a), "r" (&v->counter)
|
||||
: "cc", "memory");
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
#define atomic_dec_return(v) (atomic_sub_return(1, v))
|
||||
|
||||
#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
|
||||
|
||||
#endif /* __CR_ATOMIC_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue