From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>
Subject: [Qemu-devel] [PULL 06/15] vhost: replace ffsl with ctzl
Date: Wed, 11 Jun 2014 15:29:44 +0100 [thread overview]
Message-ID: <1402496993-27206-7-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1402496993-27206-1-git-send-email-peter.maydell@linaro.org>
From: Natanael Copa <ncopa@alpinelinux.org>
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 <ncopa@alpinelinux.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
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
next prev parent reply other threads:[~2014-06-11 14:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 14:29 [Qemu-devel] [PULL 00/15] bsd-user queue Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 01/15] bsd-user: refresh freebsd system call numbers Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 02/15] util/hbitmap.c: Use ctpopl rather than reimplementing a local equivalent Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 03/15] bsd-user/mmap.c: Don't try to override g_malloc/g_free Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 04/15] util/qemu-openpty: fix build with musl libc by include termios.h as fallback Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 05/15] xen: replace ffsl with ctzl Peter Maydell
2014-06-11 14:29 ` Peter Maydell [this message]
2014-06-11 14:29 ` [Qemu-devel] [PULL 07/15] exec: " Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 08/15] bsd-user: add HOST_VARIANT_DIR for various *BSD dependent code Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 09/15] bsd-user: GPL v2 attribution update and style Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 10/15] bsd-user: Implement strace support for print_sysctl syscall Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 11/15] bsd-user: Implement strace support for print_ioctl syscall Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 12/15] bsd-user: Implement strace support for __acl_* syscalls Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 13/15] bsd-user: Implement strace support for extattr_* syscalls Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 14/15] bsd-user: Implement strace support for thr_* syscalls Peter Maydell
2014-06-11 14:29 ` [Qemu-devel] [PULL 15/15] bsd-user: Fix syscall format, add strace support for more syscalls Peter Maydell
2014-06-11 20:33 ` [Qemu-devel] [PULL 00/15] bsd-user queue Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402496993-27206-7-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).