summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-08-11 17:20:11 +0000
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>2008-08-11 17:20:11 +0000
commit6a6cafbe8dd1e33530e726ee7d1c3acc340c6c15 (patch)
tree4d21cd48abb1becadf99452fe9c6618f847ddd1f
parent86149aa255dcfb145bb4f2ad66b80dce4d620f34 (diff)
Pull in timespec, list, and type compat changes to support
building against a wider range of kernels. git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@152 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
-rw-r--r--autoconf/spl-build.m492
-rw-r--r--configure.ac3
-rw-r--r--include/linux/list_compat.h27
-rw-r--r--include/linux/time_compat.h21
-rw-r--r--include/sys/types.h8
-rw-r--r--modules/spl/spl-time.c9
6 files changed, 145 insertions, 15 deletions
diff --git a/autoconf/spl-build.m4 b/autoconf/spl-build.m4
index cb782f9d4..ada13247b 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 <linux/bitops.h>
- ],[
- 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 <linux/bitops.h>
+ ],[
+ 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 <linux/time.h>
+ ],[
+ 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 <linux/time.h>
+ ],[
+ 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 1e8c4c0f5..f93208115 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 000000000..e5daa0410
--- /dev/null
+++ b/include/linux/list_compat.h
@@ -0,0 +1,27 @@
+#ifndef _SPL_LIST_COMPAT_H
+#define _SPL_LIST_COMPAT_H
+
+#include <linux/list.h>
+
+#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 000000000..1b4727dcd
--- /dev/null
+++ b/include/linux/time_compat.h
@@ -0,0 +1,21 @@
+#ifndef _SPL_TIME_COMPAT_H
+#define _SPL_TIME_COMPAT_H
+
+#include <linux/time.h>
+
+/* 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 eba23eae0..1dec7b8d0 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 b2cb12186..c8cd048d5 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