1 #ifndef __BACKPORT_TIMEKEEPING_H
2 #define __BACKPORT_TIMEKEEPING_H
3 #include <linux/version.h>
4 #include <linux/types.h>
6 #if LINUX_VERSION_IS_GEQ(3,17,0)
7 #include_next <linux/timekeeping.h>
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)
16 return ktime_to_ns(ktime_get());
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)
23 return ktime_to_ns(ktime_get_boottime());
27 #if LINUX_VERSION_IS_LESS(4,18,0)
28 static inline time64_t
ktime_get_boottime_seconds(void)
30 return ktime_divns(ktime_get_boottime(), NSEC_PER_SEC
);
34 #if LINUX_VERSION_IS_LESS(3,19,0)
35 static inline time64_t
ktime_get_seconds(void)
44 static inline time64_t
ktime_get_real_seconds(void)
54 #if LINUX_VERSION_IS_LESS(3,17,0)
55 static inline void ktime_get_ts64(struct timespec64
*ts
)
61 #endif /* __BACKPORT_TIMEKEEPING_H */