Perl/Base/TimerEventFD.pm

filter: Statementstmt 89.6% 26 / 29 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 86.3% 38 / 44 CC 4 SCAR 7.5
CC
4
Cov
83%
_parse64
4.5
_read
2.0
BEGIN
1.0
CRAP 2.1
« Perl/Constants.pm ↑ Summary Perl.pm »
1 package Linux::Perl::Base::TimerEventFD;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 Linux::Perl::Base::TimerEventFD
11  
12 =head1 DESCRIPTION
13  
14 L<Linux::Perl::timerfd> and L<Linux::Perl::eventfd> require a fair amount of
15 similar logic to implement. This base class contains that logic.
16  
17 =cut
18  
19 8 ▶use parent qw( Linux::Perl::Base::BitsTest );
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 8 ▶use Linux::Perl::Constants::Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 8 ▶use Linux::Perl::Endian;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 8 *_flag_CLOEXEC = \*Linux::Perl::Constants::Fcntl::flag_CLOEXEC;
25 8 *_flag_NONBLOCK = \*Linux::Perl::Constants::Fcntl::flag_NONBLOCK;
26  
27 #----------------------------------------------------------------------
28  
29 =head1 METHODS
30  
31 =head2 I<OBJ>->fileno()
32  
33 Returns the file descriptor number.
34  
35 =cut
36  
37 28 ▶sub fileno { fileno $_[0][0] }
Subroutine fileno: called CC=1 SCAR=0.0
Pod documented
38  
39 #----------------------------------------------------------------------
40  
41 20 ▶sub _read {
Subroutine _read: called CC=2 SCAR=6.9
42 20 ▶ return undef if !sysread $_[0][0], my $buf, 8;
Branch: 1 branch
BranchTrueFalseTotal
unless sysread $_[0][0], my $buf, 8 4 16 20
43  
44 16 return _parse64($buf);
45 }
46  
47 8 my ($big, $low);
48  
49 16 ▶sub _parse64 {
Subroutine _parse64: called CC=3 SCAR=15.0
50 16 my ($buf) = @_;
51  
52 16 ▶ if (__PACKAGE__->_PERL_CAN_64BIT()) {
Branch: 1 branch
BranchTrueFalseTotal
if (__PACKAGE__->_PERL_CAN_64BIT) { } 16 0 16
53 16 $low = unpack('Q', $buf);
54 }
55 else {
56 0 if (Linux::Perl::Endian::SYSTEM_IS_BIG_ENDIAN()) {
57 ($big, $low) = unpack 'NN', $buf;
58 }
59 else {
60 0 ($low, $big) = unpack 'VV', $buf;
61 }
62  
63 #TODO: Need to test what happens on a 32-bit Perl.
64 0 ▶ $big && die "No 64-bit support! (high=$big, low=$low)";
Branch: 1 branch
BranchTrueFalseTotal
$big and die "No 64-bit support! (high=$big, low=$low)" 0 0 0
65 }
66  
67 16 return $low;
68 }
69  
70 8 1;
« Perl/Constants.pm ↑ Summary Perl.pm »