]> git.proxmox.com Git - mirror_spl.git/commitdiff
Linux 5.0 compat: Fix timespec_sub()
authorTony Hutter <hutter2@llnl.gov>
Tue, 29 Jan 2019 02:44:14 +0000 (18:44 -0800)
committerTony Hutter <hutter2@llnl.gov>
Fri, 22 Feb 2019 17:47:27 +0000 (09:47 -0800)
The 5.0 kernel no longer include timespec_sub().  It only has
timespec64_sub().  Add a compatibility function.

Signed-off-by: Tony Hutter <hutter2@llnl.gov>

config/kernel-timespec_sub.m4 [new file with mode: 0644]
config/spl-build.m4
include/sys/time.h
module/splat/splat-kmem.c

diff --git a/config/kernel-timespec_sub.m4 b/config/kernel-timespec_sub.m4
new file mode 100644 (file)
index 0000000..01f0970
--- /dev/null
@@ -0,0 +1,20 @@
+dnl #
+dnl # 5.0 API change
+dnl #
+dnl # Does timespec_sub() exists?  If not, use timespec64_sub().
+dnl #
+AC_DEFUN([SPL_AC_KERNEL_TIMESPEC_SUB], [
+       AC_MSG_CHECKING([whether timespec_sub() exists])
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/time.h>
+       ],[
+               struct timespec a = {0}, b = {0};
+               timespec_sub(a, b);
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_KERNEL_TIMESPEC_SUB, 1,
+                   [kernel has timespec_sub])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
index 094b1314f5c467d9b49417a5f5c5bff9f166ad6a..6d51187dd711fc29f9d29d573d63fe9d311435c4 100644 (file)
@@ -56,6 +56,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
        SPL_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
        SPL_AC_KERNEL_TOTALRAM_PAGES_FUNC
+       SPL_AC_KERNEL_TIMESPEC_SUB
 ])
 
 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
index d2b20c8f63d54ebe999e681e3353e6754155c36c..461e7317d711cda291a33fad143fa99f5dc093da 100644 (file)
@@ -57,6 +57,17 @@ typedef struct timespec              timespec_t;
 
 static const int hz = HZ;
 
+/* 5.0 kernels no longer have timespec_sub(), only timespec64_sub() */
+#if !defined(HAVE_KERNEL_TIMESPEC_SUB) && defined(HAVE_INODE_TIMESPEC64_TIMES)
+static inline struct timespec timespec_sub(struct timespec a,
+    struct timespec b) {
+       struct timespec64 res;
+       res = timespec64_sub(timespec_to_timespec64(a),
+           timespec_to_timespec64(b));
+       return timespec64_to_timespec(res);
+}
+#endif
+
 #define        TIMESPEC_OVERFLOW(ts)           \
        ((ts)->tv_sec < TIME_MIN || (ts)->tv_sec > TIME_MAX)
 
index d0649ad9a058467d117246561d94a8fc9331e996..22f02d5eac604ae5e4770e109f7854564d688d2e 100644 (file)
@@ -30,6 +30,7 @@
 #include <sys/random.h>
 #include <sys/thread.h>
 #include <sys/vmsystm.h>
+#include <sys/time.h>
 #include "splat-internal.h"
 
 #define SPLAT_KMEM_NAME                        "kmem"