#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
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;
}
/**