diff options
| author | Daniel Eischen <deischen@FreeBSD.org> | 2003-11-04 19:49:56 +0000 |
|---|---|---|
| committer | Daniel Eischen <deischen@FreeBSD.org> | 2003-11-04 19:49:56 +0000 |
| commit | 358702366c7f1153b632164a0ebbbc2e54609c72 (patch) | |
| tree | a33d6c63283c302eaad019257473e23862fdb6d0 /lib/libc | |
| parent | 2a2cfa95fff3f419a940e8345f21759f2812854c (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/include/libc_private.h | 8 | ||||
| -rw-r--r-- | lib/libc/stdlib/malloc.c | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index f369cc7fe25c..d4265e9fcc1b 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -38,6 +38,8 @@ #ifndef _LIBC_PRIVATE_H_ #define _LIBC_PRIVATE_H_ +#include <spinlock.h> + /* * This global flag is non-zero when a process has created one * or more threads. It is used to avoid calling locking functions @@ -120,4 +122,10 @@ int _yp_check(char **); */ extern const char *__progname; +/* + * This is the lock to make malloc() thread-safe. It is externalized + * so that thread libraries can protect malloc across fork(). + */ +extern spinlock_t *__malloc_lock; + #endif /* _LIBC_PRIVATE_H_ */ diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 7006df261e55..d99457abaa9a 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); # include "libc_private.h" # include "spinlock.h" static spinlock_t thread_lock = _SPINLOCK_INITIALIZER; + spinlock_t *__malloc_lock = &thread_lock; # define _MALLOC_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock); # define _MALLOC_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock); #endif /* __FreeBSD__ */ |
