tools arch x86: Introduce atomic_cmpxchg()
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 8a73615df3b8973df2de1455c00e9169522d8257 Gitweb: http://git.kernel.org/tip/8a73615df3b8973df2de1455c00e9169522d8257 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 22 Feb 2017 16:55:43 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 3 Mar 2017 19:07:13 -0300
tools arch x86: Introduce atomic_cmpxchg()
Will be used by atomic_cmpxchg_relaxed(), in turn used by refcount.h.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Elena Reshetova <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/arch/x86/include/asm/atomic.h | 7 +++++++ 1 file changed, 7 insertions(+)
tools/arch/x86/include/asm/atomic.h +7 -0
@@ -7,6 +7,8 @@#define LOCK_PREFIX "\n\tlock; " +#include <asm/cmpxchg.h> +/* * 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 */