Merge branch 'clarify-io-errors' of https://github.com/Hi-Angel/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#include "lib/seqlock.h"
8
9/*
10 * Clock sources
11 */
12enum fio_cs {
13 CS_GTOD = 1,
14 CS_CGETTIME,
15 CS_CPUCLOCK,
16 CS_INVAL,
17};
18
19extern int fio_get_mono_time(struct timespec *);
20extern void fio_gettime(struct timespec *, void *);
21extern void fio_gtod_init(void);
22extern void fio_clock_init(void);
23extern int fio_start_gtod_thread(void);
24extern int fio_monotonic_clocktest(int debug);
25extern void fio_local_clock_init(void);
26
27extern struct fio_ts {
28 struct seqlock seqlock;
29 struct timespec ts;
30} *fio_ts;
31
32static 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
47extern void fio_gtod_set_cpu(unsigned int cpu);
48
49#endif