This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix Win32 breakage caused by changes to op.c in change 23433.
authorSteve Hay <SteveHay@planit.com>
Tue, 16 Nov 2004 09:42:50 +0000 (09:42 +0000)
committerSteve Hay <SteveHay@planit.com>
Tue, 16 Nov 2004 09:42:50 +0000 (09:42 +0000)
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

embed.fnc
embed.h
global.sym
op.c
op.h
proto.h
regcomp.c

index 614e975..64d052f 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -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
diff --git a/embed.h b/embed.h
index d082754..0587801 100644 (file)
--- a/embed.h
+++ b/embed.h
 #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
 #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
index d97151e..0ff8888 100644 (file)
@@ -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
diff --git a/op.c b/op.c
index 614e211..8a5c765 100644 (file)
--- a/op.c
+++ b/op.c
@@ -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))
diff --git a/op.h b/op.h
index d72c52e..2e73168 100644 (file)
--- a/op.h
+++ b/op.h
@@ -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
diff --git a/proto.h b/proto.h
index bd14810..5897ead 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -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);
index 97e81bc..7b4d647 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -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);