summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-04-21 11:16:24 +0200
committerGerd Hoffmann <kraxel@redhat.com>2017-04-24 10:12:28 +0200
commitd6eb1413920affb7be3df9982682dd183a805dd7 (patch)
tree535d96bffe88eacb65707509cd69b92ff6da27b8 /util
parenta27450ec042fd646269d1594368305877dfe7e53 (diff)
downloadqemu-d6eb1413920affb7be3df9982682dd183a805dd7.zip
bitmap: add bitmap_copy_and_clear_atomic
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20170421091632.30900-2-kraxel@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/bitmap.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/bitmap.c b/util/bitmap.c
index c1a84ca5e3..efced9a7d8 100644
--- a/util/bitmap.c
+++ b/util/bitmap.c
@@ -287,6 +287,17 @@ bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr)
return dirty != 0;
}
+void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src,
+ long nr)
+{
+ while (nr > 0) {
+ *dst = atomic_xchg(src, 0);
+ dst++;
+ src++;
+ nr -= BITS_PER_LONG;
+ }
+}
+
#define ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
/**