From: Jarkko Hietaniemi Date: Fri, 31 Jul 1998 13:13:57 +0000 (+0300) Subject: better validation of SysV IPC availability X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6087ac4414f58a8f56f41d3b670cd75f7a5e6936;p=p5sagit%2Fp5-mst-13.2.git better validation of SysV IPC availability Message-Id: <199807311013.NAA28887@koah.research.nokia.com> Subject: Re: lib/ipc_sysv.t fails under FreeBSD 2.2.1 p4raw-id: //depot/maint-5.005/perl@1692 --- diff --git a/Configure b/Configure index 9d2a2bf..197295f 100755 --- a/Configure +++ b/Configure @@ -7631,6 +7631,25 @@ echo " " case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in *"$undef"*) h_msg=false;; esac +case "$osname" in +freebsd) + case "`ipcs 2>&1`" in + "SVID messages"*"not configured"*) + echo "But your FreeBSD kernel does not have the msg*(2) configured." >&4 + h_msg=false + val="$undef" + set msgctl d_msgctl + eval $setvar + set msgget d_msgget + eval $setvar + set msgsnd d_msgsnd + eval $setvar + set msgrcv d_msgrcv + eval $setvar + ;; + esac + ;; +esac : we could also check for sys/ipc.h ... if $h_msg && $test `./findhdr sys/msg.h`; then echo "You have the full msg*(2) library." >&4 @@ -8113,6 +8132,23 @@ echo " " case "$d_semctl$d_semget$d_semop" in *"$undef"*) h_sem=false;; esac +case "$osname" in +freebsd) + case "`ipcs 2>&1`" in + "SVID messages"*"not configured"*) + echo "But your FreeBSD kernel does not have the sem*(2) configured." >&4 + h_sem=false + val="$undef" + set semctl d_semctl + eval $setvar + set semget d_semget + eval $setvar + set semop d_semop + eval $setvar + ;; + esac + ;; +esac : we could also check for sys/ipc.h ... if $h_sem && $test `./findhdr sys/sem.h`; then echo "You have the full sem*(2) library." >&4 @@ -8459,6 +8495,25 @@ echo " " case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in *"$undef"*) h_shm=false;; esac +case "$osname" in +freebsd) + case "`ipcs 2>&1`" in + "SVID shared memory"*"not configured"*) + echo "But your FreeBSD kernel does not have the shm*(2) configured." >&4 + h_shm=false + val="$undef" + set shmctl d_shmctl + evat $setvar + set shmget d_shmget + evat $setvar + set shmat d_shmat + evat $setvar + set shmdt d_shmdt + evat $setvar + ;; + esac + ;; +esac : we could also check for sys/ipc.h ... if $h_shm && $test `./findhdr sys/shm.h`; then echo "You have the full shm*(2) library." >&4 diff --git a/INSTALL b/INSTALL index fe78b1b..8360e1d 100644 --- a/INSTALL +++ b/INSTALL @@ -1203,6 +1203,13 @@ Old versions of the DB library (including the DB library which comes with FreeBSD 2.1) had broken handling of recno databases with modified bval settings. Upgrade your DB library or OS. +=item Bad arg length for semctl, is XX, should be ZZZ + +If you get this error message from the lib/ipc_sysv test, your System +V IPC may be broken. The XX typically is 20, and that is what ZZZ +also should be. Consider upgrading your OS, or reconfiguring your OS +to include the System V semaphores. + =item Miscellaneous Some additional things that have been reported for either perl4 or perl5: @@ -1213,6 +1220,9 @@ NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR. UTS may need one or more of -DCRIPPLED_CC, -K or -g, and undef LSTAT. +FreeBSD will fail the lib/ipc_sysv.t test if SysV IPC has not been +configured to the kernel. + If you get syntax errors on '(', try -DCRIPPLED_CC. Machines with half-implemented dbm routines will need to #undef I_ODBM diff --git a/ext/IPC/SysV/SysV.xs b/ext/IPC/SysV/SysV.xs index 3503ad9..818c751 100644 --- a/ext/IPC/SysV/SysV.xs +++ b/ext/IPC/SysV/SysV.xs @@ -41,6 +41,7 @@ pack(obj) SV * obj PPCODE: { +#ifdef HAS_MSG SV *sv; struct msqid_ds ds; AV *list = (AV*)SvRV(obj); @@ -50,6 +51,9 @@ PPCODE: sv = *av_fetch(list,6,TRUE); ds.msg_qbytes = SvIV(sv); ST(0) = sv_2mortal(newSVpv((char *)&ds,sizeof(ds))); XSRETURN(1); +#else + croak("System V msgxxx is not implemented on this machine"); +#endif } void @@ -58,6 +62,7 @@ unpack(obj,buf) SV * buf PPCODE: { +#ifdef HAS_MSG STRLEN len; SV **sv_ptr; struct msqid_ds *ds = (struct msqid_ds *)SvPV(buf,len); @@ -92,6 +97,9 @@ PPCODE: sv_ptr = av_fetch(list,11,TRUE); sv_setiv(*sv_ptr, ds->msg_ctime); XSRETURN(1); +#else + croak("System V msgxxx is not implemented on this machine"); +#endif } MODULE=IPC::SysV PACKAGE=IPC::Semaphore::stat @@ -102,6 +110,7 @@ unpack(obj,ds) SV * ds PPCODE: { +#ifdef HAS_SEM STRLEN len; AV *list = (AV*)SvRV(obj); struct semid_ds *data = (struct semid_ds *)SvPV(ds,len); @@ -122,6 +131,9 @@ PPCODE: sv_setiv(*av_fetch(list,6,TRUE), data[0].sem_otime); sv_setiv(*av_fetch(list,7,TRUE), data[0].sem_nsems); XSRETURN(1); +#else + croak("System V semxxx is not implemented on this machine"); +#endif } void @@ -129,6 +141,7 @@ pack(obj) SV * obj PPCODE: { +#ifdef HAS_SEM SV **sv_ptr; SV *sv; struct semid_ds ds; @@ -154,6 +167,9 @@ PPCODE: ds.sem_nsems = SvIV(*sv_ptr); ST(0) = sv_2mortal(newSVpv((char *)&ds,sizeof(ds))); XSRETURN(1); +#else + croak("System V semxxx is not implemented on this machine"); +#endif } MODULE=IPC::SysV PACKAGE=IPC::SysV diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 5fdeb70..ccef016 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2479,10 +2479,12 @@ if the error went away. Sort of the cybernetic version of S<20 questions>. instead of Perl. Check the #! line, or manually feed your script into Perl yourself. -=item System V IPC is not implemented on this machine +=item System V %s is not implemented on this machine -(F) You tried to do something with a function beginning with "sem", "shm", -or "msg". See L, for example. +(F) You tried to do something with a function beginning with "sem", +"shm", or "msg" but that System V IPC is not implemented in your +machine. In some machines the functionality can exist but be +unconfigured. Consult your system support. =item Syswrite on closed filehandle diff --git a/t/lib/ipc_sysv.t b/t/lib/ipc_sysv.t index f74c5fa..30ea48d 100755 --- a/t/lib/ipc_sysv.t +++ b/t/lib/ipc_sysv.t @@ -28,6 +28,27 @@ my $sem; $SIG{__DIE__} = 'cleanup'; # will cleanup $msg and $sem if needed +# FreeBSD is known to throw this if there's no SysV IPC in the kernel. +$SIG{SYS} = sub { + print STDERR <