void mi_start (void) { const char *type_string; const char *interval_string; char *end; int success = 1; interval_string = getenv ("_MEMPROF_INTERVAL"); if (!interval_string) interval_string = "10000"; profile_interval = strtol (interval_string, &end, 10); if (*interval_string == '\0' || *end != '\0' || profile_interval <= 0) { mi_debug ("Invalid interval %s\n", interval_string); profile_interval = 10000; } type_string = getenv ("_MEMPROF_SPEED_TYPE"); if (!type_string) type_string = "cycles"; if (strcmp (type_string, "time") == 0) { if (start_rtc_timer ()) profile_type = SPEED_PROF_RTC; else if (start_itimer_timer (ITIMER_REAL)) profile_type = SPEED_PROF_ITIMER; else success = 0; } else if (strcmp (type_string, "cycles") == 0) { if (mi_perfctr_start (profile_interval)) profile_type = SPEED_PROF_PERFCTR; else if (start_itimer_timer (ITIMER_PROF)) profile_type = SPEED_PROF_ITIMER; else success = 0; } else { mi_debug ("Unknown value for _MEMPROF_SPEED_TYPE: %s\n"); _exit (1); } if (!success) { mi_debug ("Couldn't start timer\n"); _exit (1); } }
static void abort_unitialized (const char *call) { mi_debug ("MemProf: unexpected library call during initialization: %s\n", call); abort(); }