From: Vincent Pit Date: Sun, 21 Sep 2008 11:58:05 +0000 (+0200) Subject: Enable thread-safety for perls that just lacks MY_CXT_CLONE X-Git-Tag: v0.21_01~6 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=5841f65c4501de2869bdb1f5a8ef29a4f966bb7e;p=perl%2Fmodules%2FVariable-Magic.git Enable thread-safety for perls that just lacks MY_CXT_CLONE --- diff --git a/Magic.xs b/Magic.xs index c692014..9145ab3 100644 --- a/Magic.xs +++ b/Magic.xs @@ -47,14 +47,21 @@ # define VMG_MULTIPLICITY 0 #endif -#if VMG_MULTIPLICITY && defined(dMY_CXT) && defined(MY_CXT) && defined(START_MY_CXT) && defined(MY_CXT_INIT) && defined(MY_CXT_CLONE) +#if VMG_MULTIPLICITY && 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 MY_CXT_CLONE +# define MY_CXT_CLONE \ + dMY_CXT_SV; \ + my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1)); \ + Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t); \ + sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) +# endif #else # define VMG_THREADSAFE 0 # undef dMY_CXT # define dMY_CXT dNOOP # undef MY_CXT -# define MY_CXT vmg_globaldata +# define MY_CXT vmg_globaldata # undef START_MY_CXT # define START_MY_CXT STATIC my_cxt_t MY_CXT; # undef MY_CXT_INIT