diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-21 11:16:24 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2017-04-24 10:12:28 +0200 |
commit | d6eb1413920affb7be3df9982682dd183a805dd7 (patch) | |
tree | 535d96bffe88eacb65707509cd69b92ff6da27b8 | |
parent | a27450ec042fd646269d1594368305877dfe7e53 (diff) | |
download | qemu-d6eb1413920affb7be3df9982682dd183a805dd7.zip qemu-d6eb1413920affb7be3df9982682dd183a805dd7.tar.gz qemu-d6eb1413920affb7be3df9982682dd183a805dd7.tar.bz2 |
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>
-rw-r--r-- | include/qemu/bitmap.h | 2 | ||||
-rw-r--r-- | util/bitmap.c | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index 63ea2d0..c318da1 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -220,6 +220,8 @@ void bitmap_set(unsigned long *map, long i, long len); void bitmap_set_atomic(unsigned long *map, long i, long len); void bitmap_clear(unsigned long *map, long start, long nr); bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr); +void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src, + long nr); unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, diff --git a/util/bitmap.c b/util/bitmap.c index c1a84ca..efced9a 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)) /** |