0001
0002 #ifndef ASM_VDSO_GETTIMEOFDAY_H
0003 #define ASM_VDSO_GETTIMEOFDAY_H
0004
0005 #define VDSO_HAS_TIME 1
0006
0007 #define VDSO_HAS_CLOCK_GETRES 1
0008
0009 #include <asm/syscall.h>
0010 #include <asm/timex.h>
0011 #include <asm/unistd.h>
0012 #include <linux/compiler.h>
0013
0014 #define vdso_calc_delta __arch_vdso_calc_delta
0015 static __always_inline u64 __arch_vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
0016 {
0017 return (cycles - last) * mult;
0018 }
0019
0020 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
0021 {
0022 return _vdso_data;
0023 }
0024
0025 static inline u64 __arch_get_hw_counter(s32 clock_mode, const struct vdso_data *vd)
0026 {
0027 u64 adj, now;
0028
0029 now = get_tod_clock();
0030 adj = vd->arch_data.tod_steering_end - now;
0031 if (unlikely((s64) adj > 0))
0032 now += (vd->arch_data.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
0033 return now;
0034 }
0035
0036 static __always_inline
0037 long clock_gettime_fallback(clockid_t clkid, struct __kernel_timespec *ts)
0038 {
0039 return syscall2(__NR_clock_gettime, (long)clkid, (long)ts);
0040 }
0041
0042 static __always_inline
0043 long gettimeofday_fallback(register struct __kernel_old_timeval *tv,
0044 register struct timezone *tz)
0045 {
0046 return syscall2(__NR_gettimeofday, (long)tv, (long)tz);
0047 }
0048
0049 static __always_inline
0050 long clock_getres_fallback(clockid_t clkid, struct __kernel_timespec *ts)
0051 {
0052 return syscall2(__NR_clock_getres, (long)clkid, (long)ts);
0053 }
0054
0055 #ifdef CONFIG_TIME_NS
0056 static __always_inline
0057 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
0058 {
0059 return _timens_data;
0060 }
0061 #endif
0062
0063 #endif