Update malloc library to use internal uclibc locking primitives
to get the libpthread calls correct.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
/* On multi-threaded systems, the heap includes a lock. */
#ifdef __UCLIBC_HAS_THREADS__
/* On multi-threaded systems, the heap includes a lock. */
#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
-# include <bits/uClibc_pthread.h>
+# include <bits/uClibc_mutex.h>
# define HEAP_USE_LOCKING
# 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)
#else
# define __heap_lock(heap_lock)
# define __heap_unlock(heap_lock)
/* Locking for multithreaded apps. */
#ifdef __UCLIBC_HAS_THREADS__
/* Locking for multithreaded apps. */
#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
-# include <bits/uClibc_pthread.h>
+# include <bits/uClibc_mutex.h>
# define MALLOC_USE_LOCKING
# 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
# ifdef MALLOC_USE_SBRK
/* This lock is used to serialize uses of the `sbrk' function (in both
things will break if these multiple calls are interleaved with another
thread's use of sbrk!). */
extern malloc_mutex_t __malloc_sbrk_lock;
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__ */
# endif /* MALLOC_USE_SBRK */
#else /* !__UCLIBC_HAS_THREADS__ */