Merge branch 'dev' of https://github.com/smartxworks/fio
[fio.git] / gettime.h
... / ...
CommitLineData
1#ifndef FIO_GETTIME_H
2#define FIO_GETTIME_H
3
4#include <sys/time.h>
5
6#include "arch/arch.h"
7
8/*
9 * Clock sources
10 */
11enum fio_cs {
12 CS_GTOD = 1,
13 CS_CGETTIME,
14 CS_CPUCLOCK,
15 CS_INVAL,
16};
17
18extern void fio_gettime(struct timespec *, void *);
19extern void fio_gtod_init(void);
20extern void fio_clock_init(void);
21extern int fio_start_gtod_thread(void);
22extern int fio_monotonic_clocktest(int debug);
23extern void fio_local_clock_init(void);
24
25extern struct timespec *fio_ts;
26
27static inline int fio_gettime_offload(struct timespec *ts)
28{
29 time_t last_sec;
30
31 if (!fio_ts)
32 return 0;
33
34 do {
35 read_barrier();
36 last_sec = ts->tv_sec = fio_ts->tv_sec;
37 ts->tv_nsec = fio_ts->tv_nsec;
38 } while (fio_ts->tv_sec != last_sec);
39
40 return 1;
41}
42
43extern void fio_gtod_set_cpu(unsigned int cpu);
44
45#endif