[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 01/13] hbitmap: serialization
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 01/13] hbitmap: serialization |
Date: |
Thu, 3 Dec 2015 15:35:11 +0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, 11/11 18:16, Vladimir Sementsov-Ogievskiy wrote:
> +void hbitmap_deserialize_finish(HBitmap *bitmap)
> +{
> + int64_t i, size, prev_size;
> + int lev;
> +
> + /* restore levels starting from penultimate to zero level, assuming
> + * that the last level is ok */
> + size = MAX((bitmap->size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
> + for (lev = HBITMAP_LEVELS - 1; lev-- > 0; ) {
> + prev_size = size;
> + size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1);
> + memset(bitmap->levels[lev], 0, size * sizeof(unsigned long));
> +
> + for (i = 0; i < prev_size; ++i) {
> + if (bitmap->levels[lev + 1][i]) {
> + bitmap->levels[lev][i >> BITS_PER_LEVEL] |=
> + 1 << (i & (BITS_PER_LONG - 1));
This should be 1UL.
Fam
> + }
> + }
> + }
> +
> + bitmap->levels[0][0] |= 1UL << (BITS_PER_LONG - 1);
> +}
> +
> void hbitmap_free(HBitmap *hb)
> {
> unsigned i;
> --
> 2.1.4
>
>
- Re: [Qemu-devel] [PATCH 01/13] hbitmap: serialization,
Fam Zheng <=