Browse Source

- remove some bloat that was added in r23660 and subsequent r23698.
The sbrk lock is only needed for LT.old

Bernhard Reutner-Fischer 16 years ago
parent
commit
5fefc2d24a
3 changed files with 13 additions and 15 deletions
  1. 1 1
      libc/stdlib/malloc/free.c
  2. 4 4
      libc/stdlib/malloc/malloc.c
  3. 8 10
      libc/stdlib/malloc/malloc.h

+ 1 - 1
libc/stdlib/malloc/free.c

@@ -30,7 +30,7 @@
 static void
 static void
 __free_to_heap (void *mem, struct heap_free_area **heap
 __free_to_heap (void *mem, struct heap_free_area **heap
 #ifdef HEAP_USE_LOCKING
 #ifdef HEAP_USE_LOCKING
-		, malloc_mutex_t *heap_lock
+		, pthread_mutex_t *heap_lock
 #endif
 #endif
 	       )
 	       )
 {
 {

+ 4 - 4
libc/stdlib/malloc/malloc.c

@@ -28,12 +28,12 @@
 HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 256);
 HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 256);
 struct heap_free_area *__malloc_heap = HEAP_INIT_WITH_FA (initial_fa);
 struct heap_free_area *__malloc_heap = HEAP_INIT_WITH_FA (initial_fa);
 #ifdef HEAP_USE_LOCKING
 #ifdef HEAP_USE_LOCKING
-malloc_mutex_t __malloc_heap_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t __malloc_heap_lock = PTHREAD_MUTEX_INITIALIZER;
 #endif
 #endif
 
 
 #if defined(MALLOC_USE_LOCKING) && defined(MALLOC_USE_SBRK)
 #if defined(MALLOC_USE_LOCKING) && defined(MALLOC_USE_SBRK)
 /* A lock protecting our use of sbrk.  */
 /* A lock protecting our use of sbrk.  */
-malloc_mutex_t __malloc_sbrk_lock;
+pthread_mutex_t __malloc_sbrk_lock;
 #endif /* MALLOC_USE_LOCKING && MALLOC_USE_SBRK */
 #endif /* MALLOC_USE_LOCKING && MALLOC_USE_SBRK */
 
 
 
 
@@ -48,7 +48,7 @@ struct malloc_mmb *__malloc_mmapped_blocks = 0;
 HEAP_DECLARE_STATIC_FREE_AREA (initial_mmb_fa, 48); /* enough for 3 mmbs */
 HEAP_DECLARE_STATIC_FREE_AREA (initial_mmb_fa, 48); /* enough for 3 mmbs */
 struct heap_free_area *__malloc_mmb_heap = HEAP_INIT_WITH_FA (initial_mmb_fa);
 struct heap_free_area *__malloc_mmb_heap = HEAP_INIT_WITH_FA (initial_mmb_fa);
 #ifdef HEAP_USE_LOCKING
 #ifdef HEAP_USE_LOCKING
-malloc_mutex_t __malloc_mmb_heap_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t __malloc_mmb_heap_lock = PTHREAD_MUTEX_INITIALIZER;
 #endif
 #endif
 #endif /* __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
 #endif /* __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
 
 
@@ -61,7 +61,7 @@ malloc_mutex_t __malloc_mmb_heap_lock = PTHREAD_MUTEX_INITIALIZER;
 static void *
 static void *
 __malloc_from_heap (size_t size, struct heap_free_area **heap
 __malloc_from_heap (size_t size, struct heap_free_area **heap
 #ifdef HEAP_USE_LOCKING
 #ifdef HEAP_USE_LOCKING
-		, malloc_mutex_t *heap_lock
+		, pthread_mutex_t *heap_lock
 #endif
 #endif
 		)
 		)
 {
 {

+ 8 - 10
libc/stdlib/malloc/malloc.h

@@ -130,24 +130,21 @@ extern int __malloc_mmb_debug;
 
 
 
 
 /* Locking for multithreaded apps.  */
 /* Locking for multithreaded apps.  */
-#ifdef __UCLIBC_HAS_THREADS__
+#if defined __UCLIBC_HAS_THREADS__ && defined __LINUXTHREADS_OLD__
 
 
 # include <pthread.h>
 # include <pthread.h>
 # include <bits/uClibc_pthread.h>
 # include <bits/uClibc_pthread.h>
 
 
 # define MALLOC_USE_LOCKING
 # define MALLOC_USE_LOCKING
 
 
-typedef pthread_mutex_t malloc_mutex_t;
-# define MALLOC_MUTEX_INIT	PTHREAD_MUTEX_INITIALIZER
-
 # ifdef MALLOC_USE_SBRK
 # ifdef MALLOC_USE_SBRK
 /* This lock is used to serialize uses of the `sbrk' function (in both
 /* This lock is used to serialize uses of the `sbrk' function (in both
    malloc and free, sbrk may be used several times in succession, and
    malloc and free, sbrk may be used several times in succession, and
    things will break if these multiple calls are interleaved with another
    things will break if these multiple calls are interleaved with another
    thread's use of sbrk!).  */
    thread's use of sbrk!).  */
-extern malloc_mutex_t __malloc_sbrk_lock;
+__UCLIBC_MUTEX_EXTERN(__malloc_sbrk_lock);
-#  define __malloc_lock_sbrk()	__pthread_mutex_lock (&__malloc_sbrk_lock)
+#  define __malloc_lock_sbrk()	__UCLIBC_MUTEX_LOCK(__malloc_sbrk_lock)
-#  define __malloc_unlock_sbrk() __pthread_mutex_unlock (&__malloc_sbrk_lock)
+#  define __malloc_unlock_sbrk() __UCLIBC_MUTEX_UNLOCK(__malloc_sbrk_lock)
 # endif /* MALLOC_USE_SBRK */
 # endif /* MALLOC_USE_SBRK */
 
 
 #else /* !__UCLIBC_HAS_THREADS__ */
 #else /* !__UCLIBC_HAS_THREADS__ */
@@ -222,9 +219,10 @@ extern void __malloc_debug_printf (int indent, const char *fmt, ...);
 
 
 /* The malloc heap.  */
 /* The malloc heap.  */
 extern struct heap_free_area *__malloc_heap;
 extern struct heap_free_area *__malloc_heap;
-#ifdef __UCLIBC_HAS_THREADS__
+#if defined __UCLIBC_HAS_THREADS__
-extern malloc_mutex_t __malloc_heap_lock;
+#include <bits/uClibc_mutex.h>
+__UCLIBC_MUTEX_EXTERN(__malloc_heap_lock);
 #ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
 #ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
-extern malloc_mutex_t __malloc_mmb_heap_lock;
+__UCLIBC_MUTEX_EXTERN(__malloc_mmb_heap_lock);
 #endif
 #endif
 #endif
 #endif