svn commit: trunk/uClibc/libc/stdlib/malloc

andersen at uclibc.org andersen at uclibc.org
Mon Dec 11 05:28:24 UTC 2006


Author: andersen
Date: 2006-12-10 21:28:24 -0800 (Sun, 10 Dec 2006)
New Revision: 16845

Log:
mostly revert the locking changes for 'malloc', as the implementation
does not easily lend itself to becoming complete pthread cancelation
safe without first investing in some deep and serious thought...
The other malloc implementations are pthread cancelation safe, and
this one is mostly used for uClinux, where the lack is at least less
likely to be a common problem.


Modified:
   trunk/uClibc/libc/stdlib/malloc/heap.h
   trunk/uClibc/libc/stdlib/malloc/malloc.h


Changeset:
Modified: trunk/uClibc/libc/stdlib/malloc/heap.h
===================================================================
--- trunk/uClibc/libc/stdlib/malloc/heap.h	2006-12-11 04:24:55 UTC (rev 16844)
+++ trunk/uClibc/libc/stdlib/malloc/heap.h	2006-12-11 05:28:24 UTC (rev 16845)
@@ -16,7 +16,8 @@
 
 /* On multi-threaded systems, the heap includes a lock.  */
 #ifdef __UCLIBC_HAS_THREADS__
-# include <bits/uClibc_mutex.h>
+# include <pthread.h>
+# include <bits/uClibc_pthread.h>
 # define HEAP_USE_LOCKING
 #endif
 
@@ -39,7 +40,7 @@
   /* 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!  */
-  __UCLIBC_MUTEX_TYPE lock;
+  pthread_mutex_t lock;
 #endif
 };
 
@@ -135,8 +136,8 @@
 extern void __heap_check (struct heap *heap, const char *str);
 
 
-#define __heap_lock(heap)	__UCLIBC_MUTEX_LOCK (&(heap)->lock)
-#define __heap_unlock(heap)	__UCLIBC_MUTEX_UNLOCK (&(heap)->lock)
+#define __heap_lock(heap)	__pthread_mutex_lock (&(heap)->lock)
+#define __heap_unlock(heap)	__pthread_mutex_unlock (&(heap)->lock)
 
 
 /* Delete the free-area FA from HEAP.  */

Modified: trunk/uClibc/libc/stdlib/malloc/malloc.h
===================================================================
--- trunk/uClibc/libc/stdlib/malloc/malloc.h	2006-12-11 04:24:55 UTC (rev 16844)
+++ trunk/uClibc/libc/stdlib/malloc/malloc.h	2006-12-11 05:28:24 UTC (rev 16845)
@@ -125,11 +125,12 @@
 /* Locking for multithreaded apps.  */
 #ifdef __UCLIBC_HAS_THREADS__
 
-# include <bits/uClibc_mutex.h>
+# include <pthread.h>
+# include <bits/uClibc_pthread.h>
 
 # define MALLOC_USE_LOCKING
 
-typedef __UCLIBC_MUTEX_TYPE malloc_mutex_t;
+typedef pthread_mutex_t malloc_mutex_t;
 # define MALLOC_MUTEX_INIT	PTHREAD_MUTEX_INITIALIZER
 
 # ifdef MALLOC_USE_SBRK
@@ -138,8 +139,8 @@
    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()	__UCLIBC_MUTEX_LOCK (&__malloc_sbrk_lock)
-#  define __malloc_unlock_sbrk() __UCLIBC_MUTEX_UNLOCK (&__malloc_sbrk_lock)
+#  define __malloc_lock_sbrk()	__pthread_mutex_lock (&__malloc_sbrk_lock)
+#  define __malloc_unlock_sbrk() __pthread_mutex_unlock (&__malloc_sbrk_lock)
 # endif /* MALLOC_USE_SBRK */
 
 #else /* !__UCLIBC_HAS_THREADS__ */




More information about the uClibc-cvs mailing list