From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WujXT-0004rx-76 for qemu-devel@nongnu.org; Wed, 11 Jun 2014 10:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WujXS-0008RX-58 for qemu-devel@nongnu.org; Wed, 11 Jun 2014 10:30:07 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WujXR-0008DN-V8 for qemu-devel@nongnu.org; Wed, 11 Jun 2014 10:30:06 -0400 From: Peter Maydell Date: Wed, 11 Jun 2014 15:29:44 +0100 Message-Id: <1402496993-27206-7-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1402496993-27206-1-git-send-email-peter.maydell@linaro.org> References: <1402496993-27206-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 06/15] vhost: replace ffsl with ctzl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl From: Natanael Copa Avoid using the GNU extesion ffsl which is not implemented in musl libc. The atomic_xchg() means we know that vhost_log_chunk_t will never be larger than the 'long' type, so ctzl() is always sufficient. See also commit fbeadf50 (bitops: unify bitops_ffsl with the one in host-utils.h, call it bitops_ctzl) on why ctzl should be used instead of ffsl. Signed-off-by: Natanael Copa Reviewed-by: Paolo Bonzini Signed-off-by: Peter Maydell --- hw/virtio/vhost.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9e336ad..f62cfaf 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -41,7 +41,6 @@ static void vhost_dev_sync_region(struct vhost_dev *dev, for (;from < to; ++from) { vhost_log_chunk_t log; - int bit; /* We first check with non-atomic: much cheaper, * and we expect non-dirty to be the common case. */ if (!*from) { @@ -51,12 +50,11 @@ static void vhost_dev_sync_region(struct vhost_dev *dev, /* Data must be read atomically. We don't really need barrier semantics * but it's easier to use atomic_* than roll our own. */ log = atomic_xchg(from, 0); - while ((bit = sizeof(log) > sizeof(int) ? - ffsll(log) : ffs(log))) { + while (log) { + int bit = ctzl(log); hwaddr page_addr; hwaddr section_offset; hwaddr mr_offset; - bit -= 1; page_addr = addr + bit * VHOST_LOG_PAGE; section_offset = page_addr - section->offset_within_address_space; mr_offset = section_offset + section->offset_within_region; -- 1.9.2