]> granicus.if.org Git - gc/commitdiff
Declare privately and use handy GC_base_C() for constant object pointers
authorIvan Maidanski <ivmai@mail.ru>
Fri, 3 Feb 2012 15:56:22 +0000 (19:56 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 3 Feb 2012 15:56:22 +0000 (19:56 +0400)
* dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change):
Use GC_base_C() instead of GC_base() (remove cast to void pointer).
* finalize.c (GC_general_register_disappearing_link): Likewise.
* finalize.c (GC_register_disappearing_link, GC_finalize): Remove
redundant cast to void pointer and ptr_t.
* include/private/gc_priv.h (GC_base_C): New macro definition.

dbg_mlc.c
finalize.c
include/private/gc_priv.h

index daf8d23baf95bee114c284e95fc83188cfcb727a..00586d1890a884eebd69f67de8c8858a59aa2dc6 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -574,7 +574,7 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
 
   GC_API void GC_CALL GC_debug_change_stubborn(const void *p)
   {
-    const void * q = GC_base((void *)p);
+    const void * q = GC_base_C(p);
     hdr * hhdr;
 
     if (q == 0) {
@@ -591,7 +591,7 @@ GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
 
   GC_API void GC_CALL GC_debug_end_stubborn_change(const void *p)
   {
-    const void * q = GC_base((void *)p);
+    const void * q = GC_base_C(p);
     hdr * hhdr;
 
     if (q == 0) {
index f66d76e00013b50238d475f1032ab9cbfff73f96..949777733612d6ed6bac41f2e04eaab19aa18c87 100644 (file)
@@ -137,7 +137,7 @@ GC_API int GC_CALL GC_register_disappearing_link(void * * link)
 {
     ptr_t base;
 
-    base = (ptr_t)GC_base((void *)link);
+    base = (ptr_t)GC_base(link);
     if (base == 0)
         ABORT("Bad arg to GC_register_disappearing_link");
     return(GC_general_register_disappearing_link(link, base));
@@ -154,7 +154,7 @@ GC_API int GC_CALL GC_general_register_disappearing_link(void * * link,
     if (((word)link & (ALIGNMENT-1)) || link == NULL)
         ABORT("Bad arg to GC_general_register_disappearing_link");
     LOCK();
-    GC_ASSERT(obj != NULL && GC_base((void *)obj) == obj);
+    GC_ASSERT(obj != NULL && GC_base_C(obj) == obj);
     if (log_dl_table_size == -1
         || GC_dl_entries > ((word)1 << log_dl_table_size)) {
         GC_grow_table((struct hash_chain_entry ***)(&dl_head),
@@ -664,7 +664,7 @@ GC_INNER void GC_finalize(void)
               GC_bytes_finalized +=
                         curr_fo -> fo_object_size
                         + sizeof(struct finalizable_object);
-            GC_ASSERT(GC_is_marked(GC_base((ptr_t)curr_fo)));
+            GC_ASSERT(GC_is_marked(GC_base(curr_fo)));
             curr_fo = next_fo;
         } else {
             prev_fo = curr_fo;
index 09584afc89e7852f78bbea3b26c5a7714e0a068d..e2af73f3afe5098fe263cc67b1388e11abfb68b8 100644 (file)
@@ -1945,6 +1945,9 @@ GC_EXTERN GC_bool GC_print_back_height;
   GC_INNER void GC_dirty_init(void);
 #endif /* !GC_DISABLE_INCREMENTAL */
 
+/* Same as GC_base but excepts and returns a pointer to const object.   */
+#define GC_base_C(p) ((const void *)GC_base((/* no const */ void *)(p)))
+
 /* Stubborn objects: */
 void GC_read_changed(void); /* Analogous to GC_read_dirty */
 GC_bool GC_page_was_changed(struct hblk * h);