LCOV - code coverage report
Current view: top level - common - bitops.c (source / functions) Hit Total Coverage
Test: a simple test Lines: 10 10 100.0 %
Date: 2024-06-05 20:10:43 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : /*
       3             :  * Realizations of bit operations.
       4             :  */
       5             : 
       6             : #include "bitops.h"
       7             : #include "defs.h"
       8             : 
       9             : /*
      10             :  * This is a common helper function for find_next_bit and
      11             :  * find_next_zero_bit.  The difference is the "invert" argument, which
      12             :  * is XORed with each fetched word before searching it for one bits.
      13             :  */
      14       19640 : unsigned long _find_next_bit(const unsigned long *addr,
      15             :                 unsigned long nbits, unsigned long start, unsigned long invert)
      16             : {
      17             :         unsigned long tmp;
      18             : 
      19       19640 :         if (!nbits || start >= nbits)
      20             :                 return nbits;
      21             : 
      22       19640 :         tmp = addr[start / BITS_PER_LONG] ^ invert;
      23             : 
      24             :         /* Handle 1st word. */
      25       19640 :         tmp &= BITMAP_FIRST_WORD_MASK(start);
      26       19640 :         start = round_down(start, BITS_PER_LONG);
      27             : 
      28      144794 :         while (!tmp) {
      29      105514 :                 start += BITS_PER_LONG;
      30      105514 :                 if (start >= nbits)
      31             :                         return nbits;
      32             : 
      33      105514 :                 tmp = addr[start / BITS_PER_LONG] ^ invert;
      34             :         }
      35             : 
      36       19640 :         return min(start + __ffs(tmp), nbits);
      37             : }

Generated by: LCOV version 1.13