Basic XS start

This commit is contained in:
Ryan Voots 2017-05-03 20:49:48 -07:00
parent a30a9fa92a
commit 4c84df8538
5 changed files with 47 additions and 17 deletions

View file

@ -6,8 +6,22 @@ copyright_year = 2017
[@Starter]
revision = 2
installer = ModuleBuildTiny
-remove = GatherDir
-remove = MakeMaker
[Git::GatherDir]
[MakeMaker::Awesome]
; #WriteMakefile_arg = CCFLAGS => `pkg-config --cflags libpng`
header = die 'Unsupported OS' unless $^O eq 'linux';
delimiter = |
WriteMakefile_arg = | XSMULTI => 1
; #footer = |package MY;
; #footer = |sub postamble {
; #footer = | my $self = shift;
; #footer = | return $self->SUPER::postamble . "\n\nfoo: bar\n\t$(CP) bar foo\n";
; #footer = |}
[Git::NextVersion]
[AutoPrereqs]
[Prereqs]
ExtUtils::MakeMaker=7.12

View file

@ -5,12 +5,6 @@ use warnings;
require Exporter;
our @ISA = qw/Exporter/;
BEGIN {
# Force reloading of all .ph files
delete $INC{$_} for (grep {/\.ph$/} keys %INC);
require 'syscall.ph';
}
my @mount_consts = qw/MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_REMOUNT MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_BIND MS_MOVE MS_REC MS_SILENT MS_POSIXACL MS_UNBINDABLE MS_PRIVATE MS_SLAVE MS_SHARED MS_RELATIME MS_KERNMOUNT MS_I_VERSION MS_STRICTATIME MS_LAZYTIME MS_ACTIVE MS_NOUSER/;
our @EXPORT_OK = (@mount_consts, qw/mount/);

23
lib/Sys/Linux/Mount.xs Normal file
View file

@ -0,0 +1,23 @@
#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 <sys/mount.h>
MODULE = Sys::Linux::Mount PACKAGE = Sys::Linux::Mount
PROTOTYPES: ENABLE
# XS code goes here
# XS comments begin with " #" to avoid them being interpreted as pre-processor
# directives
int
_unshare_sys(source, target, filesystem, mount, data)
const char *source
const char *target
const char *filesystem
unsigned long mountflags
const char *data
CODE:
return mount(source, target, filesystem, mount, (const void *) data);

View file

@ -10,12 +10,6 @@ require XSLoader;
XSLoader::load();
BEGIN {
# Force reloading of all .ph files
delete $INC{$_} for (grep {/\.ph$/} keys %INC);
require 'syscall.ph';
}
my @unshare_consts = qw/CSIGNAL CLONE_VM CLONE_FS CLONE_FILES CLONE_SIGHAND CLONE_PTRACE CLONE_VFORK CLONE_PARENT CLONE_THREAD CLONE_NEWNS CLONE_SYSVSEM CLONE_SETTLS CLONE_PARENT_SETTID CLONE_CHILD_CLEARTID CLONE_DETACHED CLONE_UNTRACED CLONE_CHILD_SETTID CLONE_NEWCGROUP CLONE_NEWUTS CLONE_NEWIPC CLONE_NEWUSER CLONE_NEWPID CLONE_NEWNET CLONE_IO/;
our @EXPORT_OK = (@unshare_consts, qw/unshare/);

View file

@ -1,9 +1,10 @@
#define PERL_NO_GET_CONTEXT // we'll define thread context if necessary (faster)
#define _GNU_SOURCE
#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()
#include <sched.h>
// additional c code goes here
MODULE = Sys::Linux::Unshare PACKAGE = Sys::Linux::Unshare
@ -14,5 +15,9 @@ PROTOTYPES: ENABLE
# XS comments begin with " #" to avoid them being interpreted as pre-processor
# directives
unsigned int
rand()
int
_unshare_sys(flags)
int flags
CODE:
return unshare(flags);