* Paolo Bonzini (pbonz...@redhat.com) wrote: > > > On 16/06/2016 19:12, Dr. David Alan Gilbert (git) wrote: > > From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> > > > > e.g. BIT_RANGE(15, 0) gives 0xff00 > > That looks more like BIT_RANGE(15, 8). :)
Yes (and in the comment below) - I'll repost after waiting to see if there's any other nasties. Dave > > Paolo > > > Suggested by: Paolo Bonzini <pbonz...@redhat.com> > > Signed-off-by: Dr. David Alan Gilbert <dgilb...@redhat.com> > > --- > > include/qemu/bitops.h | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h > > index 755fdd1..e411688 100644 > > --- a/include/qemu/bitops.h > > +++ b/include/qemu/bitops.h > > @@ -23,6 +23,9 @@ > > #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) > > #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) > > #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * > > sizeof(long)) > > +/* e.g. BIT_RANGE(15, 0) -> 0xff00 */ > > +#define BIT_RANGE(hb, lb) ((2ull << (hb)) - (1ull << (lb))) > > + > > -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK