timekeeping_internal.h 824 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef _TIMEKEEPING_INTERNAL_H
  2. #define _TIMEKEEPING_INTERNAL_H
  3. /*
  4. * timekeeping debug functions
  5. */
  6. #include <linux/clocksource.h>
  7. #include <linux/time.h>
  8. #ifdef CONFIG_DEBUG_FS
  9. extern void tk_debug_account_sleep_time(struct timespec64 *t);
  10. #else
  11. #define tk_debug_account_sleep_time(x)
  12. #endif
  13. #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
  14. static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask)
  15. {
  16. cycle_t ret = (now - last) & mask;
  17. /*
  18. * Prevent time going backwards by checking the MSB of mask in
  19. * the result. If set, return 0.
  20. */
  21. return ret & ~(mask >> 1) ? 0 : ret;
  22. }
  23. #else
  24. static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask)
  25. {
  26. return (now - last) & mask;
  27. }
  28. #endif
  29. extern time64_t __ktime_get_real_seconds(void);
  30. #endif /* _TIMEKEEPING_INTERNAL_H */