From 744842bf666f31cfdd355598c244cef2487eded4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Thu, 22 Apr 2010 05:41:17 +0000 Subject: nptl: fix malloc library locking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update malloc library to use internal uclibc locking primitives to get the libpthread calls correct. Signed-off-by: Timo Teräs Signed-off-by: Austin Foxley --- libc/stdlib/malloc/heap.h | 7 +++---- libc/stdlib/malloc/malloc.h | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'libc') diff --git a/libc/stdlib/malloc/heap.h b/libc/stdlib/malloc/heap.h index c0c5df821..30380791f 100644 --- a/libc/stdlib/malloc/heap.h +++ b/libc/stdlib/malloc/heap.h @@ -16,11 +16,10 @@ /* On multi-threaded systems, the heap includes a lock. */ #ifdef __UCLIBC_HAS_THREADS__ -# include -# include +# include # define HEAP_USE_LOCKING -# define __heap_lock(heap_lock) __pthread_mutex_lock (heap_lock) -# define __heap_unlock(heap_lock) __pthread_mutex_unlock (heap_lock) +# define __heap_lock(heap_lock) __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(*(heap_lock)) +# define __heap_unlock(heap_lock) __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(*(heap_lock)) #else # define __heap_lock(heap_lock) # define __heap_unlock(heap_lock) diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h index 2afc3a805..0a4b43b86 100644 --- a/libc/stdlib/malloc/malloc.h +++ b/libc/stdlib/malloc/malloc.h @@ -132,13 +132,12 @@ extern int __malloc_mmb_debug; /* Locking for multithreaded apps. */ #ifdef __UCLIBC_HAS_THREADS__ -# include -# include +# include # define MALLOC_USE_LOCKING -typedef pthread_mutex_t malloc_mutex_t; -# define MALLOC_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER +typedef __UCLIBC_MUTEX_TYPE malloc_mutex_t; +# define MALLOC_MUTEX_INIT __UCLIBC_MUTEX_INITIALIZER # ifdef MALLOC_USE_SBRK /* This lock is used to serialize uses of the `sbrk' function (in both @@ -146,8 +145,8 @@ typedef pthread_mutex_t malloc_mutex_t; things will break if these multiple calls are interleaved with another thread's use of sbrk!). */ extern malloc_mutex_t __malloc_sbrk_lock; -# define __malloc_lock_sbrk() __pthread_mutex_lock (&__malloc_sbrk_lock) -# define __malloc_unlock_sbrk() __pthread_mutex_unlock (&__malloc_sbrk_lock) +# define __malloc_lock_sbrk() __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE (__malloc_sbrk_lock) +# define __malloc_unlock_sbrk() __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE (__malloc_sbrk_lock) # endif /* MALLOC_USE_SBRK */ #else /* !__UCLIBC_HAS_THREADS__ */ -- cgit v1.2.3