tile: support atomic64_dec_if_positive()
Use the normal cmpxchg() idiom to implement this functionality. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
This commit is contained in:
parent
ef567f25d5
commit
adf6d9b30f
|
@ -24,6 +24,7 @@ config TILE
|
||||||
select MODULES_USE_ELF_RELA
|
select MODULES_USE_ELF_RELA
|
||||||
select HAVE_ARCH_TRACEHOOK
|
select HAVE_ARCH_TRACEHOOK
|
||||||
select HAVE_SYSCALL_TRACEPOINTS
|
select HAVE_SYSCALL_TRACEPOINTS
|
||||||
|
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
|
||||||
|
|
||||||
# FIXME: investigate whether we need/want these options.
|
# FIXME: investigate whether we need/want these options.
|
||||||
# select HAVE_IOREMAP_PROT
|
# select HAVE_IOREMAP_PROT
|
||||||
|
|
|
@ -131,4 +131,25 @@ static inline int atomic_read(const atomic_t *v)
|
||||||
#include <asm/atomic_64.h>
|
#include <asm/atomic_64.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
static inline long long atomic64_dec_if_positive(atomic64_t *v)
|
||||||
|
{
|
||||||
|
long long c, old, dec;
|
||||||
|
|
||||||
|
c = atomic64_read(v);
|
||||||
|
for (;;) {
|
||||||
|
dec = c - 1;
|
||||||
|
if (unlikely(dec < 0))
|
||||||
|
break;
|
||||||
|
old = atomic64_cmpxchg((v), c, dec);
|
||||||
|
if (likely(old == c))
|
||||||
|
break;
|
||||||
|
c = old;
|
||||||
|
}
|
||||||
|
return dec;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
#endif /* _ASM_TILE_ATOMIC_H */
|
#endif /* _ASM_TILE_ATOMIC_H */
|
||||||
|
|
Loading…
Reference in New Issue