First attempt at moving to XS

This commit is contained in:
Ryan Voots 2017-05-03 20:16:40 -07:00
parent 72e6e79407
commit d411c54886
5 changed files with 46 additions and 1 deletions

22
.gitignore vendored Normal file
View file

@ -0,0 +1,22 @@
/blib/
/.build/
_build/
cover_db/
inc/
Build
!Build/
Build.bat
.last_cover_stats
/Makefile
/Makefile.old
/MANIFEST.bak
/META.yml
/META.json
/MYMETA.*
nytprof.out
/pm_to_blib
*.o
*.bs
/_eumm/
Sys-Linux-Namespace*
test*

View file

@ -1,4 +1,4 @@
name = Sys-Linux-Unshare name = Sys-Linux-Namespace
author = Ryan Voots <simcop2387@simcop2387.info> author = Ryan Voots <simcop2387@simcop2387.info>
license = Perl_5 license = Perl_5
copyright_holder = Ryan Voots copyright_holder = Ryan Voots

View file

@ -1,4 +1,5 @@
package Sys::Linux::Namespace; package Sys::Linux::Namespace;
# ABSTRACT: Sets up linux kernel namespaces
use strict; use strict;
use warnings; use warnings;

View file

@ -6,6 +6,10 @@ use Data::Dumper;
require Exporter; require Exporter;
our @ISA = qw/Exporter/; our @ISA = qw/Exporter/;
require XSLoader;
XSLoader::load();
BEGIN { BEGIN {
# Force reloading of all .ph files # Force reloading of all .ph files
delete $INC{$_} for (grep {/\.ph$/} keys %INC); delete $INC{$_} for (grep {/\.ph$/} keys %INC);

18
unshare.XS Normal file
View file

@ -0,0 +1,18 @@
#define PERL_NO_GET_CONTEXT // we'll define thread context if necessary (faster)
#include "EXTERN.h" // globals/constant import locations
#include "perl.h" // Perl symbols, structures and constants definition
#include "XSUB.h" // xsubpp functions and macros
#include <stdlib.h> // rand()
// additional c code goes here
MODULE = Sys::Linux::Unshare PACKAGE = Sys::Linux::Unshare
PROTOTYPES: ENABLE
# XS code goes here
# XS comments begin with " #" to avoid them being interpreted as pre-processor
# directives
unsigned int
rand()