Remove closure data from GC_register_disclaim_proc.
authorPetter Urkedal <paurkedal@gmail.com>
Wed, 25 Jan 2012 19:30:02 +0000 (20:30 +0100)
committerPetter Urkedal <paurkedal@gmail.com>
Wed, 25 Jan 2012 19:30:02 +0000 (20:30 +0100)
* include/gc_disclaim.h, fnlz_mlc.c (GC_disclaim_proc, GC_register_disclaim_proc):
Remove CD from typedef and function.
* reclaim.c (GC_reclaim_uninit, GC_reclaim_block): Adjust calls.
* include/private/gc_priv.h, misc.c: Remove CD from object kind struct and
initializers.

fnlz_mlc.c
include/gc_disclaim.h
include/private/gc_priv.h
misc.c
reclaim.c

index b43569a..12767aa 100644 (file)
@@ -26,8 +26,7 @@
 
 STATIC int GC_finalized_kind = 0;
 
-STATIC int GC_CALLBACK GC_finalized_disclaim(void *obj,
-                                             void *cd GC_ATTR_UNUSED)
+STATIC int GC_CALLBACK GC_finalized_disclaim(void *obj)
 {
     void **fc_addr;
     const struct GC_finalizer_closure *fc;
@@ -66,18 +65,15 @@ GC_API void GC_CALL GC_init_finalized_malloc(void)
     GC_finalized_objfreelist = (ptr_t *)GC_new_free_list_inner();
     GC_finalized_kind = GC_new_kind_inner((void **)GC_finalized_objfreelist,
                                           GC_DS_LENGTH, TRUE, TRUE);
-    GC_register_disclaim_proc(GC_finalized_kind, GC_finalized_disclaim,
-                              NULL, TRUE);
+    GC_register_disclaim_proc(GC_finalized_kind, GC_finalized_disclaim, TRUE);
     UNLOCK();
 }
 
 GC_API void GC_CALL GC_register_disclaim_proc(int kind, GC_disclaim_proc proc,
-                                              void *cd,
                                               int mark_unconditionally)
 {
     GC_ASSERT((unsigned)kind < MAXOBJKINDS);
     GC_obj_kinds[kind].ok_disclaim_proc = proc;
-    GC_obj_kinds[kind].ok_disclaim_cd = cd;
     GC_obj_kinds[kind].ok_mark_unconditionally = (GC_bool)mark_unconditionally;
 }
 
index 3f0ed6b..beb1bc1 100644 (file)
@@ -25,9 +25,8 @@
 /* finalized allocations.  The function is thread-safe.                 */
 GC_API void GC_CALL GC_init_finalized_malloc(void);
 
-/* Type of a disclaim call-back, always stored along with closure data  */
-/* passed as the second argument.                                       */
-typedef int (GC_CALLBACK * GC_disclaim_proc)(void * /*obj*/, void * /*cd*/);
+/* Type of a disclaim call-back.                                        */
+typedef int (GC_CALLBACK * GC_disclaim_proc)(void * /*obj*/);
 
 /* Register "proc" to be called on each object of "kind" ready to be    */
 /* reclaimed.  If "proc" returns non-zero, the collector will not       */
@@ -37,7 +36,6 @@ typedef int (GC_CALLBACK * GC_disclaim_proc)(void * /*obj*/, void * /*cd*/);
 /* to reclaim.                                                          */
 GC_API void GC_CALL GC_register_disclaim_proc(int /*kind*/,
                                               GC_disclaim_proc /*proc*/,
-                                              void * /*cd*/,
                                               int /*mark_from_all*/);
 
 /* The finalizer closure used by GC_finalized_malloc.                   */
index dc2944f..8ab53a5 100644 (file)
@@ -1261,13 +1261,12 @@ GC_EXTERN struct obj_kind {
                         /* Mark from all, including unmarked, objects   */
                         /* in block.  Used to protect objects reachable */
                         /* from reclaim notifiers.                      */
-     int (GC_CALLBACK *ok_disclaim_proc)(void * /*obj*/, void * /*cd*/);
-     void *ok_disclaim_cd;
+     int (GC_CALLBACK *ok_disclaim_proc)(void * /*obj*/);
                         /* The disclaim procedure is called before obj  */
                         /* is reclaimed, but must also tolerate being   */
                         /* called with object from freelist.  Non-zero  */
                         /* exit prevents object from being reclaimed.   */
-#    define OK_DISCLAIM_INITZ /* comma */, FALSE, NULL, NULL
+#    define OK_DISCLAIM_INITZ /* comma */, FALSE, NULL
 #  else
 #    define OK_DISCLAIM_INITZ /* empty */
 #  endif /* !ENABLE_DISCLAIM */
diff --git a/misc.c b/misc.c
index 19ddb8b..56153da 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1488,7 +1488,6 @@ GC_API unsigned GC_CALL GC_new_kind_inner(void **fl, GC_word descr,
 #   ifdef ENABLE_DISCLAIM
         GC_obj_kinds[result].ok_mark_unconditionally = FALSE;
         GC_obj_kinds[result].ok_disclaim_proc = 0;
-        GC_obj_kinds[result].ok_disclaim_cd = NULL;
 #   endif
     return result;
 }
index ac626af..dee0d56 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
@@ -224,8 +224,7 @@ STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
     word *p, *q, *plim;
     signed_word n_bytes_found = 0;
     struct obj_kind *ok = &GC_obj_kinds[hhdr->hb_obj_kind];
-    int (GC_CALLBACK *proc)(void *, void *) = ok->ok_disclaim_proc;
-    void *cd = ok -> ok_disclaim_cd;
+    int (GC_CALLBACK *disclaim)(void *) = ok->ok_disclaim_proc;
 
     GC_ASSERT(sz == hhdr -> hb_sz);
     p = (word *)(hbp -> hb_body);
@@ -233,7 +232,7 @@ STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
 
     while (p <= plim) {
         int marked = mark_bit_from_hdr(hhdr, bit_no);
-        if (!marked && (*proc)(p, cd)) {
+        if (!marked && (*disclaim)(p)) {
             hhdr -> hb_n_marks++;
             marked = 1;
         }
@@ -386,7 +385,7 @@ STATIC void GC_reclaim_block(struct hblk *hbp, word report_if_found)
 #             ifdef ENABLE_DISCLAIM
                 if (EXPECT(hhdr->hb_flags & HAS_DISCLAIM, 0)) {
                   struct obj_kind *ok = &GC_obj_kinds[hhdr->hb_obj_kind];
-                  if ((*ok->ok_disclaim_proc)(hbp, ok->ok_disclaim_cd)) {
+                  if ((*ok->ok_disclaim_proc)(hbp)) {
                     /* Not disclaimed => resurrect the object. */
                     set_mark_bit_from_hdr(hhdr, 0);
                     goto in_use;