OSDN Git Service

Rename mutex stuff to use heap-specific names.
authorMiles Bader <miles@lsi.nec.co.jp>
Fri, 19 Jul 2002 04:26:41 +0000 (04:26 -0000)
committerMiles Bader <miles@lsi.nec.co.jp>
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 74b5660..0d64650 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 <miles@gnu.org>
 
 #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 22591d6..d0e1d75 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 <miles@gnu.org>
@@ -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 8ee9254..4047697 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 <miles@gnu.org>
@@ -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 42f0cf5..d67f464 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 <miles@gnu.org>
@@ -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 20ef655..d8eaf7e 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 <miles@gnu.org>
@@ -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);
 }