]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/0006-bitmap-add-bitmap_copy_and_clear_atomic.patch
bump version to 2.9.1-9
[pve-qemu.git] / debian / patches / extra / 0006-bitmap-add-bitmap_copy_and_clear_atomic.patch
CommitLineData
3dcc8d3b 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
ddbcf45e
WB
2From: Gerd Hoffmann <kraxel@redhat.com>
3Date: Fri, 21 Apr 2017 11:16:24 +0200
3dcc8d3b 4Subject: [PATCH] bitmap: add bitmap_copy_and_clear_atomic
ddbcf45e
WB
5
6Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7Message-id: 20170421091632.30900-2-kraxel@redhat.com
8Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9---
10 include/qemu/bitmap.h | 2 ++
11 util/bitmap.c | 11 +++++++++++
12 2 files changed, 13 insertions(+)
13
14diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
15index 63ea2d0b1e..c318da12d7 100644
16--- a/include/qemu/bitmap.h
17+++ b/include/qemu/bitmap.h
18@@ -220,6 +220,8 @@ void bitmap_set(unsigned long *map, long i, long len);
19 void bitmap_set_atomic(unsigned long *map, long i, long len);
20 void bitmap_clear(unsigned long *map, long start, long nr);
21 bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr);
22+void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src,
23+ long nr);
24 unsigned long bitmap_find_next_zero_area(unsigned long *map,
25 unsigned long size,
26 unsigned long start,
27diff --git a/util/bitmap.c b/util/bitmap.c
28index c1a84ca5e3..efced9a7d8 100644
29--- a/util/bitmap.c
30+++ b/util/bitmap.c
31@@ -287,6 +287,17 @@ bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr)
32 return dirty != 0;
33 }
34
35+void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src,
36+ long nr)
37+{
38+ while (nr > 0) {
39+ *dst = atomic_xchg(src, 0);
40+ dst++;
41+ src++;
42+ nr -= BITS_PER_LONG;
43+ }
44+}
45+
46 #define ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
47
48 /**
49--
502.11.0
51