From d6eb1413920affb7be3df9982682dd183a805dd7 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 21 Apr 2017 11:16:24 +0200 Subject: bitmap: add bitmap_copy_and_clear_atomic Signed-off-by: Gerd Hoffmann Message-id: 20170421091632.30900-2-kraxel@redhat.com Signed-off-by: Gerd Hoffmann --- util/bitmap.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'util/bitmap.c') 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)) /** -- cgit v1.2.3