X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=gettime.c;h=15356b1b9227c2b92f7676aae124664647f0e5d1;hp=0ad8d9244f3a18217631dae029137393207e28db;hb=5bd9c78ce361e3a924013299c53fd823fba05818;hpb=09a324028d68c485a8c4b33257b262123c27394f diff --git a/gettime.c b/gettime.c index 0ad8d924..15356b1b 100644 --- a/gettime.c +++ b/gettime.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "fio.h" #include "smalloc.h" @@ -139,7 +140,11 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller) case CS_CGETTIME: { struct timespec ts; +#ifdef FIO_HAVE_CLOCK_MONOTONIC + if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { +#else if (clock_gettime(CLOCK_REALTIME, &ts) < 0) { +#endif log_err("fio: clock_gettime fails\n"); assert(0); } @@ -230,7 +235,7 @@ static void calibrate_cpu_clock(void) for (i = 0; i < 10; i++) { double this = cycles[i]; - if ((max(this, mean) - min(this, mean)) > S) + if ((fmax(this, mean) - fmin(this, mean)) > S) continue; samples++; avg += this;