[Gc] Patch for adjusting printf actual param types

Ivan Maidanski ivmai at mail.ru
Sat Oct 25 11:53:46 PDT 2008


Hi!

This patch adjusts the types of actual parameters for GC_..._printf() according to its format specifiers.

Bye.

-------------- next part --------------
diff -ru bdwgc/allchblk.c updated/bdwgc/allchblk.c
--- bdwgc/allchblk.c	2008-07-26 04:51:34.000000000 +0400
+++ updated/bdwgc/allchblk.c	2008-10-25 13:41:18.000000000 +0400
@@ -117,7 +117,7 @@
 		              (unsigned long)i);
 #     else
         if (0 != h) GC_printf("Free list %lu (Total size %lu):\n",
-		              i, (unsigned long)GC_free_bytes[i]);
+		              (long)i, (unsigned long)GC_free_bytes[i]);
 #     endif
       while (h != 0) {
         hhdr = HDR(h);
@@ -183,7 +183,7 @@
 	    hhdr = HDR(p);
 	    GC_printf("\t%p ", p);
 	    if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
-		GC_printf("Missing header!!(%d)\n", hhdr);
+		GC_printf("Missing header!!(%p)\n", hhdr);
 		p += HBLKSIZE;
 		continue;
 	    }
diff -ru bdwgc/backgraph.c updated/bdwgc/backgraph.c
--- bdwgc/backgraph.c	2008-10-01 01:37:28.000000000 +0400
+++ updated/bdwgc/backgraph.c	2008-10-25 13:51:31.000000000 +0400
@@ -378,7 +378,7 @@
     word this_height;
     if (GC_is_marked(q) && !(FLAG_MANY & (word)GET_OH_BG_PTR(p))) {
       if (GC_print_stats)
-	  GC_log_printf("Found bogus pointer from 0x%lx to 0x%lx\n", q, p);
+	  GC_log_printf("Found bogus pointer from %p to %p\n", q, p);
 	/* Reachable object "points to" unreachable one.		*/
 	/* Could be caused by our lax treatment of GC descriptors.	*/
       this_height = 1;
@@ -468,7 +468,7 @@
     GC_print_heap_obj(GC_deepest_obj);
   }
   if (GC_print_stats) {
-    GC_log_printf("Needed max total of %ld back-edge structs\n",
+    GC_log_printf("Needed max total of %d back-edge structs\n",
 	          GC_n_back_edge_structs);
   }
   GC_apply_to_each_object(reset_back_edge);
diff -ru bdwgc/dbg_mlc.c updated/bdwgc/dbg_mlc.c
--- bdwgc/dbg_mlc.c	2008-10-16 23:09:23.000000000 +0400
+++ updated/bdwgc/dbg_mlc.c	2008-10-25 13:57:00.000000000 +0400
@@ -193,8 +193,7 @@
 	GC_err_printf("No debug info in object: Can't find reference\n");
 	goto out;
       }
-      GC_err_printf("Reachable via %d levels of pointers from ",
-		 (unsigned long)i);
+      GC_err_printf("Reachable via %d levels of pointers from ", i);
       switch(source) {
 	case GC_REFD_FROM_ROOT:
 	  GC_err_printf("root at %p\n\n", base);
@@ -418,7 +417,7 @@
     if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz))
         || ohdr -> oh_string == 0) {
         GC_err_printf("<smashed>, appr. sz = %ld)\n",
-        	       (GC_size((ptr_t)ohdr) - DEBUG_BYTES));
+		      (unsigned long)(GC_size((ptr_t)ohdr) - DEBUG_BYTES));
     } else {
         if ((word)(ohdr -> oh_string) < HBLKSIZE) {
             GC_err_puts("(smashed string)");
diff -ru bdwgc/dyn_load.c updated/bdwgc/dyn_load.c
--- bdwgc/dyn_load.c	2008-10-16 19:07:16.000000000 +0400
+++ updated/bdwgc/dyn_load.c	2008-10-25 16:19:26.000000000 +0400
@@ -594,7 +594,7 @@
 #   endif /* SOLARISDL */
 
     if (fd < 0) {
-      sprintf(buf, "/proc/%d", getpid());
+      sprintf(buf, "/proc/%ld", (long)getpid());
 	/* The above generates a lint complaint, since pid_t varies.	*/
 	/* It's unclear how to improve this.				*/
       fd = open(buf, O_RDONLY);
@@ -613,7 +613,7 @@
 						(current_sz * sizeof(prmap_t)));
     }
     if (ioctl(fd, PIOCMAP, addr_map) < 0) {
-        GC_err_printf("fd = %d, errno = %d, needed_sz = %d, addr_map = 0x%X\n",
+        GC_err_printf("fd = %d, errno = %d, needed_sz = %d, addr_map = %p\n",
                         fd, errno, needed_sz, addr_map);
     	ABORT("/proc PIOCMAP ioctl failed");
     };
diff -ru bdwgc/finalize.c updated/bdwgc/finalize.c
--- bdwgc/finalize.c	2008-10-16 18:43:18.000000000 +0400
+++ updated/bdwgc/finalize.c	2008-10-25 14:17:43.000000000 +0400
@@ -166,7 +166,7 @@
     		      &log_dl_table_size);
 	if (GC_print_stats) {
 	    GC_log_printf("Grew dl table to %u entries\n",
-	    	      (1 << log_dl_table_size));
+	    	      (1 << (unsigned)log_dl_table_size));
 	}
     }
     index = HASH2(link, log_dl_table_size);
@@ -324,7 +324,7 @@
     		      &log_fo_table_size);
 	if (GC_print_stats) {
 	    GC_log_printf("Grew fo table to %u entries\n",
-	    	          (1 << log_fo_table_size));
+	    	          (1 << (unsigned)log_fo_table_size));
 	}
     }
     /* in the THREADS case signals are disabled and we hold allocation	*/
@@ -860,10 +860,10 @@
 void GC_print_finalization_stats(void)
 {
     struct finalizable_object *fo = GC_finalize_now;
-    size_t ready = 0;
+    unsigned ready = 0;
 
     GC_printf("%u finalization table entries; %u disappearing links\n",
-	       GC_fo_entries, GC_dl_entries);
+	       (unsigned)GC_fo_entries, (unsigned)GC_dl_entries);
     for (; 0 != fo; fo = fo_next(fo)) ++ready;
     GC_printf("%u objects are eligible for immediate finalization\n", ready);
 }
diff -ru bdwgc/include/private/gc_pmark.h updated/bdwgc/include/private/gc_pmark.h
--- bdwgc/include/private/gc_pmark.h	2008-10-11 13:01:06.000000000 +0400
+++ updated/bdwgc/include/private/gc_pmark.h	2008-10-25 15:13:41.000000000 +0400
@@ -296,11 +296,13 @@
     } \
     GC_ASSERT(hhdr == GC_find_header(base)); \
     GC_ASSERT(gran_displ % BYTES_TO_GRANULES(hhdr -> hb_sz) == 0); \
-    TRACE(source, GC_log_printf("GC:%d: passed validity tests\n",GC_gc_no)); \
+    TRACE(source, GC_log_printf("GC:%u: passed validity tests\n", \
+				(int)GC_gc_no)); \
     SET_MARK_BIT_EXIT_IF_SET(hhdr, gran_displ, exit_label); \
-    TRACE(source, GC_log_printf("GC:%d: previously unmarked\n",GC_gc_no)); \
+    TRACE(source, GC_log_printf("GC:%u: previously unmarked\n", \
+				(int)GC_gc_no)); \
     TRACE_TARGET(base, \
-	GC_log_printf("GC:%d: marking %p from %p instead\n", GC_gc_no, \
+	GC_log_printf("GC:%u: marking %p from %p instead\n", (int)GC_gc_no, \
 		      base, source)); \
     INCR_MARKS(hhdr); \
     GC_STORE_BACK_PTR((ptr_t)source, base); \
@@ -352,11 +354,13 @@
     /* May get here for pointer to start of block not at	*/ \
     /* beginning of object.  If so, it's valid, and we're fine. */ \
     GC_ASSERT(high_prod >= 0 && high_prod <= HBLK_OBJS(hhdr -> hb_sz)); \
-    TRACE(source, GC_log_printf("GC:%d: passed validity tests\n",GC_gc_no)); \
+    TRACE(source, GC_log_printf("GC:%u: passed validity tests\n", \
+				(int)GC_gc_no)); \
     SET_MARK_BIT_EXIT_IF_SET(hhdr, high_prod, exit_label); \
-    TRACE(source, GC_log_printf("GC:%d: previously unmarked\n",GC_gc_no)); \
+    TRACE(source, GC_log_printf("GC:%u: previously unmarked\n", \
+				(int)GC_gc_no)); \
     TRACE_TARGET(base, \
-	GC_log_printf("GC:%d: marking %p from %p instead\n", GC_gc_no, \
+	GC_log_printf("GC:%u: marking %p from %p instead\n", (int)GC_gc_no, \
 		      base, source)); \
     INCR_MARKS(hhdr); \
     GC_STORE_BACK_PTR((ptr_t)source, base); \
diff -ru bdwgc/malloc.c updated/bdwgc/malloc.c
--- bdwgc/malloc.c	2008-10-16 16:23:24.000000000 +0400
+++ updated/bdwgc/malloc.c	2008-10-25 14:21:19.000000000 +0400
@@ -400,7 +400,7 @@
     if (p == 0) return;
     	/* Required by ANSI.  It's not my fault ...	*/
 #   ifdef LOG_ALLOCS
-      GC_err_printf("GC_free(%p): %d\n", p, GC_gc_no);
+      GC_err_printf("GC_free(%p): %lu\n", p, (long)GC_gc_no);
 #   endif
     h = HBLKPTR(p);
     hhdr = HDR(h);
diff -ru bdwgc/mark.c updated/bdwgc/mark.c
--- bdwgc/mark.c	2008-10-16 16:25:01.000000000 +0400
+++ updated/bdwgc/mark.c	2008-10-25 16:17:44.000000000 +0400
@@ -322,8 +322,8 @@
     	        scan_ptr = GC_push_next_marked_dirty(scan_ptr);
     	        if (scan_ptr == 0) {
 		    if (GC_print_stats) {
-			GC_log_printf("Marked from %u dirty pages\n",
-				      GC_n_rescuing_pages);
+			GC_log_printf("Marked from %lu dirty pages\n",
+				      (unsigned long)GC_n_rescuing_pages);
 		    }
     	    	    GC_push_roots(FALSE, cold_gc_frame);
     	    	    GC_objects_are_marked = TRUE;
@@ -582,7 +582,7 @@
     GC_mark_stack_too_small = TRUE;
     if (GC_print_stats) {
 	GC_log_printf("Mark stack overflow; current size = %lu entries\n",
-	    	      GC_mark_stack_size);
+	    	      (unsigned long)GC_mark_stack_size);
     }
     return(msp - GC_MARK_STACK_DISCARDS);
 }
@@ -644,8 +644,8 @@
 #	  ifdef ENABLE_TRACE
 	    if (GC_trace_addr >= current_p
 		&& GC_trace_addr < current_p + descr) {
-		GC_log_printf("GC:%d Large section; start %p len %lu\n",
-			      GC_gc_no, current_p, (unsigned long) descr);
+		GC_log_printf("GC:%u Large section; start %p len %lu\n",
+			      (int)GC_gc_no, current_p, (unsigned long) descr);
 	    }
 #	  endif /* ENABLE_TRACE */
 #	  ifdef PARALLEL_MARK
@@ -661,8 +661,8 @@
 #	      ifdef ENABLE_TRACE
 	        if (GC_trace_addr >= current_p
 		    && GC_trace_addr < current_p + descr) {
-		    GC_log_printf("GC:%d splitting (parallel) %p at %p\n",
-				  GC_gc_no, current_p, current_p + new_size);
+		    GC_log_printf("GC:%u splitting (parallel) %p at %p\n",
+				(int)GC_gc_no, current_p, current_p + new_size);
 	        }
 #	      endif /* ENABLE_TRACE */
 	      current_p += new_size;
@@ -677,8 +677,8 @@
 #	  ifdef ENABLE_TRACE
 	    if (GC_trace_addr >= current_p
 		&& GC_trace_addr < current_p + descr) {
-		GC_log_printf("GC:%d splitting %p at %p\n",
-			      GC_gc_no, current_p, limit);
+		GC_log_printf("GC:%u splitting %p at %p\n",
+			      (unsigned)GC_gc_no, current_p, limit);
 	    }
 #	  endif /* ENABLE_TRACE */
           /* Make sure that pointers overlapping the two ranges are	*/
@@ -690,8 +690,8 @@
 #	  ifdef ENABLE_TRACE
 	    if (GC_trace_addr >= current_p
 		&& GC_trace_addr < current_p + WORDS_TO_BYTES(WORDSZ-2)) {
-		GC_log_printf("GC:%d Tracing from %p bitmap descr %lu\n",
-			      GC_gc_no, current_p, (unsigned long) descr);
+		GC_log_printf("GC:%u Tracing from %p bitmap descr %lu\n",
+			      (int)GC_gc_no, current_p, (unsigned long) descr);
 	    }
 #	  endif /* ENABLE_TRACE */
           descr &= ~GC_DS_TAGS;
@@ -704,8 +704,8 @@
 		PREFETCH((ptr_t)current);
 #               ifdef ENABLE_TRACE
 	          if (GC_trace_addr == current_p) {
-	            GC_log_printf("GC:%d Considering(3) %p -> %p\n",
-			          GC_gc_no, current_p, (ptr_t) current);
+	            GC_log_printf("GC:%u Considering(3) %p -> %p\n",
+			          (int)GC_gc_no, current_p, (ptr_t) current);
 	          }
 #               endif /* ENABLE_TRACE */
                 PUSH_CONTENTS((ptr_t)current, mark_stack_top,
@@ -722,8 +722,8 @@
 	    if (GC_trace_addr >= current_p
 		&& GC_base(current_p) != 0
 		&& GC_base(current_p) == GC_base(GC_trace_addr)) {
-		GC_log_printf("GC:%d Tracing from %p proc descr %lu\n",
-			      GC_gc_no, current_p, (unsigned long) descr);
+		GC_log_printf("GC:%u Tracing from %p proc descr %lu\n",
+			      (int)GC_gc_no, current_p, (unsigned long) descr);
 	    }
 #	  endif /* ENABLE_TRACE */
           credit -= GC_PROC_BYTES;
@@ -771,8 +771,8 @@
 #   ifdef ENABLE_TRACE
 	if (GC_trace_addr >= current_p
 	    && GC_trace_addr < limit) {
-	    GC_log_printf("GC:%d Tracing from %p len %lu\n",
-			  GC_gc_no, current_p, (unsigned long) descr);
+	    GC_log_printf("GC:%u Tracing from %p len %lu\n",
+			  (int)GC_gc_no, current_p, (unsigned long) descr);
 	}
 #   endif /* ENABLE_TRACE */
     /* The simple case in which we're scanning a range.	*/
@@ -828,8 +828,8 @@
   	  PREFETCH((ptr_t)current);
 #         ifdef ENABLE_TRACE
 	    if (GC_trace_addr == current_p) {
-	        GC_log_printf("GC:%d Considering(1) %p -> %p\n",
-			      GC_gc_no, current_p, (ptr_t) current);
+	        GC_log_printf("GC:%u Considering(1) %p -> %p\n",
+			      (int)GC_gc_no, current_p, (ptr_t) current);
 	    }
 #         endif /* ENABLE_TRACE */
           PUSH_CONTENTS((ptr_t)current, mark_stack_top,
@@ -844,8 +844,8 @@
 	/* validity test.						*/
 #       ifdef ENABLE_TRACE
 	    if (GC_trace_addr == current_p) {
-	        GC_log_printf("GC:%d Considering(2) %p -> %p\n",
-			      GC_gc_no, current_p, (ptr_t) deferred);
+	        GC_log_printf("GC:%u Considering(2) %p -> %p\n",
+			      (int)GC_gc_no, current_p, (ptr_t) deferred);
 	    }
 #       endif /* ENABLE_TRACE */
         PUSH_CONTENTS((ptr_t)deferred, mark_stack_top,
@@ -1457,8 +1457,8 @@
     	if (i < 0) i = TRACE_ENTRIES-1;
     	p = GC_trace_buf + i;
     	if (p -> gc_no < gc_no || p -> kind == 0) return;
-    	printf("Trace:%s (gc:%d,bytes:%d) 0x%X, 0x%X\n",
-    		p -> kind, p -> gc_no, p -> bytes_allocd,
+    	printf("Trace:%s (gc:%u,bytes:%lu) 0x%X, 0x%X\n",
+    		p -> kind, (int)p -> gc_no, (long)p -> bytes_allocd,
     		(p -> arg1) ^ 0x80000000, (p -> arg2) ^ 0x80000000);
     }
     printf("Trace incomplete\n");
diff -ru bdwgc/misc.c updated/bdwgc/misc.c
--- bdwgc/misc.c	2008-10-20 00:59:26.000000000 +0400
+++ updated/bdwgc/misc.c	2008-10-25 16:00:42.000000000 +0400
@@ -144,7 +144,11 @@
       GC_size_map[0] = 1;
     for (i = 1; i <= GRANULES_TO_BYTES(TINY_FREELISTS-1) - EXTRA_BYTES; i++) {
         GC_size_map[i] = ROUNDED_UP_GRANULES(i);
-        /*GC_ASSERT(GC_size_map[i] < TINY_FREELISTS);*/
+	
+	/* Workaround for a bug in VC++ 2008 for amd64.	*/
+#	ifndef _MSC_VER
+	  GC_ASSERT(GC_size_map[i] < TINY_FREELISTS);
+#	endif
     }
     /* We leave the rest of the array to be filled in on demand. */
 }
diff -ru bdwgc/os_dep.c updated/bdwgc/os_dep.c
--- bdwgc/os_dep.c	2008-10-19 20:54:24.000000000 +0400
+++ updated/bdwgc/os_dep.c	2008-10-25 16:20:36.000000000 +0400
@@ -265,8 +265,8 @@
 	    close(f);
 #	    ifdef THREADS
 	      if (maps_size > old_maps_size) {
-		GC_err_printf("Old maps size = %d, new maps size = %d\n",
-			      old_maps_size, maps_size);
+		GC_err_printf("Old maps size = %lu, new maps size = %lu\n",
+			      (long)old_maps_size, (long)maps_size);
 		ABORT("Unexpected asynchronous /proc/self/maps growth: "
 		      "Unregistered thread?");
 	      }
@@ -2527,8 +2527,7 @@
 #   define PROTECT(addr, len) \
 	  if (!VirtualProtect((addr), (len), PAGE_EXECUTE_READ, \
 	  		      &protect_junk)) { \
-	    DWORD last_error = GetLastError(); \
-	    GC_printf("Last error code: %lx\n", last_error); \
+	    GC_printf("Last error code: %lx\n", (long)GetLastError()); \
 	    ABORT("VirtualProtect failed"); \
 	  }
 #   define UNPROTECT(addr, len) \
@@ -3171,7 +3170,7 @@
 	    	      (unsigned long)
 	    	      		(GC_bytes_allocd + GC_bytes_allocd_before_gc));
     }
-    sprintf(buf, "/proc/%d", getpid());
+    sprintf(buf, "/proc/%ld", (long)getpid());
     fd = open(buf, O_RDONLY);
     if (fd < 0) {
     	ABORT("/proc open failed");
diff -ru bdwgc/pthread_stop_world.c updated/bdwgc/pthread_stop_world.c
--- bdwgc/pthread_stop_world.c	2008-10-11 11:23:08.000000000 +0400
+++ updated/bdwgc/pthread_stop_world.c	2008-10-25 14:42:08.000000000 +0400
@@ -296,7 +296,7 @@
 #	endif
 #	ifdef IA64
 #         if DEBUG_THREADS
-            GC_printf("Reg stack for thread 0x%x = [%lx,%lx)\n",
+            GC_printf("Reg stack for thread 0x%x = [%p,%p)\n",
     	              (unsigned)p -> id, bs_lo, bs_hi);
 #	  endif
           if (THREAD_EQUAL(p -> id, me)) {
@@ -310,7 +310,7 @@
       }
     }
     if (GC_print_stats == VERBOSE) {
-	GC_log_printf("Pushed %d thread stacks\n", nthreads);
+	GC_log_printf("Pushed %d thread stacks\n", (int)nthreads);
     }
     if (!found_me && !GC_in_thread_creation)
       ABORT("Collecting from unknown thread.");
diff -ru bdwgc/pthread_support.c updated/bdwgc/pthread_support.c
--- bdwgc/pthread_support.c	2008-10-22 12:51:45.000000000 +0400
+++ updated/bdwgc/pthread_support.c	2008-10-25 14:46:54.000000000 +0400
@@ -298,7 +298,8 @@
 	my_mark_no = GC_mark_no;
     }
 #   ifdef DEBUG_THREADS
-	GC_printf("Starting mark helper for mark number %lu\n", my_mark_no);
+	GC_printf("Starting mark helper for mark number %lu\n",
+		(unsigned long)my_mark_no);
 #   endif
     GC_help_marker(my_mark_no);
   }
@@ -1061,7 +1062,7 @@
 #   ifdef DEBUG_THREADS
         GC_printf("Starting thread 0x%x\n", (unsigned)my_pthread);
         GC_printf("pid = %ld\n", (long) getpid());
-        GC_printf("sp = 0x%lx\n", (long) &arg);
+        GC_printf("sp = %p\n", &arg);
 #   endif
     LOCK();
     me = GC_register_my_thread_inner(sb, my_pthread);
@@ -1069,7 +1070,7 @@
     UNLOCK();
     start = si -> start_routine;
 #   ifdef DEBUG_THREADS
-	GC_printf("start_routine = %p\n", (void *)start);
+	GC_printf("start_routine = %p\n", (void *)(signed_word)start);
 #   endif
     start_arg = si -> arg;
     sem_post(&(si -> registered));	/* Last action on si.	*/
diff -ru bdwgc/reclaim.c updated/bdwgc/reclaim.c
--- bdwgc/reclaim.c	2008-09-26 12:04:28.000000000 +0400
+++ updated/bdwgc/reclaim.c	2008-10-25 15:15:37.000000000 +0400
@@ -403,12 +403,11 @@
     unsigned n_marks = GC_n_set_marks(hhdr);
     
     if (hhdr -> hb_n_marks != n_marks) {
-      GC_printf("(%u:%u,%u!=%u)", hhdr -> hb_obj_kind,
-    			          bytes,
-    			          hhdr -> hb_n_marks, n_marks);
+      GC_printf("(%u:%u,%u!=%u)", hhdr -> hb_obj_kind, (unsigned)bytes,
+    			          (unsigned)hhdr -> hb_n_marks, n_marks);
     } else {
       GC_printf("(%u:%u,%u)", hhdr -> hb_obj_kind,
-    			      bytes, n_marks);
+    			      (unsigned)bytes, n_marks);
     }
     bytes += HBLKSIZE-1;
     bytes &= ~(HBLKSIZE-1);
@@ -442,10 +441,10 @@
     while (flh){
         struct hblk *block = HBLKPTR(flh);
         if (block != lastBlock){
-            GC_printf("\nIn heap block at 0x%x:\n\t", block);
+            GC_printf("\nIn heap block at %p:\n\t", block);
             lastBlock = block;
         }
-        GC_printf("%d: 0x%x;", ++n, flh);
+        GC_printf("%d: %p;", ++n, flh);
         flh = obj_link(flh);
     }
 }
diff -ru bdwgc/thread_local_alloc.c updated/bdwgc/thread_local_alloc.c
--- bdwgc/thread_local_alloc.c	2008-10-16 16:30:50.000000000 +0400
+++ updated/bdwgc/thread_local_alloc.c	2008-10-25 15:03:06.000000000 +0400
@@ -176,7 +176,8 @@
     GC_FAST_MALLOC_GRANS(result, granules, tiny_fl, DIRECT_GRANULES,
 		         NORMAL, GC_core_malloc(bytes), obj_link(result)=0);
 #   ifdef LOG_ALLOCS
-      GC_err_printf("GC_malloc(%d) = %p : %d\n", bytes, result, GC_gc_no);
+      GC_err_printf("GC_malloc(%u) = %p : %u\n",
+			(unsigned)bytes, result, (unsigned)GC_gc_no);
 #   endif
     return result;
 }


More information about the Gc mailing list