On Mon, 2026-10-26 at 10:40 +0800, Wang Yechao wrote: > BITS_TO_U64S was a private macro in migration/vmstate-types.c, > defining the number of 64-bit words used on the wire for bitmaps. > Move it to include/qemu/bitops.h alongside the existing > BITS_TO_U32S so it can be shared with other code. > > While moving it, express the divisor with sizeof(uint64_t) instead > of the hardcoded 64, keeping it consistent with BITS_TO_U32S. This > is semantically equivalent. > > Signed-off-by: Wang Yechao <[email protected]> > Signed-off-by: Xuemei Liu <[email protected]> > Reviewed-by: Daniel Henrique Barboza > <[email protected]>
Reviewed-by: Alistair Francis <[email protected]> Alistair > --- > include/qemu/bitops.h | 1 + > migration/vmstate-types.c | 3 +-- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h > index f7363a5479..383648fe59 100644 > --- a/include/qemu/bitops.h > +++ b/include/qemu/bitops.h > @@ -20,6 +20,7 @@ > #define BITS_PER_LONG (sizeof (unsigned long) * > BITS_PER_BYTE) > #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * > sizeof(long)) > #define BITS_TO_U32S(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * > sizeof(uint32_t)) > +#define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * > sizeof(uint64_t)) > > #define BIT(nr) (1UL << (nr)) > #define BIT_ULL(nr) (1ULL << (nr)) > diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c > index c2d4645f31..8094d76f1b 100644 > --- a/migration/vmstate-types.c > +++ b/migration/vmstate-types.c > @@ -16,6 +16,7 @@ > #include "migration.h" > #include "migration/vmstate.h" > #include "migration/client-options.h" > +#include "qemu/bitops.h" > #include "qemu/error-report.h" > #include "qemu/queue.h" > #include "trace.h" > @@ -596,8 +597,6 @@ const VMStateInfo vmstate_info_tmp = { > * bit words with the bits in big endian order. The in-memory format > * is an array of 'unsigned long', which may be either 32 or 64 > bits. > */ > -/* This is the number of 64 bit words sent over the wire */ > -#define BITS_TO_U64S(nr) DIV_ROUND_UP(nr, 64) > static bool load_bitmap(QEMUFile *f, void *pv, size_t size, > const VMStateField *field, Error **errp) > {
