File Coverage

Twiddling.xs
Criterion Covered Total %
statement 13 13 100.0
branch 4 4 100.0
condition n/a
subroutine n/a
pod n/a
total 17 17 100.0


line stmt bran cond sub pod time code
1             #include "EXTERN.h"
2             #include "perl.h"
3             #include "XSUB.h"
4              
5 9           int count_set_bits(long v) {
6             int c;
7 79 100         for (c = 0; v; c++)
8 70           v &= v - 1;
9 9           return c;
10             }
11              
12 10           long nearest_higher_power_of_2(long v) {
13 10 100         if (v == 0) return 1;
14 6           v--;
15 6           v |= v >> 1;
16 6           v |= v >> 2;
17 6           v |= v >> 4;
18 6           v |= v >> 8;
19 6           v |= v >> 16;
20 6           return v + 1;
21             }
22              
23             MODULE = Bit::Twiddling PACKAGE = Bit::Twiddling
24              
25             PROTOTYPES: DISABLE
26              
27             int
28             count_set_bits (v)
29             long v
30              
31             long
32             nearest_higher_power_of_2 (v)
33             long v