Commit | Line | Data |
---|---|---|
a7346816 JA |
1 | #ifndef FIO_GETTIME_H |
2 | #define FIO_GETTIME_H | |
3 | ||
3d2d14bc SW |
4 | #include <sys/time.h> |
5 | ||
27325ed5 | 6 | #include "arch/arch.h" |
817a1d83 | 7 | #include "lib/seqlock.h" |
27325ed5 | 8 | |
a7346816 JA |
9 | /* |
10 | * Clock sources | |
11 | */ | |
12 | enum fio_cs { | |
13 | CS_GTOD = 1, | |
14 | CS_CGETTIME, | |
15 | CS_CPUCLOCK, | |
01423eae | 16 | CS_INVAL, |
a7346816 JA |
17 | }; |
18 | ||
69212fc4 | 19 | extern int fio_get_mono_time(struct timespec *); |
8b6a404c | 20 | extern void fio_gettime(struct timespec *, void *); |
a7346816 JA |
21 | extern void fio_gtod_init(void); |
22 | extern void fio_clock_init(void); | |
23 | extern int fio_start_gtod_thread(void); | |
aad918e4 | 24 | extern int fio_monotonic_clocktest(int debug); |
a0eba820 | 25 | extern void fio_local_clock_init(void); |
a7346816 | 26 | |
817a1d83 BVA |
27 | extern struct fio_ts { |
28 | struct seqlock seqlock; | |
29 | struct timespec ts; | |
30 | } *fio_ts; | |
39ab7da2 | 31 | |
8b6a404c | 32 | static inline int fio_gettime_offload(struct timespec *ts) |
27325ed5 | 33 | { |
817a1d83 | 34 | unsigned int seq; |
27325ed5 | 35 | |
8b6a404c | 36 | if (!fio_ts) |
27325ed5 JA |
37 | return 0; |
38 | ||
39 | do { | |
817a1d83 BVA |
40 | seq = read_seqlock_begin(&fio_ts->seqlock); |
41 | *ts = fio_ts->ts; | |
42 | } while (read_seqlock_retry(&fio_ts->seqlock, seq)); | |
27325ed5 JA |
43 | |
44 | return 1; | |
45 | } | |
46 | ||
79c896a1 JA |
47 | extern void fio_gtod_set_cpu(unsigned int cpu); |
48 | ||
a7346816 | 49 | #endif |