Merge branch 'msys2' of https://github.com/sitsofe/fio into master
[fio.git] / gettime.h
CommitLineData
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 */
12enum fio_cs {
13 CS_GTOD = 1,
14 CS_CGETTIME,
15 CS_CPUCLOCK,
01423eae 16 CS_INVAL,
a7346816
JA
17};
18
8b6a404c 19extern void fio_gettime(struct timespec *, void *);
a7346816
JA
20extern void fio_gtod_init(void);
21extern void fio_clock_init(void);
22extern int fio_start_gtod_thread(void);
aad918e4 23extern int fio_monotonic_clocktest(int debug);
a0eba820 24extern void fio_local_clock_init(void);
a7346816 25
817a1d83
BVA
26extern struct fio_ts {
27 struct seqlock seqlock;
28 struct timespec ts;
29} *fio_ts;
39ab7da2 30
8b6a404c 31static inline int fio_gettime_offload(struct timespec *ts)
27325ed5 32{
817a1d83 33 unsigned int seq;
27325ed5 34
8b6a404c 35 if (!fio_ts)
27325ed5
JA
36 return 0;
37
38 do {
817a1d83
BVA
39 seq = read_seqlock_begin(&fio_ts->seqlock);
40 *ts = fio_ts->ts;
41 } while (read_seqlock_retry(&fio_ts->seqlock, seq));
27325ed5
JA
42
43 return 1;
44}
45
79c896a1
JA
46extern void fio_gtod_set_cpu(unsigned int cpu);
47
a7346816 48#endif