File Coverage

blib/lib/Linux/Perl/Base/TimerEventFD.pm
Criterion Covered Total %
statement 22 25 88.0
branch 3 6 50.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 34 40 85.0


line stmt bran cond sub pod time code
1             package Linux::Perl::Base::TimerEventFD;
2              
3 8     8   4056 use strict;
  8         20  
  8         261  
4 8     8   42 use warnings;
  8         17  
  8         238  
5              
6             =encoding utf-8
7              
8             =head1 NAME
9              
10             Linux::Perl::Base::TimerEventFD
11              
12             =head1 DESCRIPTION
13              
14             L and L require a fair amount of
15             similar logic to implement. This base class contains that logic.
16              
17             =cut
18              
19 8     8   43 use parent qw( Linux::Perl::Base::BitsTest );
  8         10  
  8         93  
20              
21 8     8   4233 use Linux::Perl::Constants::Fcntl;
  8         24  
  8         278  
22 8     8   2463 use Linux::Perl::Endian;
  8         52  
  8         2306  
23              
24             *_flag_CLOEXEC = \*Linux::Perl::Constants::Fcntl::flag_CLOEXEC;
25             *_flag_NONBLOCK = \*Linux::Perl::Constants::Fcntl::flag_NONBLOCK;
26              
27             #----------------------------------------------------------------------
28              
29             =head1 METHODS
30              
31             =head2 I->fileno()
32              
33             Returns the file descriptor number.
34              
35             =cut
36              
37 28     28 1 5855 sub fileno { fileno $_[0][0] }
38              
39             #----------------------------------------------------------------------
40              
41             sub _read {
42 20 100   20   1372008 return undef if !sysread $_[0][0], my $buf, 8;
43              
44 16         139 return _parse64($buf);
45             }
46              
47             my ($big, $low);
48              
49             sub _parse64 {
50 16     16   83 my ($buf) = @_;
51              
52 16 50       405 if (__PACKAGE__->_PERL_CAN_64BIT()) {
53 16         96 $low = unpack('Q', $buf);
54             }
55             else {
56 0         0 if (Linux::Perl::Endian::SYSTEM_IS_BIG_ENDIAN()) {
57             ($big, $low) = unpack 'NN', $buf;
58             }
59             else {
60 0         0 ($low, $big) = unpack 'VV', $buf;
61             }
62              
63             #TODO: Need to test what happens on a 32-bit Perl.
64 0 0       0 $big && die "No 64-bit support! (high=$big, low=$low)";
65             }
66              
67 16         200 return $low;
68             }
69              
70             1;