]> Git Repo - qemu.git/blobdiff - hw/virtio/vhost.c
vhost: replace ffsl with ctzl
[qemu.git] / hw / virtio / vhost.c
index 9e336ad81e3e6fc5fe754d5cc557ccda5f9c8f7e..f62cfaf38ef27e0251fd5a952af120f1f1c81be9 100644 (file)
@@ -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;
This page took 0.034498 seconds and 4 git commands to generate.