+# 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>
+],[
+ ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LIBCFS_HAVE_OOM_H],
+[LB_CHECK_FILE([$LINUX/include/linux/oom.h], [
+ AC_DEFINE(HAVE_LINUX_OOM_H, 1,
+ [kernel has include/oom.h])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# check set_mems_allowed
+# 2.6.31 adds function set_mems_allowed in cpuset.h
+#
+AC_DEFUN([LIBCFS_HAVE_SET_MEMS_ALLOWED],
+[AC_MSG_CHECKING([whether have set_mems_allowed()])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/cpuset.h>
+],[
+ nodemask_t mask;
+
+ set_mems_allowed(mask);
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SET_MEMS_ALLOWED, 1, [have set_mems_allowed()])
+],[
+ AC_MSG_RESULT(NO)
+])
+])
+
+
+#
+# RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
+#
+AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR],
+[AC_MSG_CHECKING([shrinker want self pointer in handler])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+],[
+ struct shrinker *tmp = NULL;
+ tmp->shrink(tmp, 0, 0);
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
+ [shrinker want self pointer in handler])
+],[
+ AC_MSG_RESULT(no)
+])
+])
+
+# 2.6.18 store oom parameters in task struct.
+# 2.6.32 store oom parameters in signal struct
+AC_DEFUN([LIBCFS_OOMADJ_IN_SIG],
+[AC_MSG_CHECKING([kernel store oom parameters in task])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sched.h>
+],[
+ ((struct signal_struct *)0)->oom_adj = 0;
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_OOMADJ_IN_SIG, 1,
+ [kernel store a oom parameters in signal struct])
+],[
+ AC_MSG_RESULT(no)
+])
+])
+
+#
+# 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
+#
+AC_DEFUN([LIBCFS_SYSCTL_CTLNAME],
+[AC_MSG_CHECKING([if ctl_table has a ctl_name field])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sysctl.h>
+],[
+ struct ctl_table ct;
+ ct.ctl_name = sizeof(ct);
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
+ [ctl_table has ctl_name field])
+],[
+ AC_MSG_RESULT(no)
+])
+])
+
+#
+# LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
+#
+# 2.6.34 adds __add_wait_queue_exclusive
+#
+AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
+[AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/wait.h>
+],[
+ wait_queue_head_t queue;
+ wait_queue_t wait;
+
+ __add_wait_queue_exclusive(&queue, &wait);
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
+ [__add_wait_queue_exclusive exists])
+],[
+ AC_MSG_RESULT(no)
+])
+])
+
+#
+# 2.6.35 kernel has sk_sleep function
+#
+AC_DEFUN([LC_SK_SLEEP],
+[AC_MSG_CHECKING([if kernel has sk_sleep])
+LB_LINUX_TRY_COMPILE([
+ #include <net/sock.h>
+],[
+ sk_sleep(NULL);
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
+],[
+ AC_MSG_RESULT(no)
+])
+])
+
+#
+# FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
+# pressure shrinker from Linux 3.0
+#
+AC_DEFUN([LC_SHRINK_CONTROL],
+[AC_MSG_CHECKING([shrink_control is present])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+],[
+ struct shrink_control tmp = {0};
+ tmp.nr_to_scan = sizeof(tmp);
+],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
+ [shrink_control is present])
+],[
+ AC_MSG_RESULT(no)
+])
+])
+
+#