gettimeofday.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ASM_VDSO_GETTIMEOFDAY_H
  3. #define ASM_VDSO_GETTIMEOFDAY_H
  4. #define VDSO_HAS_TIME 1
  5. #define VDSO_HAS_CLOCK_GETRES 1
  6. #include <asm/syscall.h>
  7. #include <asm/timex.h>
  8. #include <asm/unistd.h>
  9. #include <linux/compiler.h>
  10. #define vdso_calc_delta __arch_vdso_calc_delta
  11. static __always_inline u64 __arch_vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
  12. {
  13. return (cycles - last) * mult;
  14. }
  15. static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
  16. {
  17. return _vdso_data;
  18. }
  19. static inline u64 __arch_get_hw_counter(s32 clock_mode, const struct vdso_data *vd)
  20. {
  21. u64 adj, now;
  22. now = get_tod_clock();
  23. adj = vd->arch_data.tod_steering_end - now;
  24. if (unlikely((s64) adj > 0))
  25. now += (vd->arch_data.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
  26. return now;
  27. }
  28. static __always_inline
  29. long clock_gettime_fallback(clockid_t clkid, struct __kernel_timespec *ts)
  30. {
  31. return syscall2(__NR_clock_gettime, (long)clkid, (long)ts);
  32. }
  33. static __always_inline
  34. long gettimeofday_fallback(register struct __kernel_old_timeval *tv,
  35. register struct timezone *tz)
  36. {
  37. return syscall2(__NR_gettimeofday, (long)tv, (long)tz);
  38. }
  39. static __always_inline
  40. long clock_getres_fallback(clockid_t clkid, struct __kernel_timespec *ts)
  41. {
  42. return syscall2(__NR_clock_getres, (long)clkid, (long)ts);
  43. }
  44. #ifdef CONFIG_TIME_NS
  45. static __always_inline
  46. const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
  47. {
  48. return _timens_data;
  49. }
  50. #endif
  51. #endif