# ifndef SMALL_CONFIG
if (GC_print_stats) {
GET_TIME(start_time);
- GC_log_printf("Initiating full world-stop collection!\n");
+ GC_stats_log_printf("Initiating full world-stop collection!\n");
}
# endif
GC_promote_black_lists();
# ifndef SMALL_CONFIG
if (GC_print_stats) {
GET_TIME(current_time);
- GC_log_printf("Complete collection took %lu msecs\n",
- MS_TIME_DIFF(current_time,start_time));
+ GC_stats_log_printf("Complete collection took %lu msecs\n",
+ MS_TIME_DIFF(current_time,start_time));
}
# endif
return(TRUE);
world_stopped_total_divisor = ++divisor;
GC_ASSERT(divisor != 0);
- GC_log_printf(
+ GC_stats_log_printf(
"World-stopped marking took %lu msecs (%u in average)\n",
time_diff, total_time / divisor);
}
GC_print_finalization_stats();
# endif
- 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));
+ GC_stats_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));
}
# endif
}
struct finalizable_object *fo = GC_finalize_now;
unsigned long ready = 0;
- GC_log_printf(
+ GC_stats_log_printf(
"%lu finalization table entries; %lu disappearing links alive\n",
(unsigned long)GC_fo_entries, (unsigned long)GC_dl_entries);
for (; 0 != fo; fo = fo_next(fo)) ++ready;
- GC_log_printf("%lu objects are eligible for immediate finalization; "
- "%ld links cleared\n",
- ready, (long)GC_old_dl_entries - (long)GC_dl_entries);
+ GC_stats_log_printf("%lu objects are eligible for immediate finalization;"
+ " %ld links cleared\n",
+ ready, (long)GC_old_dl_entries - (long)GC_dl_entries);
}
#endif /* !SMALL_CONFIG */
/* GC_print_stats should be visible to extra/MacOS.c. */
extern int GC_print_stats; /* Nonzero generates basic GC log. */
/* VERBOSE generates add'l messages. */
-#else
+#else /* SMALL_CONFIG */
# define GC_print_stats 0
/* Will this remove the message character strings from the executable? */
/* With a particular level of optimizations, it should... */
/* Logging and diagnostic output: */
/* GC_printf is used typically on client explicit print requests. */
-/* It's recommended to put "\n" at 'format' string end (for atomicity). */
+/* For all GC_X_printf routines, it is recommended to put "\n" at */
+/* 'format' string end (for output atomicity). */
GC_API_PRIV void GC_printf(const char * format, ...)
GC_ATTR_FORMAT_PRINTF(1, 2);
/* A version of printf that doesn't allocate, */
GC_API_PRIV void GC_err_printf(const char * format, ...)
GC_ATTR_FORMAT_PRINTF(1, 2);
+/* Basic logging routine. Typically, GC_log_printf is called directly */
+/* only inside various DEBUG_x blocks. */
#if defined(__cplusplus) && defined(SYMBIAN)
extern "C" {
#endif
-/* Logging routine. Typically called only if GC_print_stats. It is */
-/* recommended to put "\n" at 'format' string end (for atomicity). */
GC_API_PRIV void GC_log_printf(const char * format, ...)
GC_ATTR_FORMAT_PRINTF(1, 2);
#if defined(__cplusplus) && defined(SYMBIAN)
}
#endif
-#define GC_COND_LOG_PRINTF if (!GC_print_stats) {} else GC_log_printf
+ /* GC_stats_log_printf should be called only if GC_print_stats. */
+# define GC_stats_log_printf GC_log_printf
+ /* GC_verbose_log_printf is called only if GC_print_stats is VERBOSE. */
+# define GC_verbose_log_printf GC_log_printf
+
+/* Convenient macros for GC_stats/verbose_log_printf invocation. */
+#define GC_COND_LOG_PRINTF if (!GC_print_stats) {} else GC_stats_log_printf
#define GC_VERBOSE_LOG_PRINTF \
- if (GC_print_stats != VERBOSE) {} else GC_log_printf
+ if (GC_print_stats != VERBOSE) {} else GC_verbose_log_printf
void GC_err_puts(const char *s);
/* Write s to stderr, don't buffer, don't add */
GC_err_puts(buf);
}
-void GC_log_printf(const char *format, ...)
-{
+#ifndef GC_ANDROID_LOG
+
+ void GC_log_printf(const char *format, ...)
+ {
char buf[BUFSZ + 1];
GC_PRINTF_FILLBUF(buf, format);
-# ifdef GC_ANDROID_LOG
- __android_log_write(ANDROID_LOG_INFO, GC_ANDROID_LOG_TAG, buf);
- if (GC_log == GC_DEFAULT_STDERR_FD)
- return; /* skip duplicate write to stderr */
-# endif
if (WRITE(GC_log, buf, strlen(buf)) < 0)
ABORT("write to GC log failed");
-}
+ }
+
+#else
+
+# define GC_LOG_PRINTF_IMPL(loglevel, fileLogCond, format) \
+ { \
+ char buf[BUFSZ + 1]; \
+ GC_PRINTF_FILLBUF(buf, format); \
+ __android_log_write(loglevel, GC_ANDROID_LOG_TAG, buf); \
+ if (GC_log != GC_DEFAULT_STDERR_FD && (fileLogCond) \
+ && WRITE(GC_log, buf, strlen(buf)) < 0) \
+ ABORT("write to GC log file failed"); \
+ }
+
+ void GC_log_printf(const char *format, ...)
+ {
+ GC_LOG_PRINTF_IMPL(ANDROID_LOG_INFO, TRUE, format);
+ }
+
+#endif /* GC_ANDROID_LOG */
void GC_err_puts(const char *s)
{
# ifndef SMALL_CONFIG
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));
+ GC_verbose_log_printf("Disposing of reclaim lists took %lu msecs\n",
+ MS_TIME_DIFF(done_time,start_time));
}
# endif
return(TRUE);