Linux 4.15.6
[linux/fpc-iii.git] / kernel / time / timekeeping_internal.h
blobfdbeeb02dde9fcfc40640648df6eecb910cf95e2
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>
10 #ifdef CONFIG_DEBUG_FS
11 extern void tk_debug_account_sleep_time(struct timespec64 *t);
12 #else
13 #define tk_debug_account_sleep_time(x)
14 #endif
16 #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
17 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
19 u64 ret = (now - last) & mask;
22 * Prevent time going backwards by checking the MSB of mask in
23 * the result. If set, return 0.
25 return ret & ~(mask >> 1) ? 0 : ret;
27 #else
28 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
30 return (now - last) & mask;
32 #endif
34 extern time64_t __ktime_get_real_seconds(void);
36 #endif /* _TIMEKEEPING_INTERNAL_H */