0b9c649a3395b32b793f46455d026eb59670ad66
[openwrt/staging/blogic.git] / backport / backport-include / linux / timekeeping.h
1 #ifndef __BACKPORT_TIMEKEEPING_H
2 #define __BACKPORT_TIMEKEEPING_H
3 #include <linux/version.h>
4 #include <linux/types.h>
5
6 #if LINUX_VERSION_IS_GEQ(3,17,0)
7 #include_next <linux/timekeeping.h>
8 #endif
9
10 #if LINUX_VERSION_IS_LESS(3,17,0)
11 #define ktime_get_ns LINUX_BACKPORT(ktime_get_ns)
12 extern ktime_t ktime_get(void);
13 #define ktime_get_ns LINUX_BACKPORT(ktime_get_ns)
14 static inline u64 ktime_get_ns(void)
15 {
16 return ktime_to_ns(ktime_get());
17 }
18
19 extern ktime_t ktime_get_boottime(void);
20 #define ktime_get_boot_ns LINUX_BACKPORT(ktime_get_boot_ns)
21 static inline u64 ktime_get_boot_ns(void)
22 {
23 return ktime_to_ns(ktime_get_boottime());
24 }
25 #endif /* < 3.17 */
26
27 #if LINUX_VERSION_IS_LESS(3,19,0)
28 static inline time64_t ktime_get_seconds(void)
29 {
30 struct timespec t;
31
32 ktime_get_ts(&t);
33
34 return t.tv_sec;
35 }
36 #endif
37
38 #endif /* __BACKPORT_TIMEKEEPING_H */