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   3329 use strict;
  8         16  
  8         531  
4 8     8   45 use warnings;
  8         16  
  8         209  
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   33 use parent qw( Linux::Perl::Base::BitsTest );
  8         12  
  8         46  
20              
21 8     8   3836 use Linux::Perl::Constants::Fcntl;
  8         17  
  8         201  
22 8     8   1951 use Linux::Perl::Endian;
  8         16  
  8         2277  
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 4869 sub fileno { fileno $_[0][0] }
38              
39             #----------------------------------------------------------------------
40              
41             sub _read {
42 20 100   20   1378600 return undef if !sysread $_[0][0], my $buf, 8;
43              
44 16         87 return _parse64($buf);
45             }
46              
47             my ($big, $low);
48              
49             sub _parse64 {
50 16     16   49 my ($buf) = @_;
51              
52 16 50       295 if (__PACKAGE__->_PERL_CAN_64BIT()) {
53 16         67 $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         124 return $low;
68             }
69              
70             1;