mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
hbitmap: Add @advance param to hbitmap_iter_next()
This new parameter allows the caller to just query the next dirty position without moving the iterator. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 20180613181823.13618-8-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
ec9f10fe06
commit
a33fbb4f8b
5 changed files with 26 additions and 19 deletions
|
@ -141,7 +141,7 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi)
|
|||
return cur;
|
||||
}
|
||||
|
||||
int64_t hbitmap_iter_next(HBitmapIter *hbi)
|
||||
int64_t hbitmap_iter_next(HBitmapIter *hbi, bool advance)
|
||||
{
|
||||
unsigned long cur = hbi->cur[HBITMAP_LEVELS - 1] &
|
||||
hbi->hb->levels[HBITMAP_LEVELS - 1][hbi->pos];
|
||||
|
@ -154,8 +154,12 @@ int64_t hbitmap_iter_next(HBitmapIter *hbi)
|
|||
}
|
||||
}
|
||||
|
||||
/* The next call will resume work from the next bit. */
|
||||
hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1);
|
||||
if (advance) {
|
||||
/* The next call will resume work from the next bit. */
|
||||
hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1);
|
||||
} else {
|
||||
hbi->cur[HBITMAP_LEVELS - 1] = cur;
|
||||
}
|
||||
item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur);
|
||||
|
||||
return item << hbi->granularity;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue