summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2006-12-07 23:24:19 +0000
committerEric Andersen <andersen@codepoet.org>2006-12-07 23:24:19 +0000
commit275a4c4e6fd115a0eb4c7a15e9ac4a92414cd839 (patch)
treee0e9abc0c1a61a6c1c99601caa7c9363e8910637 /libc/stdlib/malloc
parent1478c2de052374c6356db5513749a144c13791b1 (diff)
Major cleanup of internal mutex locking. Be more consistant in how we do
things, and avoid potential deadlocks caused when a thread holding a uClibc internal lock get canceled and terminates without releasing the lock. This change also provides a single place, bits/uClibc_mutex.h, for thread libraries to modify to change all instances of internal locking.
Diffstat (limited to 'libc/stdlib/malloc')
-rw-r--r--libc/stdlib/malloc/heap.h8
-rw-r--r--libc/stdlib/malloc/malloc.h8
2 files changed, 8 insertions, 8 deletions
diff --git a/libc/stdlib/malloc/heap.h b/libc/stdlib/malloc/heap.h
index b66b5ecef..ad891fafb 100644
--- a/libc/stdlib/malloc/heap.h
+++ b/libc/stdlib/malloc/heap.h
@@ -16,7 +16,7 @@
/* On multi-threaded systems, the heap includes a lock. */
#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
+# include <bits/uClibc_mutex.h>
# define HEAP_USE_LOCKING
#endif
@@ -39,7 +39,7 @@ struct heap
/* A lock that can be used by callers to control access to the heap.
The heap code _does not_ use this lock, it's merely here for the
convenience of users! */
- pthread_mutex_t lock;
+ __UCLIBC_MUTEX_TYPE lock;
#endif
};
@@ -135,8 +135,8 @@ extern void __heap_dump (struct heap *heap, const char *str);
extern void __heap_check (struct heap *heap, const char *str);
-#define __heap_lock(heap) __pthread_mutex_lock (&(heap)->lock)
-#define __heap_unlock(heap) __pthread_mutex_unlock (&(heap)->lock)
+#define __heap_lock(heap) __UCLIBC_MUTEX_LOCK (&(heap)->lock)
+#define __heap_unlock(heap) __UCLIBC_MUTEX_UNLOCK (&(heap)->lock)
/* Delete the free-area FA from HEAP. */
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h
index b41c4b08e..177d8c236 100644
--- a/libc/stdlib/malloc/malloc.h
+++ b/libc/stdlib/malloc/malloc.h
@@ -125,11 +125,11 @@ extern int __malloc_mmb_debug;
/* Locking for multithreaded apps. */
#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
+# include <bits/uClibc_mutex.h>
# define MALLOC_USE_LOCKING
-typedef pthread_mutex_t malloc_mutex_t;
+typedef __UCLIBC_MUTEX_TYPE malloc_mutex_t;
# define MALLOC_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
# ifdef MALLOC_USE_SBRK
@@ -138,8 +138,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 (&__malloc_sbrk_lock)
+# define __malloc_unlock_sbrk() __UCLIBC_MUTEX_UNLOCK (&__malloc_sbrk_lock)
# endif /* MALLOC_USE_SBRK */
#else /* !__UCLIBC_HAS_THREADS__ */