]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
include/arch: Add atomic fetch & AND operation 1125/head
authorAndrei Tatar <andrei@unikraft.io>
Mon, 2 Oct 2023 18:58:34 +0000 (20:58 +0200)
committerAndrei Tatar <andrei@unikraft.io>
Fri, 3 Nov 2023 16:31:22 +0000 (17: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>
include/uk/arch/atomic.h

index 2350b5d27ae59784c13f150d2974b7bed8f232b8..00f3fbf709b6b275fd1a078a63bb62e257b22090 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.