X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=gettime.c;h=d78cf6d0ba9281a36ec286c5e6e87843fb49e360;hp=48aeb075b65e1c9182e41a3c1240603ebf968691;hb=5ec10eaad3b09875b91e19a20bbdfa06f2117562;hpb=02bcaa8c31feb93c61b701d143a7eea3efd2124d diff --git a/gettime.c b/gettime.c index 48aeb075..d78cf6d0 100644 --- a/gettime.c +++ b/gettime.c @@ -1,15 +1,15 @@ /* - * Memory helpers + * Clock functions */ + #include #include #include "fio.h" -#include "os.h" #include "hash.h" -static int clock_gettime_works = 1; +static int clock_gettime_works; #ifdef FIO_DEBUG_TIME @@ -80,7 +80,8 @@ static void fio_exit fio_dump_gtod(void) list_for_each(entry, &hash[i]) { log = list_entry(entry, struct gtod_log, list); - printf("function %p, calls %lu\n", log->caller, log->calls); + printf("function %p, calls %lu\n", log->caller, + log->calls); total_calls += log->calls; } } @@ -100,36 +101,30 @@ static void fio_init gtod_init(void) #endif /* FIO_DEBUG_TIME */ +#ifdef FIO_DEBUG_TIME void fio_gettime(struct timeval *tp, void *caller) +#else +void fio_gettime(struct timeval *tp, void fio_unused *caller) +#endif { #ifdef FIO_DEBUG_TIME if (!caller) caller = __builtin_return_address(0); gtod_log_caller(caller); -#else - caller = NULL; #endif -repeat: - if (!clock_gettime_works) + if (!clock_gettime_works) { +gtod: gettimeofday(tp, NULL); - else { + } else { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { clock_gettime_works = 0; - goto repeat; + goto gtod; } tp->tv_sec = ts.tv_sec; tp->tv_usec = ts.tv_nsec / 1000; } } - -static void fio_init check_clock(void) -{ - struct timespec ts; - - if (clock_getres(CLOCK_MONOTONIC, &ts) < 0) - clock_gettime_works = 0; -}