summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-03-08 12:08:17 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-03-08 12:08:17 +0000
commit534825c439e9bf017f3cdaf88d284d58d5eac6bd (patch)
tree1884c58f0eef7d68e5cd924efde5a05d8c8b6e0b
parente23b9d0f648442d8e275530c0bf8b0027cee41d1 (diff)
downloadperl-534825c439e9bf017f3cdaf88d284d58d5eac6bd.tar.gz
add missing locks for op refcounts
p4raw-id: //depot/perl@5610
-rw-r--r--dosish.h2
-rw-r--r--embedvar.h2
-rw-r--r--makedef.pl1
-rw-r--r--op.c13
-rw-r--r--op.h17
-rw-r--r--perl.c6
-rw-r--r--perlapi.h2
-rw-r--r--perlvars.h4
-rw-r--r--sv.c4
-rw-r--r--unixish.h2
-rw-r--r--vms/vmsish.h2
11 files changed, 34 insertions, 21 deletions
diff --git a/dosish.h b/dosish.h
index 7b2a1bdfa5..be7020d121 100644
--- a/dosish.h
+++ b/dosish.h
@@ -30,7 +30,7 @@
# endif
#endif /* DJGPP */
-#define PERL_SYS_TERM() MALLOC_TERM
+#define PERL_SYS_TERM() OP_REFCNT_TERM; MALLOC_TERM
#define dXSUB_SYS
/*
diff --git a/embedvar.h b/embedvar.h
index f7549406ea..f8387c519d 100644
--- a/embedvar.h
+++ b/embedvar.h
@@ -1648,6 +1648,7 @@
#define PL_do_undump (PL_Vars.Gdo_undump)
#define PL_hexdigit (PL_Vars.Ghexdigit)
#define PL_malloc_mutex (PL_Vars.Gmalloc_mutex)
+#define PL_op_mutex (PL_Vars.Gop_mutex)
#define PL_patleave (PL_Vars.Gpatleave)
#define PL_thr_key (PL_Vars.Gthr_key)
@@ -1659,6 +1660,7 @@
#define PL_Gdo_undump PL_do_undump
#define PL_Ghexdigit PL_hexdigit
#define PL_Gmalloc_mutex PL_malloc_mutex
+#define PL_Gop_mutex PL_op_mutex
#define PL_Gpatleave PL_patleave
#define PL_Gthr_key PL_thr_key
diff --git a/makedef.pl b/makedef.pl
index 1170ba5912..0aec81e31a 100644
--- a/makedef.pl
+++ b/makedef.pl
@@ -413,6 +413,7 @@ unless ($define{'USE_5005THREADS'}) {
unless ($define{'USE_ITHREADS'}) {
skip_symbols [qw(
PL_ptr_table
+ PL_op_mutex
Perl_dirp_dup
Perl_cx_dup
Perl_si_dup
diff --git a/op.c b/op.c
index 11ff181c83..d6a16db0aa 100644
--- a/op.c
+++ b/op.c
@@ -22,19 +22,6 @@
/* #define PL_OP_SLAB_ALLOC */
-/* XXXXXX testing */
-#ifdef USE_ITHREADS
-# define OP_REFCNT_LOCK NOOP
-# define OP_REFCNT_UNLOCK NOOP
-# define OpREFCNT_set(o,n) ((o)->op_targ = (n))
-# define OpREFCNT_dec(o) (--(o)->op_targ)
-#else
-# define OP_REFCNT_LOCK NOOP
-# define OP_REFCNT_UNLOCK NOOP
-# define OpREFCNT_set(o,n) NOOP
-# define OpREFCNT_dec(o) 0
-#endif
-
#ifdef PL_OP_SLAB_ALLOC
#define SLAB_SIZE 8192
static char *PL_OpPtr = NULL;
diff --git a/op.h b/op.h
index c9ec2df6f0..da03aa46db 100644
--- a/op.h
+++ b/op.h
@@ -401,3 +401,20 @@ struct loop {
#define OA_SCALARREF 7
#define OA_OPTIONAL 8
+#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)
+# define OP_REFCNT_TERM MUTEX_DESTROY(&PL_op_mutex)
+# define OpREFCNT_set(o,n) ((o)->op_targ = (n))
+# define OpREFCNT_inc(o) ((o) ? (++(o)->op_targ, (o)) : Nullop)
+# define OpREFCNT_dec(o) (--(o)->op_targ)
+#else
+# define OP_REFCNT_INIT NOOP
+# define OP_REFCNT_LOCK NOOP
+# define OP_REFCNT_UNLOCK NOOP
+# define OP_REFCNT_TERM NOOP
+# define OpREFCNT_set(o,n) NOOP
+# define OpREFCNT_inc(o) (o)
+# define OpREFCNT_dec(o) 0
+#endif
diff --git a/perl.c b/perl.c
index 2dbfc8e193..715f4da4ae 100644
--- a/perl.c
+++ b/perl.c
@@ -64,8 +64,12 @@ static I32 read_e_script(pTHXo_ int idx, SV *buf_sv, int maxlen);
PERL_SET_INTERP(my_perl); \
INIT_THREADS; \
ALLOC_THREAD_KEY; \
+ PERL_SET_THX(my_perl); \
+ OP_REFCNT_INIT; \
+ } \
+ else { \
+ PERL_SET_THX(my_perl); \
} \
- PERL_SET_THX(my_perl); \
} STMT_END
# else
# define INIT_TLS_AND_INTERP \
diff --git a/perlapi.h b/perlapi.h
index 70a2187389..5e5ac2825b 100644
--- a/perlapi.h
+++ b/perlapi.h
@@ -878,6 +878,8 @@ START_EXTERN_C
#define PL_hexdigit (*Perl_Ghexdigit_ptr(NULL))
#undef PL_malloc_mutex
#define PL_malloc_mutex (*Perl_Gmalloc_mutex_ptr(NULL))
+#undef PL_op_mutex
+#define PL_op_mutex (*Perl_Gop_mutex_ptr(NULL))
#undef PL_patleave
#define PL_patleave (*Perl_Gpatleave_ptr(NULL))
#undef PL_thr_key
diff --git a/perlvars.h b/perlvars.h
index 4df31bb4a0..bd07adc59f 100644
--- a/perlvars.h
+++ b/perlvars.h
@@ -34,3 +34,7 @@ PERLVARI(Gdo_undump, bool, FALSE) /* -u or dump seen? */
#if defined(MYMALLOC) && (defined(USE_THREADS) || defined(USE_ITHREADS))
PERLVAR(Gmalloc_mutex, perl_mutex) /* Mutex for malloc */
#endif
+
+#if defined(USE_ITHREADS)
+PERLVAR(Gop_mutex, perl_mutex) /* Mutex for op refcounting */
+#endif
diff --git a/sv.c b/sv.c
index 6f40d6fa92..ff21757777 100644
--- a/sv.c
+++ b/sv.c
@@ -6382,10 +6382,6 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
# include "error: USE_THREADS and USE_ITHREADS are incompatible"
#endif
-#ifndef OpREFCNT_inc
-# define OpREFCNT_inc(o) ((o) ? (++(o)->op_targ, (o)) : Nullop)
-#endif
-
#ifndef GpREFCNT_inc
# define GpREFCNT_inc(gp) ((gp) ? (++(gp)->gp_refcnt, (gp)) : (GP*)NULL)
#endif
diff --git a/unixish.h b/unixish.h
index 24da4296fb..1168d297b6 100644
--- a/unixish.h
+++ b/unixish.h
@@ -135,7 +135,7 @@
#endif
#ifndef PERL_SYS_TERM
-#define PERL_SYS_TERM() MALLOC_TERM
+#define PERL_SYS_TERM() OP_REFCNT_TERM; MALLOC_TERM
#endif
#define BIT_BUCKET "/dev/null"
diff --git a/vms/vmsish.h b/vms/vmsish.h
index a09d2be438..6c5c506a42 100644
--- a/vms/vmsish.h
+++ b/vms/vmsish.h
@@ -257,7 +257,7 @@
#define BIT_BUCKET "_NLA0:"
#define PERL_SYS_INIT(c,v) vms_image_init((c),(v)); MALLOC_INIT
-#define PERL_SYS_TERM() MALLOC_TERM
+#define PERL_SYS_TERM() OP_REFCNT_TERM; MALLOC_TERM
#define dXSUB_SYS
#define HAS_KILL
#define HAS_WAIT