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

TOMOYO Linux Cross Reference
Linux/arch/s390/lib/find.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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  * MSB0 numbered special bitops handling.
  4  *
  5  * The bits are numbered:
  6  *   |0..............63|64............127|128...........191|192...........255|
  7  *
  8  * The reason for this bit numbering is the fact that the hardware sets bits
  9  * in a bitmap starting at bit 0 (MSB) and we don't want to scan the bitmap
 10  * from the 'wrong end'.
 11  */
 12 
 13 #include <linux/compiler.h>
 14 #include <linux/bitops.h>
 15 #include <linux/export.h>
 16 
 17 unsigned long find_first_bit_inv(const unsigned long *addr, unsigned long size)
 18 {
 19         const unsigned long *p = addr;
 20         unsigned long result = 0;
 21         unsigned long tmp;
 22 
 23         while (size & ~(BITS_PER_LONG - 1)) {
 24                 if ((tmp = *(p++)))
 25                         goto found;
 26                 result += BITS_PER_LONG;
 27                 size -= BITS_PER_LONG;
 28         }
 29         if (!size)
 30                 return result;
 31         tmp = (*p) & (~0UL << (BITS_PER_LONG - size));
 32         if (!tmp)               /* Are any bits set? */
 33                 return result + size;   /* Nope. */
 34 found:
 35         return result + (__fls(tmp) ^ (BITS_PER_LONG - 1));
 36 }
 37 EXPORT_SYMBOL(find_first_bit_inv);
 38 
 39 unsigned long find_next_bit_inv(const unsigned long *addr, unsigned long size,
 40                                 unsigned long offset)
 41 {
 42         const unsigned long *p = addr + (offset / BITS_PER_LONG);
 43         unsigned long result = offset & ~(BITS_PER_LONG - 1);
 44         unsigned long tmp;
 45 
 46         if (offset >= size)
 47                 return size;
 48         size -= result;
 49         offset %= BITS_PER_LONG;
 50         if (offset) {
 51                 tmp = *(p++);
 52                 tmp &= (~0UL >> offset);
 53                 if (size < BITS_PER_LONG)
 54                         goto found_first;
 55                 if (tmp)
 56                         goto found_middle;
 57                 size -= BITS_PER_LONG;
 58                 result += BITS_PER_LONG;
 59         }
 60         while (size & ~(BITS_PER_LONG-1)) {
 61                 if ((tmp = *(p++)))
 62                         goto found_middle;
 63                 result += BITS_PER_LONG;
 64                 size -= BITS_PER_LONG;
 65         }
 66         if (!size)
 67                 return result;
 68         tmp = *p;
 69 found_first:
 70         tmp &= (~0UL << (BITS_PER_LONG - size));
 71         if (!tmp)               /* Are any bits set? */
 72                 return result + size;   /* Nope. */
 73 found_middle:
 74         return result + (__fls(tmp) ^ (BITS_PER_LONG - 1));
 75 }
 76 EXPORT_SYMBOL(find_next_bit_inv);
 77 

~ [ 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