]> git.proxmox.com Git - mirror_spl.git/commitdiff
Pull in timespec, list, and type compat changes to support
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Mon, 11 Aug 2008 17:20:11 +0000 (17:20 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Mon, 11 Aug 2008 17:20:11 +0000 (17:20 +0000)
building against a wider range of kernels.

git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@152 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

autoconf/spl-build.m4
configure.ac
include/linux/list_compat.h [new file with mode: 0644]
include/linux/time_compat.h [new file with mode: 0644]
include/sys/types.h
modules/spl/spl-time.c

index cb782f9d4c2ec9ef59e4222690d98d2c333f5f32..ada13247b0c202dad60db07a4af70a8b4679de13 100644 (file)
@@ -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)
+       ])
+])
+
index 1e8c4c0f53e559b993183fe94106c719929f8405..f932081151321f715fcc7cf547346b4a5ab1530e 100644 (file)
@@ -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 (file)
index 0000000..e5daa04
--- /dev/null
@@ -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 (file)
index 0000000..1b4727d
--- /dev/null
@@ -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 */
+
index eba23eae0b17f249790e385b18d5ab3421f792a1..1dec7b8d0bed43b58e620aa11dada5c3b3fe5a8f 100644 (file)
@@ -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;
index b2cb12186ba1e014aed6fb360b93a463c099b4da..c8cd048d55b48af17bbd8183a25f108ea90e732e 100644 (file)
@@ -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