diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2017-09-22 14:04:10 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2017-09-22 14:04:10 +0100 |
| commit | bef81b3eb521f2825d85b8ddf246c81a28dcef35 (patch) | |
| tree | 1d75795c73f05daa4d58fa12b6b81ccdba530754 /util/bitmap.c | |
| parent | 159a9df02127cbf6fe640f67954794a99a12a005 (diff) | |
| parent | 54ae0886b12c4934e84381af777d4df6147cc2ec (diff) | |
| download | focaccia-qemu-bef81b3eb521f2825d85b8ddf246c81a28dcef35.tar.gz focaccia-qemu-bef81b3eb521f2825d85b8ddf246c81a28dcef35.zip | |
Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20170922-1' into staging
migration/next for 20170922 # gpg: Signature made Fri 22 Sep 2017 13:15:06 BST # gpg: using RSA key 0xF487EF185872D723 # gpg: Good signature from "Juan Quintela <quintela@redhat.com>" # gpg: aka "Juan Quintela <quintela@trasno.org>" # Primary key fingerprint: 1899 FF8E DEBF 58CC EE03 4B82 F487 EF18 5872 D723 * remotes/juanquintela/tags/migration/20170922-1: migration: split ufd_version_check onto receive/request features part migration: fix hardcoded function name in error report migration: pass MigrationIncomingState* into migration check functions migration: split common postcopy out of ram postcopy migration: fix ram_save_pending migration: add has_postcopy savevm handler bitmap: provide to_le/from_le helpers bitmap: introduce bitmap_count_one() bitmap: remove BITOP_WORD() migration: Split migration_fd_process_incoming migration: Create multifd migration threads migration: Create x-multifd-page-count parameter migration: Create x-multifd-channels parameter migration: Add multifd capability migration: Create migration_has_all_channels migration: Add comments to channel functions migration: Teach it about G_SOURCE_REMOVE migration: Create migration_ioc_process_incoming() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util/bitmap.c')
| -rw-r--r-- | util/bitmap.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/util/bitmap.c b/util/bitmap.c index efced9a7d8..cb618c65a5 100644 --- a/util/bitmap.c +++ b/util/bitmap.c @@ -355,3 +355,50 @@ int slow_bitmap_intersects(const unsigned long *bitmap1, } return 0; } + +long slow_bitmap_count_one(const unsigned long *bitmap, long nbits) +{ + long k, lim = nbits / BITS_PER_LONG, result = 0; + + for (k = 0; k < lim; k++) { + result += ctpopl(bitmap[k]); + } + + if (nbits % BITS_PER_LONG) { + result += ctpopl(bitmap[k] & BITMAP_LAST_WORD_MASK(nbits)); + } + + return result; +} + +static void bitmap_to_from_le(unsigned long *dst, + const unsigned long *src, long nbits) +{ + long len = BITS_TO_LONGS(nbits); + +#ifdef HOST_WORDS_BIGENDIAN + long index; + + for (index = 0; index < len; index++) { +# if HOST_LONG_BITS == 64 + dst[index] = bswap64(src[index]); +# else + dst[index] = bswap32(src[index]); +# endif + } +#else + memcpy(dst, src, len * sizeof(unsigned long)); +#endif +} + +void bitmap_from_le(unsigned long *dst, const unsigned long *src, + long nbits) +{ + bitmap_to_from_le(dst, src, nbits); +} + +void bitmap_to_le(unsigned long *dst, const unsigned long *src, + long nbits) +{ + bitmap_to_from_le(dst, src, nbits); +} |