line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bit::Manip; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
23566
|
use warnings; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
273
|
|
4
|
9
|
|
|
9
|
|
35
|
use strict; |
|
9
|
|
|
|
|
12
|
|
|
9
|
|
|
|
|
524
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require XSLoader; |
9
|
|
|
|
|
|
|
XSLoader::load('Bit::Manip', $VERSION); |
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
9
|
|
37
|
use Exporter qw(import); |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
3520
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
14
|
|
|
|
|
|
|
bit_bin |
15
|
|
|
|
|
|
|
bit_count |
16
|
|
|
|
|
|
|
bit_mask |
17
|
|
|
|
|
|
|
bit_get |
18
|
|
|
|
|
|
|
bit_set |
19
|
|
|
|
|
|
|
bit_toggle |
20
|
|
|
|
|
|
|
bit_on |
21
|
|
|
|
|
|
|
bit_off |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our %EXPORT_TAGS; |
25
|
|
|
|
|
|
|
$EXPORT_TAGS{all} = [@EXPORT_OK]; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub bit_bin { |
28
|
1024
|
|
|
1024
|
1
|
229299
|
my ($data) = @_; |
29
|
1024
|
|
|
|
|
4413
|
return sprintf("%b", $data); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
sub bit_count { |
32
|
49
|
|
|
49
|
1
|
715
|
my ($n, $set) = @_; |
33
|
|
|
|
|
|
|
|
34
|
49
|
100
|
66
|
|
|
348
|
if (! defined $n || $n !~ /^\d+/){ |
35
|
2
|
|
|
|
|
22
|
die "bit_count() requires an integer param\n"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
47
|
100
|
|
|
|
95
|
$set = 0 if ! defined $set; |
39
|
|
|
|
|
|
|
|
40
|
47
|
|
|
|
|
249
|
return _bit_count($n, $set); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
sub bit_mask { |
43
|
16
|
|
|
16
|
1
|
47
|
my ($bits, $lsb) = @_; |
44
|
16
|
|
|
|
|
117
|
return _bit_mask($bits, $lsb); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
sub bit_get { |
47
|
20
|
|
|
20
|
1
|
7774
|
my ($data, $msb, $lsb) = @_; |
48
|
|
|
|
|
|
|
|
49
|
20
|
100
|
|
|
|
41
|
$lsb = 0 if ! defined $lsb; |
50
|
|
|
|
|
|
|
|
51
|
20
|
|
|
|
|
87
|
_bit_get($data, $msb, $lsb); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
sub bit_set { |
54
|
34
|
|
|
34
|
1
|
19083
|
my ($data, $lsb, $bits, $value) = @_; |
55
|
34
|
|
|
|
|
235
|
return _bit_set($data, $lsb, $bits, $value); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
sub bit_toggle { |
58
|
48
|
|
|
48
|
1
|
16662
|
my ($data, $bit) = @_; |
59
|
48
|
|
|
|
|
104
|
return _bit_toggle($data, $bit); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
sub bit_on { |
62
|
24
|
|
|
24
|
1
|
5828
|
my ($data, $bit) = @_; |
63
|
24
|
|
|
|
|
54
|
return _bit_toggle($data, $bit); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
sub bit_off { |
66
|
24
|
|
|
24
|
1
|
8352
|
my ($data, $bit) = @_; |
67
|
24
|
|
|
|
|
57
|
return _bit_toggle($data, $bit); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
0
|
|
|
sub _vim{}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |