1 #define ST(off) stack_base[ax + (off)]
4 #define XS(name) void name(CV* cv)
6 #define XS(name) void name(cv) CV* cv;
9 #if 0 /*defined(WIN32) && defined(__GNUC__)*/ /* this bug is gone in mingw32/gcc-2.8.0*/
10 #define STRINGIFY_THINGY(x) #x
11 #define FORCE_ARG_STRING(x) STRINGIFY_THINGY(x)
13 #define FORCE_ARG_STRING(x) x
18 I32 ax = mark - stack_base + 1; \
21 #define XSANY CvXSUBANY(cv)
23 #define dXSI32 I32 ix = XSANY.any_i32
25 #define XSRETURN(off) \
27 stack_sp = stack_base + ax + ((off) - 1); \
31 /* Simple macros to put new mortal values onto the stack. */
32 /* Typically used to return values from XS functions. */
33 #define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) )
34 #define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) )
35 #define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0)))
36 #define XST_mNO(i) (ST(i) = &sv_no )
37 #define XST_mYES(i) (ST(i) = &sv_yes )
38 #define XST_mUNDEF(i) (ST(i) = &sv_undef)
40 #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END
41 #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END
42 #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END
43 #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END
44 #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END
45 #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END
46 #define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END
48 #define newXSproto(a,b,c,d) sv_setpv((SV*)newXS(a,b,c), d)
51 # define XS_VERSION_BOOTCHECK \
53 char *xs_version = FORCE_ARG_STRING(XS_VERSION); \
54 char *vn = "", *module = SvPV(ST(0),na); \
55 if (items >= 2) /* version supplied as bootstrap arg */ \
58 /* XXX GV_ADDWARN */ \
59 Sv = perl_get_sv(form("%s::%s", module, \
60 vn = "XS_VERSION"), FALSE); \
61 if (!Sv || !SvOK(Sv)) \
62 Sv = perl_get_sv(form("%s::%s", module, \
63 vn = "VERSION"), FALSE); \
65 if (Sv && (!SvOK(Sv) || strNE(xs_version, SvPV(Sv, na)))) \
66 croak("%s object version %s does not match $%s::%s %_", \
67 module, xs_version, module, vn, Sv); \
70 # define XS_VERSION_BOOTCHECK