]> git.vpit.fr Git - perl/modules/Variable-Magic.git/commitdiff
Enable thread-safety for perls that just lacks MY_CXT_CLONE
authorVincent Pit <vince@profvince.com>
Sun, 21 Sep 2008 11:58:05 +0000 (13:58 +0200)
committerVincent Pit <vince@profvince.com>
Sun, 21 Sep 2008 12:04:36 +0000 (14:04 +0200)
Magic.xs

index c692014ba849694ab98fb37e8f47ddb5726f53c9..9145ab3ab585315be827bf2875eaea5b8084e7c9 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
 # 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