From: Ilya Zakharevich Date: Tue, 25 Nov 1997 15:59:16 +0000 (+0000) Subject: Move malloc_mutex initialisation/destruction: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=18f739eeef869ffadc3775821df62e4b90bf75b0;p=p5sagit%2Fp5-mst-13.2.git Move malloc_mutex initialisation/destruction: Subject: patch to 5.004_54 for pthreads with Perl's malloc p4raw-id: //depot/perl@299 --- diff --git a/malloc.c b/malloc.c index 5f0c7fd..ae3773a 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 8a292e3..44f99c4 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 b62e3d0..9a3d267 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 381d574..8257b36 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 697765e..0ffb04c 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 isn't * included until after runops is initialised. diff --git a/plan9/plan9ish.h b/plan9/plan9ish.h index 3a5ad5e..9c8bd50 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 a13e2bd..e4687ce 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 410031c..f0de807 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