1 #include <linux/bitops.h>
3 #undef find_first_zero_bit
7 __find_first_zero_bit(const unsigned long * addr
, unsigned long size
)
13 * We must test the size in words, not in bits, because
14 * otherwise incoming sizes in the range -63..-1 will not run
15 * any scasq instructions, and then the flags used by the je
16 * instruction will have whatever random value was in place
17 * before. Nobody should call us like that, but
18 * find_next_zero_bit() does when offset and size are at the
19 * same word and it fails to find a zero itself.
28 " xorq -8(%%rdi),%%rax\n"
31 "1: subq %[addr],%%rdi\n"
34 :"=d" (res
), "=&c" (d0
), "=&D" (d1
), "=&a" (d2
)
35 :"0" (0ULL), "1" (size
), "2" (addr
), "3" (-1ULL),
36 [addr
] "S" (addr
) : "memory");
38 * Any register would do for [addr] above, but GCC tends to
39 * prefer rbx over rsi, even though rsi is readily available
40 * and doesn't have to be saved.
46 * find_first_zero_bit - find the first zero bit in a memory region
47 * @addr: The address to start the search at
48 * @size: The maximum size to search
50 * Returns the bit-number of the first zero bit, not the number of the byte
53 long find_first_zero_bit(const unsigned long * addr
, unsigned long size
)
55 return __find_first_zero_bit (addr
, size
);
59 __find_first_bit(const unsigned long * addr
, unsigned long size
)
65 * We must test the size in words, not in bits, because
66 * otherwise incoming sizes in the range -63..-1 will not run
67 * any scasq instructions, and then the flags used by the jz
68 * instruction will have whatever random value was in place
69 * before. Nobody should call us like that, but
70 * find_next_bit() does when offset and size are at the same
71 * word and it fails to find a one itself.
81 " bsfq (%%rdi),%%rax\n"
82 "1: subq %[addr],%%rdi\n"
85 :"=a" (res
), "=&c" (d0
), "=&D" (d1
)
86 :"0" (0ULL), "1" (size
), "2" (addr
),
87 [addr
] "r" (addr
) : "memory");
92 * find_first_bit - find the first set bit in a memory region
93 * @addr: The address to start the search at
94 * @size: The maximum size to search
96 * Returns the bit-number of the first set bit, not the number of the byte
99 long find_first_bit(const unsigned long * addr
, unsigned long size
)
101 return __find_first_bit(addr
,size
);
104 #include <linux/module.h>
106 EXPORT_SYMBOL(find_first_bit
);
107 EXPORT_SYMBOL(find_first_zero_bit
);
This page took 0.051303 seconds and 5 git commands to generate.