From 0b017e2e482c31380c1e53bf0cabd62b8ad0448c Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Sun, 25 Feb 2007 23:39:11 +0100 Subject: [PATCH] added a perl module for fcntl locking --- lib/perl/Filelock/Filelock.pm | 44 +++++++++++++++++++++++++++++++++++ lib/perl/Filelock/Filelock.xs | 30 ++++++++++++++++++++++++ lib/perl/Filelock/MANIFEST | 10 ++++++++ lib/perl/Filelock/Makefile | 26 +++++++++++++++++++++ lib/perl/Filelock/Makefile.PL | 9 +++++++ lib/perl/Makefile | 4 ++++ 6 files changed, 123 insertions(+) create mode 100644 lib/perl/Filelock/Filelock.pm create mode 100644 lib/perl/Filelock/Filelock.xs create mode 100644 lib/perl/Filelock/MANIFEST create mode 100644 lib/perl/Filelock/Makefile create mode 100644 lib/perl/Filelock/Makefile.PL diff --git a/lib/perl/Filelock/Filelock.pm b/lib/perl/Filelock/Filelock.pm new file mode 100644 index 00000000..cace0666 --- /dev/null +++ b/lib/perl/Filelock/Filelock.pm @@ -0,0 +1,44 @@ +# Perl module for setting process limits +# +# (c) 2007 Pavel Charvat +# +# This software may be freely distributed and used according to the terms +# of the GNU Lesser General Public License. +# +# +# +# Interface: +# Sherlock::Filelock::fcntllock($handle, $type, $whence, $start, $len) +# + +package Sherlock::Filelock; + +use 5.006; +use strict; +use warnings; + +require Exporter; +require DynaLoader; + +our @ISA = qw(Exporter DynaLoader); +unshift @DynaLoader::dl_library_path, "lib"; + +# This allows declaration use Filelock ':all'; +# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK +# will save memory. +our %EXPORT_TAGS = ( 'all' => [ qw( + +) ] ); + +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); + +our @EXPORT = qw( +); +our $VERSION = '0.01'; + +bootstrap Sherlock::Filelock $VERSION; + +# Preloaded methods go here. + +1; +__END__ diff --git a/lib/perl/Filelock/Filelock.xs b/lib/perl/Filelock/Filelock.xs new file mode 100644 index 00000000..7b830e29 --- /dev/null +++ b/lib/perl/Filelock/Filelock.xs @@ -0,0 +1,30 @@ +/* + * PerlXS module for managing file locks + * + * (c) 2007 Pavel Charvat + */ + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include +#include + + +MODULE = Sherlock::Filelock PACKAGE = Sherlock::Filelock + +PROTOTYPES: ENABLED + +int +fcntl_lock(IN int fd, IN int cmd, IN int type, IN int whence, IN int start, IN int len) +CODE: + struct flock fl; + fl.l_type = type; + fl.l_whence = whence; + fl.l_start = start; + fl.l_len = len; + + RETVAL = fcntl(fd, cmd, &fl); +OUTPUT: + RETVAL diff --git a/lib/perl/Filelock/MANIFEST b/lib/perl/Filelock/MANIFEST new file mode 100644 index 00000000..1136c004 --- /dev/null +++ b/lib/perl/Filelock/MANIFEST @@ -0,0 +1,10 @@ +Makefile +Makefile.PL +MANIFEST +Fcntllock.pm +Fcntllock.xs +CVS/Entries +CVS/Repository +CVS/Root +lib/Sherlock/.exists +.cvsignore diff --git a/lib/perl/Filelock/Makefile b/lib/perl/Filelock/Makefile new file mode 100644 index 00000000..bf64672f --- /dev/null +++ b/lib/perl/Filelock/Makefile @@ -0,0 +1,26 @@ +# Makefile for the Filelock Perl module (c) 2007 Pavel Chrvat + +DIRS+=lib/perl/Filelock/arch/auto/Sherlock/Filelock +FILELOCK_DIR=lib/perl/Filelock + +PROGS+=$(o)/lib/perl/Filelock/Filelock.pm +ifdef CONFIG_DARWIN +SOEXT=bundle +else +SOEXT=so +endif + +extras:: $(o)/lib/perl/Filelock/arch/auto/Sherlock/Filelock/Filelock.$(SOEXT) + +$(o)/lib/perl/Filelock/arch/auto/Sherlock/Filelock/Filelock.$(SOEXT): $(o)/$(FILELOCK_DIR)/Filelock.xs $(o)/$(FILELOCK_DIR)/Filelock.pm $(o)/$(FILELOCK_DIR)/Makefile + cd $(o)/$(FILELOCK_DIR) && $(MAKE) -f Makefile + cp $@ run/$(DATADIR)/ + +$(o)/$(FILELOCK_DIR)/Makefile: $(o)/$(FILELOCK_DIR)/Makefile.PL + cd $(o)/$(FILELOCK_DIR) && perl Makefile.PL + +$(o)/$(FILELOCK_DIR)/Filelock.xs: $(s)/$(FILELOCK_DIR)/Filelock.xs + cp $^ $@ + +$(o)/$(FILELOCK_DIR)/Makefile.PL: $(s)/$(FILELOCK_DIR)/Makefile.PL + cp $^ $@ diff --git a/lib/perl/Filelock/Makefile.PL b/lib/perl/Filelock/Makefile.PL new file mode 100644 index 00000000..b0092ea4 --- /dev/null +++ b/lib/perl/Filelock/Makefile.PL @@ -0,0 +1,9 @@ +# Makefile for Perl MakeMaker (c) 2007 Pavel Charvat + +use ExtUtils::MakeMaker; +WriteMakefile( + 'NAME' => 'Sherlock::Filelock', + 'VERSION_FROM' => 'Filelock.pm', + 'INST_LIB' => 'lib', + 'INST_ARCHLIB' => 'arch', +); diff --git a/lib/perl/Makefile b/lib/perl/Makefile index 8de91140..a95678b6 100644 --- a/lib/perl/Makefile +++ b/lib/perl/Makefile @@ -6,3 +6,7 @@ PROGS+=$(addprefix $(o)/lib/perl/,Config.pm) ifdef CONFIG_UCW_PERL_ULIMIT include $(s)/lib/perl/Ulimit/Makefile endif + +ifdef CONFIG_UCW_PERL_FILELOCK +include $(s)/lib/perl/Filelock/Makefile +endif -- 2.39.2