engines/filecreate: don't use file hash
[fio.git] / lib / ffz.h
CommitLineData
064c636d
JA
1#ifndef FIO_FFZ_H
2#define FIO_FFZ_H
3
f8582257
JA
4#include <inttypes.h>
5
6static inline int ffs64(uint64_t word)
064c636d 7{
09174445 8 int r = 0;
064c636d 9
0ce8b119
JA
10 if ((word & 0xffffffff) == 0) {
11 r += 32;
12 word >>= 32;
13 }
064c636d
JA
14 if (!(word & 0xffff)) {
15 word >>= 16;
16 r += 16;
17 }
18 if (!(word & 0xff)) {
19 word >>= 8;
20 r += 8;
21 }
22 if (!(word & 0xf)) {
23 word >>= 4;
24 r += 4;
25 }
26 if (!(word & 3)) {
27 word >>= 2;
28 r += 2;
29 }
034ada86 30 if (!(word & 1))
064c636d 31 r += 1;
064c636d
JA
32
33 return r;
34}
35
f8582257
JA
36#ifndef ARCH_HAVE_FFZ
37
0ce8b119 38static inline int ffz(unsigned long bitmask)
064c636d 39{
f8582257
JA
40 return ffs64(~bitmask);
41}
42
43#else
44#define ffz(bitmask) arch_ffz(bitmask)
45#endif
46
47static inline int ffz64(uint64_t bitmask)
48{
49 return ffs64(~bitmask);
064c636d
JA
50}
51
52#endif