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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  4  * All Rights Reserved.
  5  */
  6 #ifndef __XFS_BIT_H__
  7 #define __XFS_BIT_H__
  8 
  9 /*
 10  * XFS bit manipulation routines.
 11  */
 12 
 13 /*
 14  * masks with n high/low bits set, 64-bit values
 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 /* Get high bit set out of 32-bit argument, -1 if none set */
 30 static inline int xfs_highbit32(uint32_t v)
 31 {
 32         return fls(v) - 1;
 33 }
 34 
 35 /* Get high bit set out of 64-bit argument, -1 if none set */
 36 static inline int xfs_highbit64(uint64_t v)
 37 {
 38         return fls64(v) - 1;
 39 }
 40 
 41 /* Get low bit set out of 32-bit argument, -1 if none set */
 42 static inline int xfs_lowbit32(uint32_t v)
 43 {
 44         return ffs(v) - 1;
 45 }
 46 
 47 /* Get low bit set out of 64-bit argument, -1 if none set */
 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) {        /* lower bits */
 54                 n = ffs(w);
 55         } else {        /* upper bits */
 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 /* Return whether bitmap is empty (1 == empty) */
 67 extern int xfs_bitmap_empty(uint *map, uint size);
 68 
 69 /* Count continuous one bits in map starting with start_bit */
 70 extern int xfs_contig_bits(uint *map, uint size, uint start_bit);
 71 
 72 /* Find next set bit in map */
 73 extern int xfs_next_bit(uint *map, uint size, uint start_bit);
 74 
 75 #endif  /* __XFS_BIT_H__ */
 76 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php