From patchwork Thu Jun 16 17:12:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 636602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rVrYz1dfwz9sxR for ; Fri, 17 Jun 2016 03:52:23 +1000 (AEST) Received: from localhost ([::1]:51338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDbSn-0001Xt-39 for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2016 13:52:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDaq2-0000pc-Pz for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:12:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDaq0-0006Iv-TI for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:12:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDaq0-0006Io-Nq for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:12:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 5FE78627FA for ; Thu, 16 Jun 2016 17:12:16 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-110.ams2.redhat.com [10.36.116.110]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5GHCDBK024583; Thu, 16 Jun 2016 13:12:15 -0400 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, pbonzini@redhat.com, aarcange@redhat.com, ehabkost@redhat.com Date: Thu, 16 Jun 2016 18:12:09 +0100 Message-Id: <1466097133-5489-2-git-send-email-dgilbert@redhat.com> In-Reply-To: <1466097133-5489-1-git-send-email-dgilbert@redhat.com> References: <1466097133-5489-1-git-send-email-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 16 Jun 2016 17:12:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/5] BIT_RANGE convenience macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Dr. David Alan Gilbert" e.g. BIT_RANGE(15, 0) gives 0xff00 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))) + /** * set_bit - Set a bit in memory