Clear f on error get_next_file_rr()
[fio.git] / lib / ffz.h
1 #ifndef FIO_FFZ_H
2 #define FIO_FFZ_H
3
4 static inline int __ffs(int word)
5 {
6         int r = 0;
7
8         if (!(word & 0xffff)) {
9                 word >>= 16;
10                 r += 16;
11         }
12         if (!(word & 0xff)) {
13                 word >>= 8;
14                 r += 8;
15         }
16         if (!(word & 0xf)) {
17                 word >>= 4;
18                 r += 4;
19         }
20         if (!(word & 3)) {
21                 word >>= 2;
22                 r += 2;
23         }
24         if (!(word & 1)) {
25                 word >>= 1;
26                 r += 1;
27         }
28
29         return r;
30 }
31
32 static inline int ffz(unsigned int bitmask)
33 {
34         return __ffs(~bitmask);
35 }
36
37 #endif