commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd-l4/libhurd-slab ChangeLog slab.c slab.h


From: Marcus Brinkmann
Subject: hurd-l4/libhurd-slab ChangeLog slab.c slab.h
Date: Sat, 11 Oct 2003 18:08:48 -0400

CVSROOT:        /cvsroot/hurd
Module name:    hurd-l4
Branch:         
Changes by:     Marcus Brinkmann <address@hidden>       03/10/11 18:08:48

Modified files:
        libhurd-slab   : ChangeLog slab.c slab.h 

Log message:
        2003-10-11  Marcus Brinkmann  <address@hidden>
        
        * slab.h (hurd_slab_constructor_t): Add new HOOK argument.
        (hurd_slab_destructor_t): Likewise.
        (hurd_slab_create): Likewise.
        * slab.c (struct hurd_slab_space): New member HOOK.  Move member
        LOCK to beginning of struct.
        (grow): Call constructor with hook value.
        (reap): Call destructor with hook value.
        (hurd_slab_create): Add argument HOOK, initialize (*SPACE)->hook.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/libhurd-slab/ChangeLog.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/libhurd-slab/slab.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd-l4/libhurd-slab/slab.h.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: hurd-l4/libhurd-slab/ChangeLog
diff -u hurd-l4/libhurd-slab/ChangeLog:1.3 hurd-l4/libhurd-slab/ChangeLog:1.4
--- hurd-l4/libhurd-slab/ChangeLog:1.3  Wed Sep 17 11:12:22 2003
+++ hurd-l4/libhurd-slab/ChangeLog      Sat Oct 11 18:08:48 2003
@@ -1,3 +1,15 @@
+2003-10-11  Marcus Brinkmann  <address@hidden>
+
+       * slab.h (hurd_slab_constructor_t): Add new HOOK argument.
+       (hurd_slab_destructor_t): Likewise.
+       (hurd_slab_create): Likewise.
+       * slab.c (struct hurd_slab_space): New member HOOK.  Move member
+       LOCK to beginning of struct.
+       (grow): Call constructor with hook value.
+       (reap): Call destructor with hook value.
+       (hurd_slab_create): Add argument HOOK, initialize (*SPACE)->hook.
+
+
 2003-09-17  Johan Rydberg  <address@hidden>
 
        * slab.h: Add alignment argument.
Index: hurd-l4/libhurd-slab/slab.c
diff -u hurd-l4/libhurd-slab/slab.c:1.6 hurd-l4/libhurd-slab/slab.c:1.7
--- hurd-l4/libhurd-slab/slab.c:1.6     Mon Sep 22 10:36:03 2003
+++ hurd-l4/libhurd-slab/slab.c Sat Oct 11 18:08:48 2003
@@ -74,6 +74,9 @@
 /* The type of a slab space.  */
 struct hurd_slab_space
 {
+  /* Protects this structure, along with all the slabs.  */
+  pthread_mutex_t lock;
+
   struct hurd_slab *slab_first;
   struct hurd_slab *slab_last;
 
@@ -97,11 +100,11 @@
   /* The constructor.  */
   hurd_slab_constructor_t constructor;
 
-  /* Protects this structure, along with all the slabs.  */
-  pthread_mutex_t lock;
-
   /* The destructor.  */
   hurd_slab_destructor_t destructor;
+
+  /* The user's private data.  */
+  void *hook;
 };
 
 
@@ -175,7 +178,7 @@
                {
                  void *buffer = (((void *) bufctl) 
                                  - (space->size - sizeof *bufctl));
-                 (*space->destructor) (buffer);
+                 (*space->destructor) (space->hook, buffer);
                }
            }
          /* The slab is located at the end of the page (with the buffers
@@ -252,7 +255,7 @@
       /* Invoke constructor at object creation time, not when it is
         really allocated (for faster allocation).  */
       if (space->constructor)
-       (*space->constructor) (p);
+       (*space->constructor) (space->hook, p);
 
       /* The most activity is in front of the object, so it is most
         likely to be overwritten if a freed buffer gets accessed.
@@ -293,6 +296,7 @@
 hurd_slab_create (size_t size, size_t alignment,
                  hurd_slab_constructor_t constructor,
                  hurd_slab_destructor_t destructor,
+                 void *hook,
                  hurd_slab_space_t *space)
 {
   error_t err;
@@ -326,6 +330,7 @@
 
   (*space)->constructor = constructor;
   (*space)->destructor = destructor;
+  (*space)->hook = hook;
 
   /* Calculate the number of objects that fit in a slab.  */
   (*space)->full_refcount 
Index: hurd-l4/libhurd-slab/slab.h
diff -u hurd-l4/libhurd-slab/slab.h:1.5 hurd-l4/libhurd-slab/slab.h:1.6
--- hurd-l4/libhurd-slab/slab.h:1.5     Sat Oct  4 11:54:01 2003
+++ hurd-l4/libhurd-slab/slab.h Sat Oct 11 18:08:48 2003
@@ -29,17 +29,27 @@
 struct hurd_slab_space;
 typedef struct hurd_slab_space *hurd_slab_space_t;
 
+/* Initialize the slab object pointed to by BUFFER.  HOOK is as
+   provided to hurd_slab_create.  */
+typedef error_t (*hurd_slab_constructor_t) (void *hook, void *buffer);
+
+/* Destroy the slab object pointed to by BUFFER.  HOOK is as provided
+   to hurd_slab_create.  */
+typedef void (*hurd_slab_destructor_t) (void *hook, void *buffer);
 /* Initialize the slab object pointed to by BUFFER.  */
 typedef error_t (*hurd_slab_constructor_t) (void *buffer);
 
 /* Destroy the slab object pointed to by BUFFER.  */
 typedef void (*hurd_slab_destructor_t) (void *buffer);
 
-/* Create a new slab space with the given object size, alignment, 
-   constructor and destructor.  ALIGNMENT can be zero.  */
+
+/* Create a new slab space with the given object size, alignment,
+   constructor and destructor.  ALIGNMENT can be zero.  HOOK is passed
+   as the first argument to the constructor and destructor.  */
 error_t hurd_slab_create (size_t size, size_t alignment,
                          hurd_slab_constructor_t constructor,
                          hurd_slab_destructor_t destructor,
+                         void *hook,
                          hurd_slab_space_t *space);
 
 /* Allocate a new object from the slab space SPACE.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]