timekeeping_internal.h 827 B

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