>From 7e7c3a20d08831cd64b77a4e8d8f693b4725ef89 Mon Sep 17 00:00:00 2001 From: Akira Yokosawa <akiyks@xxxxxxxxx> Date: Tue, 11 Dec 2018 21:37:11 +0900 Subject: [PATCH 3/4] CodeSamples: Fix definition of cmpxchg() in api-gcc.h Do the same change as CodeSamples/formal/litmus/api.h. Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx> --- CodeSamples/api-pthreads/api-gcc.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CodeSamples/api-pthreads/api-gcc.h b/CodeSamples/api-pthreads/api-gcc.h index 3afe340..b66f4b9 100644 --- a/CodeSamples/api-pthreads/api-gcc.h +++ b/CodeSamples/api-pthreads/api-gcc.h @@ -168,8 +168,9 @@ struct __xchg_dummy { ({ \ typeof(*ptr) _____actual = (o); \ \ - __atomic_compare_exchange_n(ptr, (void *)&_____actual, (n), 1, \ - __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? (o) : (o)+1; \ + __atomic_compare_exchange_n((ptr), (void *)&_____actual, (n), 0, \ + __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); \ + _____actual; \ }) static __inline__ int atomic_cmpxchg(atomic_t *v, int old, int new) -- 2.7.4