+# LIBCFS_CRED_WRAPPERS
+#
+# wrappers for task's credentials are in sles11
+#
+AC_DEFUN([LIBCFS_CRED_WRAPPERS],
+[AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sched.h>
+],[
+ uid_t uid;
+
+ uid = current_uid();
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LN_STRUCT_CRED_IN_TASK
+#
+# struct cred was introduced in 2.6.29 to streamline credentials in task struct
+#
+AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
+[AC_MSG_CHECKING([if kernel has struct cred])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sched.h>
+],[
+ struct task_struct *tsk = NULL;
+ tsk->real_cred = NULL;
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LIBCFS_FUNC_UNSHARE_FS_STRUCT
+#
+# unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
+# mess with copy_fs_struct
+#
+AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
+[AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sched.h>
+ #include <linux/fs_struct.h>
+],[
+ unshare_fs_struct();
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
+],[
+ AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+#
+# LIBCFS_HAVE_IS_COMPAT_TASK
+#
+# Added in 2.6.17, it wasn't until 2.6.29 that all
+# Linux architectures have is_compat_task()
+#
+AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
+[AC_MSG_CHECKING([if is_compat_task() is declared])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/compat.h>
+],[
+ int i = is_compat_task();
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
+#
+# 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
+#
+AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
+[AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
+LB_LINUX_TRY_COMPILE([
+ #include <asm/stacktrace.h>
+ unsigned long walkstack(struct thread_info *tinfo,
+ unsigned long *stack,
+ unsigned long bp,
+ const struct stacktrace_ops *ops,
+ void *data,
+ unsigned long *end,
+ int *graph);
+],[
+ struct stacktrace_ops ops;
+
+ ops.walk_stack = walkstack;
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+