fi
])
+
+
dnl #
dnl # 2.6.x API change
dnl # check if uintptr_t typedef is defined
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 #
[drivers/base/core.c],
[AC_DEFINE(HAVE_DEVICE_CREATE, 1,
[device_create() is available])],
- [])
+ [])
])
dnl #
[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)
+ ])
+])
+
--- /dev/null
+#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 */
+
--- /dev/null
+#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 */
+
}
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)
{
ts->tv_nsec = nsec;
}
EXPORT_SYMBOL(set_normalized_timespec);
+#endif