From 46f8b3adaf013dfd033e54d8fdab2e7376e47365 Mon Sep 17 00:00:00 2001 From: zhangyuan29 Date: Fri, 6 Dec 2024 19:44:05 +0800 Subject: [PATCH] atomic: Unify the compare_exchange functions of nx and stdatomic define nx_atomic_compare_exchange_weak and nx_atomic_compare_exchange_strong function Signed-off-by: zhangyuan29 --- include/nuttx/atomic.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/nuttx/atomic.h b/include/nuttx/atomic.h index f364831c1f..ad952177c4 100644 --- a/include/nuttx/atomic.h +++ b/include/nuttx/atomic.h @@ -81,6 +81,15 @@ extern "C++" # define atomic_fetch_or(obj, val) ATOMIC_FUNC(fetch_or, 4)(obj, val, __ATOMIC_ACQ_REL) # define atomic_fetch_xor(obj, val) ATOMIC_FUNC(fetch_xor, 4)(obj, val, __ATOMIC_ACQ_REL) +# define nx_atomic_compare_exchange_weak_4(obj, expect, desired, success, failure) \ + nx_atomic_compare_exchange_4(obj, expect, desired, true, success, failure) +# define nx_atomic_compare_exchange_weak_8(obj, expect, desired, success, failure) \ + nx_atomic_compare_exchange_8(obj, expect, desired, true, success, failure) +# define nx_atomic_compare_exchange_strong_4(obj, expect, desired, success, failure) \ + nx_atomic_compare_exchange_4(obj, expect, desired, false, success, failure) +# define nx_atomic_compare_exchange_strong_8(obj, expect, desired, success, failure) \ + nx_atomic_compare_exchange_8(obj, expect, desired, false, success, failure) + typedef volatile int32_t atomic_t; typedef volatile int64_t atomic64_t; #endif