blob: 86d55bd9d6298b69de406a3d7209184ba786db0a [file] [log] [blame]
Jens Axboea7346812012-02-09 15:02:39 +01001#ifndef FIO_GETTIME_H
2#define FIO_GETTIME_H
3
Jens Axboe04194192014-12-16 19:43:55 -07004#include "arch/arch.h"
5
Jens Axboea7346812012-02-09 15:02:39 +01006/*
7 * Clock sources
8 */
9enum fio_cs {
10 CS_GTOD = 1,
11 CS_CGETTIME,
12 CS_CPUCLOCK,
Jens Axboe01423ea2012-12-14 20:37:06 +010013 CS_INVAL,
Jens Axboea7346812012-02-09 15:02:39 +010014};
15
16extern void fio_gettime(struct timeval *, void *);
17extern void fio_gtod_init(void);
18extern void fio_clock_init(void);
19extern int fio_start_gtod_thread(void);
Jens Axboe10564132014-12-23 10:41:34 -070020extern int fio_monotonic_clocktest(int debug);
Jens Axboe5d879392012-12-18 09:12:27 +010021extern void fio_local_clock_init(int);
Jens Axboea7346812012-02-09 15:02:39 +010022
Jens Axboe39ab7da2012-11-06 22:10:43 +010023extern struct timeval *fio_tv;
24
Jens Axboe04194192014-12-16 19:43:55 -070025static inline int fio_gettime_offload(struct timeval *tv)
26{
Castor Fuaedc0b62015-02-13 06:46:04 -080027 time_t last_sec;
Jens Axboe04194192014-12-16 19:43:55 -070028
29 if (!fio_tv)
30 return 0;
31
32 do {
33 read_barrier();
34 last_sec = tv->tv_sec = fio_tv->tv_sec;
35 tv->tv_usec = fio_tv->tv_usec;
36 } while (fio_tv->tv_sec != last_sec);
37
38 return 1;
39}
40
Jens Axboe80ac0202014-12-16 20:38:53 -070041extern void fio_gtod_set_cpu(unsigned int cpu);
42
Jens Axboea7346812012-02-09 15:02:39 +010043#endif