X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Magic.xs;h=b810d91f9db40a63c90e9a75711a8861a809967f;hb=2ccccc5e7ea3f299777e0b67db864a1ea60688a6;hp=947ae72a0246b945f2759deaaa5cbff9afe43382;hpb=8c151d16f3a7a40201fab13e4fb92433eb6f9c7c;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/Magic.xs b/Magic.xs index 947ae72..b810d91 100644 --- a/Magic.xs +++ b/Magic.xs @@ -62,7 +62,9 @@ #endif #if VMG_MULTIPLICITY && defined(USE_ITHREADS) && defined(dMY_CXT) && defined(MY_CXT) && defined(START_MY_CXT) && defined(MY_CXT_INIT) && (defined(MY_CXT_CLONE) || defined(dMY_CXT_SV)) -# define VMG_THREADSAFE 1 +# ifndef VMG_THREADSAFE +# define VMG_THREADSAFE 1 +# endif # ifndef MY_CXT_CLONE # define MY_CXT_CLONE \ dMY_CXT_SV; \ @@ -71,6 +73,7 @@ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) # endif #else +# undef VMG_THREADSAFE # define VMG_THREADSAFE 0 # undef dMY_CXT # define dMY_CXT dNOOP @@ -1243,11 +1246,18 @@ static int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) { svr = POPs; if (SvOK(svr)) ret = (int) SvIV(svr); + if (SvROK(svr)) + SvREFCNT_inc(svr); + else + svr = NULL; PUTBACK; FREETMPS; LEAVE; + if (svr && !SvTEMP(svr)) + sv_2mortal(svr); + if (chain) { vmg_dispell_guard_new(*chain); *chain = NULL; @@ -1836,14 +1846,9 @@ static signed char vmg_destruct_level(pTHX) { #endif /* VMG_THREADSAFE */ -static void vmg_teardown(pTHX_ void *interp) { +static void vmg_teardown(pTHX_ void *param) { dMY_CXT; -#if VMG_MULTIPLICITY - if (aTHX != interp) - return; -#endif - #if VMG_THREADSAFE VMG_LOADED_LOCK; @@ -1934,11 +1939,7 @@ static void vmg_setup(pTHX) { newCONSTSUB(stash, "VMG_OP_INFO_NAME", newSVuv(VMG_OP_INFO_NAME)); newCONSTSUB(stash, "VMG_OP_INFO_OBJECT", newSVuv(VMG_OP_INFO_OBJECT)); -#if VMG_MULTIPLICITY - call_atexit(vmg_teardown, aTHX); -#else call_atexit(vmg_teardown, NULL); -#endif return; }