summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Mulder <hansmu@xs4all.nl>1998-11-07 23:06:20 +0100
committerJarkko Hietaniemi <jhi@iki.fi>1998-11-07 21:14:18 +0000
commit3541dd58afee4802e6d8771e6ed02e20cc107e31 (patch)
treebc1451cb3edc634038097a76d378eb01f690f511
parentacc3bde0c1cc7602c674eca404394646c15d87f1 (diff)
downloadperl-3541dd58afee4802e6d8771e6ed02e20cc107e31.tar.gz
Finalize the Mach CThreads support.
To: Gurusamy Sarathy <gsar@engin.umich.edu> Cc: jhi@iki.fi, perl5-porters@perl.org Subject: [PATCH] Re: Not OK: perl 5.00553 on OPENSTEP-Mach 4_1 (UNINSTALLED) Message-Id: <9811072105.AA07794@icgned.icgroup.nl> p4raw-id: //depot/cfgperl@2211
-rw-r--r--malloc.c24
-rw-r--r--perl.h18
2 files changed, 32 insertions, 10 deletions
diff --git a/malloc.c b/malloc.c
index 65cddbee83..5d795e4ed7 100644
--- a/malloc.c
+++ b/malloc.c
@@ -570,6 +570,13 @@ static char bucket_of[] =
# define BIG_SIZE (1<<16) /* 64K */
# endif
+#ifdef I_MACH_CTHREADS
+#undef MUTEX_LOCK
+#define MUTEX_LOCK(m) STMT_START { if (*m) mutex_lock(*m); } STMT_END
+#undef MUTEX_UNLOCK
+#define MUTEX_UNLOCK(m) STMT_START { if (*m) mutex_unlock(*m); } STMT_END
+#endif
+
static char *emergency_buffer;
static MEM_SIZE emergency_buffer_size;
static Malloc_t emergency_sbrk(MEM_SIZE size);
@@ -670,7 +677,8 @@ static u_int start_slack;
static u_int goodsbrk;
#ifdef DEBUGGING
-#define P_ASSERT(p,diag) if (!(p)) botch(diag,STRINGIFY(p)); else
+#undef ASSERT
+#define ASSERT(p,diag) if (!(p)) botch(diag,STRINGIFY(p)); else
static void
botch(char *diag, char *s)
{
@@ -678,7 +686,7 @@ botch(char *diag, char *s)
PerlProc_abort();
}
#else
-#define P_ASSERT(p, diag)
+#define ASSERT(p, diag)
#endif
Malloc_t
@@ -1219,7 +1227,7 @@ free(void *mp)
}
MUTEX_LOCK(&PL_malloc_mutex);
#ifdef RCHECK
- P_ASSERT(ovp->ov_rmagic == RMAGIC, "chunk's head overwrite");
+ ASSERT(ovp->ov_rmagic == RMAGIC, "chunk's head overwrite");
if (OV_INDEX(ovp) <= MAX_SHORT_BUCKET) {
int i;
MEM_SIZE nbytes = ovp->ov_size + 1;
@@ -1227,16 +1235,16 @@ free(void *mp)
if ((i = nbytes & 3)) {
i = 4 - i;
while (i--) {
- P_ASSERT(*((char *)((caddr_t)ovp + nbytes - RSLOP + i))
+ ASSERT(*((char *)((caddr_t)ovp + nbytes - RSLOP + i))
== RMAGIC_C, "chunk's tail overwrite");
}
}
nbytes = (nbytes + 3) &~ 3;
- P_ASSERT(*(u_int *)((caddr_t)ovp + nbytes - RSLOP) == RMAGIC, "chunk's tail overwrite");
+ ASSERT(*(u_int *)((caddr_t)ovp + nbytes - RSLOP) == RMAGIC, "chunk's tail overwrite");
}
ovp->ov_rmagic = RMAGIC - 1;
#endif
- P_ASSERT(OV_INDEX(ovp) < NBUCKETS, "chunk's head overwrite");
+ ASSERT(OV_INDEX(ovp) < NBUCKETS, "chunk's head overwrite");
size = OV_INDEX(ovp);
ovp->ov_next = nextf[size];
nextf[size] = ovp;
@@ -1352,11 +1360,11 @@ realloc(void *mp, size_t nbytes)
if ((i = nb & 3)) {
i = 4 - i;
while (i--) {
- P_ASSERT(*((char *)((caddr_t)ovp + nb - RSLOP + i)) == RMAGIC_C, "chunk's tail overwrite");
+ ASSERT(*((char *)((caddr_t)ovp + nb - RSLOP + i)) == RMAGIC_C, "chunk's tail overwrite");
}
}
nb = (nb + 3) &~ 3;
- P_ASSERT(*(u_int *)((caddr_t)ovp + nb - RSLOP) == RMAGIC, "chunk's tail overwrite");
+ ASSERT(*(u_int *)((caddr_t)ovp + nb - RSLOP) == RMAGIC, "chunk's tail overwrite");
/*
* Convert amount of memory requested into
* closest block size stored in hash buckets
diff --git a/perl.h b/perl.h
index e2a5a4c900..ba898c49e2 100644
--- a/perl.h
+++ b/perl.h
@@ -1816,8 +1816,22 @@ typedef Sighandler_t Sigsave_t;
#endif
#ifdef MYMALLOC
-# define MALLOC_INIT MUTEX_INIT(&PL_malloc_mutex)
-# define MALLOC_TERM MUTEX_DESTROY(&PL_malloc_mutex)
+# ifdef I_MACH_CTHREADS
+# define MALLOC_INIT \
+ STMT_START { \
+ PL_malloc_mutex = NULL; \
+ MUTEX_INIT(&PL_malloc_mutex); \
+ } STMT_END
+# define MALLOC_TERM \
+ STMT_START { \
+ perl_mutex tmp = PL_malloc_mutex; \
+ PL_malloc_mutex = NULL; \
+ MUTEX_DESTROY(&tmp); \
+ } STMT_END
+# else
+# define MALLOC_INIT MUTEX_INIT(&PL_malloc_mutex)
+# define MALLOC_TERM MUTEX_DESTROY(&PL_malloc_mutex)
+# endif
#else
# define MALLOC_INIT
# define MALLOC_TERM