From: Andrei Tatar Date: Tue, 7 Nov 2023 13:53:45 +0000 (+0100) Subject: include/arch: Add raw compare-exchange operation X-Git-Tag: RELEASE-0.16.0~203 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4a48944275b4fd28a996c06419616df304fb5bb1;p=unikraft%2Funikraft.git include/arch: Add raw compare-exchange operation 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 Reviewed-by: Simon Kuenzer Approved-by: Simon Kuenzer GitHub-Closes: #1156 --- diff --git a/include/uk/arch/atomic.h b/include/uk/arch/atomic.h index 2350b5d27..f03f1e692 100644 --- a/include/uk/arch/atomic.h +++ b/include/uk/arch/atomic.h @@ -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; \