From 9f3c0ec2ea41ed3d63bddc7981e80b5ad7c85f60 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 --- 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 2350b5d27..00f3fbf70 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