Added gc_log()

This commit is contained in:
Justin Ethier 2018-07-05 13:24:00 -04:00
parent 17c454f2ec
commit 053ef0ada5

19
gc.c
View file

@ -184,14 +184,24 @@ void print_allocated_obj_counts()
} }
} }
void print_current_time() void print_current_time(FILE *stream)
{ {
time_t rawtime; time_t rawtime;
struct tm * timeinfo; struct tm * timeinfo;
time ( &rawtime ); time ( &rawtime );
timeinfo = localtime ( &rawtime ); timeinfo = localtime ( &rawtime );
fprintf(stderr, "%s", asctime (timeinfo)); fprintf(stream, "%s", asctime (timeinfo));
}
void gc_log(FILE *stream, const char *format, ...)
{
va_list vargs;
va_start(vargs, format);
print_current_time(stream);
vfprintf(stream, format, vargs);
fprintf(stream, "\n");
va_end(vargs);
} }
#endif #endif
@ -2425,10 +2435,9 @@ void gc_collector()
//int old_clear, old_mark; //int old_clear, old_mark;
#if GC_DEBUG_TRACE #if GC_DEBUG_TRACE
print_allocated_obj_counts(); print_allocated_obj_counts();
print_current_time(); gc_log(stderr, " - Starting gc_collector");
fprintf(stderr, " - Starting gc_collector\n");
#endif #endif
fprintf(stderr, " - Starting gc_collector\n"); // TODO: DEBUGGING!!! //fprintf(stderr, " - Starting gc_collector\n"); // TODO: DEBUGGING!!!
//clear : //clear :
ck_pr_cas_int(&gc_stage, STAGE_RESTING, STAGE_CLEAR_OR_MARKING); ck_pr_cas_int(&gc_stage, STAGE_RESTING, STAGE_CLEAR_OR_MARKING);
// exchange values of markColor and clearColor // exchange values of markColor and clearColor