From 254bfe2748749336d077ba43153d8751d6faf1d9 Mon Sep 17 00:00:00 2001 From: Andrei Tatar Date: Mon, 2 Oct 2023 20:58:34 +0200 Subject: [PATCH] include/arch: Add atomic fetch & AND operation This change adds a Unikraft macro for an architecture's atomic fetch & AND operation, similar to the fetch & OR we already have. It also fixes the order of the fetch & OR operations to be truthful to the docstring. Signed-off-by: Andrei Tatar Reviewed-by: Simon Kuenzer Approved-by: Simon Kuenzer GitHub-Closes: #1125 --- include/uk/arch/atomic.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/uk/arch/atomic.h b/include/uk/arch/atomic.h index f03f1e692..b1bbd26fa 100644 --- a/include/uk/arch/atomic.h +++ b/include/uk/arch/atomic.h @@ -79,7 +79,13 @@ extern "C" { * Perform an atomic OR operation and return the previous value. */ #define ukarch_or(src, val) \ - __atomic_or_fetch(src, val, __ATOMIC_SEQ_CST) + __atomic_fetch_or(src, val, __ATOMIC_SEQ_CST) + +/** + * Perform an atomic AND operation and return the previous value. + */ +#define ukarch_and(src, val) \ + __atomic_fetch_and(src, val, __ATOMIC_SEQ_CST) /** * Writes *src into *dst, and returns the previous contents of *dst. -- 2.39.5