From a5414fd15ca7b0629ce77950585d4002ff2ef09a Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 14 Jan 2004 22:37:55 +0000 Subject: Include missing errno.h header (as noted by Alan Hourihane). Fix uninitialized pthread mutex used to lock the list of aligned memory blocks. --- libc/stdlib/malloc-simple/alloc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libc/stdlib') diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c index fcac02927..4c6edd1f9 100644 --- a/libc/stdlib/malloc-simple/alloc.c +++ b/libc/stdlib/malloc-simple/alloc.c @@ -6,12 +6,14 @@ * Parts of the memalign code were stolen from malloc-930716. */ +#define _GNU_SOURCE #include #include #include #include #include #include +#include #include @@ -121,9 +123,9 @@ void free(void *ptr) #ifdef L_memalign #ifdef __UCLIBC_HAS_THREADS__ #include -extern pthread_mutex_t __malloclock; -# define LOCK __pthread_mutex_lock(&__malloclock) -# define UNLOCK __pthread_mutex_unlock(&__malloclock); +pthread_mutex_t __malloc_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +# define LOCK __pthread_mutex_lock(&__malloc_lock) +# define UNLOCK __pthread_mutex_unlock(&__malloc_lock); #else # define LOCK # define UNLOCK -- cgit v1.2.3