]> granicus.if.org Git - gc/commitdiff
Replace conditional GC_log_printf calls with GC_COND/VERBOSE_LOG_PRINTF
authorIvan Maidanski <ivmai@mail.ru>
Mon, 12 Nov 2012 17:56:57 +0000 (21:56 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 12 Nov 2012 17:56:57 +0000 (21:56 +0400)
(code refactoring)

* allchblk.c (GC_freehblk): Replace
"if (GC_print_stats) GC_log_printf" with GC_COND_LOG_PRINTF.
* alloc.c (GC_timeout_stop_func, GC_maybe_gc, GC_try_to_collect_inner,
GC_stopped_mark, GC_finish_collection, GC_expand_hp_inner,
GC_collect_or_expand): Likewise.
* backgraph.c (backwards_height, GC_print_back_graph_stats): Likewise.
* checksums.c (GC_check_blocks, GC_check_dirty): Likewise.
* dyn_load.c (GC_register_dynamic_libraries): Likewise.
* finalize.c (GC_general_register_disappearing_link,
GC_register_finalizer_inner): Likewise.
* gcj_mlc.c (GC_init_gcj_malloc): Likewise.
* headers.c (GC_scratch_alloc): Likewise.
* mark.c (GC_mark_some_inner, GC_mark_some,
GC_signal_mark_stack_overflow, GC_return_mark_stack,
alloc_mark_stack): Likewise.
* obj_map.c (GC_add_map_entry): Likewise.
* os_dep.c (GC_get_maps, backing_store_base_from_proc,
GC_register_data_segments, detect_GetWriteWatch,
GC_add_current_malloc_heap, GC_remap, PROTECT, GC_write_fault_handler,
GC_dirty_init, GC_mprotect_thread): Likewise.
* pthread_stop_world.c (GC_stop_world, GC_start_world, GC_stop_init):
Likewise.
* pthread_support.c (start_mark_threads, GC_thr_init): Likewise.
* win32_threads.c (GC_register_my_thread_inner, GC_thr_init):
Likewise.
* alloc.c (GC_finish_collection): Replace
"if (GC_print_stats == VERBOSE) GC_log_printf" with
GC_VERBOSE_LOG_PRINTF.
* blacklst.c (GC_promote_black_lists): Likewise.
* darwin_stop_world.c (GC_push_all_stacks): Likewise.
* mark.c (GC_mark_local, GC_do_parallel_mark): Likewise.
* os_dep.c (GC_dirty_init): Likewise.
* pthread_stop_world.c (GC_push_all_stacks): Likewise.
* win32_threads.c (GC_push_all_stacks): Likewise.
* include/private/gc_priv.h (GC_COND_LOG_PRINTF,
GC_VERBOSE_LOG_PRINTF): New macro (check GC_print_stats and call
GC_log_printf if enabled).
* os_dep.c (GC_dirty_init, GC_read_dirty): Replace
"if (GC_print_stats) GC_err_printf" with WARN.

17 files changed:
allchblk.c
alloc.c
backgraph.c
blacklst.c
checksums.c
darwin_stop_world.c
dyn_load.c
finalize.c
gcj_mlc.c
headers.c
include/private/gc_priv.h
mark.c
obj_map.c
os_dep.c
pthread_stop_world.c
pthread_support.c
win32_threads.c

index b4879389035300d2c1acb1983f1337b8ba2d3d83..5ddafdb3f7ffc113885cad2313140c1b36f2f42b 100644 (file)
@@ -845,9 +845,8 @@ 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_log_printf("Duplicate large block deallocation of %p\n",
-                        (void *)hbp);
+        GC_COND_LOG_PRINTF("Duplicate large block deallocation of %p\n",
+                           (void *)hbp);
         ABORT("Duplicate large block deallocation");
       }
 
diff --git a/alloc.c b/alloc.c
index ef9d118fd42d403557ecee65d4fec804a710762d..c0440e116cdf9d00d1396bd77d6471abe9929b62 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -181,11 +181,9 @@ GC_API GC_stop_func GC_CALL GC_get_stop_func(void)
     GET_TIME(current_time);
     time_diff = MS_TIME_DIFF(current_time,GC_start_time);
     if (time_diff >= GC_time_limit) {
-        if (GC_print_stats) {
-          GC_log_printf(
+        GC_COND_LOG_PRINTF(
                 "Abandoning stopped marking after %lu msecs (attempt %d)\n",
                 time_diff, GC_n_attempts);
-        }
         return(1);
     }
     return(0);
@@ -368,11 +366,9 @@ STATIC void GC_maybe_gc(void)
               GC_wait_for_reclaim();
 #         endif
           if (GC_need_full_gc || n_partial_gcs >= GC_full_freq) {
-            if (GC_print_stats) {
-              GC_log_printf(
+            GC_COND_LOG_PRINTF(
                 "***>Full mark for collection %lu after %lu allocd bytes\n",
                 (unsigned long)GC_gc_no + 1, (unsigned long)GC_bytes_allocd);
-            }
             GC_promote_black_lists();
             (void)GC_reclaim_all((GC_stop_func)0, TRUE);
             GC_notify_full_gc();
@@ -421,10 +417,8 @@ GC_INNER GC_bool GC_try_to_collect_inner(GC_stop_func stop_func)
     ASSERT_CANCEL_DISABLED();
     if (GC_dont_gc || (*stop_func)()) return FALSE;
     if (GC_incremental && GC_collection_in_progress()) {
-      if (GC_print_stats) {
-        GC_log_printf(
+      GC_COND_LOG_PRINTF(
             "GC_try_to_collect_inner: finishing collection in progress\n");
-      }
       /* Just finish collection already in progress.    */
         while(GC_collection_in_progress()) {
             if ((*stop_func)()) return(FALSE);
@@ -613,12 +607,10 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
 #   ifdef THREAD_LOCAL_ALLOC
       GC_world_stopped = TRUE;
 #   endif
-    if (GC_print_stats) {
         /* Output blank line for convenience here */
-        GC_log_printf(
+    GC_COND_LOG_PRINTF(
               "\n--> Marking for collection %lu after %lu allocated bytes\n",
               (unsigned long)GC_gc_no + 1, (unsigned long) GC_bytes_allocd);
-    }
 #   ifdef MAKE_BACK_GRAPH
       if (GC_print_back_height) {
         GC_build_back_graph();
@@ -633,10 +625,8 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
         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_COND_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;
@@ -648,13 +638,11 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
         }
 
     GC_gc_no++;
-    if (GC_print_stats) {
-      GC_log_printf("GC %lu reclaimed %ld bytes --> heapsize: %lu"
-                    " bytes" IF_USE_MUNMAP(" (%lu unmapped)") "\n",
-                    (unsigned long)GC_gc_no, (long)GC_bytes_found,
-                    (unsigned long)GC_heapsize /*, */
-                    COMMA_IF_USE_MUNMAP((unsigned long)GC_unmapped_bytes));
-    }
+    GC_COND_LOG_PRINTF("GC %lu reclaimed %ld bytes --> heapsize: %lu"
+                       " bytes" IF_USE_MUNMAP(" (%lu unmapped)") "\n",
+                       (unsigned long)GC_gc_no, (long)GC_bytes_found,
+                       (unsigned long)GC_heapsize /*, */
+                       COMMA_IF_USE_MUNMAP((unsigned long)GC_unmapped_bytes));
 
     /* Check all debugged objects for consistency */
     if (GC_debugging_started) {
@@ -914,18 +902,15 @@ 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);
+    GC_VERBOSE_LOG_PRINTF("Bytes recovered before sweep - f.l. count = %ld\n",
+                          (long)GC_bytes_found);
 
     /* Reconstruct free lists to contain everything not marked */
     GC_start_reclaim(FALSE);
-    if (GC_print_stats) {
-      GC_log_printf("Heap contains %lu pointer-containing "
-                    "+ %lu pointer-free reachable bytes\n",
-                    (unsigned long)GC_composite_in_use,
-                    (unsigned long)GC_atomic_in_use);
-    }
+    GC_COND_LOG_PRINTF("Heap contains %lu pointer-containing"
+                       " + %lu pointer-free reachable bytes\n",
+                       (unsigned long)GC_composite_in_use,
+                       (unsigned long)GC_atomic_in_use);
     if (GC_is_full_gc) {
         GC_used_heap_size_after_full = USED_HEAP_SIZE;
         GC_need_full_gc = FALSE;
@@ -934,12 +919,12 @@ STATIC void GC_finish_collection(void)
                             > min_bytes_allocd();
     }
 
-    if (GC_print_stats == VERBOSE) {
-      GC_log_printf("Immediately reclaimed %ld bytes, heapsize:"
-                    " %lu bytes" IF_USE_MUNMAP(" (%lu unmapped)") "\n",
-                    (long)GC_bytes_found, (unsigned long)GC_heapsize /*, */
-                    COMMA_IF_USE_MUNMAP((unsigned long)GC_unmapped_bytes));
-    }
+    GC_VERBOSE_LOG_PRINTF("Immediately reclaimed %ld bytes, heapsize:"
+                          " %lu bytes" IF_USE_MUNMAP(" (%lu unmapped)") "\n",
+                          (long)GC_bytes_found,
+                          (unsigned long)GC_heapsize /*, */
+                          COMMA_IF_USE_MUNMAP((unsigned long)
+                                              GC_unmapped_bytes));
 
     /* Reset or increment counters for next cycle */
     GC_n_attempts = 0;
@@ -1177,16 +1162,13 @@ 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 (GC_print_stats) {
-            GC_log_printf("Failed to expand heap by %lu bytes\n",
-                          (unsigned long)bytes);
-        }
+        GC_COND_LOG_PRINTF("Failed to expand heap by %lu bytes\n",
+                           (unsigned long)bytes);
         return(FALSE);
     }
-    if (GC_print_stats) {
-      GC_log_printf("Increasing heap size by %lu after %lu allocated bytes\n",
-                    (unsigned long)bytes, (unsigned long)GC_bytes_allocd);
-    }
+    GC_COND_LOG_PRINTF(
+                "Increasing heap size by %lu after %lu allocated bytes\n",
+                (unsigned long)bytes, (unsigned long)GC_bytes_allocd);
     /* Adjust heap limits generously for blacklisting to work better.   */
     /* GC_add_to_heap performs minimal adjustment needed for            */
     /* correctness.                                                     */
@@ -1320,8 +1302,8 @@ GC_INNER GC_bool GC_collect_or_expand(word needed_blocks,
         RESTORE_CANCEL(cancel_state);
         return(FALSE);
       }
-    } else if (GC_fail_count && GC_print_stats) {
-      GC_log_printf("Memory available again...\n");
+    } else if (GC_fail_count) {
+      GC_COND_LOG_PRINTF("Memory available again...\n");
     }
     RESTORE_CANCEL(cancel_state);
     return(TRUE);
index 74437ba284f2d8b5e9010057c672cf5e8b6d4e9b..3659f8782cee5f0a46194e37bb0f38ab5b79f264 100644 (file)
@@ -376,8 +376,7 @@ static word backwards_height(ptr_t p)
   FOR_EACH_PRED(q, p, {
     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 %p to %p\n", q, p);
+      GC_COND_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;
@@ -467,10 +466,8 @@ void GC_print_back_graph_stats(void)
             "of unreachable objects:\n");
     GC_print_heap_obj(GC_deepest_obj);
   }
-  if (GC_print_stats) {
-    GC_log_printf("Needed max total of %d back-edge structs\n",
-                  GC_n_back_edge_structs);
-  }
+  GC_COND_LOG_PRINTF("Needed max total of %d back-edge structs\n",
+                     GC_n_back_edge_structs);
   GC_apply_to_each_object(reset_back_edge);
   GC_deepest_obj = 0;
 }
index 11556a4a8021704bc368aabc4e11e8fc34d44153..77ad6758eacb6c0c75c7a84496a96f3406bc8a2d 100644 (file)
@@ -147,9 +147,9 @@ GC_INNER void GC_promote_black_lists(void)
     GC_incomplete_normal_bl = very_old_normal_bl;
     GC_incomplete_stack_bl = very_old_stack_bl;
     GC_total_stack_black_listed = total_stack_black_listed();
-    if (GC_print_stats == VERBOSE)
-        GC_log_printf("%lu bytes in heap blacklisted for interior pointers\n",
-                      (unsigned long)GC_total_stack_black_listed);
+    GC_VERBOSE_LOG_PRINTF(
+                "%lu bytes in heap blacklisted for interior pointers\n",
+                (unsigned long)GC_total_stack_black_listed);
     if (GC_total_stack_black_listed != 0) {
         GC_black_list_spacing =
                 HBLKSIZE*(GC_heapsize/GC_total_stack_black_listed);
index 8ca587df37feecc2cf7e3f54ce2c6457979a041c..f5ad843a11dc78818f78305e21836683fe2024e5 100644 (file)
@@ -162,12 +162,11 @@ STATIC void GC_check_blocks(void)
 
     GC_bytes_in_used_blocks = 0;
     GC_apply_to_all_blocks(GC_add_block, (word)0);
-    if (GC_print_stats)
-      GC_log_printf("GC_bytes_in_used_blocks = %lu,"
-                    " bytes_in_free_blocks = %lu, heapsize = %lu\n",
-                    (unsigned long)GC_bytes_in_used_blocks,
-                    (unsigned long)bytes_in_free_blocks,
-                    (unsigned long)GC_heapsize);
+    GC_COND_LOG_PRINTF("GC_bytes_in_used_blocks = %lu,"
+                       " bytes_in_free_blocks = %lu, heapsize = %lu\n",
+                       (unsigned long)GC_bytes_in_used_blocks,
+                       (unsigned long)bytes_in_free_blocks,
+                       (unsigned long)GC_heapsize);
     if (GC_bytes_in_used_blocks + bytes_in_free_blocks != GC_heapsize) {
         GC_err_printf("LOST SOME BLOCKS!!\n");
     }
@@ -200,9 +199,8 @@ void GC_check_dirty(void)
         }
     }
 out:
-    if (GC_print_stats)
-      GC_log_printf("Checked %lu clean and %lu dirty pages\n",
-                    (unsigned long)GC_n_clean, (unsigned long)GC_n_dirty);
+    GC_COND_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_err_printf("Found %d dirty bit errors (%d were faulted)\n",
                       GC_n_dirty_errors, GC_n_faulted_dirty_errors);
index 8fb1d331ea6f867772d6b2a0b223a7df363a6ab5..a63d64e574d42a8dc8b71642f3dd960b3e58a597 100644 (file)
@@ -322,8 +322,7 @@ GC_INNER void GC_push_all_stacks(void)
   }
 
   mach_port_deallocate(my_task, my_thread);
-  if (GC_print_stats == VERBOSE)
-    GC_log_printf("Pushed %d thread stacks\n", nthreads);
+  GC_VERBOSE_LOG_PRINTF("Pushed %d thread stacks\n", nthreads);
   if (!found_me && !GC_in_thread_creation)
     ABORT("Collecting from unknown thread");
   GC_total_stacksize = total_size;
index 708667f8f2f26cbd503219320ad463a275db5a98..8e07de3218113ba157f6db487ea05ee6a5af4592 100644 (file)
@@ -1018,13 +1018,11 @@ 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) {
-            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);
-            }
+          GC_COND_LOG_PRINTF("dynamic_load: status = %d\n", status);
+          if (errno < sys_nerr) {
+            GC_COND_LOG_PRINTF("dynamic_load: %s\n", sys_errlist[errno]);
+          } else {
+            GC_COND_LOG_PRINTF("dynamic_load: err_code = %d\n", errno);
           }
           ABORT("ldr_next_module failed");
         }
@@ -1111,12 +1109,10 @@ GC_INNER void GC_register_dynamic_libraries(void)
           if (errno == EINVAL) {
             break; /* Moved past end of shared library list --> finished */
           } else {
-            if (GC_print_stats) {
-              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);
-              }
+            if (errno < sys_nerr) {
+              GC_COND_LOG_PRINTF("dynamic_load: %s\n", sys_errlist[errno]);
+            } else {
+              GC_COND_LOG_PRINTF("dynamic_load: err_code = %d\n", errno);
             }
             ABORT("shl_get failed");
           }
index 0e20f5510f0d20a2f0a125340f8c679fc623621f..1c5ebafb072dfa0517dbfea271864655d9c0c556 100644 (file)
@@ -150,10 +150,8 @@ GC_API int GC_CALL GC_general_register_disappearing_link(void * * link,
         || GC_dl_entries > ((word)1 << log_dl_table_size)) {
         GC_grow_table((struct hash_chain_entry ***)&GC_dl_head,
                       &log_dl_table_size);
-        if (GC_print_stats) {
-            GC_log_printf("Grew dl table to %u entries\n",
-                      (1 << (unsigned)log_dl_table_size));
-        }
+        GC_COND_LOG_PRINTF("Grew dl table to %u entries\n",
+                           1 << (unsigned)log_dl_table_size);
     }
     index = HASH2(link, log_dl_table_size);
     for (curr_dl = GC_dl_head[index]; curr_dl != 0;
@@ -370,10 +368,8 @@ STATIC void GC_register_finalizer_inner(void * obj,
         || GC_fo_entries > ((word)1 << log_fo_table_size)) {
         GC_grow_table((struct hash_chain_entry ***)&GC_fo_head,
                       &log_fo_table_size);
-        if (GC_print_stats) {
-            GC_log_printf("Grew fo table to %u entries\n",
-                          (1 << (unsigned)log_fo_table_size));
-        }
+        GC_COND_LOG_PRINTF("Grew fo table to %u entries\n",
+                           1 << (unsigned)log_fo_table_size);
     }
     /* in the THREADS case we hold allocation lock.             */
     base = (ptr_t)obj;
index d2dcbb58e7b20291727cf2e29d85bcaa5b4e2677..78950e25f13f230c53a3f9fc6e6bd9e7ec80d24a 100644 (file)
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -88,8 +88,8 @@ GC_API void GC_CALL GC_init_gcj_malloc(int mp_index,
 #   else
       ignore_gcj_info = (0 != GETENV("GC_IGNORE_GCJ_INFO"));
 #   endif
-    if (GC_print_stats && ignore_gcj_info) {
-        GC_log_printf("Gcj-style type information is disabled!\n");
+    if (ignore_gcj_info) {
+      GC_COND_LOG_PRINTF("Gcj-style type information is disabled!\n");
     }
     GC_ASSERT(GC_mark_procs[mp_index] == (GC_mark_proc)0); /* unused */
     GC_mark_procs[mp_index] = (GC_mark_proc)(word)mp;
index 47cc526e905218379a3b71bf3cb1e95e7fc73ea5..d650fe7876de9b0481f1f7c006364ab51289fb36 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -144,8 +144,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
         result = (ptr_t)GET_MEM(bytes_to_get);
         GC_add_to_our_memory(result, bytes_to_get);
         if (result == 0) {
-            if (GC_print_stats)
-                GC_log_printf("Out of memory - trying to allocate less\n");
+            GC_COND_LOG_PRINTF("Out of memory - trying to allocate less\n");
             scratch_free_ptr -= bytes;
             bytes_to_get = bytes;
 #           ifdef USE_MMAP
index c33e01881277b2912a29a0a4925555b2973f8360..6352267db03089b01bb6f8532f854814cc1a9a29 100644 (file)
@@ -2039,6 +2039,10 @@ GC_API_PRIV void GC_log_printf(const char * format, ...)
   }
 #endif
 
+#define GC_COND_LOG_PRINTF if (!GC_print_stats) {} else GC_log_printf
+#define GC_VERBOSE_LOG_PRINTF \
+                if (GC_print_stats != VERBOSE) {} else GC_log_printf
+
 void GC_err_puts(const char *s);
                         /* Write s to stderr, don't buffer, don't add   */
                         /* newlines, don't ...                          */
diff --git a/mark.c b/mark.c
index 433086f40a36892fba036a473a0b7959118443b1..e941abf8feb442af9f604f224ef94f760d0a44e5 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -336,10 +336,8 @@ static void alloc_mark_stack(size_t);
             } else {
                 scan_ptr = GC_push_next_marked_dirty(scan_ptr);
                 if (scan_ptr == 0) {
-                    if (GC_print_stats) {
-                        GC_log_printf("Marked from %lu dirty pages\n",
-                                      (unsigned long)GC_n_rescuing_pages);
-                    }
+                    GC_COND_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;
                     if (GC_mark_state != MS_INVALID) {
@@ -567,10 +565,8 @@ static void alloc_mark_stack(size_t);
 
 handle_ex:
     /* Exception handler starts here for all cases. */
-      if (GC_print_stats) {
-        GC_log_printf(
+      GC_COND_LOG_PRINTF(
           "Caught ACCESS_VIOLATION in marker; memory mapping disappeared\n");
-      }
 
       /* We have bad roots on the stack.  Discard mark stack.   */
       /* Rescan from marked objects.  Redetermine roots.        */
@@ -592,10 +588,8 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp)
 {
     GC_mark_state = MS_INVALID;
     GC_mark_stack_too_small = TRUE;
-    if (GC_print_stats) {
-        GC_log_printf("Mark stack overflow; current size = %lu entries\n",
-                      (unsigned long)GC_mark_stack_size);
-    }
+    GC_COND_LOG_PRINTF("Mark stack overflow; current size = %lu entries\n",
+                       (unsigned long)GC_mark_stack_size);
     return(msp - GC_MARK_STACK_DISCARDS);
 }
 
@@ -946,9 +940,7 @@ STATIC void GC_return_mark_stack(mse * low, mse * high)
     my_start = my_top + 1;
     if ((word)(my_start - GC_mark_stack + stack_size)
                 > (word)GC_mark_stack_size) {
-      if (GC_print_stats) {
-          GC_log_printf("No room to copy back mark stack\n");
-      }
+      GC_COND_LOG_PRINTF("No room to copy back mark stack\n");
       GC_mark_state = MS_INVALID;
       GC_mark_stack_too_small = TRUE;
       /* We drop the local mark stack.  We'll fix things later. */
@@ -1028,8 +1020,7 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id)
     GC_ASSERT((word)AO_load(&GC_first_nonempty) >= (word)GC_mark_stack &&
         (word)AO_load(&GC_first_nonempty) <=
             (word)AO_load((volatile AO_t *)&GC_mark_stack_top) + sizeof(mse));
-    if (GC_print_stats == VERBOSE)
-        GC_log_printf("Starting mark helper %lu\n", (unsigned long)id);
+    GC_VERBOSE_LOG_PRINTF("Starting mark helper %lu\n", (unsigned long)id);
     GC_release_mark_lock();
     for (;;) {
         size_t n_on_stack;
@@ -1091,9 +1082,8 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id)
                     /* both conditions actually held simultaneously.    */
                     GC_helper_count--;
                     if (0 == GC_helper_count) need_to_notify = TRUE;
-                    if (GC_print_stats == VERBOSE)
-                      GC_log_printf("Finished mark helper %lu\n",
-                                    (unsigned long)id);
+                    GC_VERBOSE_LOG_PRINTF("Finished mark helper %lu\n",
+                                          (unsigned long)id);
                     GC_release_mark_lock();
                     if (need_to_notify) GC_notify_all_marker();
                     return;
@@ -1136,9 +1126,8 @@ STATIC void GC_do_parallel_mark(void)
     /* all the time, especially since it's cheap.                       */
     if (GC_help_wanted || GC_active_count != 0 || GC_helper_count != 0)
         ABORT("Tried to start parallel mark in bad state");
-    if (GC_print_stats == VERBOSE)
-        GC_log_printf("Starting marking for mark phase number %lu\n",
-                      (unsigned long)GC_mark_no);
+    GC_VERBOSE_LOG_PRINTF("Starting marking for mark phase number %lu\n",
+                          (unsigned long)GC_mark_no);
     GC_first_nonempty = (AO_t)GC_mark_stack;
     GC_active_count = 0;
     GC_helper_count = 1;
@@ -1152,9 +1141,8 @@ STATIC void GC_do_parallel_mark(void)
     /* Done; clean up.  */
     while (GC_helper_count > 0) GC_wait_marker();
     /* GC_helper_count cannot be incremented while GC_help_wanted == FALSE */
-    if (GC_print_stats == VERBOSE)
-        GC_log_printf("Finished marking for mark phase number %lu\n",
-                      (unsigned long)GC_mark_no);
+    GC_VERBOSE_LOG_PRINTF("Finished marking for mark phase number %lu\n",
+                          (unsigned long)GC_mark_no);
     GC_mark_no++;
     GC_release_mark_lock();
     GC_notify_all_marker();
@@ -1227,15 +1215,11 @@ static void alloc_mark_stack(size_t n)
           GC_mark_stack_size = n;
           /* FIXME: Do we need some way to reset GC_mark_stack_size?    */
           GC_mark_stack_limit = new_stack + n;
-          if (GC_print_stats) {
-              GC_log_printf("Grew mark stack to %lu frames\n",
-                            (unsigned long) GC_mark_stack_size);
-          }
+          GC_COND_LOG_PRINTF("Grew mark stack to %lu frames\n",
+                             (unsigned long)GC_mark_stack_size);
         } else {
-          if (GC_print_stats) {
-              GC_log_printf("Failed to grow mark stack to %lu frames\n",
-                            (unsigned long) n);
-          }
+          GC_COND_LOG_PRINTF("Failed to grow mark stack to %lu frames\n",
+                             (unsigned long)n);
         }
     } else {
         if (new_stack == 0) {
index ed75ef1210a7cdf80435e8e8da7a9bb8c0cbef4c..c935bf3f2cefd7bd03f8b27eca33add10d4b8965 100644 (file)
--- a/obj_map.c
+++ b/obj_map.c
@@ -59,9 +59,9 @@ GC_INNER void GC_register_displacement_inner(size_t offset)
     }
     new_map = (short *)GC_scratch_alloc(MAP_LEN * sizeof(short));
     if (new_map == 0) return(FALSE);
-    if (GC_print_stats)
-        GC_log_printf("Adding block map for size of %u granules (%u bytes)\n",
-                  (unsigned)granules, (unsigned)(GRANULES_TO_BYTES(granules)));
+    GC_COND_LOG_PRINTF(
+                "Adding block map for size of %u granules (%u bytes)\n",
+                (unsigned)granules, (unsigned)GRANULES_TO_BYTES(granules));
     if (granules == 0) {
       for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) {
         new_map[displ] = 1;  /* Nonzero to get us out of marker fast path. */
@@ -74,7 +74,7 @@ GC_INNER void GC_register_displacement_inner(size_t offset)
     GC_obj_map[granules] = new_map;
     return(TRUE);
   }
-#endif
+#endif /* MARK_BIT_PER_GRANULE */
 
 GC_INNER void GC_initialize_offsets(void)
 {
index 69ee1116112ebc03e4a7fc81e6a7e19ba756ba42..45d4a3102e851a9a9c2b7ebe4011b85922686bbf 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -265,8 +265,7 @@ GC_INNER char * GC_get_maps(void)
               return 0;
 #           ifdef THREADS
               if (maps_size > old_maps_size) {
-                if (GC_print_stats)
-                  GC_log_printf(
+                GC_COND_LOG_PRINTF(
                         "Unexpected maps size growth from %lu to %lu\n",
                         (unsigned long)old_maps_size,
                         (unsigned long)maps_size);
@@ -424,9 +423,7 @@ GC_INNER char * GC_get_maps(void)
   {
     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_COND_LOG_PRINTF("Failed to find backing store base from /proc\n");
         return 0;
     }
     return my_start;
@@ -1481,70 +1478,50 @@ void GC_register_data_segments(void)
     }
     myexefile = fopen(path, "rb");
     if (myexefile == 0) {
-        if (GC_print_stats) {
-            GC_err_printf("Could not open executable %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("Could not open executable %s\n", path);
         ABORT("Failed to open executable");
     }
     if (fread((char *)(&hdrdos), 1, sizeof(hdrdos), myexefile)
           < sizeof(hdrdos)) {
-        if (GC_print_stats) {
-            GC_err_printf("Could not read MSDOS header from %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("Could not read MSDOS header from %s\n", path);
         ABORT("Couldn't read MSDOS header");
     }
     if (E_MAGIC(hdrdos) != EMAGIC) {
-        if (GC_print_stats) {
-            GC_err_printf("Executable has wrong DOS magic number: %s\n",
-                          path);
-        }
+        GC_COND_LOG_PRINTF("Executable has wrong DOS magic number: %s\n",
+                           path);
         ABORT("Bad DOS magic number");
     }
     if (fseek(myexefile, E_LFANEW(hdrdos), SEEK_SET) != 0) {
-        if (GC_print_stats) {
-            GC_err_printf("Seek to new header failed in %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("Seek to new header failed in %s\n", path);
         ABORT("Bad DOS magic number");
     }
     if (fread((char *)(&hdr386), 1, sizeof(hdr386), myexefile)
           < sizeof(hdr386)) {
-        if (GC_print_stats) {
-            GC_err_printf("Could not read MSDOS header from %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("Could not read MSDOS header from %s\n", path);
         ABORT("Couldn't read OS/2 header");
     }
     if (E32_MAGIC1(hdr386) != E32MAGIC1 || E32_MAGIC2(hdr386) != E32MAGIC2) {
-        if (GC_print_stats) {
-            GC_err_printf("Executable has wrong OS/2 magic number: %s\n",
-                          path);
-        }
+        GC_COND_LOG_PRINTF("Executable has wrong OS/2 magic number: %s\n",
+                           path);
         ABORT("Bad OS/2 magic number");
     }
     if (E32_BORDER(hdr386) != E32LEBO || E32_WORDER(hdr386) != E32LEWO) {
-        if (GC_print_stats) {
-            GC_err_printf("Executable has wrong byte order: %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("Executable has wrong byte order: %s\n", path);
         ABORT("Bad byte order");
     }
     if (E32_CPU(hdr386) == E32CPU286) {
-        if (GC_print_stats) {
-            GC_err_printf("GC cannot handle 80286 executables: %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("GC cannot handle 80286 executables: %s\n", path);
         ABORT("Intel 80286 executables are unsupported");
     }
     if (fseek(myexefile, E_LFANEW(hdrdos) + E32_OBJTAB(hdr386),
               SEEK_SET) != 0) {
-        if (GC_print_stats) {
-            GC_err_printf("Seek to object table failed: %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("Seek to object table failed: %s\n", path);
         ABORT("Seek to object table failed");
     }
     for (nsegs = E32_OBJCNT(hdr386); nsegs > 0; nsegs--) {
       int flags;
       if (fread((char *)(&seg), 1, sizeof(seg), myexefile) < sizeof(seg)) {
-        if (GC_print_stats) {
-            GC_err_printf("Could not read obj table entry from %s\n", path);
-        }
+        GC_COND_LOG_PRINTF("Could not read obj table entry from %s\n", path);
         ABORT("Couldn't read obj table entry");
       }
       flags = O32_FLAGS(seg);
@@ -1641,13 +1618,13 @@ void GC_register_data_segments(void)
           GetWriteWatch_func = NULL;
         }
       }
-      if (GC_print_stats) {
+#     ifndef SMALL_CONFIG
         if (GetWriteWatch_func == NULL) {
-          GC_log_printf("Did not find a usable GetWriteWatch()\n");
+          GC_COND_LOG_PRINTF("Did not find a usable GetWriteWatch()\n");
         } else {
-          GC_log_printf("Using GetWriteWatch()\n");
+          GC_COND_LOG_PRINTF("Using GetWriteWatch()\n");
         }
-      }
+#     endif
       done = TRUE;
     }
 
@@ -1781,9 +1758,8 @@ void GC_register_data_segments(void)
           return;
         }
     }
-    if (GC_print_stats)
-      GC_log_printf("Found new system malloc AllocationBase at %p\n",
-                    candidate);
+    GC_COND_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;
@@ -2486,10 +2462,9 @@ GC_INNER void GC_remap(ptr_t start, size_t bytes)
 #       else
           if (mprotect(start_addr, len, (PROT_READ | PROT_WRITE)
                             | (GC_pages_executable ? PROT_EXEC : 0)) != 0) {
-            if (GC_print_stats)
-              GC_log_printf(
-                        "mprotect failed at %p (length %lu) with errno %d\n",
-                        start_addr, (unsigned long)len, errno);
+            GC_COND_LOG_PRINTF("mprotect failed at %p (length %lu)"
+                               " with errno %d\n",
+                               start_addr, (unsigned long)len, errno);
             ABORT("mprotect remapping failed");
           }
 #       endif /* !NACL */
@@ -2825,8 +2800,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
   /* Initialize virtual dirty bit implementation.       */
   GC_INNER void GC_dirty_init(void)
   {
-    if (GC_print_stats == VERBOSE)
-      GC_log_printf("Initializing DEFAULT_VDB...\n");
+    GC_VERBOSE_LOG_PRINTF("Initializing DEFAULT_VDB...\n");
     GC_dirty_maintained = TRUE;
   }
 
@@ -2871,8 +2845,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
   /* Initialize virtual dirty bit implementation.       */
   GC_INNER void GC_dirty_init(void)
   {
-    if (GC_print_stats == VERBOSE)
-      GC_log_printf("Initializing MANUAL_VDB...\n");
+    GC_VERBOSE_LOG_PRINTF("Initializing MANUAL_VDB...\n");
     /* GC_dirty_pages and GC_grungy_pages are already cleared.  */
     GC_dirty_maintained = TRUE;
   }
@@ -2992,8 +2965,8 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
                             GC_pages_executable ? PAGE_EXECUTE_READ : \
                                                   PAGE_READONLY, \
                             &protect_junk)) { \
-          if (GC_print_stats) \
-            GC_log_printf("Last error code: 0x%lx\n", (long)GetLastError()); \
+          GC_COND_LOG_PRINTF("Last error code: 0x%lx\n", \
+                             (long)GetLastError()); \
           ABORT("VirtualProtect failed"); \
         }
 #   define UNPROTECT(addr, len) \
@@ -3202,8 +3175,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
 
             if (old_handler == (SIG_HNDLR_PTR)SIG_DFL) {
 #               if !defined(MSWIN32) && !defined(MSWINCE)
-                    if (GC_print_stats)
-                      GC_log_printf("Unexpected segfault at %p\n", addr);
+                    GC_COND_LOG_PRINTF("Unexpected segfault at %p\n", addr);
                     ABORT("Unexpected bus error or segmentation fault");
 #               else
                     return(EXCEPTION_CONTINUE_SEARCH);
@@ -3254,8 +3226,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
 #   if defined(MSWIN32) || defined(MSWINCE)
       return EXCEPTION_CONTINUE_SEARCH;
 #   else
-      if (GC_print_stats)
-        GC_log_printf("Unexpected segfault at %p\n", addr);
+      GC_COND_LOG_PRINTF("Unexpected segfault at %p\n", addr);
       ABORT("Unexpected bus error or segmentation fault");
 #   endif
   }
@@ -3319,8 +3290,7 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
         (void)sigaddset(&act.sa_mask, GC_get_suspend_signal());
 #     endif
 #   endif /* !MSWIN32 */
-    if (GC_print_stats == VERBOSE)
-      GC_log_printf(
+    GC_VERBOSE_LOG_PRINTF(
                 "Initializing mprotect virtual dirty bit implementation\n");
     GC_dirty_maintained = TRUE;
     if (GC_page_size % HBLKSIZE != 0) {
@@ -3345,13 +3315,11 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
         GC_old_segv_handler_used_si = FALSE;
       }
       if (GC_old_segv_handler == (SIG_HNDLR_PTR)SIG_IGN) {
-        if (GC_print_stats)
-          GC_err_printf("Previously ignored segmentation violation!?\n");
+        WARN("Previously ignored segmentation violation!?\n", 0);
         GC_old_segv_handler = (SIG_HNDLR_PTR)SIG_DFL;
       }
       if (GC_old_segv_handler != (SIG_HNDLR_PTR)SIG_DFL) {
-        if (GC_print_stats == VERBOSE)
-          GC_log_printf("Replaced other SIGSEGV handler\n");
+        GC_VERBOSE_LOG_PRINTF("Replaced other SIGSEGV handler\n");
       }
 #   if defined(HPUX) || defined(LINUX) || defined(HURD) \
        || (defined(FREEBSD) && defined(SUNOS5SIGS))
@@ -3368,16 +3336,14 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
 #       endif
       }
       if (GC_old_bus_handler == (SIG_HNDLR_PTR)SIG_IGN) {
-        if (GC_print_stats)
-          GC_err_printf("Previously ignored bus error!?\n");
+        WARN("Previously ignored bus error!?\n", 0);
 #       if !defined(LINUX)
           GC_old_bus_handler = (SIG_HNDLR_PTR)SIG_DFL;
 #       else
           /* GC_old_bus_handler is not used by GC_write_fault_handler.  */
 #       endif
-      } else if (GC_old_bus_handler != (SIG_HNDLR_PTR)SIG_DFL
-                 && GC_print_stats == VERBOSE) {
-          GC_log_printf("Replaced other SIGBUS handler\n");
+      } else if (GC_old_bus_handler != (SIG_HNDLR_PTR)SIG_DFL) {
+          GC_VERBOSE_LOG_PRINTF("Replaced other SIGBUS handler\n");
       }
 #   endif /* HPUX || LINUX || HURD || (FREEBSD && SUNOS5SIGS) */
 #   endif /* ! MS windows */
@@ -3388,8 +3354,7 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
 #   if defined(MSWIN32)
       GC_old_segv_handler = SetUnhandledExceptionFilter(GC_write_fault_handler);
       if (GC_old_segv_handler != NULL) {
-        if (GC_print_stats)
-          GC_log_printf("Replaced other UnhandledExceptionFilter\n");
+        GC_COND_LOG_PRINTF("Replaced other UnhandledExceptionFilter\n");
       } else {
           GC_old_segv_handler = SIG_DFL;
       }
@@ -3673,10 +3638,9 @@ GC_INNER void GC_dirty_init(void)
 
     if (GC_bytes_allocd != 0 || GC_bytes_allocd_before_gc != 0) {
       memset(GC_written_pages, 0xff, sizeof(page_hash_table));
-      if (GC_print_stats == VERBOSE)
-        GC_log_printf("Allocated %lu bytes: all pages may have been written\n",
-                      (unsigned long)(GC_bytes_allocd
-                                      + GC_bytes_allocd_before_gc));
+      GC_VERBOSE_LOG_PRINTF(
+                "Allocated %lu bytes: all pages may have been written\n",
+                (unsigned long)(GC_bytes_allocd + GC_bytes_allocd_before_gc));
     }
 
     (void)snprintf(buf, sizeof(buf), "/proc/%ld", (long)getpid());
@@ -3717,10 +3681,9 @@ GC_INNER void GC_read_dirty(void)
         /* Retry with larger buffer.    */
         word new_size = 2 * GC_proc_buf_size;
         char *new_buf;
-        if (GC_print_stats)
-          GC_err_printf("/proc read failed: GC_proc_buf_size = %lu\n",
-                        (unsigned long)GC_proc_buf_size);
 
+        WARN("/proc read failed: GC_proc_buf_size = %" WARN_PRIdPTR "\n",
+             (signed_word)GC_proc_buf_size);
         new_buf = GC_scratch_alloc(new_size);
         if (new_buf != 0) {
             GC_proc_buf = bufp = new_buf;
@@ -4077,9 +4040,8 @@ STATIC void *GC_mprotect_thread(void *arg)
 #   endif /* THREADS */
 
     if (r != MACH_MSG_SUCCESS) {
-      if (GC_print_stats)
-        GC_log_printf("mach_msg failed with code %d: %s\n", (int)r,
-                      mach_error_string(r));
+      GC_COND_LOG_PRINTF("mach_msg failed with code %d: %s\n", (int)r,
+                         mach_error_string(r));
       ABORT("mach_msg failed");
     }
 
@@ -4162,16 +4124,14 @@ GC_INNER void GC_dirty_init(void)
       /* gracefully (unprotecting all pages and clearing                */
       /* GC_mach_handler_thread).  For now, we just disable incremental */
       /* mode if fork() handling is requested by the client.            */
-      if (GC_print_stats)
-        GC_log_printf(
-            "GC incremental mode disabled since fork() handling requested\n");
+      GC_COND_LOG_PRINTF("GC incremental mode disabled since fork()"
+                         " handling requested\n");
       return;
     }
 # endif
 
-  if (GC_print_stats == VERBOSE)
-    GC_log_printf(
-      "Initializing mach/darwin mprotect virtual dirty bit implementation\n");
+  GC_VERBOSE_LOG_PRINTF("Initializing mach/darwin mprotect"
+                        " virtual dirty bit implementation\n");
 # ifdef BROKEN_EXCEPTION_HANDLING
     WARN("Enabling workarounds for various darwin "
          "exception handling bugs.\n", 0);
@@ -4234,8 +4194,7 @@ GC_INNER void GC_dirty_init(void)
       if (sigaction(SIGBUS, &sa, &oldsa) < 0)
         ABORT("sigaction failed");
       if ((SIG_HNDLR_PTR)oldsa.sa_handler != SIG_DFL) {
-        if (GC_print_stats == VERBOSE)
-          GC_err_printf("Replaced other SIGBUS handler\n");
+        GC_VERBOSE_LOG_PRINTF("Replaced other SIGBUS handler\n");
       }
     }
 # endif /* BROKEN_EXCEPTION_HANDLING  */
index 3f288b7c9baf41476dadbcc90a30ad53b60bb1c1..cbae189caf4c28e83132412ada360d6150e52e18 100644 (file)
@@ -407,9 +407,7 @@ GC_INNER void GC_push_all_stacks(void)
 #       endif
       }
     }
-    if (GC_print_stats == VERBOSE) {
-      GC_log_printf("Pushed %d thread stacks\n", (int)nthreads);
-    }
+    GC_VERBOSE_LOG_PRINTF("Pushed %d thread stacks\n", (int)nthreads);
     if (!found_me && !GC_in_thread_creation)
       ABORT("Collecting from unknown thread");
     GC_total_stacksize = total_size;
@@ -601,9 +599,7 @@ GC_INNER void GC_stop_world(void)
         if (wait_usecs > RETRY_INTERVAL) {
           int newly_sent = GC_suspend_all();
 
-          if (GC_print_stats) {
-            GC_log_printf("Resent %d signals after timeout\n", newly_sent);
-          }
+          GC_COND_LOG_PRINTF("Resent %d signals after timeout\n", newly_sent);
           sem_getvalue(&GC_suspend_ack_sem, &ack_count);
           if (newly_sent < n_live_threads - ack_count) {
             WARN("Lost some threads during GC_stop_world?!\n",0);
@@ -830,8 +826,7 @@ GC_INNER void GC_start_world(void)
       for (i = 0; i < n_live_threads; i++) {
         while (0 != (code = sem_wait(&GC_restart_ack_sem))) {
           if (errno != EINTR) {
-            if (GC_print_stats)
-              GC_log_printf("sem_wait() returned %d\n", code);
+            GC_COND_LOG_PRINTF("sem_wait() returned %d\n", code);
             ABORT("sem_wait() for restart handler failed");
           }
         }
@@ -911,8 +906,8 @@ GC_INNER void GC_stop_init(void)
     if (0 != GETENV("GC_NO_RETRY_SIGNALS")) {
         GC_retry_signals = FALSE;
     }
-    if (GC_print_stats && GC_retry_signals) {
-      GC_log_printf("Will retry suspend signal if necessary\n");
+    if (GC_retry_signals) {
+      GC_COND_LOG_PRINTF("Will retry suspend signal if necessary\n");
     }
 # endif /* !GC_OPENBSD_THREADS && !NACL */
 }
index 16dd7b3c2b82207962fae719e4a615189739654f..a9baa57e2123a529c9e402f46b344a6ced853524 100644 (file)
@@ -430,9 +430,7 @@ static void start_mark_threads(void)
         break;
       }
     }
-    if (GC_print_stats) {
-      GC_log_printf("Started %d mark helper threads\n", GC_markers_m1);
-    }
+    GC_COND_LOG_PRINTF("Started %d mark helper threads\n", GC_markers_m1);
     pthread_attr_destroy(&attr);
 }
 
@@ -1084,17 +1082,14 @@ GC_INNER void GC_thr_init(void)
 #  endif
   }
 # ifdef PARALLEL_MARK
-    if (GC_print_stats) {
-      GC_log_printf(
-                "Number of processors = %d, number of marker threads = %d\n",
-                GC_nprocs, GC_markers_m1 + 1);
-    }
+    GC_COND_LOG_PRINTF("Number of processors = %d,"
+                       " number of marker threads = %d\n",
+                       GC_nprocs, GC_markers_m1 + 1);
     if (GC_markers_m1 <= 0) {
       /* Disable parallel marking.      */
       GC_parallel = FALSE;
-      if (GC_print_stats) {
-        GC_log_printf("Single marker thread, turning off parallel marking\n");
-      }
+      GC_COND_LOG_PRINTF(
+                "Single marker thread, turning off parallel marking\n");
     } else {
       /* Disable true incremental collection, but generational is OK.   */
       GC_time_limit = GC_TIME_UNLIMITED;
@@ -1104,8 +1099,7 @@ GC_INNER void GC_thr_init(void)
       start_mark_threads();
     }
 # else
-    if (GC_print_stats)
-      GC_log_printf("Number of processors = %d\n", GC_nprocs);
+    GC_COND_LOG_PRINTF("Number of processors = %d\n", GC_nprocs);
 # endif
 }
 
index 44f01b0068fa9925b6ad5e38756c136a3512ae69..66a983ca3ee8873e5dc51e3c2b7f26e9544a7544 100644 (file)
@@ -458,9 +458,8 @@ STATIC GC_thread GC_register_my_thread_inner(const struct GC_stack_base *sb,
                         (HANDLE*)&(me -> handle),
                         0 /* dwDesiredAccess */, FALSE /* bInheritHandle */,
                         DUPLICATE_SAME_ACCESS)) {
-        if (GC_print_stats)
-          GC_log_printf("DuplicateHandle failed with error code: %d\n",
-                        (int)GetLastError());
+        GC_COND_LOG_PRINTF("DuplicateHandle failed with error code: %d\n",
+                           (int)GetLastError());
         ABORT("DuplicateHandle failed");
     }
 # endif
@@ -1513,10 +1512,9 @@ GC_INNER void GC_push_all_stacks(void)
     }
   }
 # ifndef SMALL_CONFIG
-    if (GC_print_stats == VERBOSE) {
-      GC_log_printf("Pushed %d thread stacks%s\n", nthreads,
-            GC_win32_dll_threads ? " based on DllMain thread tracking" : "");
-    }
+    GC_VERBOSE_LOG_PRINTF("Pushed %d thread stacks%s\n", nthreads,
+                          GC_win32_dll_threads ?
+                                " based on DllMain thread tracking" : "");
 # endif
   if (!found_me && !GC_in_thread_creation)
     ABORT("Collecting from unknown thread");
@@ -2489,9 +2487,7 @@ GC_INNER void GC_thr_init(void)
 # ifdef PARALLEL_MARK
     /* If we are using a parallel marker, actually start helper threads. */
     if (GC_parallel) start_mark_threads();
-    if (GC_print_stats) {
-      GC_log_printf("Started %d mark helper threads\n", GC_markers_m1);
-    }
+    GC_COND_LOG_PRINTF("Started %d mark helper threads\n", GC_markers_m1);
 # endif
 }