From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDb2R-0006zB-1t for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:25:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDb2L-00010H-Uc for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:25:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58709) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDb2L-000104-Oo for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:25:01 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6733F3B72A for ; Thu, 16 Jun 2016 17:25:01 +0000 (UTC) Date: Thu, 16 Jun 2016 18:24:57 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20160616172457.GA19710@work-vm> References: <1466097133-5489-1-git-send-email-dgilbert@redhat.com> <1466097133-5489-2-git-send-email-dgilbert@redhat.com> <8110e8af-8c2a-48e4-27b9-d111bcf15ad6@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8110e8af-8c2a-48e4-27b9-d111bcf15ad6@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/5] BIT_RANGE convenience macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, aarcange@redhat.com, ehabkost@redhat.com * Paolo Bonzini (pbonzini@redhat.com) wrote: > > > On 16/06/2016 19:12, Dr. David Alan Gilbert (git) wrote: > > From: "Dr. David Alan Gilbert" > > > > 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 > > Signed-off-by: Dr. David Alan Gilbert > > --- > > 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 / dgilbert@redhat.com / Manchester, UK