Skip Menu |

This queue is for tickets about the POSIX-RT-Semaphore CPAN distribution.

Report information
The Basics
Id: 45898
Status: resolved
Priority: 0/
Queue: POSIX-RT-Semaphore

People
Owner: mjp [...] cpan.org
Requestors: bvakili [...] oanda.com
Cc: mjp [...] cpan.org
AdminCc:

Bug Information
Severity: Important
Broken in: 0.04
Fixed in: 0.05



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; }
RT-Send-CC: mjp [...] pilcrow.madison.wi.us
No worries. BTW, a typo was found in the 'hints/solaris.pl' script. Just a missing closing brace '}'. This should remove additional warnings. I've uploaded a new patch to include this. Cheers, -- Bijan On Wed, 2009-05-20 at 21:08 -0500, Mike Pomraning wrote: Thanks. Show quoted text
> > -Mike
diff -Nru ./hints/solaris.pl ./hints/solaris.pl --- ./hints/solaris.pl 2006-08-06 19:32:30.000000000 -0400 +++ ./hints/solaris.pl 2009-05-13 13:37:49.000000000 -0400 @@ -2,6 +2,7 @@ use POSIX qw(uname); if (substr((uname())[2], 2) <= 6) { $self->{LIBS} = ['-lposix4']; +} else { $self->{LIBS} = ['-lrt']; } diff -Nru ./Makefile.PL ./Makefile.PL --- ./Makefile.PL 2003-11-02 23:54:58.000000000 -0500 +++ ./Makefile.PL 2009-05-13 13:05:24.000000000 -0400 @@ -7,7 +7,7 @@ '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' => ['-rt', '-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 -Nru ./t/util.pl ./t/util.pl --- ./t/util.pl 2006-08-06 23:09:07.000000000 -0400 +++ ./t/util.pl 2009-05-13 13:05:42.000000000 -0400 @@ -14,7 +14,7 @@ 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; }
Bijan, Please try the attached patch when you've a moment, on BSD and Solaris. Thanks, Mike
diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/Changes POSIX-RT-Semaphore-0.04/Changes --- POSIX-RT-Semaphore-0.04.orig/Changes 2006-08-07 00:41:23.000000000 -0500 +++ POSIX-RT-Semaphore-0.04/Changes 2009-05-21 21:01:40.000000000 -0500 @@ -1,7 +1,16 @@ Revision history for Perl extension POSIX::RT::Semaphore. +BV := Bijan Vakili <bvakili#oanda_com> ER := Eric Rybski <rybskej#yahoo_com> +0.05 Thu May 21 20:48:11 2009 + - version 0.05 + - Copyrights updated + - Build fixes for FreeBSD and Solaris linkage, and FreeBSD name + limitations (thx BV). Favor librt by default. Drop dec_osf and + hpux hints. + - Semaphore.pm: Note FreeBSD 14 character name limit. + 0.04 Sun Aug 7 00:40:43 2006 - version 0.04 - Semaphore.pm: Update CAVEATs with portability concerns. Remove diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/hints/dec_osf.pl POSIX-RT-Semaphore-0.04/hints/dec_osf.pl --- POSIX-RT-Semaphore-0.04.orig/hints/dec_osf.pl 2006-08-06 19:07:01.000000000 -0500 +++ POSIX-RT-Semaphore-0.04/hints/dec_osf.pl 1969-12-31 18:00:00.000000000 -0600 @@ -1,3 +0,0 @@ -# OSF1 td158.testdrive.hp.com V5.1 2650 alpha -# -$self->{LIBS} = ['-lrt']; diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/hints/hpux.pl POSIX-RT-Semaphore-0.04/hints/hpux.pl --- POSIX-RT-Semaphore-0.04.orig/hints/hpux.pl 2006-08-06 22:19:29.000000000 -0500 +++ POSIX-RT-Semaphore-0.04/hints/hpux.pl 1969-12-31 18:00:00.000000000 -0600 @@ -1,3 +0,0 @@ -# HP-UX 11i Version 2 sem_init(2) manpage -# -$self->{LIBS} = ['-lrt']; diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/hints/solaris.pl POSIX-RT-Semaphore-0.04/hints/solaris.pl --- POSIX-RT-Semaphore-0.04.orig/hints/solaris.pl 2006-08-06 18:32:30.000000000 -0500 +++ POSIX-RT-Semaphore-0.04/hints/solaris.pl 2009-05-21 20:59:48.000000000 -0500 @@ -2,6 +2,6 @@ use POSIX qw(uname); if (substr((uname())[2], 2) <= 6) { $self->{LIBS} = ['-lposix4']; -else { +} else { $self->{LIBS} = ['-lrt']; } diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/Makefile.PL POSIX-RT-Semaphore-0.04/Makefile.PL --- POSIX-RT-Semaphore-0.04.orig/Makefile.PL 2003-11-02 22:54:58.000000000 -0600 +++ POSIX-RT-Semaphore-0.04/Makefile.PL 2009-05-21 20:42:38.000000000 -0500 @@ -7,7 +7,7 @@ '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'], # 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 --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/MANIFEST POSIX-RT-Semaphore-0.04/MANIFEST --- POSIX-RT-Semaphore-0.04.orig/MANIFEST 2006-08-06 23:46:06.000000000 -0500 +++ POSIX-RT-Semaphore-0.04/MANIFEST 2009-05-21 21:01:23.000000000 -0500 @@ -20,7 +20,5 @@ t/fork-inherit-named.t t/fork-inherit-unnamed.t t/fork-reopen.t -hints/dec_osf.pl -hints/hpux.pl hints/solaris.pl META.yml Module meta-data (added by MakeMaker) diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/README POSIX-RT-Semaphore-0.04/README --- POSIX-RT-Semaphore-0.04.orig/README 2003-11-07 00:37:22.000000000 -0600 +++ POSIX-RT-Semaphore-0.04/README 2009-05-21 20:42:58.000000000 -0500 @@ -24,7 +24,7 @@ Put the correct copyright and licence information here. -Copyright (C) 2003 by Michael J. Pomraning +Copyright (C) 2009 by Michael J. Pomraning This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/Semaphore.pm POSIX-RT-Semaphore-0.04/Semaphore.pm --- POSIX-RT-Semaphore-0.04.orig/Semaphore.pm 2006-08-06 23:30:31.000000000 -0500 +++ POSIX-RT-Semaphore-0.04/Semaphore.pm 2009-05-21 20:46:00.000000000 -0500 @@ -289,6 +289,8 @@ with a single, leading slash and no other slashes (e.g., "/my_sem"). However, at least the OSF/Digital/Tru64 implementation currently maps names directly to the filesystem, encouraging semaphores such as "/tmp/my_sem". +On at least some FreeBSD implementations, semaphore pathnames may be no +longer than 14 characters. L</getvalue> may not support the special negative semantics, and L</timedwait> may not be supported at all. @@ -312,11 +314,11 @@ Michael J. Pomraning -Please report bugs to E<lt>mjp-perl AT pilcrow.madison.wi.usE<gt> +Please report bugs via rt.cpan.org. =head1 COPYRIGHT AND LICENSE -Copyright 2006 by Michael J. Pomraning +Copyright 2009 by Michael J. Pomraning This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --exclude Makefile.old -ruN POSIX-RT-Semaphore-0.04.orig/t/util.pl POSIX-RT-Semaphore-0.04/t/util.pl --- POSIX-RT-Semaphore-0.04.orig/t/util.pl 2006-08-06 22:09:07.000000000 -0500 +++ POSIX-RT-Semaphore-0.04/t/util.pl 2009-05-21 20:53:49.000000000 -0500 @@ -14,7 +14,7 @@ sub zero_but_true($) { return ($_[0] and $_[0] == 0); } sub make_semname { - my $name = "unlikely_to_exist.$$"; + my $name = "/abc.$$"; # FreeBSD has 14 char limit? return ($^O eq 'dec_osf') ? "/tmp/$name" : $name; }
Solaris / FreeBSD build issues should be addressed in newly uploaded 0.05
On Mon May 25 21:38:29 2009, MJP wrote: Show quoted text
> Solaris / FreeBSD build issues should be addressed in newly uploaded 0.05
I tested it on Solaris, Linux and FreeBSD. Everything works. Thanks! BTW, the FreeBSD CPAN tests are failing for 0.05 because they need to load the semaphore kernel module *before* running the tests. FreeBSD doesn't load this kernel module by default. To load the module, you need to run the following as 'root': kldload sem You may want to add this to the 'CAVEATS' of your man page and the README for the source package for any FreeBSD users. Cheers! -- Bijan