LCOV - code coverage report
Current view: top level - /home/runner/zephyrproject/zephyr/lib/utils - bitmask.c (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 30 0
Test Date: 2026-03-12 12:01:18 Functions: 0.0 % 1 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0.0 % 12 0

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  * Copyright (c) 2025 Nordic Semiconductor ASA
       3                 :             :  *
       4                 :             :  * SPDX-License-Identifier: Apache-2.0
       5                 :             :  */
       6                 :             : #include <zephyr/sys/util.h>
       7                 :             : #include <zephyr/sys/math_extras.h>
       8                 :             : 
       9                 :           0 : int bitmask_find_gap(uint32_t mask, size_t num_bits, size_t total_bits, bool first_match)
      10                 :             : {
      11                 :           0 :         uint32_t max = UINT32_MAX;
      12                 :           0 :         int max_loc = -1;
      13                 :             : 
      14         [ #  # ]:           0 :         if (total_bits < 32) {
      15                 :           0 :                 mask |= ~BIT_MASK(total_bits);
      16                 :             :         }
      17                 :             : 
      18                 :           0 :         mask = ~mask;
      19         [ #  # ]:           0 :         while (mask != 0U) {
      20                 :           0 :                 uint32_t block_size;
      21                 :           0 :                 uint32_t loc;
      22                 :           0 :                 int nidx;
      23                 :           0 :                 uint32_t idx = 31 - u32_count_leading_zeros(mask);
      24                 :           0 :                 uint32_t rmask = ~BIT_MASK(idx);
      25                 :             : 
      26                 :           0 :                 rmask |= mask;
      27                 :           0 :                 rmask = ~rmask;
      28         [ #  # ]:           0 :                 if (rmask != 0U) {
      29                 :           0 :                         nidx = 31 - u32_count_leading_zeros(rmask);
      30                 :           0 :                         block_size = idx - nidx;
      31                 :           0 :                         loc = nidx + 1;
      32                 :           0 :                         mask &= BIT_MASK(nidx);
      33                 :             :                 } else {
      34                 :           0 :                         mask = 0;
      35                 :           0 :                         block_size = idx + 1;
      36                 :           0 :                         loc = 0;
      37                 :             :                 }
      38                 :             : 
      39   [ #  #  #  # ]:           0 :                 if ((block_size == num_bits) || (first_match && block_size > num_bits)) {
      40                 :           0 :                         max_loc = loc;
      41                 :           0 :                         max = block_size;
      42                 :           0 :                         break;
      43         [ #  # ]:           0 :                 } else if (block_size >= num_bits && block_size < max) {
      44                 :           0 :                         max_loc = loc;
      45                 :           0 :                         max = block_size;
      46                 :             :                 }
      47                 :             :         }
      48                 :             : 
      49                 :           0 :         return max_loc;
      50                 :             : }
        

Generated by: LCOV version 2.0-1