Use fork if available.
[p5sagit/p5-mst-13.2.git] / XSUB.h
diff --git a/XSUB.h b/XSUB.h
index 8c2caa6..f8d3107 100644 (file)
--- a/XSUB.h
+++ b/XSUB.h
 #define XSRETURN_UNDEF do { XST_mUNDEF(0); XSRETURN(1); } while (0)
 #define XSRETURN_EMPTY do {                XSRETURN(0); } while (0)
 
-#define newXSproto(a,b,c,d)    sv_setpv(newXS(a,b,c), d)
+#define newXSproto(a,b,c,d)    sv_setpv((SV*)newXS(a,b,c), d)
+
+#ifdef XS_VERSION
+# define XS_VERSION_BOOTCHECK \
+    do {                                                                      \
+        char vn[255], *module = SvPV(ST(0),na);                               \
+        if (items >= 2)         /* version supplied as bootstrap arg */       \
+            Sv=ST(1);                                                         \
+        else {                  /* read version from module::VERSION */       \
+            sprintf(vn,"%s::VERSION", module);                                \
+            Sv = perl_get_sv(vn, FALSE);   /* XXX GV_ADDWARN */               \
+        }                                                                     \
+        if (Sv && (!SvOK(Sv) || strNE(XS_VERSION, SvPV(Sv,na))) )             \
+            croak("%s object version %s does not match %s.pm $VERSION %s",    \
+              module,XS_VERSION, module,(Sv && SvOK(Sv))?SvPV(Sv,na):"(undef)");\
+    } while (0)
+#else
+# define XS_VERSION_BOOTCHECK
+#endif
+