diff --git a/autoconf/spl-build.m4 b/autoconf/spl-build.m4 index cb782f9d4c..ada13247b0 100644 --- a/autoconf/spl-build.m4 +++ b/autoconf/spl-build.m4 @@ -289,6 +289,8 @@ AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], fi ]) + + dnl # dnl # 2.6.x API change dnl # check if uintptr_t typedef is defined @@ -445,17 +447,17 @@ dnl # 2.6.16 API change. dnl # Check if 'fls64()' is available dnl # AC_DEFUN([SPL_AC_FLS64], - [AC_MSG_CHECKING([whether fls64() is available]) - SPL_LINUX_TRY_COMPILE([ - #include - ],[ - return fls64(0); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FLS64, 1, [fls64() is available]) - ],[ - AC_MSG_RESULT(no) - ]) + [AC_MSG_CHECKING([whether fls64() is available]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + return fls64(0); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FLS64, 1, [fls64() is available]) + ],[ + AC_MSG_RESULT(no) + ]) ]) dnl # @@ -469,7 +471,7 @@ AC_DEFUN([SPL_AC_DEVICE_CREATE], [ [drivers/base/core.c], [AC_DEFINE(HAVE_DEVICE_CREATE, 1, [device_create() is available])], - []) + []) ]) dnl # @@ -483,5 +485,69 @@ AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [ [drivers/base/class.c], [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1, [class_device_create() is available])], - []) + []) ]) + +dnl # +dnl # 2.6.26 API change, set_normalized_timespec() is exported. +dnl # +AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [ + SPL_CHECK_SYMBOL_EXPORT( + [class_device_create], + [drivers/base/class.c], + [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1, + [class_device_create() is available])], + []) +]) + +dnl # +dnl # 2.6.26 API change, set_normalized_timespec() is exported. +dnl # +AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [ + SPL_CHECK_SYMBOL_EXPORT( + [set_normalized_timespec], + [kernel/time.c], + [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1, + [set_normalized_timespec() is available as export])], + []) +]) + +dnl # +dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c +dnl # previously it was available in time.h as an inline. +dnl # +AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], + [AC_MSG_CHECKING([whether set_normalized_timespec() is an inline]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + void set_normalized_timespec(struct timespec *ts, + time_t sec, long nsec) { } + ],[ + AC_MSG_RESULT(no) + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1, + [set_normalized_timespec() is available as inline]) + ]) +]) + +dnl # +dnl # 2.6.18 API change, +dnl # timespec_sub() inline function available in linux/time.h +dnl # +AC_DEFUN([SPL_AC_TIMESPEC_SUB], + [AC_MSG_CHECKING([whether timespec_sub() is available]) + SPL_LINUX_TRY_COMPILE([ + #include + ],[ + struct timespec a, b, c = { 0 }; + c = timespec_sub(a, b); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + diff --git a/configure.ac b/configure.ac index 1e8c4c0f53..f932081151 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,9 @@ SPL_AC_CTL_UNNUMBERED SPL_AC_FLS64 SPL_AC_DEVICE_CREATE SPL_AC_CLASS_DEVICE_CREATE +SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT +SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE +SPL_AC_TIMESPEC_SUB TOPDIR=`/bin/pwd` diff --git a/include/linux/list_compat.h b/include/linux/list_compat.h new file mode 100644 index 0000000000..e5daa0410f --- /dev/null +++ b/include/linux/list_compat.h @@ -0,0 +1,27 @@ +#ifndef _SPL_LIST_COMPAT_H +#define _SPL_LIST_COMPAT_H + +#include + +#ifndef list_for_each_entry_safe_reverse + +/** + * list_for_each_entry_safe_reverse + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + * + * Iterate backwards over list of given type, safe against removal + * of list entry. + */ +#define list_for_each_entry_safe_reverse(pos, n, head, member) \ + for (pos = list_entry((head)->prev, typeof(*pos), member), \ + n = list_entry(pos->member.prev, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.prev, typeof(*n), member)) + +#endif /* list_for_each_entry_safe_reverse */ + +#endif /* SPL_LIST_COMPAT_H */ + diff --git a/include/linux/time_compat.h b/include/linux/time_compat.h new file mode 100644 index 0000000000..1b4727dcd5 --- /dev/null +++ b/include/linux/time_compat.h @@ -0,0 +1,21 @@ +#ifndef _SPL_TIME_COMPAT_H +#define _SPL_TIME_COMPAT_H + +#include + +/* timespec_sub() API changes + * 2.6.18 - 2.6.x: Inline function provided by linux/time.h + */ +#ifndef HAVE_TIMESPEC_SUB +static inline struct timespec +timespec_sub(struct timespec lhs, struct timespec rhs) +{ + struct timespec ts_delta; + set_normalized_timespec(&ts_delta, lhs.tv_sec - rhs.tv_sec, + lhs.tv_nsec - rhs.tv_nsec); + return ts_delta; +} +#endif /* HAVE_TIMESPEC_SUB */ + +#endif /* _SPL_TIME_COMPAT_H */ + diff --git a/include/sys/types.h b/include/sys/types.h index eba23eae0b..1dec7b8d0b 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -13,6 +13,14 @@ extern "C" { typedef unsigned long uintptr_t; #endif +#ifndef ULLONG_MAX +#define ULLONG_MAX (~0ULL) +#endif + +#ifndef LLONG_MAX +#define LLONG_MAX ((long long)(~0ULL>>1)) +#endif + typedef enum { B_FALSE=0, B_TRUE=1 } boolean_t; typedef unsigned long intptr_t; typedef unsigned long ulong_t; diff --git a/modules/spl/spl-time.c b/modules/spl/spl-time.c index b2cb12186b..c8cd048d55 100644 --- a/modules/spl/spl-time.c +++ b/modules/spl/spl-time.c @@ -67,9 +67,13 @@ __gethrtime(void) { } EXPORT_SYMBOL(__gethrtime); -/* Not exported from the kernel, but we need it for timespec_sub. Be very - * careful here we are using the kernel prototype, so that must not change. +/* set_normalized_timespec() API changes + * 2.6.0 - 2.6.15: Inline function provided by linux/time.h + * 2.6.16 - 2.6.25: Function prototypedefined but not exported + * 2.6.26 - 2.6.x: Function defined and exported */ +#if !defined(HAVE_SET_NORMALIZED_TIMESPEC_INLINE) && \ + !defined(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT) void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec) { @@ -85,3 +89,4 @@ set_normalized_timespec(struct timespec *ts, time_t sec, long nsec) ts->tv_nsec = nsec; } EXPORT_SYMBOL(set_normalized_timespec); +#endif