Subject: | Patch for Solaris and FreeBSD |
The POSIX::RT::Semaphore only seems to install successfully on Linux.
The CPAN tests shows errors for Solaris and FreeBSD (see references
below). However, the POSIX API for semaphores also exists on these
platforms.
I've attached a patch to get this module working on Solaris and FreeBSD.
Fixes include:
[1]
Linking to the real-time library (librt) for Solaris.
[2]
Fixing the common test module (t/util.pl) to use standard POSIX
semaphore names. This includes using the '/' prefix and limiting the
semaphore name to under 14 characters. Both are required for proper
execution on Solaris and FreeBSD.
I've tested this patch using perl v5.8.8 on:
a) Solaris 10 Update 6 (SPARC and i386 architectures)
b) FreeBSD 7.0 (i386 architecture)
SPECIAL NOTE FOR CPAN TESTING:
On FreeBSD, the POSIX semaphore driver is not loaded by default. This
driver must be loaded into the kernel *prior* to execution. For
example, this can be done using 'kldload sem' as root (see references
below). I did not include this in the patch.
REFERENCES:
FreeBSD POSIX semaphore man page:
http://www.freebsd.org/cgi/man.cgi?query=sem&sektion=4&apropos=0&manpath=FreeBSD+7.2-RELEASE
Solaris 10 POSIX sem_init() API page:
http://docs.sun.com/app/docs/doc/816-5171/sem-init-3rt?l=en&q=sem_init&a=view
CPAN test results for this module v0.04:
http://www.cpantesters.org/show/POSIX-RT-Semaphore.html#0.04
--
-- Bijan
Subject: | POSIX-RT-Semaphore.diff |
diff -rupN POSIX-RT-Semaphore-0.04/Makefile.PL POSIX-RT-Semaphore-0.04-patched/Makefile.PL
--- POSIX-RT-Semaphore-0.04/Makefile.PL 2003-11-02 23:54:58.000000000 -0500
+++ POSIX-RT-Semaphore-0.04-patched/Makefile.PL 2009-05-08 16:58:09.000000000 -0400
@@ -7,7 +7,7 @@ WriteMakefile(
'VERSION_FROM' => 'Semaphore.pm', # finds $VERSION
'PREREQ_PM' => {}, # e.g., Module::Name => 1.1
'AUTHOR' => 'mjp <mjp@pilcrow.madison.wi.us>',
- 'LIBS' => ['-lpthread'], # e.g., '-lm'
+ 'LIBS' => ['-lrt', '-lpthread'], # e.g., '-lm'
'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
'INC' => '-I.', # e.g., '-I. -I/usr/include/other'
# Un-comment this if you add C files to link with later:
diff -rupN POSIX-RT-Semaphore-0.04/t/util.pl POSIX-RT-Semaphore-0.04-patched/t/util.pl
--- POSIX-RT-Semaphore-0.04/t/util.pl 2006-08-06 23:09:07.000000000 -0400
+++ POSIX-RT-Semaphore-0.04-patched/t/util.pl 2009-05-08 16:58:16.000000000 -0400
@@ -14,7 +14,7 @@ sub is_implemented(&) {
sub zero_but_true($) { return ($_[0] and $_[0] == 0); }
sub make_semname {
- my $name = "unlikely_to_exist.$$";
+ my $name = "/unlikely.$$";
return ($^O eq 'dec_osf') ? "/tmp/$name" : $name;
}