]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - kernel/time/timekeeping_internal.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / kernel / time / timekeeping_internal.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
5c83545f
CC
2#ifndef _TIMEKEEPING_INTERNAL_H
3#define _TIMEKEEPING_INTERNAL_H
4/*
5 * timekeeping debug functions
6 */
3a978377 7#include <linux/clocksource.h>
5c83545f
CC
8#include <linux/time.h>
9
10#ifdef CONFIG_DEBUG_FS
7d489d15 11extern void tk_debug_account_sleep_time(struct timespec64 *t);
5c83545f
CC
12#else
13#define tk_debug_account_sleep_time(x)
14#endif
15
09ec5442 16#ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
a5a1d1c2 17static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
09ec5442 18{
a5a1d1c2 19 u64 ret = (now - last) & mask;
09ec5442 20
1f45f1f3
YY
21 /*
22 * Prevent time going backwards by checking the MSB of mask in
23 * the result. If set, return 0.
24 */
25 return ret & ~(mask >> 1) ? 0 : ret;
09ec5442
TG
26}
27#else
a5a1d1c2 28static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
3a978377
TG
29{
30 return (now - last) & mask;
31}
09ec5442 32#endif
3a978377 33
dee36654
D
34extern time64_t __ktime_get_real_seconds(void);
35
5c83545f 36#endif /* _TIMEKEEPING_INTERNAL_H */