gettime: improve gettimeofday() offload support
[fio.git] / gettime.h
... / ...
CommitLineData
1#ifndef FIO_GETTIME_H
2#define FIO_GETTIME_H
3
4#include "arch/arch.h"
5
6/*
7 * Clock sources
8 */
9enum fio_cs {
10 CS_GTOD = 1,
11 CS_CGETTIME,
12 CS_CPUCLOCK,
13 CS_INVAL,
14};
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);
20extern int fio_monotonic_clocktest(void);
21extern void fio_local_clock_init(int);
22
23extern struct timeval *fio_tv;
24
25static inline int fio_gettime_offload(struct timeval *tv)
26{
27 size_t last_sec;
28
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
41#endif