~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/xfs/libxfs/xfs_bit.h

Version: ~ [ linux-5.5-rc1 ] ~ [ linux-5.4.2 ] ~ [ linux-5.3.15 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.88 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.158 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.206 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.206 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.78 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  3  * All Rights Reserved.
  4  *
  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.
  8  *
  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.
 13  *
 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
 17  */
 18 #ifndef __XFS_BIT_H__
 19 #define __XFS_BIT_H__
 20 
 21 /*
 22  * XFS bit manipulation routines.
 23  */
 24 
 25 /*
 26  * masks with n high/low bits set, 64-bit values
 27  */
 28 static inline __uint64_t xfs_mask64hi(int n)
 29 {
 30         return (__uint64_t)-1 << (64 - (n));
 31 }
 32 static inline __uint32_t xfs_mask32lo(int n)
 33 {
 34         return ((__uint32_t)1 << (n)) - 1;
 35 }
 36 static inline __uint64_t xfs_mask64lo(int n)
 37 {
 38         return ((__uint64_t)1 << (n)) - 1;
 39 }
 40 
 41 /* Get high bit set out of 32-bit argument, -1 if none set */
 42 static inline int xfs_highbit32(__uint32_t v)
 43 {
 44         return fls(v) - 1;
 45 }
 46 
 47 /* Get high bit set out of 64-bit argument, -1 if none set */
 48 static inline int xfs_highbit64(__uint64_t v)
 49 {
 50         return fls64(v) - 1;
 51 }
 52 
 53 /* Get low bit set out of 32-bit argument, -1 if none set */
 54 static inline int xfs_lowbit32(__uint32_t v)
 55 {
 56         return ffs(v) - 1;
 57 }
 58 
 59 /* Get low bit set out of 64-bit argument, -1 if none set */
 60 static inline int xfs_lowbit64(__uint64_t v)
 61 {
 62         __uint32_t      w = (__uint32_t)v;
 63         int             n = 0;
 64 
 65         if (w) {        /* lower bits */
 66                 n = ffs(w);
 67         } else {        /* upper bits */
 68                 w = (__uint32_t)(v >> 32);
 69                 if (w) {
 70                         n = ffs(w);
 71                         if (n)
 72                                 n += 32;
 73                 }
 74         }
 75         return n - 1;
 76 }
 77 
 78 /* Return whether bitmap is empty (1 == empty) */
 79 extern int xfs_bitmap_empty(uint *map, uint size);
 80 
 81 /* Count continuous one bits in map starting with start_bit */
 82 extern int xfs_contig_bits(uint *map, uint size, uint start_bit);
 83 
 84 /* Find next set bit in map */
 85 extern int xfs_next_bit(uint *map, uint size, uint start_bit);
 86 
 87 #endif  /* __XFS_BIT_H__ */
 88 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp