diff options
author | jasone <jasone@FreeBSD.org> | 2006-01-12 07:28:21 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2006-01-12 07:28:21 +0000 |
commit | 3668a2e4940ebe0e7c33729ad375a9a7b0c6ceb1 (patch) | |
tree | 25770955017440672d2cba68e6d8c382b53d9f75 /lib/libthr | |
parent | 40e5b400fdbcc7db744cb07d18d2c5dcfdb6fd18 (diff) | |
download | FreeBSD-src-3668a2e4940ebe0e7c33729ad375a9a7b0c6ceb1.zip FreeBSD-src-3668a2e4940ebe0e7c33729ad375a9a7b0c6ceb1.tar.gz |
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)
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_fork.c | 14 |
1 files changed, 4 insertions, 10 deletions
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) { |