1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
10 * XFS bit manipulation routines.
14 * masks with n high/low bits set, 64-bit values
16 static inline uint64_t xfs_mask64hi(int n
)
18 return (uint64_t)-1 << (64 - (n
));
20 static inline uint32_t xfs_mask32lo(int n
)
22 return ((uint32_t)1 << (n
)) - 1;
24 static inline uint64_t xfs_mask64lo(int n
)
26 return ((uint64_t)1 << (n
)) - 1;
29 /* Get high bit set out of 32-bit argument, -1 if none set */
30 static inline int xfs_highbit32(uint32_t v
)
35 /* Get high bit set out of 64-bit argument, -1 if none set */
36 static inline int xfs_highbit64(uint64_t v
)
41 /* Get low bit set out of 32-bit argument, -1 if none set */
42 static inline int xfs_lowbit32(uint32_t v
)
47 /* Get low bit set out of 64-bit argument, -1 if none set */
48 static inline int xfs_lowbit64(uint64_t v
)
50 uint32_t w
= (uint32_t)v
;
53 if (w
) { /* lower bits */
55 } else { /* upper bits */
56 w
= (uint32_t)(v
>> 32);
66 /* Return whether bitmap is empty (1 == empty) */
67 extern int xfs_bitmap_empty(uint
*map
, uint size
);
69 /* Count continuous one bits in map starting with start_bit */
70 extern int xfs_contig_bits(uint
*map
, uint size
, uint start_bit
);
72 /* Find next set bit in map */
73 extern int xfs_next_bit(uint
*map
, uint size
, uint start_bit
);
75 #endif /* __XFS_BIT_H__ */