]> Git Repo - uclibc-ng.git/commitdiff
Rename mutex stuff to use heap-specific names.
authorMiles Bader <[email protected]>
Fri, 19 Jul 2002 04:26:41 +0000 (04:26 -0000)
committerMiles Bader <[email protected]>
Fri, 19 Jul 2002 04:26:41 +0000 (04:26 -0000)
Doc fix.

libc/stdlib/malloc/heap.h
libc/stdlib/malloc/heap_alloc.c
libc/stdlib/malloc/heap_alloc_at.c
libc/stdlib/malloc/heap_append_free.c
libc/stdlib/malloc/heap_free.c

index 74b56603bf691b8f2d7aae552da43934f510a8a6..0d6465050bc5a3675bfbf64282ba2baba0f42eb3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * libc/stdlib/malloc-zarg/heap.h -- heap allocator used for malloc
+ * libc/stdlib/malloc/heap.h -- heap allocator used for malloc
  *
  *  Copyright (C) 2002  NEC Corporation
  *  Copyright (C) 2002  Miles Bader <[email protected]>
 
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
-typedef pthread_mutex_t mutex_t;
-# define MUTEX_INITIALIZER  PTHREAD_MUTEX_INITIALIZER
-# define mutex_lock(x)     pthread_mutex_lock(&(x))
-# define mutex_unlock(x)    pthread_mutex_unlock(&(x));
+typedef pthread_mutex_t heap_mutex_t;
+# define HEAP_MUTEX_INIT       PTHREAD_MUTEX_INITIALIZER
+# define __heap_lock(heap)     pthread_mutex_lock (&(heap)->lock)
+# define __heap_unlock(heap)   pthread_mutex_unlock (&(heap)->lock);
 #else
-/* Mutex operations are currently a nop.  */
-typedef int mutex_t;
-# define MUTEX_INITIALIZER 0
-# define mutex_lock(x)
-# define mutex_unlock(x)
+/* Without threads, Mutex operations are a nop.  */
+typedef int heap_mutex_t;
+# define HEAP_MUTEX_INIT       0
+# define __heap_lock(heap)
+# define __heap_unlock(heap)
 #endif
 
 
@@ -36,13 +36,15 @@ typedef int mutex_t;
 #define HEAP_GRANULARITY       (sizeof (double))
 
 
+/* A heap is a collection of memory blocks, from which smaller blocks
+   of memory can be allocated.  */
 struct heap
 {
   struct heap_free_area *free_areas;
-  mutex_t lock;
+  heap_mutex_t lock;
 };
 
-#define HEAP_INIT      { 0, MUTEX_INITIALIZER }
+#define HEAP_INIT      { 0, HEAP_MUTEX_INIT }
 
 
 /* A free-list area `header'.  These are actually stored at the _ends_ of
index 22591d6131ea8fc7e34247a26035483a6d5679a3..d0e1d752abc8303a53b9e8d3c5acd93d4201dcb2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * libc/stdlib/malloc-zarg/heap_alloc.c -- allocate from a heap
+ * libc/stdlib/malloc/heap_alloc.c -- allocate memory from a heap
  *
  *  Copyright (C) 2002  NEC Corporation
  *  Copyright (C) 2002  Miles Bader <[email protected]>
@@ -33,7 +33,7 @@ __heap_alloc (struct heap *heap, size_t *size)
        we must make sure that every allocated block can hold one.  */
     _size = HEAP_ADJUST_SIZE (sizeof (struct heap_free_area));
 
-  mutex_lock (heap->lock);
+  __heap_lock (heap);
 
   HEAP_DEBUG (heap, "before __heap_alloc");
 
@@ -49,7 +49,7 @@ __heap_alloc (struct heap *heap, size_t *size)
 
   HEAP_DEBUG (heap, "after __heap_alloc");
 
-  mutex_unlock (heap->lock);
+  __heap_unlock (heap);
 
   return mem;
 }
index 8ee9254886bdae4e80df580abe79393dc64da348..4047697c59f3cb513e7bee12f805ce68babc02e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * libc/stdlib/malloc-zarg/heap_alloc_at.c -- allocate at a specific address
+ * libc/stdlib/malloc/heap_alloc_at.c -- allocate at a specific address
  *
  *  Copyright (C) 2002  NEC Corporation
  *  Copyright (C) 2002  Miles Bader <[email protected]>
@@ -26,7 +26,7 @@ __heap_alloc_at (struct heap *heap, void *mem, size_t size)
 
   size = HEAP_ADJUST_SIZE (size);
 
-  mutex_lock (heap->lock);
+  __heap_lock (heap);
 
   HEAP_DEBUG (heap, "before __heap_alloc_at");
 
@@ -45,7 +45,7 @@ __heap_alloc_at (struct heap *heap, void *mem, size_t size)
 
   HEAP_DEBUG (heap, "after __heap_alloc_at");
 
-  mutex_unlock (heap->lock);
+  __heap_unlock (heap);
 
   return alloced;
 }
index 42f0cf5bb7c411c59c7a8f7322667e22f39622ce..d67f46495f3157f566779b461bdb697a169daad2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * libc/stdlib/malloc-zarg/heap_append_free.c -- append to heap free area
+ * libc/stdlib/malloc/heap_append_free.c -- append memory to a heap free area
  *
  *  Copyright (C) 2002  NEC Corporation
  *  Copyright (C) 2002  Miles Bader <[email protected]>
@@ -25,7 +25,7 @@ __heap_append_free (struct heap *heap, void *mem, size_t size)
   int success = 0;
   struct heap_free_area *fa;
 
-  mutex_lock (heap->lock);
+  __heap_lock (heap);
 
   HEAP_DEBUG (heap, "before __heap_append_free");
 
@@ -65,7 +65,7 @@ __heap_append_free (struct heap *heap, void *mem, size_t size)
 
   HEAP_DEBUG (heap, "after __heap_append_free");
 
-  mutex_unlock (heap->lock);
+  __heap_unlock (heap);
 
   return success;
 }
index 20ef655720aac0d2c14927a06d01653389054de5..d8eaf7e66e81d82647c2d4391ca8c5b014832cab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * libc/stdlib/malloc-zarg/heap_free.c -- return memory to a heap
+ * libc/stdlib/malloc/heap_free.c -- return memory to a heap
  *
  *  Copyright (C) 2002  NEC Corporation
  *  Copyright (C) 2002  Miles Bader <[email protected]>
@@ -23,7 +23,7 @@ __heap_free (struct heap *heap, void *mem, size_t size)
   struct heap_free_area *prev_fa, *fa, *new_fa;
   void *end = (char *)mem + size;
 
-  mutex_lock (heap->lock);
+  __heap_lock (heap);
 
   HEAP_DEBUG (heap, "before __heap_free");
 
@@ -123,5 +123,5 @@ __heap_free (struct heap *heap, void *mem, size_t size)
  done:
   HEAP_DEBUG (heap, "after __heap_free");
 
-  mutex_unlock (heap->lock);
+  __heap_unlock (heap);
 }
This page took 0.03589 seconds and 4 git commands to generate.