better validation of SysV IPC availability
[p5sagit/p5-mst-13.2.git] / ext / IPC / SysV / SysV.xs
index b97e9e5..818c751 100644 (file)
 #   include <vm/vm_param.h>
 #endif
 
-#ifndef newCONSTSUB
-static void
-newCONSTSUB(stash,name,sv)
-    HV *stash;
-    char *name;
-    SV *sv;
-{
-#ifdef dTHR
-    dTHR;
-#endif
-    U32 oldhints = hints;
-    HV *old_cop_stash = curcop->cop_stash;
-    HV *old_curstash = curstash;
-    line_t oldline = curcop->cop_line;
-    curcop->cop_line = copline;
-
-    hints &= ~HINT_BLOCK_SCOPE;
-    if(stash)
-       curstash = curcop->cop_stash = stash;
-
-    newSUB(
-       start_subparse(FALSE, 0),
-       newSVOP(OP_CONST, 0, newSVpv(name,0)),
-       newSVOP(OP_CONST, 0, &sv_no),   /* SvPV(&sv_no) == "" -- GMB */
-       newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
-    );
-
-    hints = oldhints;
-    curcop->cop_stash = old_cop_stash;
-    curstash = old_curstash;
-    curcop->cop_line = oldline;
-}
-#endif
-
 MODULE=IPC::SysV       PACKAGE=IPC::Msg::stat
 
 PROTOTYPES: ENABLE
@@ -75,6 +41,7 @@ pack(obj)
     SV * obj
 PPCODE:
 {
+#ifdef HAS_MSG
     SV *sv;
     struct msqid_ds ds;
     AV *list = (AV*)SvRV(obj);
@@ -84,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
@@ -92,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);
@@ -126,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
@@ -136,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);
@@ -156,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
@@ -163,6 +141,7 @@ pack(obj)
     SV * obj
 PPCODE:
 {
+#ifdef HAS_SEM
     SV **sv_ptr;
     SV *sv;
     struct semid_ds ds;
@@ -188,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
@@ -199,7 +181,7 @@ ftok(path, id)
     CODE:
 #if defined(HAS_SEM) || defined(HAS_SHM)
         key_t k = ftok(path, id);
-        ST(0) = k == (key_t) -1 ? &sv_undef : sv_2mortal(newSViv(k));
+        ST(0) = k == (key_t) -1 ? &PL_sv_undef : sv_2mortal(newSViv(k));
 #else
         DIE(no_func, "ftok");
 #endif