Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / fs / xfs / xfs_bit.h
blob1a838a076f727830964d442f00f73c4e72ddaf07
1 /*
2 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef __XFS_BIT_H__
19 #define __XFS_BIT_H__
22 * XFS bit manipulation routines.
26 * masks with n high/low bits set, 32-bit values & 64-bit values
28 #define XFS_MASK32HI(n) xfs_mask32hi(n)
29 static inline __uint32_t xfs_mask32hi(int n)
31 return (__uint32_t)-1 << (32 - (n));
33 #define XFS_MASK64HI(n) xfs_mask64hi(n)
34 static inline __uint64_t xfs_mask64hi(int n)
36 return (__uint64_t)-1 << (64 - (n));
38 #define XFS_MASK32LO(n) xfs_mask32lo(n)
39 static inline __uint32_t xfs_mask32lo(int n)
41 return ((__uint32_t)1 << (n)) - 1;
43 #define XFS_MASK64LO(n) xfs_mask64lo(n)
44 static inline __uint64_t xfs_mask64lo(int n)
46 return ((__uint64_t)1 << (n)) - 1;
49 /* Get high bit set out of 32-bit argument, -1 if none set */
50 <<<<<<< HEAD:fs/xfs/xfs_bit.h
51 static inline int xfs_highbit32(__uint32_t v)
53 return fls(v) - 1;
56 /* Get high bit set out of 64-bit argument, -1 if none set */
57 static inline int xfs_highbit64(__uint64_t v)
59 return fls64(v) - 1;
62 /* Get low bit set out of 32-bit argument, -1 if none set */
63 static inline int xfs_lowbit32(__uint32_t v)
65 __uint32_t t = v;
66 return (t) ? find_first_bit((unsigned long *)&t, 32) : -1;
68 =======
69 extern int xfs_highbit32(__uint32_t v);
70 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/xfs/xfs_bit.h
72 /* Get low bit set out of 64-bit argument, -1 if none set */
73 <<<<<<< HEAD:fs/xfs/xfs_bit.h
74 static inline int xfs_lowbit64(__uint64_t v)
76 __uint64_t t = v;
77 return (t) ? find_first_bit((unsigned long *)&t, 64) : -1;
79 =======
80 extern int xfs_lowbit64(__uint64_t v);
82 /* Get high bit set out of 64-bit argument, -1 if none set */
83 extern int xfs_highbit64(__uint64_t);
84 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:fs/xfs/xfs_bit.h
86 /* Return whether bitmap is empty (1 == empty) */
87 extern int xfs_bitmap_empty(uint *map, uint size);
89 /* Count continuous one bits in map starting with start_bit */
90 extern int xfs_contig_bits(uint *map, uint size, uint start_bit);
92 /* Find next set bit in map */
93 extern int xfs_next_bit(uint *map, uint size, uint start_bit);
95 #endif /* __XFS_BIT_H__ */