]> Git Repo - qemu.git/blobdiff - include/qemu/bitops.h
cpu-exec: Add "nochain" debug flag
[qemu.git] / include / qemu / bitops.h
index 8abdcf90778aa33da5c3c4982052420ee8b79a77..81642251525ed2f06a0b1ac9f5a1712bed862d10 100644 (file)
@@ -16,6 +16,7 @@
 #include <assert.h>
 
 #include "host-utils.h"
+#include "atomic.h"
 
 #define BITS_PER_BYTE           CHAR_BIT
 #define BITS_PER_LONG           (sizeof (unsigned long) * BITS_PER_BYTE)
@@ -38,6 +39,19 @@ static inline void set_bit(long nr, unsigned long *addr)
     *p  |= mask;
 }
 
+/**
+ * set_bit_atomic - Set a bit in memory atomically
+ * @nr: the bit to set
+ * @addr: the address to start counting from
+ */
+static inline void set_bit_atomic(long nr, unsigned long *addr)
+{
+    unsigned long mask = BIT_MASK(nr);
+    unsigned long *p = addr + BIT_WORD(nr);
+
+    atomic_or(p, mask);
+}
+
 /**
  * clear_bit - Clears a bit in memory
  * @nr: Bit to clear
This page took 0.024159 seconds and 4 git commands to generate.