From: Vincent Pit Date: Sat, 20 Sep 2008 21:05:31 +0000 (+0200) Subject: Thread detection macros overhaul X-Git-Tag: v0.20~12 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=f346204d7035c0bc27598666f04408cd67b905c4;p=perl%2Fmodules%2FVariable-Magic.git Thread detection macros overhaul --- diff --git a/Magic.xs b/Magic.xs index 1ac63cb..00384fe 100644 --- a/Magic.xs +++ b/Magic.xs @@ -30,34 +30,53 @@ #define VMG_HAS_PERL_AND(P, R, V, S) (PERL_VERSION_GE((R), (V), (S)) && (!VMG_PERL_PATCHLEVEL || (VMG_PERL_PATCHLEVEL >= (P)))) -/* --- Compatibility ------------------------------------------------------- */ +/* --- Threads and multiplicity -------------------------------------------- */ -#ifndef Newx -# define Newx(v, n, c) New(0, v, n, c) +#ifndef NOOP +# define NOOP #endif -#ifndef SvMAGIC_set -# define SvMAGIC_set(sv, val) (SvMAGIC(sv) = (val)) +#ifndef dNOOP +# define dNOOP #endif -#ifndef mPUSHi -# define mPUSHi(I) PUSHs(sv_2mortal(newSViv(I))) +#if defined(MULTIPLICITY) || defined(PERL_IMPLICIT_CONTEXT) +# define VMG_MULTIPLICITY 1 +# ifndef tTHX +# define tTHX PerlInterpreter* +# endif +#else +# define VMG_MULTIPLICITY 0 #endif -#ifndef dMY_CXT -# define dMY_CXT +#if VMG_MULTIPLICITY && defined(dMY_CXT) && defined(MY_CXT) && defined(START_MY_CXT) && defined(MY_CXT_INIT) && defined(MY_CXT_CLONE) +# define VMG_THREADSAFE 1 +#else +# define VMG_THREADSAFE 0 +# undef dMY_CXT +# define dMY_CXT dNOOP # undef MY_CXT # define MY_CXT vmg_globaldata # undef START_MY_CXT # define START_MY_CXT STATIC my_cxt_t MY_CXT; # undef MY_CXT_INIT -# define MY_CXT_INIT +# define MY_CXT_INIT NOOP # undef MY_CXT_CLONE -# undef aMY_CXT -# undef pMY_CXT -# define VMG_THREADSAFE 0 -#else -# define VMG_THREADSAFE 1 +# define MY_CXT_CLONE NOOP +#endif + +/* --- Compatibility ------------------------------------------------------- */ + +#ifndef Newx +# define Newx(v, n, c) New(0, v, n, c) +#endif + +#ifndef SvMAGIC_set +# define SvMAGIC_set(sv, val) (SvMAGIC(sv) = (val)) +#endif + +#ifndef mPUSHi +# define mPUSHi(I) PUSHs(sv_2mortal(newSViv(I))) #endif #ifndef PERL_MAGIC_ext