| 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<Linux::Perl>: | ||||||||||
| 29 | |||||||||||
| 30 | =over | ||||||||||
| 31 | |||||||||||
| 32 | =item * L<Linux::Perl::eventfd> | ||||||||||
| 33 | |||||||||||
| 34 | =item * L<Linux::Perl::aio> | ||||||||||
| 35 | |||||||||||
| 36 | =item * L<Linux::Perl::uname> | ||||||||||
| 37 | |||||||||||
| 38 | =back | ||||||||||
| 39 | |||||||||||
| 40 | The distribution contains a number of other modules, none of which is | ||||||||||
| 41 | intended for outside use. | ||||||||||
| 42 | |||||||||||
| 43 | =head1 PLATFORM-SPECIFIC INVOCATION | ||||||||||
| 44 | |||||||||||
| 45 | Each Linux::Perl system call implementation can be called with a | ||||||||||
| 46 | platform-neutral syntax as well as with a platform-specific one: | ||||||||||
| 47 | |||||||||||
| 48 | my $efd = Linux::Perl::eventfd->new(); | ||||||||||
| 49 | |||||||||||
| 50 | my $efd = Linux::Perl::eventfd::x86_64->new(); | ||||||||||
| 51 | |||||||||||
| 52 | The platform-specific call is a bit lighter because it avoids loading | ||||||||||
| 53 | L<Config> to determine the current platform. | ||||||||||
| 54 | |||||||||||
| 55 | =head1 PLATFORM SUPPORT | ||||||||||
| 56 | |||||||||||
| 57 | The following platforms are supported: | ||||||||||
| 58 | |||||||||||
| 59 | =over | ||||||||||
| 60 | |||||||||||
| 61 | =item * x86_64 (i.e., 64-bit Intel/AMD) | ||||||||||
| 62 | |||||||||||
| 63 | This is probably the only platform that will foreseeably receive substantial | ||||||||||
| 64 | testing during development. | ||||||||||
| 65 | |||||||||||
| 66 | =item * i386 (32-bit Intel/AMD) | ||||||||||
| 67 | |||||||||||
| 68 | =back | ||||||||||
| 69 | |||||||||||
| 70 | Support for adding new platforms is usually trivial; just send a pull request. | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 75 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 76 | |||||||||||
| 77 | 8 | ▶ | use Linux::Perl::X (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 78 | |||||||||||
| 79 | 8 | our $VERSION = '0.01-TRIAL4'; | |||||||||
| 80 | |||||||||||
| 81 | sub call { | ||||||||||
| 82 | 40 | ▶ | local $!; | ||||||||
|
Subroutine
call: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||
| 83 | 40 | my $ok = syscall(0 + $_[0], @_[1 .. $#_]); | |||||||||
| 84 | 40 | ▶ | if ($ok == -1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 0 | die Linux::Perl::X->create('Call', $_[0], $!); | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 40 | return $ok; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | =head1 REPOSITORY | ||||||||||
| 92 | |||||||||||
| 93 | L<https://github.com/FGasper/p5-Linux-Perl> | ||||||||||
| 94 | |||||||||||
| 95 | =head1 AUTHOR | ||||||||||
| 96 | |||||||||||
| 97 | Felipe Gasper (FELIPE) | ||||||||||
| 98 | |||||||||||
| 99 | =head1 COPYRIGHT | ||||||||||
| 100 | |||||||||||
| 101 | Copyright 2018 by L<Gasper Software Consulting|http://gaspersoftware.com> | ||||||||||
| 102 | |||||||||||
| 103 | =head1 LICENSE | ||||||||||
| 104 | |||||||||||
| 105 | This distribution is released under the same license as Perl. | ||||||||||
| 106 | |||||||||||
| 107 | =cut | ||||||||||
| 108 | |||||||||||
| 109 | 8 | 1; | |||||||||