summaryrefslogtreecommitdiff
path: root/libhurd-slab/slab.c
diff options
context:
space:
mode:
Diffstat (limited to 'libhurd-slab/slab.c')
-rw-r--r--libhurd-slab/slab.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/libhurd-slab/slab.c b/libhurd-slab/slab.c
index 375df6d9..51261e21 100644
--- a/libhurd-slab/slab.c
+++ b/libhurd-slab/slab.c
@@ -27,7 +27,7 @@
#include <assert.h>
#include <string.h>
#include <unistd.h>
-#include <pthread.h>
+#include <cthreads.h>
#include <stdint.h>
#include "slab.h"
@@ -332,7 +332,7 @@ hurd_slab_init (hurd_slab_space_t space, size_t size, size_t alignment,
- sizeof (union hurd_bufctl)))
return EINVAL;
- err = pthread_mutex_init (&space->lock, NULL);
+ err = mutex_init (&space->lock);
if (err)
return err;
@@ -388,11 +388,11 @@ hurd_slab_destroy (hurd_slab_space_t space)
/* The caller wants to destroy the slab. It can not be destroyed if
there are any outstanding memory allocations. */
- pthread_mutex_lock (&space->lock);
+ mutex_lock (&space->lock);
err = reap (space);
if (err)
{
- pthread_mutex_unlock (&space->lock);
+ mutex_unlock (&space->lock);
return err;
}
@@ -400,14 +400,12 @@ hurd_slab_destroy (hurd_slab_space_t space)
{
/* There are still slabs, i.e. there is outstanding allocations.
Return EBUSY. */
- pthread_mutex_unlock (&space->lock);
+ mutex_unlock (&space->lock);
return EBUSY;
}
/* FIXME: Remove slab space from pager's reap functionality. */
- /* The only resource that needs to be deallocated is the mutex. */
- pthread_mutex_destroy (&space->lock);
return 0;
}
@@ -433,7 +431,7 @@ hurd_slab_alloc (hurd_slab_space_t space, void **buffer)
error_t err;
union hurd_bufctl *bufctl;
- pthread_mutex_lock (&space->lock);
+ mutex_lock (&space->lock);
/* If there is no slabs with free buffer, the cache has to be
expanded with another slab. If the slab space has not yet been
@@ -443,7 +441,7 @@ hurd_slab_alloc (hurd_slab_space_t space, void **buffer)
err = grow (space);
if (err)
{
- pthread_mutex_unlock (&space->lock);
+ mutex_unlock (&space->lock);
return err;
}
}
@@ -474,7 +472,7 @@ hurd_slab_alloc (hurd_slab_space_t space, void **buffer)
space->first_free = new_first;
}
*buffer = ((void *) bufctl) - (space->size - sizeof *bufctl);
- pthread_mutex_unlock (&space->lock);
+ mutex_unlock (&space->lock);
return 0;
}
@@ -498,7 +496,7 @@ hurd_slab_dealloc (hurd_slab_space_t space, void *buffer)
assert (space->initialized);
- pthread_mutex_lock (&space->lock);
+ mutex_lock (&space->lock);
bufctl = (buffer + (space->size - sizeof *bufctl));
put_on_slab_list (slab = bufctl->slab, bufctl);
@@ -511,5 +509,5 @@ hurd_slab_dealloc (hurd_slab_space_t space, void *buffer)
|| slab->refcount < space->first_free->refcount)
space->first_free = slab;
- pthread_mutex_unlock (&space->lock);
+ mutex_unlock (&space->lock);
}