]> granicus.if.org Git - gc/commitdiff
2011-04-03 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Sun, 3 Apr 2011 15:29:32 +0000 (15:29 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:57 +0000 (21:06 +0400)
* allchblk.c (GC_freehblk): Use GC_log_printf instead of GC_printf
inside "if (GC_print_stats)" branch.
* alloc.c (GC_collect_or_expand): Ditto.
* dyn_load.c (GC_register_dynamic_libraries): Ditto.
* headers.c (GC_scratch_alloc): Ditto.
* os_dep.c (GC_get_maps, GC_remap, PROTECT,
GC_write_fault_handler, GC_dirty_init, GC_mprotect_thread): Ditto.
* alloc.c (min_bytes_allocd): Use GC_log_printf instead of
GC_printf for DEBUG_THREADS output.
* darwin_stop_world.c (GC_stack_range_for, GC_suspend_thread_list,
GC_stop_world, GC_thread_resume, GC_start_world): Ditto.
* pthread_start.c (GC_inner_start_routine): Ditto.
* pthread_stop_world.c (GC_suspend_handler, GC_restart_handler,
GC_push_all_stacks, GC_suspend_all, GC_stop_world,
GC_start_world): Ditto.
* pthread_support.c (GC_mark_thread, GC_get_nprocs,
GC_start_rtn_prepare_thread, pthread_create): Ditto.
* alloc.c (GC_adj_bytes_allocd, GC_maybe_gc, GC_stopped_mark,
GC_finish_collection): Reformat code.
* pthread_stop_world.c (GC_print_sig_mask): Ditto.
* pthread_support.c (GC_thr_init): Ditto.
* checksums.c (GC_update_check_page): Use GC_printf() instead of
GC_err_printf() for error printing.
* checksums.c (GC_check_blocks, GC_check_dirty): Use GC_log_printf
instead of GC_printf for logging purposes.
* dyn_load.c (sys_errlist, sys_nerr, errno): Move declaration of
external variable outside from GC_register_dynamic_libraries.
* dyn_load.c (GC_register_dynamic_libraries): Don't use
sys_errlist value if errno equals to sys_nerr.
* dyn_load.c (GC_register_dynamic_libraries): Use GC_log_printf
instead of GC_printf for DL_VERBOSE output.
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove,
GC_init_dyld): Use GC_log_printf instead of GC_printf for
DARWIN_DEBUG output.
* os_dep.c (catch_exception_raise): Use GC_log_printf
instead of GC_printf for DEBUG_EXCEPTION_HANDLING output.
* reclaim.c (GC_print_free_list): Move "n" increment out of
GC_printf() call.

12 files changed:
ChangeLog
allchblk.c
alloc.c
checksums.c
darwin_stop_world.c
dyn_load.c
headers.c
os_dep.c
pthread_start.c
pthread_stop_world.c
pthread_support.c
reclaim.c

index f033f2e6183cc9a651a7447884edbe204c9cac3b..e94be3a700678dee5ddc50fe912058fae74607c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,44 @@
+2011-04-03  Ivan Maidanski  <ivmai@mail.ru>
+
+       * allchblk.c (GC_freehblk): Use GC_log_printf instead of GC_printf
+       inside "if (GC_print_stats)" branch.
+       * alloc.c (GC_collect_or_expand): Ditto.
+       * dyn_load.c (GC_register_dynamic_libraries): Ditto.
+       * headers.c (GC_scratch_alloc): Ditto.
+       * os_dep.c (GC_get_maps, GC_remap, PROTECT,
+       GC_write_fault_handler, GC_dirty_init, GC_mprotect_thread): Ditto.
+       * alloc.c (min_bytes_allocd): Use GC_log_printf instead of
+       GC_printf for DEBUG_THREADS output.
+       * darwin_stop_world.c (GC_stack_range_for, GC_suspend_thread_list,
+       GC_stop_world, GC_thread_resume, GC_start_world): Ditto.
+       * pthread_start.c (GC_inner_start_routine): Ditto.
+       * pthread_stop_world.c (GC_suspend_handler, GC_restart_handler,
+       GC_push_all_stacks, GC_suspend_all, GC_stop_world,
+       GC_start_world): Ditto.
+       * pthread_support.c (GC_mark_thread, GC_get_nprocs,
+       GC_start_rtn_prepare_thread, pthread_create): Ditto.
+       * alloc.c (GC_adj_bytes_allocd, GC_maybe_gc, GC_stopped_mark,
+       GC_finish_collection): Reformat code.
+       * pthread_stop_world.c (GC_print_sig_mask): Ditto.
+       * pthread_support.c (GC_thr_init): Ditto.
+       * checksums.c (GC_update_check_page): Use GC_printf() instead of
+       GC_err_printf() for error printing.
+       * checksums.c (GC_check_blocks, GC_check_dirty): Use GC_log_printf
+       instead of GC_printf for logging purposes.
+       * dyn_load.c (sys_errlist, sys_nerr, errno): Move declaration of
+       external variable outside from GC_register_dynamic_libraries.
+       * dyn_load.c (GC_register_dynamic_libraries): Don't use
+       sys_errlist value if errno equals to sys_nerr.
+       * dyn_load.c (GC_register_dynamic_libraries): Use GC_log_printf
+       instead of GC_printf for DL_VERBOSE output.
+       * dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove,
+       GC_init_dyld): Use GC_log_printf instead of GC_printf for
+       DARWIN_DEBUG output.
+       * os_dep.c (catch_exception_raise): Use GC_log_printf
+       instead of GC_printf for DEBUG_EXCEPTION_HANDLING output.
+       * reclaim.c (GC_print_free_list): Move "n" increment out of
+       GC_printf() call.
+
 2011-04-03  Ivan Maidanski  <ivmai@mail.ru>
 
        * win32_threads.c (DEBUG_CYGWIN_THREADS, DEBUG_WIN32_PTHREADS,
index 637d20d08d26af63efdea905ac8167c6e8d5f425..efcc00ab9e67ea942ea36889cdaf235bef409b67 100644 (file)
@@ -848,7 +848,7 @@ GC_INNER void GC_freehblk(struct hblk *hbp)
     /* Check for duplicate deallocation in the easy case */
       if (HBLK_IS_FREE(hhdr)) {
         if (GC_print_stats)
-          GC_printf("Duplicate large block deallocation of %p\n", hbp);
+          GC_log_printf("Duplicate large block deallocation of %p\n", hbp);
         ABORT("Duplicate large block deallocation");
       }
 
diff --git a/alloc.c b/alloc.c
index 457a0178c264bd93b044af59bb9154ab4be0deb2..dffbc014623cb0220aa881be2b501dd7865d3700 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -180,7 +180,7 @@ GC_API GC_stop_func GC_CALL GC_get_stop_func(void)
     time_diff = MS_TIME_DIFF(current_time,GC_start_time);
     if (time_diff >= GC_time_limit) {
         if (GC_print_stats) {
-            GC_log_printf(
+          GC_log_printf(
                 "Abandoning stopped marking after %lu msecs (attempt %d)\n",
                 time_diff, GC_n_attempts);
         }
@@ -217,7 +217,8 @@ static word min_bytes_allocd(void)
         stack_size = GC_total_stacksize;
         /* For now, we just use the value computed during the latest GC. */
 #       ifdef DEBUG_THREADS
-          GC_printf("Total stacks size: %lu\n", (unsigned long)stack_size);
+          GC_log_printf("Total stacks size: %lu\n",
+                        (unsigned long)stack_size);
 #       endif
       }
 #   endif
@@ -238,9 +239,8 @@ static word min_bytes_allocd(void)
 STATIC word GC_adj_bytes_allocd(void)
 {
     signed_word result;
-    signed_word expl_managed =
-                (signed_word)GC_non_gc_bytes
-                - (signed_word)GC_non_gc_bytes_at_gc;
+    signed_word expl_managed = (signed_word)GC_non_gc_bytes
+                                - (signed_word)GC_non_gc_bytes_at_gc;
 
     /* Don't count what was explicitly freed, or newly allocated for    */
     /* explicit management.  Note that deallocating an explicitly       */
@@ -364,10 +364,9 @@ STATIC void GC_maybe_gc(void)
 #         endif
           if (GC_need_full_gc || n_partial_gcs >= GC_full_freq) {
             if (GC_print_stats) {
-                GC_log_printf(
+              GC_log_printf(
                   "***>Full mark for collection %lu after %ld allocd bytes\n",
-                  (unsigned long)GC_gc_no+1,
-                  (long)GC_bytes_allocd);
+                  (unsigned long)GC_gc_no + 1, (long)GC_bytes_allocd);
             }
             GC_promote_black_lists();
             (void)GC_reclaim_all((GC_stop_func)0, TRUE);
@@ -471,7 +470,7 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
       if (GC_print_stats) {
         GET_TIME(current_time);
         GC_log_printf("Complete collection took %lu msecs\n",
-                  MS_TIME_DIFF(current_time,start_time));
+                      MS_TIME_DIFF(current_time,start_time));
       }
 #   endif
     return(TRUE);
@@ -624,20 +623,20 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
             GC_clear_a_few_frames();
             GC_noop(0,0,0,0,0,0);
         GC_initiate_gc();
-        for(i = 0;;i++) {
-            if ((*stop_func)()) {
-                    if (GC_print_stats) {
-                        GC_log_printf("Abandoned stopped marking after "
-                                "%u iterations\n", i);
-                    }
-                    GC_deficit = i; /* Give the mutator a chance. */
-#                   ifdef THREAD_LOCAL_ALLOC
-                      GC_world_stopped = FALSE;
-#                   endif
-                    START_WORLD();
-                    return(FALSE);
+        for (i = 0;;i++) {
+          if ((*stop_func)()) {
+            if (GC_print_stats) {
+              GC_log_printf("Abandoned stopped marking after %u iterations\n",
+                            i);
             }
-            if (GC_mark_some((ptr_t)(&dummy))) break;
+            GC_deficit = i;     /* Give the mutator a chance.   */
+#           ifdef THREAD_LOCAL_ALLOC
+              GC_world_stopped = FALSE;
+#           endif
+            START_WORLD();
+            return(FALSE);
+          }
+          if (GC_mark_some((ptr_t)(&dummy))) break;
         }
 
     GC_gc_no++;
@@ -876,7 +875,7 @@ STATIC void GC_finish_collection(void)
 
     if (GC_print_stats == VERBOSE)
         GC_log_printf("Bytes recovered before sweep - f.l. count = %ld\n",
-                  (long)GC_bytes_found);
+                      (long)GC_bytes_found);
 
     /* Reconstruct free lists to contain everything not marked */
     GC_start_reclaim(FALSE);
@@ -895,16 +894,16 @@ STATIC void GC_finish_collection(void)
     }
 
     if (GC_print_stats == VERBOSE) {
-#       ifdef USE_MUNMAP
-          GC_log_printf("Immediately reclaimed %ld bytes in heap"
-                        " of size %lu bytes (%lu unmapped)\n",
-                        (long)GC_bytes_found, (unsigned long)GC_heapsize,
-                        (unsigned long)GC_unmapped_bytes);
-#       else
-          GC_log_printf("Immediately reclaimed %ld bytes in heap"
-                        " of size %lu bytes\n",
-                        (long)GC_bytes_found, (unsigned long)GC_heapsize);
-#       endif
+#     ifdef USE_MUNMAP
+        GC_log_printf("Immediately reclaimed %ld bytes in heap"
+                      " of size %lu bytes (%lu unmapped)\n",
+                      (long)GC_bytes_found, (unsigned long)GC_heapsize,
+                      (unsigned long)GC_unmapped_bytes);
+#     else
+        GC_log_printf(
+                "Immediately reclaimed %ld bytes in heap of size %lu bytes\n",
+                (long)GC_bytes_found, (unsigned long)GC_heapsize);
+#     endif
     }
 
     /* Reset or increment counters for next cycle */
@@ -928,7 +927,7 @@ STATIC void GC_finish_collection(void)
         /* A convenient place to output finalization statistics. */
         GC_print_finalization_stats();
 
-        GC_log_printf("Finalize + initiate sweep took %lu + %lu msecs\n",
+        GC_log_printf("Finalize plus initiate sweep took %lu + %lu msecs\n",
                       MS_TIME_DIFF(finalize_time,start_time),
                       MS_TIME_DIFF(done_time,finalize_time));
       }
@@ -1075,19 +1074,19 @@ GC_INNER void GC_add_to_heap(struct hblk *p, size_t bytes)
   {
     unsigned i;
 
-    GC_printf("Total heap size: %lu\n", (unsigned long) GC_heapsize);
+    GC_printf("Total heap size: %lu\n", (unsigned long)GC_heapsize);
     for (i = 0; i < GC_n_heap_sects; i++) {
-        ptr_t start = GC_heap_sects[i].hs_start;
-        size_t len = GC_heap_sects[i].hs_bytes;
-        struct hblk *h;
-        unsigned nbl = 0;
+      ptr_t start = GC_heap_sects[i].hs_start;
+      size_t len = GC_heap_sects[i].hs_bytes;
+      struct hblk *h;
+      unsigned nbl = 0;
 
-        for (h = (struct hblk *)start; h < (struct hblk *)(start + len); h++) {
-            if (GC_is_black_listed(h, HBLKSIZE)) nbl++;
-        }
-        GC_printf("Section %d from %p to %p %lu/%lu blacklisted\n",
-                  i, start, start + len,
-                  (unsigned long)nbl, (unsigned long)(len/HBLKSIZE));
+      for (h = (struct hblk *)start; h < (struct hblk *)(start + len); h++) {
+        if (GC_is_black_listed(h, HBLKSIZE)) nbl++;
+      }
+      GC_printf("Section %d from %p to %p %lu/%lu blacklisted\n",
+                i, start, start + len,
+                (unsigned long)nbl, (unsigned long)(len/HBLKSIZE));
     }
   }
 #endif
@@ -1141,7 +1140,7 @@ GC_INNER GC_bool GC_expand_hp_inner(word n)
     }
     space = GET_MEM(bytes);
     GC_add_to_our_memory((ptr_t)space, bytes);
-    if( space == 0 ) {
+    if (space == 0) {
         if (GC_print_stats) {
             GC_log_printf("Failed to expand heap by %ld bytes\n",
                           (unsigned long)bytes);
@@ -1272,7 +1271,7 @@ GC_INNER GC_bool GC_collect_or_expand(word needed_blocks,
         return(FALSE);
       }
     } else if (GC_fail_count && GC_print_stats) {
-      GC_printf("Memory available again...\n");
+      GC_log_printf("Memory available again...\n");
     }
     RESTORE_CANCEL(cancel_state);
     return(TRUE);
index e565ccd6e28f3bec30bd291af9fb9c35910a8e4f..0400697d446d63237598c51f4ac07d0b46780ab4 100644 (file)
@@ -110,7 +110,7 @@ STATIC void GC_update_check_page(struct hblk *h, int index)
     pe -> new_sum = GC_checksum(h);
 #   if !defined(MSWIN32) && !defined(MSWINCE)
         if (pe -> new_sum != 0x80000000 && !GC_page_was_ever_dirty(h)) {
-            GC_printf("GC_page_was_ever_dirty(%p) is wrong\n", h);
+            GC_err_printf("GC_page_was_ever_dirty(%p) is wrong\n", h);
         }
 #   endif
     if (GC_page_was_dirty(h)) {
@@ -165,12 +165,13 @@ STATIC void GC_check_blocks(void)
 
     GC_bytes_in_used_blocks = 0;
     GC_apply_to_all_blocks(GC_add_block, (word)0);
-    GC_printf("GC_bytes_in_used_blocks = %lu, bytes_in_free_blocks = %lu ",
-              (unsigned long)GC_bytes_in_used_blocks,
-              (unsigned long)bytes_in_free_blocks);
-    GC_printf("GC_heapsize = %lu\n", (unsigned long)GC_heapsize);
+    GC_log_printf(
+                "GC_bytes_in_used_blocks = %lu, bytes_in_free_blocks = %lu ",
+                (unsigned long)GC_bytes_in_used_blocks,
+                (unsigned long)bytes_in_free_blocks);
+    GC_log_printf("GC_heapsize = %lu\n", (unsigned long)GC_heapsize);
     if (GC_bytes_in_used_blocks + bytes_in_free_blocks != GC_heapsize) {
-        GC_printf("LOST SOME BLOCKS!!\n");
+        GC_log_printf("LOST SOME BLOCKS!!\n");
     }
 }
 
@@ -202,18 +203,19 @@ void GC_check_dirty(void)
         }
     }
 out:
-    GC_printf("Checked %lu clean and %lu dirty pages\n",
-              (unsigned long) GC_n_clean, (unsigned long) GC_n_dirty);
+    GC_log_printf("Checked %lu clean and %lu dirty pages\n",
+                  (unsigned long)GC_n_clean, (unsigned long)GC_n_dirty);
     if (GC_n_dirty_errors > 0) {
-        GC_printf("Found %d dirty bit errors (%d were faulted)\n",
-                  GC_n_dirty_errors, GC_n_faulted_dirty_errors);
+        GC_log_printf("Found %d dirty bit errors (%d were faulted)\n",
+                      GC_n_dirty_errors, GC_n_faulted_dirty_errors);
     }
     if (GC_n_changed_errors > 0) {
-        GC_printf("Found %lu changed bit errors\n",
-                  (unsigned long)GC_n_changed_errors);
-        GC_printf("These may be benign (provoked by nonpointer changes)\n");
+        GC_log_printf("Found %lu changed bit errors\n",
+                      (unsigned long)GC_n_changed_errors);
+        GC_log_printf(
+                "These may be benign (provoked by nonpointer changes)\n");
 #       ifdef THREADS
-          GC_printf(
+          GC_log_printf(
             "Also expect 1 per thread currently allocating a stubborn obj\n");
 #       endif
     }
index 50e2a5399f589e8d2bf02c8b6925df63de4f46dd..4fcd7bac36eb0d3716e69811b62b454ae9772186 100644 (file)
@@ -145,7 +145,7 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
                                    (natural_t *)&state,
                                    &thread_state_count);
 #   ifdef DEBUG_THREADS
-      GC_printf("thread_get_state return value = %d\n", kern_result);
+      GC_log_printf("thread_get_state returns value = %d\n", kern_result);
 #   endif
     if (kern_result != KERN_SUCCESS)
       ABORT("thread_get_state failed");
@@ -255,8 +255,8 @@ STATIC ptr_t GC_stack_range_for(ptr_t *phi, thread_act_t thread, GC_thread p,
     *phi = (p->flags & MAIN_THREAD) != 0 ? GC_stackbottom : p->stack_end;
 # endif
 # ifdef DEBUG_THREADS
-    GC_printf("Darwin: Stack for thread 0x%lx = [%p,%p)\n",
-              (unsigned long) thread, lo, *phi);
+    GC_log_printf("Darwin: Stack for thread 0x%lx = [%p,%p)\n",
+                  (unsigned long)thread, lo, *phi);
 # endif
   return lo;
 }
@@ -386,8 +386,8 @@ STATIC GC_bool GC_suspend_thread_list(thread_act_array_t act_list, int count,
 #   endif
 
 #   ifdef DEBUG_THREADS
-      GC_printf("Attempting to suspend thread 0x%lx\n",
-                (unsigned long)thread);
+      GC_log_printf("Attempting to suspend thread 0x%lx\n",
+                    (unsigned long)thread);
 #   endif
     /* find the current thread in the old list */
     found = FALSE;
@@ -431,8 +431,8 @@ STATIC GC_bool GC_suspend_thread_list(thread_act_array_t act_list, int count,
       continue;
     }
 #   ifdef DEBUG_THREADS
-      GC_printf("Thread state for 0x%lx = %d\n", (unsigned long)thread,
-                info.run_state);
+      GC_log_printf("Thread state for 0x%lx = %d\n", (unsigned long)thread,
+                    info.run_state);
 #   endif
     if (info.suspend_count != 0) {
       /* thread is already suspended. */
@@ -442,7 +442,7 @@ STATIC GC_bool GC_suspend_thread_list(thread_act_array_t act_list, int count,
     }
 
 #   ifdef DEBUG_THREADS
-      GC_printf("Suspending 0x%lx\n", (unsigned long)thread);
+      GC_log_printf("Suspending 0x%lx\n", (unsigned long)thread);
 #   endif
     kern_result = thread_suspend(thread);
     if (kern_result != KERN_SUCCESS) {
@@ -474,8 +474,8 @@ GC_INNER void GC_stop_world(void)
   kern_return_t kern_result;
 
 # ifdef DEBUG_THREADS
-    GC_printf("Stopping the world from thread 0x%lx\n",
-              (unsigned long)my_thread);
+    GC_log_printf("Stopping the world from thread 0x%lx\n",
+                  (unsigned long)my_thread);
 # endif
 # ifdef PARALLEL_MARK
     if (GC_parallel) {
@@ -564,7 +564,7 @@ GC_INNER void GC_stop_world(void)
 # endif
 
 # ifdef DEBUG_THREADS
-    GC_printf("World stopped from 0x%lx\n", (unsigned long)my_thread);
+    GC_log_printf("World stopped from 0x%lx\n", (unsigned long)my_thread);
 # endif
   mach_port_deallocate(my_task, my_thread);
 }
@@ -581,8 +581,8 @@ GC_INLINE void GC_thread_resume(thread_act_t thread)
       ABORT("thread_info failed");
 # endif
 # ifdef DEBUG_THREADS
-    GC_printf("Resuming thread 0x%lx with state %d\n",
-              (unsigned long)thread, info.run_state);
+    GC_log_printf("Resuming thread 0x%lx with state %d\n",
+                  (unsigned long)thread, info.run_state);
 # endif
   /* Resume the thread */
   kern_result = thread_resume(thread);
@@ -597,7 +597,7 @@ GC_INNER void GC_start_world(void)
   task_t my_task = current_task();
   int i;
 # ifdef DEBUG_THREADS
-    GC_printf("World starting\n");
+    GC_log_printf("World starting\n");
 # endif
 # ifdef MPROTECT_VDB
     if(GC_incremental) {
@@ -639,8 +639,8 @@ GC_INNER void GC_start_world(void)
           /* The thread is found in GC_mach_threads.      */
           if (GC_mach_threads[j].already_suspended) {
 #           ifdef DEBUG_THREADS
-              GC_printf("Not resuming already suspended thread 0x%lx\n",
-                        (unsigned long)thread);
+              GC_log_printf("Not resuming already suspended thread 0x%lx\n",
+                            (unsigned long)thread);
 #           endif
           } else {
             GC_thread_resume(thread);
@@ -669,7 +669,7 @@ GC_INNER void GC_start_world(void)
   }
 
 # ifdef DEBUG_THREADS
-    GC_printf("World started\n");
+    GC_log_printf("World started\n");
 # endif
 }
 
index 698e8aa45c853606ed27906aa0f312e42d26ae2b..f504a9568f33079fc8c7f4284ea4be5c0ed09959 100644 (file)
@@ -998,6 +998,10 @@ GC_INNER void GC_register_dynamic_libraries(void)
 
 #include <loader.h>
 
+extern char *sys_errlist[];
+extern int sys_nerr;
+extern int errno;
+
 GC_INNER void GC_register_dynamic_libraries(void)
 {
   int status;
@@ -1031,18 +1035,15 @@ GC_INNER void GC_register_dynamic_libraries(void)
       /* Check status AFTER checking moduleid because */
       /* of a bug in the non-shared ldr_next_module stub */
         if (status != 0) {
-            if (GC_print_stats) {
-                extern char *sys_errlist[];
-                extern int sys_nerr;
-                extern int errno;
-                GC_printf("dynamic_load: status = %d\n", status);
-                if (errno <= sys_nerr) {
-                    GC_printf("dynamic_load: %s\n", sys_errlist[errno]);
-                } else {
-                    GC_printf("dynamic_load: err_code = %d\n", errno);
-                }
+          if (GC_print_stats) {
+            GC_log_printf("dynamic_load: status = %d\n", status);
+            if (errno < sys_nerr) {
+              GC_log_printf("dynamic_load: %s\n", sys_errlist[errno]);
+            } else {
+              GC_log_printf("dynamic_load: err_code = %d\n", errno);
             }
-            ABORT("ldr_next_module failed");
+          }
+          ABORT("ldr_next_module failed");
         }
 
       /* Get the module information */
@@ -1056,11 +1057,11 @@ GC_INNER void GC_register_dynamic_libraries(void)
               continue;    /* skip the main module */
 
 #     ifdef DL_VERBOSE
-          GC_printf("---Module---\n");
-          GC_printf("Module ID            = %16ld\n", moduleinfo.lmi_modid);
-          GC_printf("Count of regions     = %16d\n", moduleinfo.lmi_nregion);
-          GC_printf("flags for module     = %16lx\n", moduleinfo.lmi_flags);
-          GC_printf("pathname of module   = \"%s\"\n", moduleinfo.lmi_name);
+        GC_log_printf("---Module---\n");
+        GC_log_printf("Module ID\t = %16ld\n", moduleinfo.lmi_modid);
+        GC_log_printf("Count of regions = %16d\n", moduleinfo.lmi_nregion);
+        GC_log_printf("flags for module = %16lx\n", moduleinfo.lmi_flags);
+        GC_log_printf("module pathname\t = \"%s\"\n", moduleinfo.lmi_name);
 #     endif
 
       /* For each region in this module */
@@ -1077,21 +1078,21 @@ GC_INNER void GC_register_dynamic_libraries(void)
                 continue;
 
 #         ifdef DL_VERBOSE
-              GC_printf("--- Region ---\n");
-              GC_printf("Region number    = %16ld\n",
-                        regioninfo.lri_region_no);
-              GC_printf("Protection flags = %016x\n",  regioninfo.lri_prot);
-              GC_printf("Virtual address  = %16p\n",   regioninfo.lri_vaddr);
-              GC_printf("Mapped address   = %16p\n",   regioninfo.lri_mapaddr);
-              GC_printf("Region size      = %16ld\n",  regioninfo.lri_size);
-              GC_printf("Region name      = \"%s\"\n", regioninfo.lri_name);
+            GC_log_printf("--- Region ---\n");
+            GC_log_printf("Region number\t = %16ld\n",
+                          regioninfo.lri_region_no);
+            GC_log_printf("Protection flags = %016x\n", regioninfo.lri_prot);
+            GC_log_printf("Virtual address\t = %16p\n", regioninfo.lri_vaddr);
+            GC_log_printf("Mapped address\t = %16p\n",
+                          regioninfo.lri_mapaddr);
+            GC_log_printf("Region size\t = %16ld\n", regioninfo.lri_size);
+            GC_log_printf("Region name\t = \"%s\"\n", regioninfo.lri_name);
 #         endif
 
           /* register region as a garbage collection root */
-            GC_add_roots_inner (
-                (char *)regioninfo.lri_mapaddr,
-                (char *)regioninfo.lri_mapaddr + regioninfo.lri_size,
-                TRUE);
+          GC_add_roots_inner((char *)regioninfo.lri_mapaddr,
+                        (char *)regioninfo.lri_mapaddr + regioninfo.lri_size,
+                        TRUE);
 
         }
     }
@@ -1129,10 +1130,10 @@ GC_INNER void GC_register_dynamic_libraries(void)
             break; /* Moved past end of shared library list --> finished */
           } else {
             if (GC_print_stats) {
-              if (errno <= sys_nerr) {
-                GC_printf("dynamic_load: %s\n", sys_errlist[errno]);
+              if (errno < sys_nerr) {
+                GC_log_printf("dynamic_load: %s\n", sys_errlist[errno]);
               } else {
-                GC_printf("dynamic_load: err_code = %d\n", errno);
+                GC_log_printf("dynamic_load: err_code = %d\n", errno);
               }
             }
             ABORT("shl_get failed");
@@ -1141,16 +1142,16 @@ GC_INNER void GC_register_dynamic_libraries(void)
         }
 
 #     ifdef DL_VERBOSE
-          GC_printf("---Shared library---\n");
-          GC_printf("\tfilename        = \"%s\"\n", shl_desc->filename);
-          GC_printf("\tindex           = %d\n", index);
-          GC_printf("\thandle          = %08x\n",
-                                        (unsigned long) shl_desc->handle);
-          GC_printf("\ttext seg. start = %08x\n", shl_desc->tstart);
-          GC_printf("\ttext seg. end   = %08x\n", shl_desc->tend);
-          GC_printf("\tdata seg. start = %08x\n", shl_desc->dstart);
-          GC_printf("\tdata seg. end   = %08x\n", shl_desc->dend);
-          GC_printf("\tref. count      = %lu\n", shl_desc->ref_count);
+        GC_log_printf("---Shared library---\n");
+        GC_log_printf("\tfilename\t= \"%s\"\n", shl_desc->filename);
+        GC_log_printf("\tindex\t\t= %d\n", index);
+        GC_log_printf("\thandle\t\t= %08x\n",
+                      (unsigned long) shl_desc->handle);
+        GC_log_printf("\ttext seg.start\t= %08x\n", shl_desc->tstart);
+        GC_log_printf("\ttext seg.end\t= %08x\n", shl_desc->tend);
+        GC_log_printf("\tdata seg.start\t= %08x\n", shl_desc->dstart);
+        GC_log_printf("\tdata seg.end\t= %08x\n", shl_desc->dend);
+        GC_log_printf("\tref.count\t= %lu\n", shl_desc->ref_count);
 #     endif
 
       /* register shared library's data segment as a garbage collection root */
@@ -1252,8 +1253,8 @@ STATIC void GC_dyld_image_add(const struct GC_MACH_HEADER *hdr, intptr_t slide)
       /* The user callback is called holding the lock   */
       if (callback == 0 || callback(name, (void*)start, (size_t)sec->size)) {
 #       ifdef DARWIN_DEBUG
-          GC_printf("Adding section at %p-%p (%lu bytes) from image %s\n",
-                    start,end,sec->size,name);
+          GC_log_printf("Adding section at %p-%p (%lu bytes) from image %s\n",
+                        start, end, sec->size, name);
 #       endif
         GC_add_roots_inner((ptr_t)start, (ptr_t)end, FALSE);
       }
@@ -1277,8 +1278,8 @@ STATIC void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
       start = slide + sec->addr;
       end = start + sec->size;
 #   ifdef DARWIN_DEBUG
-      GC_printf("Removing section at %p-%p (%lu bytes) from image %s\n",
-                start,end,sec->size,GC_dyld_name_for_hdr(hdr));
+      GC_log_printf("Removing section at %p-%p (%lu bytes) from image %s\n",
+                    start, end, sec->size, GC_dyld_name_for_hdr(hdr));
 #   endif
       GC_remove_roots((char*)start,(char*)end);
     }
@@ -1306,7 +1307,7 @@ GC_INNER void GC_init_dyld(void)
   if (initialized) return;
 
 # ifdef DARWIN_DEBUG
-    GC_printf("Registering dyld callbacks...\n");
+    GC_log_printf("Registering dyld callbacks...\n");
 # endif
 
   /* Apple's Documentation:
@@ -1341,7 +1342,7 @@ GC_INNER void GC_init_dyld(void)
     if (GETENV("DYLD_BIND_AT_LAUNCH") == 0) {
       /* The environment variable is unset, so we should bind manually. */
 #     ifdef DARWIN_DEBUG
-        GC_printf("Forcing full bind of GC code...\n");
+        GC_log_printf("Forcing full bind of GC code...\n");
 #     endif
       /* FIXME: '_dyld_bind_fully_image_containing_address' is deprecated. */
       if (!_dyld_bind_fully_image_containing_address(
index c4f5023caaaff9e536282ea44354912521395558..de82c2043adf0dab188d73bfd5aa8a36ab584f92 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -145,7 +145,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
         GC_add_to_our_memory(result, bytes_to_get);
         if (result == 0) {
             if (GC_print_stats)
-                GC_printf("Out of memory - trying to allocate less\n");
+                GC_log_printf("Out of memory - trying to allocate less\n");
             scratch_free_ptr -= bytes;
             bytes_to_get = bytes;
 #           ifdef USE_MMAP
index 398d7d4b69db6ddc86a8a0652d467dafaf01afbd..3bb778c1f5b0de492a8f3af748cb713af64982fd 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -271,9 +271,10 @@ GC_INNER char * GC_get_maps(void)
 #           ifdef THREADS
               if (maps_size > old_maps_size) {
                 if (GC_print_stats)
-                  GC_printf("Unexpected maps size growth from %lu to %lu\n",
-                            (unsigned long)old_maps_size,
-                            (unsigned long)maps_size);
+                  GC_log_printf(
+                        "Unexpected maps size growth from %lu to %lu\n",
+                        (unsigned long)old_maps_size,
+                        (unsigned long)maps_size);
                 ABORT("Unexpected asynchronous /proc/self/maps growth: "
                       "unregistered thread?");
               }
@@ -425,7 +426,7 @@ GC_bool GC_enclosing_mapping(ptr_t addr, ptr_t *startp, ptr_t *endp)
     ptr_t my_start, my_end;
     if (!GC_enclosing_mapping(GC_save_regs_in_stack(), &my_start, &my_end)) {
         if (GC_print_stats) {
-            GC_log_printf("Failed to find backing store base from /proc\n");
+          GC_log_printf("Failed to find backing store base from /proc\n");
         }
         return 0;
     }
@@ -1775,8 +1776,8 @@ void GC_register_data_segments(void)
         }
     }
     if (GC_print_stats)
-          GC_log_printf("Found new system malloc AllocationBase at %p\n",
-                        candidate);
+      GC_log_printf("Found new system malloc AllocationBase at %p\n",
+                    candidate);
     new_l -> allocation_base = candidate;
     new_l -> next = GC_malloc_heap_l;
     GC_malloc_heap_l = new_l;
@@ -2467,8 +2468,8 @@ GC_INNER void GC_remap(ptr_t start, size_t bytes)
 
       if (result != 0) {
         if (GC_print_stats)
-          GC_printf("Mprotect failed at %p (length %lu) with errno %d\n",
-                    start_addr, (unsigned long)len, errno);
+          GC_log_printf("Mprotect failed at %p (length %lu) with errno %d\n",
+                        start_addr, (unsigned long)len, errno);
         ABORT("mprotect remapping failed");
       }
       GC_unmapped_bytes -= len;
@@ -2940,19 +2941,19 @@ STATIC void GC_default_push_other_roots(void)
 #   include <sys/syscall.h>
 
 #   define PROTECT(addr, len) \
-          if (mprotect((caddr_t)(addr), (size_t)(len), \
-                       PROT_READ \
-                       | (pages_executable ? PROT_EXEC : 0)) < 0) { \
-            ABORT("mprotect failed"); \
-          }
+        if (mprotect((caddr_t)(addr), (size_t)(len), \
+                     PROT_READ \
+                     | (pages_executable ? PROT_EXEC : 0)) < 0) { \
+          ABORT("mprotect failed"); \
+        }
 #   define UNPROTECT(addr, len) \
-          if (mprotect((caddr_t)(addr), (size_t)(len), \
-                       (PROT_READ | PROT_WRITE) \
-                       | (pages_executable ? PROT_EXEC : 0)) < 0) { \
-            ABORT(pages_executable ? "un-mprotect executable page" \
-                                     " failed (probably disabled by OS)" : \
-                                "un-mprotect failed"); \
-          }
+        if (mprotect((caddr_t)(addr), (size_t)(len), \
+                     (PROT_READ | PROT_WRITE) \
+                     | (pages_executable ? PROT_EXEC : 0)) < 0) { \
+          ABORT(pages_executable ? "un-mprotect executable page" \
+                                   " failed (probably disabled by OS)" : \
+                              "un-mprotect failed"); \
+        }
 #   undef IGNORE_PAGES_EXECUTABLE
 
 # else /* MSWIN32 */
@@ -2962,21 +2963,21 @@ STATIC void GC_default_push_other_roots(void)
 
     static DWORD protect_junk;
 #   define PROTECT(addr, len) \
-          if (!VirtualProtect((addr), (len), \
-                              pages_executable ? PAGE_EXECUTE_READ : \
-                                                 PAGE_READONLY, \
-                              &protect_junk)) { \
-            if (GC_print_stats) \
-              GC_printf("Last error code: 0x%lx\n", (long)GetLastError()); \
-            ABORT("VirtualProtect failed"); \
-          }
+        if (!VirtualProtect((addr), (len), \
+                            pages_executable ? PAGE_EXECUTE_READ : \
+                                               PAGE_READONLY, \
+                            &protect_junk)) { \
+          if (GC_print_stats) \
+            GC_log_printf("Last error code: 0x%lx\n", (long)GetLastError()); \
+          ABORT("VirtualProtect failed"); \
+        }
 #   define UNPROTECT(addr, len) \
-          if (!VirtualProtect((addr), (len), \
-                              pages_executable ? PAGE_EXECUTE_READWRITE : \
-                                                 PAGE_READWRITE, \
-                              &protect_junk)) { \
-            ABORT("un-VirtualProtect failed"); \
-          }
+        if (!VirtualProtect((addr), (len), \
+                            pages_executable ? PAGE_EXECUTE_READWRITE : \
+                                               PAGE_READWRITE, \
+                            &protect_junk)) { \
+          ABORT("un-VirtualProtect failed"); \
+        }
 # endif /* MSWIN32 || MSWINCE || DARWIN */
 
 # if defined(MSWIN32)
@@ -3169,7 +3170,7 @@ STATIC void GC_default_push_other_roots(void)
             if (old_handler == (SIG_HNDLR_PTR)SIG_DFL) {
 #               if !defined(MSWIN32) && !defined(MSWINCE)
                     if (GC_print_stats)
-                        GC_printf("Unexpected segfault at %p\n", addr);
+                      GC_log_printf("Unexpected segfault at %p\n", addr);
                     ABORT("Unexpected bus error or segmentation fault");
 #               else
                     return(EXCEPTION_CONTINUE_SEARCH);
@@ -3221,7 +3222,7 @@ STATIC void GC_default_push_other_roots(void)
       return EXCEPTION_CONTINUE_SEARCH;
 #   else
       if (GC_print_stats)
-        GC_printf("Unexpected segfault at %p\n", addr);
+        GC_log_printf("Unexpected segfault at %p\n", addr);
       ABORT("Unexpected bus error or segmentation fault");
 #   endif
   }
@@ -3279,7 +3280,7 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
 #     endif /* SIG_SUSPEND */
 #   endif
     if (GC_print_stats == VERBOSE)
-        GC_log_printf(
+      GC_log_printf(
                 "Initializing mprotect virtual dirty bit implementation\n");
     GC_dirty_maintained = TRUE;
     if (GC_page_size % HBLKSIZE != 0) {
@@ -3629,15 +3630,13 @@ GC_INNER void GC_dirty_init(void)
 
     GC_dirty_maintained = TRUE;
     if (GC_bytes_allocd != 0 || GC_bytes_allocd_before_gc != 0) {
-        register int i;
-
-        for (i = 0; i < PHT_SIZE; i++)
-          GC_written_pages[i] = (word)(-1);
-        if (GC_print_stats == VERBOSE)
-            GC_log_printf(
-                      "Allocated bytes:%lu:all pages may have been written\n",
-                      (unsigned long)
-                                (GC_bytes_allocd + GC_bytes_allocd_before_gc));
+      register int i;
+      for (i = 0; i < PHT_SIZE; i++)
+        GC_written_pages[i] = (word)(-1);
+      if (GC_print_stats == VERBOSE)
+        GC_log_printf("Allocated bytes:%lu:all pages may have been written\n",
+                      (unsigned long)(GC_bytes_allocd
+                                      + GC_bytes_allocd_before_gc));
     }
     sprintf(buf, "/proc/%ld", (long)getpid());
     fd = open(buf, O_RDONLY);
@@ -3679,8 +3678,8 @@ GC_INNER void GC_read_dirty(void)
         char *new_buf;
 
         if (GC_print_stats)
-            GC_log_printf("/proc read failed: GC_proc_buf_size = %lu\n",
-                          (unsigned long)GC_proc_buf_size);
+          GC_log_printf("/proc read failed: GC_proc_buf_size = %lu\n",
+                        (unsigned long)GC_proc_buf_size);
 
         new_buf = GC_scratch_alloc(new_size);
         if (new_buf != 0) {
@@ -4037,8 +4036,8 @@ STATIC void *GC_mprotect_thread(void *arg)
 
     if (r != MACH_MSG_SUCCESS) {
       if (GC_print_stats)
-        GC_printf("mach_msg failed with code %d: %s\n", (int)r,
-                  mach_error_string(r));
+        GC_log_printf("mach_msg failed with code %d: %s\n", (int)r,
+                      mach_error_string(r));
       ABORT("mach_msg failed");
     }
 
@@ -4297,8 +4296,9 @@ catch_exception_raise(mach_port_t exception_port, mach_port_t thread,
   if (exception != EXC_BAD_ACCESS || code[0] != KERN_PROTECTION_FAILURE) {
 #   ifdef DEBUG_EXCEPTION_HANDLING
       /* We aren't interested, pass it on to the old handler */
-      GC_printf("Exception: 0x%x Code: 0x%x 0x%x in catch...\n", exception,
-                code_count > 0 ? code[0] : -1, code_count > 1 ? code[1] : -1);
+      GC_log_printf("Exception: 0x%x Code: 0x%x 0x%x in catch...\n",
+                    exception, code_count > 0 ? code[0] : -1,
+                    code_count > 1 ? code[1] : -1);
 #   endif
     return FWD();
   }
index cbe5a8576fbc4f86902d206b2b867cdb9d5755e5..48c2d95ae0bba2404af781299a5bb7fdd259b0aa 100644 (file)
@@ -60,7 +60,7 @@ void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb, void *arg)
 # endif
   result = (*start)(start_arg);
 # ifdef DEBUG_THREADS
-    GC_printf("Finishing thread 0x%x\n", (unsigned)pthread_self());
+    GC_log_printf("Finishing thread 0x%x\n", (unsigned)pthread_self());
 # endif
   me -> status = result;
 # ifndef NACL
index 0687bbc82a0a5cefae8901655a54ebc70e33c8b0..4ec6fe1fc7db28d9ab1cfe620a38afe15cd5e2fc 100644 (file)
@@ -65,10 +65,11 @@ int GC_nacl_thread_used[MAX_NACL_GC_THREADS];
     int i;
 
     if (pthread_sigmask(SIG_BLOCK, NULL, &blocked) != 0)
-        ABORT("pthread_sigmask failed");
+      ABORT("pthread_sigmask failed");
     GC_printf("Blocked: ");
     for (i = 1; i < NSIG; i++) {
-        if (sigismember(&blocked, i)) { GC_printf("%d ", i); }
+      if (sigismember(&blocked, i))
+        GC_printf("%d ", i);
     }
     GC_printf("\n");
   }
@@ -196,7 +197,7 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context)
       /* cancellation point is inherently a problem, unless there is    */
       /* some way to disable cancellation in the handler.               */
 # ifdef DEBUG_THREADS
-    GC_printf("Suspending 0x%x\n", (unsigned)my_thread);
+    GC_log_printf("Suspending 0x%x\n", (unsigned)my_thread);
 # endif
 
   me = GC_lookup_thread(my_thread);
@@ -250,7 +251,7 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context)
   /* unlikely to be efficient.                                          */
 
 # ifdef DEBUG_THREADS
-    GC_printf("Continuing 0x%x\n", (unsigned)my_thread);
+    GC_log_printf("Continuing 0x%x\n", (unsigned)my_thread);
 # endif
   RESTORE_CANCEL(cancel_state);
 }
@@ -272,7 +273,8 @@ STATIC void GC_restart_handler(int sig)
   */
 
 # ifdef DEBUG_THREADS
-    GC_printf("In GC_restart_handler for 0x%x\n", (unsigned)pthread_self());
+    GC_log_printf("In GC_restart_handler for 0x%x\n",
+                  (unsigned)pthread_self());
 # endif
 }
 
@@ -299,7 +301,7 @@ GC_INNER void GC_push_all_stacks(void)
 
     if (!GC_thr_initialized) GC_thr_init();
 #   ifdef DEBUG_THREADS
-      GC_printf("Pushing stacks from thread 0x%x\n", (unsigned) me);
+      GC_log_printf("Pushing stacks from thread 0x%x\n", (unsigned)me);
 #   endif
     for (i = 0; i < THREAD_TABLE_SZ; i++) {
       for (p = GC_threads[i]; p != 0; p = p -> next) {
@@ -327,8 +329,8 @@ GC_INNER void GC_push_all_stacks(void)
             IF_IA64(bs_lo = BACKING_STORE_BASE;)
         }
 #       ifdef DEBUG_THREADS
-          GC_printf("Stack for thread 0x%x = [%p,%p)\n",
-                    (unsigned)(p -> id), lo, hi);
+          GC_log_printf("Stack for thread 0x%x = [%p,%p)\n",
+                        (unsigned)(p -> id), lo, hi);
 #       endif
         if (0 == lo) ABORT("GC_push_all_stacks: sp not set!");
         GC_push_all_stack_sections(lo, hi, p -> traced_stack_sect);
@@ -345,8 +347,8 @@ GC_INNER void GC_push_all_stacks(void)
 #       endif
 #       ifdef IA64
 #         ifdef DEBUG_THREADS
-            GC_printf("Reg stack for thread 0x%x = [%p,%p)\n",
-                      (unsigned)p -> id, bs_lo, bs_hi);
+            GC_log_printf("Reg stack for thread 0x%x = [%p,%p)\n",
+                          (unsigned)p -> id, bs_lo, bs_hi);
 #         endif
           /* FIXME:  This (if p->id==me) may add an unbounded number of */
           /* entries, and hence overflow the mark stack, which is bad.  */
@@ -358,7 +360,7 @@ GC_INNER void GC_push_all_stacks(void)
       }
     }
     if (GC_print_stats == VERBOSE) {
-        GC_log_printf("Pushed %d thread stacks\n", (int)nthreads);
+      GC_log_printf("Pushed %d thread stacks\n", (int)nthreads);
     }
     if (!found_me && !GC_in_thread_creation)
       ABORT("Collecting from unknown thread");
@@ -417,8 +419,8 @@ STATIC int GC_suspend_all(void)
               n_live_threads++;
 #           endif
 #           ifdef DEBUG_THREADS
-              GC_printf("Sending suspend signal to 0x%x\n",
-                        (unsigned)(p -> id));
+              GC_log_printf("Sending suspend signal to 0x%x\n",
+                            (unsigned)(p -> id));
 #           endif
 
 #           ifdef GC_OPENBSD_THREADS
@@ -457,8 +459,8 @@ STATIC int GC_suspend_all(void)
 #     define NACL_PARK_WAIT_NANOSECONDS (100 * 1000)
 #   endif
 #   ifdef DEBUG_THREADS
-      GC_printf("pthread_stop_world: num_threads %d\n",
-                 GC_nacl_num_gc_threads - 1);
+      GC_log_printf("pthread_stop_world: num_threads %d\n",
+                    GC_nacl_num_gc_threads - 1);
 #   endif
     GC_nacl_thread_parker = pthread_self();
     GC_nacl_park_threads_now = 1;
@@ -488,8 +490,8 @@ STATIC int GC_suspend_all(void)
       ts.tv_sec = 0;
       ts.tv_nsec = NACL_PARK_WAIT_NANOSECONDS;
 #     ifdef DEBUG_THREADS
-        GC_printf("Sleep waiting for %d threads to park...\n",
-                   GC_nacl_num_gc_threads - num_threads_parked - 1);
+        GC_log_printf("Sleep waiting for %d threads to park...\n",
+                      GC_nacl_num_gc_threads - num_threads_parked - 1);
 #     endif
       /* This requires _POSIX_TIMERS feature.   */
       nanosleep(&ts, 0);
@@ -507,7 +509,7 @@ GC_INNER void GC_stop_world(void)
 # endif
   GC_ASSERT(I_HOLD_LOCK());
 # ifdef DEBUG_THREADS
-    GC_printf("Stopping the world from 0x%x\n", (unsigned)pthread_self());
+    GC_log_printf("Stopping the world from 0x%x\n", (unsigned)pthread_self());
 # endif
 
   /* Make sure all free list construction has stopped before we start.  */
@@ -576,7 +578,7 @@ GC_INNER void GC_stop_world(void)
       GC_release_mark_lock();
 # endif
 # ifdef DEBUG_THREADS
-    GC_printf("World stopped from 0x%x\n", (unsigned)pthread_self());
+    GC_log_printf("World stopped from 0x%x\n", (unsigned)pthread_self());
     GC_stopping_thread = 0;
 # endif
 }
@@ -723,7 +725,7 @@ GC_INNER void GC_start_world(void)
 #   endif
 
 #   ifdef DEBUG_THREADS
-      GC_printf("World starting\n");
+      GC_log_printf("World starting\n");
 #   endif
 
 #   ifndef GC_OPENBSD_THREADS
@@ -738,8 +740,8 @@ GC_INNER void GC_start_world(void)
               n_live_threads++;
 #           endif
 #           ifdef DEBUG_THREADS
-              GC_printf("Sending restart signal to 0x%x\n",
-                        (unsigned)(p -> id));
+              GC_log_printf("Sending restart signal to 0x%x\n",
+                            (unsigned)(p -> id));
 #           endif
 
 #         ifdef GC_OPENBSD_THREADS
@@ -770,16 +772,16 @@ GC_INNER void GC_start_world(void)
         while (0 != (code = sem_wait(&GC_restart_ack_sem)))
             if (errno != EINTR) {
                 if (GC_print_stats)
-                  GC_printf("sem_wait() returned %d\n", code);
+                  GC_log_printf("sem_wait() returned %d\n", code);
                 ABORT("sem_wait() for restart handler failed");
             }
 #   endif
 #   ifdef DEBUG_THREADS
-      GC_printf("World started\n");
+      GC_log_printf("World started\n");
 #   endif
 # else /* NACL */
 #   ifdef DEBUG_THREADS
-      GC_printf("World starting...\n");
+      GC_log_printf("World starting...\n");
 #   endif
     GC_nacl_park_threads_now = 0;
 # endif
@@ -839,7 +841,7 @@ GC_INNER void GC_stop_init(void)
         GC_retry_signals = FALSE;
     }
     if (GC_print_stats && GC_retry_signals) {
-        GC_log_printf("Will retry suspend signal if necessary\n");
+      GC_log_printf("Will retry suspend signal if necessary\n");
     }
 # endif /* !GC_OPENBSD_THREADS && !NACL */
 }
index c78faeaae6cd7f6adfd2225fe2ed354f21a1d614..0f1d9242374c75c8f7b98c72013f2cf26ad5329c 100644 (file)
@@ -388,8 +388,8 @@ STATIC void * GC_mark_thread(void * id)
         my_mark_no = GC_mark_no;
     }
 #   ifdef DEBUG_THREADS
-      GC_printf("Starting mark helper for mark number %lu\n",
-                (unsigned long)my_mark_no);
+      GC_log_printf("Starting mark helper for mark number %lu\n",
+                    (unsigned long)my_mark_no);
 #   endif
     GC_help_marker(my_mark_no);
   }
@@ -439,7 +439,7 @@ static void start_mark_threads(void)
       }
     }
     if (GC_print_stats) {
-        GC_log_printf("Started %ld mark helper threads\n", GC_markers - 1);
+      GC_log_printf("Started %ld mark helper threads\n", GC_markers - 1);
     }
     pthread_attr_destroy(&attr);
 }
@@ -861,7 +861,7 @@ STATIC void GC_fork_child_proc(void)
       numCpus = pm_sysinfo.idle_vp_count;
 
 #  ifdef DEBUG_THREADS
-     GC_printf("Number of active CPUs in this system: %d\n", numCpus);
+     GC_log_printf("Number of active CPUs in this system: %d\n", numCpus);
 #  endif
     return(numCpus);
   }
@@ -984,8 +984,9 @@ GC_INNER void GC_thr_init(void)
   }
 # ifdef PARALLEL_MARK
     if (GC_print_stats) {
-      GC_log_printf("Number of processors = %ld, "
-                "number of marker threads = %ld\n", GC_nprocs, GC_markers);
+      GC_log_printf(
+        "Number of processors = %ld, number of marker threads = %ld\n",
+        GC_nprocs, GC_markers);
     }
     if (GC_markers <= 1) {
       GC_parallel = FALSE;
@@ -1406,8 +1407,8 @@ GC_INNER void * GC_start_rtn_prepare_thread(void *(**pstart)(void *),
 
     my_pthread = pthread_self();
 #   ifdef DEBUG_THREADS
-        GC_printf("Starting thread 0x%x, pid = %ld, sp = %p\n",
-                  (unsigned)my_pthread, (long) getpid(), &arg);
+      GC_log_printf("Starting thread 0x%x, pid = %ld, sp = %p\n",
+                    (unsigned)my_pthread, (long)getpid(), &arg);
 #   endif
     LOCK();
     me = GC_register_my_thread_inner(sb, my_pthread);
@@ -1418,7 +1419,7 @@ GC_INNER void * GC_start_rtn_prepare_thread(void *(**pstart)(void *),
     UNLOCK();
     *pstart = si -> start_routine;
 #   ifdef DEBUG_THREADS
-        GC_printf("start_routine = %p\n", (void *)(signed_word)(*pstart));
+      GC_log_printf("start_routine = %p\n", (void *)(signed_word)(*pstart));
 #   endif
     *pstart_arg = si -> arg;
     sem_post(&(si -> registered));      /* Last action on si.   */
@@ -1523,15 +1524,15 @@ GC_API int WRAP_FUNC(pthread_create)(pthread_t *new_thread,
     si -> flags = my_flags;
     UNLOCK();
 #   ifdef DEBUG_THREADS
-        GC_printf("About to start new thread from thread 0x%x\n",
-                  (unsigned)pthread_self());
+      GC_log_printf("About to start new thread from thread 0x%x\n",
+                    (unsigned)pthread_self());
 #   endif
     GC_need_to_lock = TRUE;
 
     result = REAL_FUNC(pthread_create)(new_thread, attr, GC_start_routine, si);
 
 #   ifdef DEBUG_THREADS
-        GC_printf("Started thread 0x%x\n", (unsigned)(*new_thread));
+      GC_log_printf("Started thread 0x%x\n", (unsigned)(*new_thread));
 #   endif
     /* Wait until child has been added to the thread table.             */
     /* This also ensures that we hold onto si until the child is done   */
index 0199d8c7e6be07a604332d8e0b25f727643fc2a5..a0f6dd32d6fadb587e0e49ab0fb087b18bc76a5e 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
@@ -404,10 +404,10 @@ STATIC void GC_print_block_descr(struct hblk *h,
 
     if (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);
+                (unsigned)hhdr -> hb_n_marks, n_marks);
     } else {
       GC_printf("(%u:%u,%u)", hhdr -> hb_obj_kind,
-                              (unsigned)bytes, n_marks);
+                (unsigned)bytes, n_marks);
     }
     bytes += HBLKSIZE-1;
     bytes &= ~(HBLKSIZE-1);
@@ -436,15 +436,15 @@ void GC_print_free_list(int kind, size_t sz_in_granules)
     struct obj_kind * ok = &GC_obj_kinds[kind];
     ptr_t flh = ok -> ok_freelist[sz_in_granules];
     struct hblk *lastBlock = 0;
-    int n = 0;
+    int n;
 
-    while (flh) {
+    for (n = 1; flh; n++) {
         struct hblk *block = HBLKPTR(flh);
         if (block != lastBlock) {
-            GC_printf("\nIn heap block at %p:\n\t", block);
-            lastBlock = block;
+          GC_printf("\nIn heap block at %p:\n\t", block);
+          lastBlock = block;
         }
-        GC_printf("%d: %p;", ++n, flh);
+        GC_printf("%d: %p;", n, flh);
         flh = obj_link(flh);
     }
 }
@@ -602,7 +602,7 @@ GC_INNER GC_bool GC_reclaim_all(GC_stop_func stop_func, GC_bool ignore_old)
       if (GC_print_stats == VERBOSE) {
         GET_TIME(done_time);
         GC_log_printf("Disposing of reclaim lists took %lu msecs\n",
-                  MS_TIME_DIFF(done_time,start_time));
+                      MS_TIME_DIFF(done_time,start_time));
       }
 #   endif
     return(TRUE);