2008-10-23 12:26:29 +07:00
|
|
|
#ifndef _ASM_X86_VGTOD_H
|
|
|
|
#define _ASM_X86_VGTOD_H
|
2007-07-21 22:10:01 +07:00
|
|
|
|
2014-03-18 05:22:10 +07:00
|
|
|
#include <linux/compiler.h>
|
2007-07-21 22:10:01 +07:00
|
|
|
#include <linux/clocksource.h>
|
|
|
|
|
2014-03-18 05:22:10 +07:00
|
|
|
#ifdef BUILD_VDSO32_64
|
|
|
|
typedef u64 gtod_long_t;
|
|
|
|
#else
|
|
|
|
typedef unsigned long gtod_long_t;
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* vsyscall_gtod_data will be accessed by 32 and 64 bit code at the same time
|
|
|
|
* so be carefull by modifying this structure.
|
|
|
|
*/
|
2007-07-21 22:10:01 +07:00
|
|
|
struct vsyscall_gtod_data {
|
2014-03-18 05:22:10 +07:00
|
|
|
unsigned seq;
|
2007-07-21 22:10:01 +07:00
|
|
|
|
2014-03-18 05:22:10 +07:00
|
|
|
int vclock_mode;
|
|
|
|
cycle_t cycle_last;
|
|
|
|
cycle_t mask;
|
|
|
|
u32 mult;
|
|
|
|
u32 shift;
|
2012-03-23 11:15:51 +07:00
|
|
|
|
|
|
|
/* open coded 'struct timespec' */
|
2012-09-05 03:14:46 +07:00
|
|
|
u64 wall_time_snsec;
|
2014-03-18 05:22:10 +07:00
|
|
|
gtod_long_t wall_time_sec;
|
|
|
|
gtod_long_t monotonic_time_sec;
|
2012-09-05 03:14:46 +07:00
|
|
|
u64 monotonic_time_snsec;
|
2014-03-18 05:22:10 +07:00
|
|
|
gtod_long_t wall_time_coarse_sec;
|
|
|
|
gtod_long_t wall_time_coarse_nsec;
|
|
|
|
gtod_long_t monotonic_time_coarse_sec;
|
|
|
|
gtod_long_t monotonic_time_coarse_nsec;
|
2012-03-23 11:15:51 +07:00
|
|
|
|
2014-03-18 05:22:10 +07:00
|
|
|
int tz_minuteswest;
|
|
|
|
int tz_dsttime;
|
2007-07-21 22:10:01 +07:00
|
|
|
};
|
|
|
|
extern struct vsyscall_gtod_data vsyscall_gtod_data;
|
|
|
|
|
2014-03-18 05:22:10 +07:00
|
|
|
static inline unsigned gtod_read_begin(const struct vsyscall_gtod_data *s)
|
|
|
|
{
|
|
|
|
unsigned ret;
|
|
|
|
|
|
|
|
repeat:
|
|
|
|
ret = ACCESS_ONCE(s->seq);
|
|
|
|
if (unlikely(ret & 1)) {
|
|
|
|
cpu_relax();
|
|
|
|
goto repeat;
|
|
|
|
}
|
|
|
|
smp_rmb();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int gtod_read_retry(const struct vsyscall_gtod_data *s,
|
|
|
|
unsigned start)
|
|
|
|
{
|
|
|
|
smp_rmb();
|
|
|
|
return unlikely(s->seq != start);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gtod_write_begin(struct vsyscall_gtod_data *s)
|
|
|
|
{
|
|
|
|
++s->seq;
|
|
|
|
smp_wmb();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gtod_write_end(struct vsyscall_gtod_data *s)
|
|
|
|
{
|
|
|
|
smp_wmb();
|
|
|
|
++s->seq;
|
|
|
|
}
|
|
|
|
|
2008-10-23 12:26:29 +07:00
|
|
|
#endif /* _ASM_X86_VGTOD_H */
|