]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
include/arch: Add atomic fetch & AND operation
authorAndrei Tatar <andrei@unikraft.io>
Mon, 2 Oct 2023 18:58:34 +0000 (20:58 +0200)
committerSimon Kuenzer <simon@unikraft.io>
Tue, 28 Nov 2023 21:31:54 +0000 (22:31 +0100)
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 <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1125

include/uk/arch/atomic.h

index f03f1e692e120c69791f69b32b3401e1ffbc4899..b1bbd26fa5bf346de01a192dde5b1879e6f7cc61 100644 (file)
@@ -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.