From patchwork Thu Feb 14 01:47:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 220343 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 85BCA2C0297 for ; Thu, 14 Feb 2013 14:16:39 +1100 (EST) Received: from localhost ([::1]:49804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5nvx-0007MC-TG for incoming@patchwork.ozlabs.org; Wed, 13 Feb 2013 20:48:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5nvb-00075p-5w for qemu-devel@nongnu.org; Wed, 13 Feb 2013 20:48:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U5nvW-0006K1-IU for qemu-devel@nongnu.org; Wed, 13 Feb 2013 20:47:59 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:33472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5nvW-0006Jn-72 for qemu-devel@nongnu.org; Wed, 13 Feb 2013 20:47:54 -0500 Received: by mail-pa0-f53.google.com with SMTP id bg4so1016100pad.26 for ; Wed, 13 Feb 2013 17:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=viZZh5yosKWG6/jaJErDPVvMFtcHwqHqVaoo7A77AJY=; b=DVQVHa5ZcMqHCe8Zo9tgQFewxgC/Qh7E+WWLiCa/dmy3yX9y1wG1R5GSfWoBW1vSZ1 F95l249hB5tWCNRtMBCAhPiBQnHB3jPZQtH5ZDzLcSKD5Kz2eLeHPilvJQxUAfPapu3z tPAvMyEDN5X4WaualBafKLdi1q2bOTZgzoBgiNafAQ6stWWLR0J/ADiOCB2fIu3RI/ZZ KZeoAS/QwDVcaEWkbAvCu34Jk9rC2mNLQZ2xgm1SYz9V+PcrV9xPGTVNfuqaT7BNc8yM iAzwCHnMdvoraDquXXb7nD4OxIDyLXB8BZngnR8x87358uOtwMxSeYsiEbMJa3+hoThv zavw== X-Received: by 10.66.88.37 with SMTP id bd5mr69508072pab.75.1360806473233; Wed, 13 Feb 2013 17:47:53 -0800 (PST) Received: from pebble.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id c3sm44029148pax.9.2013.02.13.17.47.51 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 13 Feb 2013 17:47:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 13 Feb 2013 17:47:36 -0800 Message-Id: <1360806463-23632-4-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1360806463-23632-1-git-send-email-rth@twiddle.net> References: <1360806463-23632-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.53 Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 03/10] hbitmap: Use non-bitops ctzl X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+incoming=patchwork.ozlabs.org@nongnu.org Both uses of ctz have already eliminated zero, and thus the difference in edge conditions between the two routines is irrelevant. Signed-off-by: Richard Henderson Acked-by: Paolo Bonzini --- include/qemu/hbitmap.h | 3 ++- util/hbitmap.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h index 250de03..550d7ce 100644 --- a/include/qemu/hbitmap.h +++ b/include/qemu/hbitmap.h @@ -16,6 +16,7 @@ #include #include #include "bitops.h" +#include "host-utils.h" typedef struct HBitmap HBitmap; typedef struct HBitmapIter HBitmapIter; @@ -170,7 +171,7 @@ static inline int64_t hbitmap_iter_next(HBitmapIter *hbi) /* The next call will resume work from the next bit. */ hbi->cur[HBITMAP_LEVELS - 1] = cur & (cur - 1); - item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + bitops_ctzl(cur); + item = ((uint64_t)hbi->pos << BITS_PER_LEVEL) + ctzl(cur); return item << hbi->granularity; } diff --git a/util/hbitmap.c b/util/hbitmap.c index a0df5d3..d936831 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -126,7 +126,8 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi) * The index of this word's least significant set bit provides * the low-order bits. */ - pos = (pos << BITS_PER_LEVEL) + bitops_ctzl(cur); + assert(cur); + pos = (pos << BITS_PER_LEVEL) + ctzl(cur); hbi->cur[i] = cur & (cur - 1); /* Set up next level for iteration. */