]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
include/arch: Add raw compare-exchange operation
authorAndrei Tatar <andrei@unikraft.io>
Tue, 7 Nov 2023 13:53:45 +0000 (14:53 +0100)
committerSimon Kuenzer <simon@unikraft.io>
Mon, 27 Nov 2023 22:07:18 +0000 (23:07 +0100)
This change adds a Unikraft macro for the raw compare-exchange
operation, which in contrast to the existing macro may modify its
arguments.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1156

include/uk/arch/atomic.h

index 2350b5d27ae59784c13f150d2974b7bed8f232b8..f03f1e692e120c69791f69b32b3401e1ffbc4899 100644 (file)
@@ -93,6 +93,10 @@ extern "C" {
 #define ukarch_exchange_n(dst, v) \
        __atomic_exchange_n(dst, v, __ATOMIC_SEQ_CST)
 
+#define ukarch_compare_exchange_n(dst, exp, des)  \
+       __atomic_compare_exchange_n(dst, exp, des, 0, \
+                                   __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
+
 #define ukarch_compare_exchange_sync(ptr, old, new)                            \
        ({                                                                     \
                __typeof__(*ptr) stored = old;                                 \