]> Git Repo - qemu.git/blobdiff - include/qemu/bitops.h
qemu-timer: add timer_init and timer_init_ns/us/ms
[qemu.git] / include / qemu / bitops.h
index 340b1e73bd95391c32a6e1d6bb9b10b3ab65cd27..181bd460630d89504519db749354fdc326008b79 100644 (file)
@@ -12,7 +12,9 @@
 #ifndef BITOPS_H
 #define BITOPS_H
 
-#include "qemu-common.h"
+#include <stdint.h>
+#include <assert.h>
+
 #include "host-utils.h"
 
 #define BITS_PER_BYTE           CHAR_BIT
@@ -157,7 +159,17 @@ unsigned long find_next_zero_bit(const unsigned long *addr,
 static inline unsigned long find_first_bit(const unsigned long *addr,
                                            unsigned long size)
 {
-    return find_next_bit(addr, size, 0);
+    unsigned long result, tmp;
+
+    for (result = 0; result < size; result += BITS_PER_LONG) {
+        tmp = *addr++;
+        if (tmp) {
+            result += ctzl(tmp);
+            return result < size ? result : size;
+        }
+    }
+    /* Not found */
+    return size;
 }
 
 /**
This page took 0.022445 seconds and 4 git commands to generate.