X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=autovivification.xs;h=90ba95deac26e1d1fe2959bcb64ed9d88e431bb8;hb=a91ce6bf68065e904a947f03f477e68992c2f6a1;hp=a42b9803aa74ef2d46f71c976a885715d575df41;hpb=ad00023390af9c24d0387cf02af806fe180f68bd;p=perl%2Fmodules%2Fautovivification.git diff --git a/autovivification.xs b/autovivification.xs index a42b980..90ba95d 100644 --- a/autovivification.xs +++ b/autovivification.xs @@ -288,7 +288,9 @@ STATIC U32 a_hash = 0; STATIC UV a_hint(pTHX) { #define a_hint() a_hint(aTHX) SV *hint; -#if A_HAS_PERL(5, 9, 5) +#ifdef cop_hints_fetch_pvn + hint = cop_hints_fetch_pvn(PL_curcop, __PACKAGE__, __PACKAGE_LEN__, a_hash, 0); +#elif A_HAS_PERL(5, 9, 5) hint = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash, NULL, __PACKAGE__, __PACKAGE_LEN__, @@ -327,10 +329,13 @@ STATIC ptable *a_op_map = NULL; STATIC perl_mutex a_op_map_mutex; +#define A_LOCK(M) MUTEX_LOCK(M) +#define A_UNLOCK(M) MUTEX_UNLOCK(M) + STATIC const a_op_info *a_map_fetch(const OP *o, a_op_info *oi) { const a_op_info *val; - MUTEX_LOCK(&a_op_map_mutex); + A_LOCK(&a_op_map_mutex); val = ptable_fetch(a_op_map, o); if (val) { @@ -338,7 +343,7 @@ STATIC const a_op_info *a_map_fetch(const OP *o, a_op_info *oi) { val = oi; } - MUTEX_UNLOCK(&a_op_map_mutex); + A_UNLOCK(&a_op_map_mutex); return val; } @@ -349,6 +354,9 @@ STATIC const a_op_info *a_map_fetch(const OP *o, a_op_info *oi) { #define dA_MAP_THX dNOOP +#define A_LOCK(M) NOOP +#define A_UNLOCK(M) NOOP + #define a_map_fetch(O) ptable_fetch(a_op_map, (O)) #endif /* !USE_ITHREADS */ @@ -371,29 +379,20 @@ STATIC const a_op_info *a_map_store_locked(pPTBLMS_ const OP *o, OP *(*old_pp)(p STATIC void a_map_store(pPTBLMS_ const OP *o, OP *(*old_pp)(pTHX), void *next, UV flags) { #define a_map_store(O, PP, N, F) a_map_store(aPTBLMS_ (O), (PP), (N), (F)) - -#ifdef USE_ITHREADS - MUTEX_LOCK(&a_op_map_mutex); -#endif + A_LOCK(&a_op_map_mutex); a_map_store_locked(o, old_pp, next, flags); -#ifdef USE_ITHREADS - MUTEX_UNLOCK(&a_op_map_mutex); -#endif + A_UNLOCK(&a_op_map_mutex); } STATIC void a_map_delete(pTHX_ const OP *o) { #define a_map_delete(O) a_map_delete(aTHX_ (O)) -#ifdef USE_ITHREADS - MUTEX_LOCK(&a_op_map_mutex); -#endif + A_LOCK(&a_op_map_mutex); - ptable_map_store(a_op_map, o, NULL); + ptable_map_delete(a_op_map, o); -#ifdef USE_ITHREADS - MUTEX_UNLOCK(&a_op_map_mutex); -#endif + A_UNLOCK(&a_op_map_mutex); } STATIC const OP *a_map_descend(const OP *o) { @@ -417,9 +416,7 @@ STATIC void a_map_store_root(pPTBLMS_ const OP *root, OP *(*old_pp)(pTHX), UV fl a_op_info *oi; const OP *o = root; -#ifdef USE_ITHREADS - MUTEX_LOCK(&a_op_map_mutex); -#endif + A_LOCK(&a_op_map_mutex); roi = a_map_store_locked(o, old_pp, (OP *) root, flags | A_HINT_ROOT); @@ -434,9 +431,7 @@ STATIC void a_map_store_root(pPTBLMS_ const OP *root, OP *(*old_pp)(pTHX), UV fl } } -#ifdef USE_ITHREADS - MUTEX_UNLOCK(&a_op_map_mutex); -#endif + A_UNLOCK(&a_op_map_mutex); return; } @@ -445,9 +440,7 @@ STATIC void a_map_update_flags_topdown(const OP *root, UV flags) { a_op_info *oi; const OP *o = root; -#ifdef USE_ITHREADS - MUTEX_LOCK(&a_op_map_mutex); -#endif + A_LOCK(&a_op_map_mutex); flags &= ~A_HINT_ROOT; @@ -459,9 +452,7 @@ STATIC void a_map_update_flags_topdown(const OP *root, UV flags) { o = a_map_descend(o); } while (o); -#ifdef USE_ITHREADS - MUTEX_UNLOCK(&a_op_map_mutex); -#endif + A_UNLOCK(&a_op_map_mutex); return; } @@ -471,9 +462,7 @@ STATIC void a_map_update_flags_topdown(const OP *root, UV flags) { STATIC void a_map_update_flags_bottomup(const OP *o, UV flags, UV rflags) { a_op_info *oi; -#ifdef USE_ITHREADS - MUTEX_LOCK(&a_op_map_mutex); -#endif + A_LOCK(&a_op_map_mutex); flags &= ~A_HINT_ROOT; rflags |= A_HINT_ROOT; @@ -485,9 +474,7 @@ STATIC void a_map_update_flags_bottomup(const OP *o, UV flags, UV rflags) { } oi->flags = rflags; -#ifdef USE_ITHREADS - MUTEX_UNLOCK(&a_op_map_mutex); -#endif + A_UNLOCK(&a_op_map_mutex); return; }