This source file includes following definitions.
- xfs_mask64hi
- xfs_mask32lo
- xfs_mask64lo
- xfs_highbit32
- xfs_highbit64
- xfs_lowbit32
- xfs_lowbit64
1
2
3
4
5
6 #ifndef __XFS_BIT_H__
7 #define __XFS_BIT_H__
8
9
10
11
12
13
14
15
16 static inline uint64_t xfs_mask64hi(int n)
17 {
18 return (uint64_t)-1 << (64 - (n));
19 }
20 static inline uint32_t xfs_mask32lo(int n)
21 {
22 return ((uint32_t)1 << (n)) - 1;
23 }
24 static inline uint64_t xfs_mask64lo(int n)
25 {
26 return ((uint64_t)1 << (n)) - 1;
27 }
28
29
30 static inline int xfs_highbit32(uint32_t v)
31 {
32 return fls(v) - 1;
33 }
34
35
36 static inline int xfs_highbit64(uint64_t v)
37 {
38 return fls64(v) - 1;
39 }
40
41
42 static inline int xfs_lowbit32(uint32_t v)
43 {
44 return ffs(v) - 1;
45 }
46
47
48 static inline int xfs_lowbit64(uint64_t v)
49 {
50 uint32_t w = (uint32_t)v;
51 int n = 0;
52
53 if (w) {
54 n = ffs(w);
55 } else {
56 w = (uint32_t)(v >> 32);
57 if (w) {
58 n = ffs(w);
59 if (n)
60 n += 32;
61 }
62 }
63 return n - 1;
64 }
65
66
67 extern int xfs_bitmap_empty(uint *map, uint size);
68
69
70 extern int xfs_contig_bits(uint *map, uint size, uint start_bit);
71
72
73 extern int xfs_next_bit(uint *map, uint size, uint start_bit);
74
75 #endif