diff options
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
-rw-r--r-- | src/lib/libc/stdlib/malloc.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index d1d8759791..ecbf93dc48 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #if defined(LIBC_SCCS) && !defined(lint) | 10 | #if defined(LIBC_SCCS) && !defined(lint) |
11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.32 1998/08/06 16:26:32 millert Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.33 1998/11/20 11:18:50 d Exp $"; |
12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ |
13 | 13 | ||
14 | /* | 14 | /* |
@@ -87,15 +87,27 @@ static char rcsid[] = "$OpenBSD: malloc.c,v 1.32 1998/08/06 16:26:32 millert Exp | |||
87 | #endif /* __OpenBSD__ */ | 87 | #endif /* __OpenBSD__ */ |
88 | 88 | ||
89 | #ifdef _THREAD_SAFE | 89 | #ifdef _THREAD_SAFE |
90 | #include <pthread.h> | 90 | # include "thread_private.h" |
91 | static pthread_mutex_t malloc_lock; | 91 | # if 0 |
92 | #define THREAD_LOCK() pthread_mutex_lock(&malloc_lock) | 92 | /* kernel threads */ |
93 | #define THREAD_UNLOCK() pthread_mutex_unlock(&malloc_lock) | 93 | # include <pthread.h> |
94 | #define THREAD_LOCK_INIT() pthread_mutex_init(&malloc_lock, 0); | 94 | static pthread_mutex_t malloc_lock; |
95 | # define THREAD_LOCK() pthread_mutex_lock(&malloc_lock) | ||
96 | # define THREAD_UNLOCK() pthread_mutex_unlock(&malloc_lock) | ||
97 | # define THREAD_LOCK_INIT() pthread_mutex_init(&malloc_lock, 0); | ||
98 | # else | ||
99 | /* user threads */ | ||
100 | # include "spinlock.h" | ||
101 | static spinlock_t malloc_lock = _SPINLOCK_INITIALIZER; | ||
102 | # define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&malloc_lock) | ||
103 | # define THREAD_UNLOCK() if (__isthreaded) _SPINUNLOCK(&malloc_lock) | ||
104 | # define THREAD_LOCK_INIT() | ||
105 | # endif | ||
95 | #else | 106 | #else |
96 | #define THREAD_LOCK() | 107 | /* no threads */ |
97 | #define THREAD_UNLOCK() | 108 | # define THREAD_LOCK() |
98 | #define THREAD_LOCK_INIT() | 109 | # define THREAD_UNLOCK() |
110 | # define THREAD_LOCK_INIT() | ||
99 | #endif | 111 | #endif |
100 | 112 | ||
101 | /* | 113 | /* |