aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/compat/compat.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/compat/compat.h40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h
index acf18e7..19f51a9 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -388,25 +388,38 @@ static inline int get_random_bytes_wait(void *buf, int nbytes)
#define system_power_efficient_wq system_unbound_wq
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) && !defined(ISRHEL7)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 3, 0)
+#include <linux/ktime.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
#include <linux/hrtimer.h>
-static inline u64 ktime_get_boot_ns(void)
+#ifndef ktime_get_real_ts64
+#define timespec64 timespec
+#define ktime_get_real_ts64 ktime_get_real_ts
+#endif
+#else
+#include <linux/timekeeping.h>
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
+static inline u64 __compat_jiffies64_to_nsecs(u64 j)
{
- return ktime_to_ns(ktime_get_boottime());
+#if !(NSEC_PER_SEC % HZ)
+ return (NSEC_PER_SEC / HZ) * j;
+# else
+ return div_u64(j * HZ_TO_USEC_NUM, HZ_TO_USEC_DEN) * 1000;
+#endif
}
+#define jiffies64_to_nsecs __compat_jiffies64_to_nsecs
#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
+static inline u64 ktime_get_coarse_boottime_ns(void)
+{
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
-#include <linux/hrtimer.h>
+ return ktime_to_ns(ktime_get_boottime());
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 12) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)) || LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 53)
+ return ktime_to_ns(ktime_mono_to_any(ns_to_ktime(jiffies64_to_nsecs(get_jiffies_64())), TK_OFFS_BOOT));
#else
-#include <linux/timekeeping.h>
+ return ktime_to_ns(ktime_get_coarse_boottime());
#endif
-static inline u64 __compat_ktime_get_boot_fast_ns(void)
-{
- return ktime_get_boot_ns();
}
-#define ktime_get_boot_fast_ns __compat_ktime_get_boot_fast_ns
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
@@ -646,11 +659,6 @@ struct __compat_dummy_container { char dev; };
#define COMPAT_CANNOT_USE_AVX512
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
-#define timespec64 timespec
-#define ktime_get_real_ts64 ktime_get_real_ts
-#endif
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
#include <net/genetlink.h>
#define genl_dump_check_consistent(a, b) genl_dump_check_consistent(a, b, &genl_family)