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