| 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 | */ |
| 11 | enum fio_cs { |
| 12 | CS_GTOD = 1, |
| 13 | CS_CGETTIME, |
| 14 | CS_CPUCLOCK, |
| 15 | CS_INVAL, |
| 16 | }; |
| 17 | |
| 18 | extern void fio_gettime(struct timespec *, void *); |
| 19 | extern void fio_gtod_init(void); |
| 20 | extern void fio_clock_init(void); |
| 21 | extern int fio_start_gtod_thread(void); |
| 22 | extern int fio_monotonic_clocktest(int debug); |
| 23 | extern void fio_local_clock_init(void); |
| 24 | |
| 25 | extern struct timespec *fio_ts; |
| 26 | |
| 27 | static 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 | |
| 43 | extern void fio_gtod_set_cpu(unsigned int cpu); |
| 44 | |
| 45 | #endif |