| 1 | package Linux::Perl::signalfd; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | ▶ | use parent qw( Linux::Perl::Base::BitsTest ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use Linux::Perl; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use Linux::Perl::EasyPack; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 3 | ▶ | use Linux::Perl::ParseFlags; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 3 | ▶ | use Linux::Perl::SigSet; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 3 | ▶ | use Linux::Perl::Constants::Fcntl; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 3 | *_flag_CLOEXEC = \*Linux::Perl::Constants::Fcntl::flag_CLOEXEC; | |||||||||||||||||||
| 15 | 3 | *_flag_NONBLOCK = \*Linux::Perl::Constants::Fcntl::flag_NONBLOCK; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 3 | ▶ | use constant _sfd_siginfo_size => 128; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | sub new { | ||||||||||||||||||||
| 22 | 2 | ▶ | my ($class, %opts) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 2 | ▶ | my $arch_module = $class->can('NR_signalfd') && $class; | ||||||||||||||||||
|
Condition66%2/3
$class->can('NR_signalfd') && $class
MC/DC50%1/2
$class->can('NR_signalfd') && $class
$class->can('NR_signalfd')
$class
Truth table66%2/3
A && B
A= $class->can('NR_signalfd')B= $class
| |||||||||||||||||||||
| 25 | 2 | ▶ | $arch_module ||= do { | ||||||||||||||||||
|
Condition66%2/3
$arch_module ||= do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
MC/DC0%0/2
$arch_module ||= do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
$arch_module
do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
Truth table66%2/3
A ||= B
A= $arch_moduleB= do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
| |||||||||||||||||||||
| 26 | 1 | require Linux::Perl::ArchLoader; | |||||||||||||||||||
| 27 | 1 | Linux::Perl::ArchLoader::get_arch_module($class); | |||||||||||||||||||
| 28 | }; | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 2 | my $flags = Linux::Perl::ParseFlags::parse( $class, $opts{'flags'} ); | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 2 | my $fd = _call_signalfd( $arch_module, -1, $flags, $opts{'signals'} ); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 2 | ▶ | local $^F = 1000 if $flags & _flag_CLOEXEC(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 2 | open my $fh, '+<&=', $fd; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 2 | return bless [$fd, $fh], $arch_module; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub fileno { return $_[0][0]; } | ||||||||||||||||||
|
Subroutine
fileno: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 3 | my ($sfd_siginfo_keys_ar, $sfd_siginfo_pack); | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | BEGIN { | ||||||||||||||||||||
| 50 | 3 | ▶ | ($sfd_siginfo_keys_ar, $sfd_siginfo_pack) = Linux::Perl::EasyPack::split_pack_list( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 51 | signo => 'L', | ||||||||||||||||||||
| 52 | errno => 'l', | ||||||||||||||||||||
| 53 | code => 'l', | ||||||||||||||||||||
| 54 | pid => 'L', | ||||||||||||||||||||
| 55 | uid => 'L', | ||||||||||||||||||||
| 56 | fd => 'l', | ||||||||||||||||||||
| 57 | tid => 'L', | ||||||||||||||||||||
| 58 | band => 'L', | ||||||||||||||||||||
| 59 | overrun => 'L', | ||||||||||||||||||||
| 60 | trapno => 'L', | ||||||||||||||||||||
| 61 | status => 'l', | ||||||||||||||||||||
| 62 | int => 'l', | ||||||||||||||||||||
| 63 | ptr => __PACKAGE__->_PACK_u64(), | ||||||||||||||||||||
| 64 | utime => __PACKAGE__->_PACK_u64(), | ||||||||||||||||||||
| 65 | stime => __PACKAGE__->_PACK_u64(), | ||||||||||||||||||||
| 66 | addr => __PACKAGE__->_PACK_u64(), | ||||||||||||||||||||
| 67 | addr_lsb => 'S', | ||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | sub read { | ||||||||||||||||||||
| 72 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
read: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 4 | ▶ | return undef if !sysread( $self->[1], my $buf, _sfd_siginfo_size() ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 4 | my %result; | |||||||||||||||||||
| 77 | 4 | @result{ @$sfd_siginfo_keys_ar } = unpack $sfd_siginfo_pack, $buf; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 4 | return \%result; | |||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | sub set_signals { | ||||||||||||||||||||
| 85 | 2 | ▶ | my ($self, @signals) = @_; | ||||||||||||||||||
|
Subroutine
set_signals: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 2 | _call_signalfd( | |||||||||||||||||||
| 88 | $self, | ||||||||||||||||||||
| 89 | $self->[0], | ||||||||||||||||||||
| 90 | 0, | ||||||||||||||||||||
| 91 | \@signals, | ||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 2 | return $self; | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | sub _call_signalfd { | ||||||||||||||||||||
| 98 | 4 | ▶ | my ($arch_module, $fd, $flags, $signals_ar) = @_; | ||||||||||||||||||
|
Subroutine
_call_signalfd: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 4 | my $sigmask = Linux::Perl::SigSet::from_list( @$signals_ar ); | |||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 4 | my $call_name = 'NR_signalfd'; | |||||||||||||||||||
| 103 | 4 | ▶ | $call_name .= '4' if $flags; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 4 | $fd = Linux::Perl::call( | |||||||||||||||||||
| 106 | $arch_module->$call_name(), | ||||||||||||||||||||
| 107 | $fd, | ||||||||||||||||||||
| 108 | $sigmask, | ||||||||||||||||||||
| 109 | length $sigmask, | ||||||||||||||||||||
| 110 | 0 + $flags, | ||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | 4 | return $fd; | |||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 3 | 1; | |||||||||||||||||||