line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Linux::Perl; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Linux::Perl - Linux system calls with pure Perl |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $efd = Linux::Perl::eventfd->new(); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#...or, if you know your architecture: |
14
|
|
|
|
|
|
|
my $efd = Linux::Perl::eventfd::x86_64->new(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
In memory-sensitive environments it is useful to minimize the number |
19
|
|
|
|
|
|
|
of XS modules that Perl loads. Oftentimes the CPAN modules that implement |
20
|
|
|
|
|
|
|
support for various Linux system calls, though, will bring in XS for the |
21
|
|
|
|
|
|
|
sake of writing platform-neutral code. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Linux::Perl accommodates use cases where platform neutrality is less of |
24
|
|
|
|
|
|
|
a concern than minimizing memory usage. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 MODULES |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Each family of system calls lives in its own namespace under C: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item * L |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item * L |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item * L |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item * L |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * L |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * L |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item * L |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=back |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The distribution contains a number of other modules, none of which is |
49
|
|
|
|
|
|
|
intended for outside use. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 PLATFORM-SPECIFIC INVOCATION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Each Linux::Perl system call implementation can be called with a |
54
|
|
|
|
|
|
|
platform-neutral syntax as well as with a platform-specific one: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $efd = Linux::Perl::eventfd->new(); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $efd = Linux::Perl::eventfd::x86_64->new(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The platform-specific call is a bit lighter because it avoids loading |
61
|
|
|
|
|
|
|
L to determine the current platform. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 PLATFORM SUPPORT |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The following platforms are supported: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * x86_64 (i.e., 64-bit Intel/AMD) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * arm (e.g., Raspberry Pi) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Note that a 64-bit Perl is assumed/required. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Support for adding new platforms just involves adding new modules with the |
78
|
|
|
|
|
|
|
necessary constants to the distribution. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
18
|
|
|
18
|
|
126
|
use strict; |
|
18
|
|
|
|
|
35
|
|
|
18
|
|
|
|
|
542
|
|
83
|
18
|
|
|
18
|
|
93
|
use warnings; |
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
433
|
|
84
|
|
|
|
|
|
|
|
85
|
18
|
|
|
18
|
|
7732
|
use Linux::Perl::X (); |
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
2073
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub call { |
90
|
113
|
|
|
113
|
0
|
692
|
local $!; |
91
|
113
|
|
|
|
|
944730
|
my $ok = syscall(0 + $_[0], @_[1 .. $#_]); |
92
|
113
|
50
|
|
|
|
788
|
if ($ok == -1) { |
93
|
0
|
|
|
|
|
0
|
die Linux::Perl::X->create('Call', $_[0], $!); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
113
|
|
|
|
|
915
|
return $ok; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 REPOSITORY |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Felipe Gasper (FELIPE) |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright 2018 by L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 LICENSE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This distribution is released under the same license as Perl. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |