Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Linux 5.0 compat: Fix timespec_sub()
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>
  • Loading branch information
tonyhutter committed Jan 29, 2019
1 parent 489f931 commit a333b28
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions config/kernel-timespec_sub.m4
@@ -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)
])
])
1 change: 1 addition & 0 deletions config/spl-build.m4
Expand Up @@ -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], [
Expand Down
11 changes: 11 additions & 0 deletions include/sys/time.h
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions module/splat/splat-kmem.c
Expand Up @@ -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"
Expand Down

0 comments on commit a333b28

Please sign in to comment.