From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDb0f-0005Pi-PA for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:23:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDb0b-0000bf-Ky for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:23:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDb0b-0000bZ-Fu for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:23:13 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 0A79DC05B1DE for ; Thu, 16 Jun 2016 17:23:13 +0000 (UTC) References: <1466097133-5489-1-git-send-email-dgilbert@redhat.com> <1466097133-5489-2-git-send-email-dgilbert@redhat.com> From: Paolo Bonzini Message-ID: <8110e8af-8c2a-48e4-27b9-d111bcf15ad6@redhat.com> Date: Thu, 16 Jun 2016 19:23:09 +0200 MIME-Version: 1.0 In-Reply-To: <1466097133-5489-2-git-send-email-dgilbert@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/5] BIT_RANGE convenience macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" , qemu-devel@nongnu.org, aarcange@redhat.com, ehabkost@redhat.com 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). :) 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))) > + >