From: Arnaldo Carvalho de Melo Date: Wed, 22 Feb 2017 19:55:43 +0000 (-0300) Subject: tools arch x86: Introduce atomic_cmpxchg() X-Git-Tag: v4.14-rc1~1048^2~43^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a73615df3b8973df2de1455c00e9169522d8257;p=platform%2Fkernel%2Flinux-rpi.git tools arch x86: Introduce atomic_cmpxchg() Will be used by atomic_cmpxchg_relaxed(), in turn used by refcount.h. Cc: Adrian Hunter Cc: David Ahern Cc: Elena Reshetova Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-kdmovd3l4gw5b1w31ypr6ddv@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/arch/x86/include/asm/atomic.h b/tools/arch/x86/include/asm/atomic.h index 059e33e..328eece 100644 --- a/tools/arch/x86/include/asm/atomic.h +++ b/tools/arch/x86/include/asm/atomic.h @@ -7,6 +7,8 @@ #define LOCK_PREFIX "\n\tlock; " +#include + /* * Atomic operations that C can't guarantee us. Useful for * resource counting etc.. @@ -62,4 +64,9 @@ static inline int atomic_dec_and_test(atomic_t *v) GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e"); } +static __always_inline int atomic_cmpxchg(atomic_t *v, int old, int new) +{ + return cmpxchg(&v->counter, old, new); +} + #endif /* _TOOLS_LINUX_ASM_X86_ATOMIC_H */