summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>1997-11-25 15:59:16 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-11-25 15:59:16 +0000
commit18f739eeef869ffadc3775821df62e4b90bf75b0 (patch)
tree53cd79aed73f55f7b2876741c2fb27786134a75a
parentd0066dc7de72349a42c2c47e1fc66da2ba66542a (diff)
downloadperl-18f739eeef869ffadc3775821df62e4b90bf75b0.tar.gz
Move malloc_mutex initialisation/destruction:
Subject: patch to 5.004_54 for pthreads with Perl's malloc p4raw-id: //depot/perl@299
-rw-r--r--malloc.c1
-rw-r--r--os2/os2.c1
-rw-r--r--os2/os2ish.h2
-rw-r--r--perl.c2
-rw-r--r--perl.h8
-rw-r--r--plan9/plan9ish.h4
-rw-r--r--unixish.h6
-rw-r--r--vms/vmsish.h4
8 files changed, 18 insertions, 10 deletions
diff --git a/malloc.c b/malloc.c
index 5f0c7fd185..ae3773acc0 100644
--- a/malloc.c
+++ b/malloc.c
@@ -191,6 +191,7 @@ emergency_sbrk(size)
}
if (!emergency_buffer) {
+ dTHR;
/* First offense, give a possibility to recover by dieing. */
/* No malloc involved here: */
GV **gvp = (GV**)hv_fetch(defstash, "^M", 2, 0);
diff --git a/os2/os2.c b/os2/os2.c
index 8a292e30f2..44f99c4c24 100644
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -1147,6 +1147,7 @@ Perl_OS2_init(char **env)
{
char *shell;
+ MALLOC_INIT;
settmppath();
OS2_Perl_data.xs_init = &Xs_OS2_init;
if (environ == NULL) {
diff --git a/os2/os2ish.h b/os2/os2ish.h
index b62e3d04d4..9a3d267ae5 100644
--- a/os2/os2ish.h
+++ b/os2/os2ish.h
@@ -74,7 +74,7 @@ void Perl_OS2_init(char **);
_wildcard(argcp, argvp); \
Perl_OS2_init(env); } STMT_END
-#define PERL_SYS_TERM()
+#define PERL_SYS_TERM() MALLOC_TERM
/* #define PERL_SYS_TERM() STMT_START { \
if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
diff --git a/perl.c b/perl.c
index 381d5748a2..8257b36408 100644
--- a/perl.c
+++ b/perl.c
@@ -134,7 +134,6 @@ perl_construct(register PerlInterpreter *sv_interp)
if (pthread_key_create(&thr_key, 0))
croak("panic: pthread_key_create");
#endif
- MUTEX_INIT(&malloc_mutex);
MUTEX_INIT(&sv_mutex);
/*
* Safe to use basic SV functions from now on (though
@@ -529,7 +528,6 @@ perl_destruct(register PerlInterpreter *sv_interp)
DEBUG_P(debprofdump());
#ifdef USE_THREADS
MUTEX_DESTROY(&sv_mutex);
- MUTEX_DESTROY(&malloc_mutex);
MUTEX_DESTROY(&eval_mutex);
COND_DESTROY(&eval_cond);
diff --git a/perl.h b/perl.h
index 697765ea29..0ffb04c74b 100644
--- a/perl.h
+++ b/perl.h
@@ -1343,6 +1343,14 @@ typedef Sighandler_t Sigsave_t;
# define RUNOPS_DEFAULT runops_standard
#endif
+#ifdef MYMALLOC
+# define MALLOC_INIT MUTEX_INIT(&malloc_mutex)
+# define MALLOC_TERM MUTEX_DESTROY(&malloc_mutex)
+#else
+# define MALLOC_INIT
+# define MALLOC_TERM
+#endif
+
/*
* These need prototyping here because <proto.h> isn't
* included until after runops is initialised.
diff --git a/plan9/plan9ish.h b/plan9/plan9ish.h
index 3a5ad5eb1a..9c8bd5049f 100644
--- a/plan9/plan9ish.h
+++ b/plan9/plan9ish.h
@@ -98,9 +98,9 @@
#define ABORT() kill(getpid(),SIGABRT);
#define BIT_BUCKET "/dev/null"
-#define PERL_SYS_INIT(c,v)
+#define PERL_SYS_INIT(c,v) MALLOC_INIT
#define dXSUB_SYS
-#define PERL_SYS_TERM()
+#define PERL_SYS_TERM() MALLOC_TERM
/*
* fwrite1() should be a routine with the same calling sequence as fwrite(),
diff --git a/unixish.h b/unixish.h
index a13e2bd86a..e4687ce50f 100644
--- a/unixish.h
+++ b/unixish.h
@@ -109,14 +109,14 @@
#ifndef PERL_SYS_INIT
#ifdef PERL_SCO5
/* this should be set in a hint file, not here */
-# define PERL_SYS_INIT(c,v) fpsetmask(0)
+# define PERL_SYS_INIT(c,v) fpsetmask(0); MALLOC_INIT
#else
-# define PERL_SYS_INIT(c,v)
+# define PERL_SYS_INIT(c,v) MALLOC_INIT
#endif
#endif
#ifndef PERL_SYS_TERM
-#define PERL_SYS_TERM()
+#define PERL_SYS_TERM() MALLOC_TERM
#endif
#define BIT_BUCKET "/dev/null"
diff --git a/vms/vmsish.h b/vms/vmsish.h
index 410031cca3..f0de807920 100644
--- a/vms/vmsish.h
+++ b/vms/vmsish.h
@@ -233,8 +233,8 @@
#endif
#define BIT_BUCKET "_NLA0:"
-#define PERL_SYS_INIT(c,v) vms_image_init((c),(v))
-#define PERL_SYS_TERM()
+#define PERL_SYS_INIT(c,v) vms_image_init((c),(v)), MALLOC_INIT
+#define PERL_SYS_TERM() MALLOC_TERM
#define dXSUB_SYS
#define HAS_KILL
#define HAS_WAIT