From 3668a2e4940ebe0e7c33729ad375a9a7b0c6ceb1 Mon Sep 17 00:00:00 2001 From: jasone Date: Thu, 12 Jan 2006 07:28:21 +0000 Subject: In preparation for a new malloc implementation: * Add posix_memalign(). * Move calloc() from calloc.c to malloc.c. Add a calloc() implementation in rtld-elf in order to make the loader happy (even though calloc() isn't used in rtld-elf). * Add _malloc_prefork() and _malloc_postfork(), and use them instead of directly manipulating __malloc_lock. Approved by: phk, markm (mentor) --- lib/libthr/thread/thr_fork.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/libthr/thread/thr_fork.c') diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c index 4c222d9..3a6ba51 100644 --- a/lib/libthr/thread/thr_fork.c +++ b/lib/libthr/thread/thr_fork.c @@ -94,12 +94,6 @@ _pthread_atfork(void (*prepare)(void), void (*parent)(void), return (0); } -/* - * For a while, allow libpthread to work with a libc that doesn't - * export the malloc lock. - */ -#pragma weak __malloc_lock - __weak_reference(_fork, fork); pid_t @@ -129,9 +123,9 @@ _fork(void) * child process because another thread in malloc code will * simply be kill by fork(). */ - if ((_thr_isthreaded() != 0) && (__malloc_lock != NULL)) { + if (_thr_isthreaded() != 0) { unlock_malloc = 1; - _spinlock(__malloc_lock); + _malloc_prefork(); } else { unlock_malloc = 0; } @@ -160,7 +154,7 @@ _fork(void) _thr_umtx_init(&_thr_atfork_lock); _thr_setthreaded(0); - /* reinitialize libc spinlocks, this includes __malloc_lock. */ + /* reinitialize libc spinlocks. */ _thr_spinlock_init(); _mutex_fork(curthread); @@ -183,7 +177,7 @@ _fork(void) _thr_signal_unblock(curthread); if (unlock_malloc) - _spinunlock(__malloc_lock); + _malloc_postfork(); /* Run down atfork parent handlers. */ TAILQ_FOREACH(af, &_thr_atfork_list, qe) { -- cgit v1.1