diff options
author | Steve Hay <SteveHay@planit.com> | 2004-11-16 09:42:50 +0000 |
---|---|---|
committer | Steve Hay <SteveHay@planit.com> | 2004-11-16 09:42:50 +0000 |
commit | 4026c95ac795414220d662f764bd6e993724505d (patch) | |
tree | 04a79e3b2ce2e22e973f154adbbdeae3c3b9d03e | |
parent | 68ccb645d74feb45c64863c3223051537fbc9fed (diff) | |
download | perl-4026c95ac795414220d662f764bd6e993724505d.tar.gz |
Fix Win32 breakage caused by changes to op.c in change 23433.
Also limit the scope of the locks in a couple of places, as suggested
by Hugo in http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2004-11/msg00286.html.
p4raw-id: //depot/perl@23499
-rw-r--r-- | embed.fnc | 4 | ||||
-rw-r--r-- | embed.h | 4 | ||||
-rw-r--r-- | global.sym | 2 | ||||
-rw-r--r-- | op.c | 20 | ||||
-rw-r--r-- | op.h | 9 | ||||
-rw-r--r-- | proto.h | 2 | ||||
-rw-r--r-- | regcomp.c | 10 |
7 files changed, 38 insertions, 13 deletions
@@ -361,8 +361,10 @@ p |I32 |keyword |char* d|I32 len Ap |void |leave_scope |I32 base p |void |lex_end p |void |lex_start |SV* line -Ap |void |op_null |OP* o +Ap |void |op_null |OP* o p |void |op_clear |OP* o +Ap |void |op_refcnt_lock +Ap |void |op_refcnt_unlock p |OP* |linklist |OP* o p |OP* |list |OP* o p |OP* |listkids |OP* o @@ -443,6 +443,8 @@ #ifdef PERL_CORE #define op_clear Perl_op_clear #endif +#define op_refcnt_lock Perl_op_refcnt_lock +#define op_refcnt_unlock Perl_op_refcnt_unlock #ifdef PERL_CORE #define linklist Perl_linklist #endif @@ -3067,6 +3069,8 @@ #ifdef PERL_CORE #define op_clear(a) Perl_op_clear(aTHX_ a) #endif +#define op_refcnt_lock() Perl_op_refcnt_lock(aTHX) +#define op_refcnt_unlock() Perl_op_refcnt_unlock(aTHX) #ifdef PERL_CORE #define linklist(a) Perl_linklist(aTHX_ a) #endif diff --git a/global.sym b/global.sym index d97151ebf1..0ff88886df 100644 --- a/global.sym +++ b/global.sym @@ -223,6 +223,8 @@ Perl_is_utf8_xdigit Perl_is_utf8_mark Perl_leave_scope Perl_op_null +Perl_op_refcnt_lock +Perl_op_refcnt_unlock Perl_load_module Perl_vload_module Perl_looks_like_number @@ -271,6 +271,7 @@ Perl_op_free(pTHX_ OP *o) { register OP *kid, *nextkid; OPCODE type; + PADOFFSET refcnt; if (!o || o->op_static) return; @@ -284,11 +285,10 @@ Perl_op_free(pTHX_ OP *o) case OP_SCOPE: case OP_LEAVEWRITE: OP_REFCNT_LOCK; - if (OpREFCNT_dec(o)) { - OP_REFCNT_UNLOCK; - return; - } + refcnt = OpREFCNT_dec(o); OP_REFCNT_UNLOCK; + if (refcnt) + return; break; default: break; @@ -474,6 +474,18 @@ Perl_op_null(pTHX_ OP *o) o->op_ppaddr = PL_ppaddr[OP_NULL]; } +void +Perl_op_refcnt_lock(pTHX) +{ + OP_REFCNT_LOCK; +} + +void +Perl_op_refcnt_unlock(pTHX) +{ + OP_REFCNT_UNLOCK; +} + /* Contextualizers */ #define LINKLIST(o) ((o)->op_next ? (o)->op_next : linklist((OP*)o)) @@ -481,8 +481,13 @@ struct loop { #ifdef USE_ITHREADS # define OP_REFCNT_INIT MUTEX_INIT(&PL_op_mutex) -# define OP_REFCNT_LOCK MUTEX_LOCK(&PL_op_mutex) -# define OP_REFCNT_UNLOCK MUTEX_UNLOCK(&PL_op_mutex) +# ifdef PERL_CORE +# define OP_REFCNT_LOCK MUTEX_LOCK(&PL_op_mutex) +# define OP_REFCNT_UNLOCK MUTEX_UNLOCK(&PL_op_mutex) +# else +# define OP_REFCNT_LOCK op_refcnt_lock() +# define OP_REFCNT_UNLOCK op_refcnt_unlock() +# endif # define OP_REFCNT_TERM MUTEX_DESTROY(&PL_op_mutex) #else # define OP_REFCNT_INIT NOOP @@ -340,6 +340,8 @@ PERL_CALLCONV void Perl_lex_end(pTHX); PERL_CALLCONV void Perl_lex_start(pTHX_ SV* line); PERL_CALLCONV void Perl_op_null(pTHX_ OP* o); PERL_CALLCONV void Perl_op_clear(pTHX_ OP* o); +PERL_CALLCONV void Perl_op_refcnt_lock(pTHX); +PERL_CALLCONV void Perl_op_refcnt_unlock(pTHX); PERL_CALLCONV OP* Perl_linklist(pTHX_ OP* o); PERL_CALLCONV OP* Perl_list(pTHX_ OP* o); PERL_CALLCONV OP* Perl_listkids(pTHX_ OP* o); @@ -4967,6 +4967,7 @@ Perl_pregfree(pTHX_ struct regexp *r) int n = r->data->count; PAD* new_comppad = NULL; PAD* old_comppad; + PADOFFSET refcnt; while (--n >= 0) { /* If you add a ->what type here, update the comment in regcomp.h */ @@ -4989,13 +4990,10 @@ Perl_pregfree(pTHX_ struct regexp *r) new_comppad : Null(PAD *) ); OP_REFCNT_LOCK; - if (!OpREFCNT_dec((OP_4tree*)r->data->data[n])) { - OP_REFCNT_UNLOCK; + refcnt = OpREFCNT_dec((OP_4tree*)r->data->data[n]); + OP_REFCNT_UNLOCK; + if (!refcnt) op_free((OP_4tree*)r->data->data[n]); - } - else { - OP_REFCNT_UNLOCK; - } PAD_RESTORE_LOCAL(old_comppad); SvREFCNT_dec((SV*)new_comppad); |