+ [shrinker has count_objects member])
+])
+]) # LIBCFS_SHRINKER_COUNT
+
+#
+# LIBCFS_IOV_ITER_HAS_TYPE
+#
+# kernel 3.15-rc4 commit 71d8e532b1549a478e6a6a8a44f309d050294d00
+# start adding the tag to iov_iter
+#
+AC_DEFUN([LIBCFS_IOV_ITER_HAS_TYPE], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if iov_iter has member type],
+iov_iter_has_type_member, [
+ #include <linux/uio.h>
+],[
+ struct iov_iter iter = { .type = ITER_KVEC };
+ (void)iter;
+],[
+ AC_DEFINE(HAVE_IOV_ITER_HAS_TYPE_MEMBER, 1,
+ [if iov_iter has member type])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_IOV_ITER_HAS_TYPE
+
+#
+# Kernel version 3.17 changed hlist_add_after to
+# hlist_add_behind
+#
+AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
+LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
+hlist_add_after, [
+ #include <linux/list.h>
+],[
+ hlist_add_after(NULL, NULL);
+],[
+ AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
+ [hlist_add_after is available])
+])
+]) # LIBCFS_HLIST_ADD_AFTER
+
+#
+# Kernel version 3.17 introduced struct timespec64
+#
+AC_DEFUN([LIBCFS_TIMESPEC64],[
+LB_CHECK_COMPILE([does 'struct timespec64' exist],
+timespec64, [
+ #include <linux/time.h>
+],[
+ struct timespec64 ts;
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
+],[
+ AC_DEFINE(HAVE_TIMESPEC64, 1,
+ ['struct timespec64' is available])
+])
+]) # LIBCFS_TIMESPEC64
+
+#
+# Kernel version 3.17 introduced ktime_get_real_ts64
+#
+AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
+LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
+ktime_get_real_ts64, [
+ #include <linux/ktime.h>
+],[
+ struct timespec64 *ts = NULL;
+
+ ktime_get_real_ts64(ts);
+],[
+ AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
+ ['ktime_get_real_ts64' is available])
+])
+]) # LIBCFS_KTIME_GET_REAL_TS64
+
+#
+# Kernel version 3.17 introduced ktime_get_real_seconds
+#
+AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
+LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
+ktime_get_real_seconds, [
+ #include <linux/hrtimer.h>
+ #include <linux/ktime.h>
+],[
+ time64_t now;
+
+ now = ktime_get_real_seconds();
+],[
+ AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
+ ['ktime_get_real_seconds' is available])
+])
+]) # LIBCFS_KTIME_GET_REAL_SECONDS
+
+#
+# Kernel version 3.17 created ktime_get_ns wrapper
+#
+AC_DEFUN([LIBCFS_KTIME_GET_NS],[
+LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
+ktime_get_ns, [
+ #include <linux/hrtimer.h>
+ #include <linux/ktime.h>
+],[
+ u64 nanoseconds;
+
+ nanoseconds = ktime_get_ns();
+],[],[
+ AC_DEFINE(NEED_KTIME_GET_NS, 1,
+ ['ktime_get_ns' is not available])
+])
+]) # LIBCFS_KTIME_GET_NS
+
+#
+# Kernel version 3.17 created ktime_get_real_ns wrapper
+#
+AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
+LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
+ktime_get_real_ns, [
+ #include <linux/hrtimer.h>
+ #include <linux/ktime.h>
+],[
+ u64 nanoseconds;
+
+ nanoseconds = ktime_get_real_ns();
+],[],[
+ AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
+ ['ktime_get_real_ns' is not available])
+])
+]) # LIBCFS_KTIME_GET_REAL_NS
+
+#
+# Kernel version 3.17 introduced ktime_to_timespec64
+#
+AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
+LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
+ktime_to_timespec64, [
+ #include <linux/hrtimer.h>
+ #include <linux/ktime.h>
+],[
+ ktime_t now = ktime_set(0, 0);
+ struct timespec64 ts;
+
+ ts = ktime_to_timespec64(now);
+],[
+ AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
+ ['ktime_to_timespec64' is available])
+])
+]) # LIBCFS_KTIME_TO_TIMESPEC64
+
+#
+# Kernel version 3.17 introduced timespec64_sub
+#
+AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
+LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
+timespec64_sub, [
+ #include <linux/time.h>
+],[
+ struct timespec64 later = { }, earlier = { }, diff;
+
+ diff = timespec64_sub(later, earlier);
+],[
+ AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
+ ['timespec64_sub' is available])
+])
+]) # LIBCFS_TIMESPEC64_SUB
+
+#
+# Kernel version 3.17 introduced timespec64_to_ktime
+#
+AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
+LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
+timespec64_to_ktime, [
+ #include <linux/ktime.h>
+],[
+ struct timespec64 ts;
+ ktime_t now;
+
+ now = timespec64_to_ktime(ts);
+],[
+ AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
+ ['timespec64_to_ktime' is available])
+])
+]) # LIBCFS_TIMESPEC64_TO_KTIME
+
+#
+# Kernel version 3.19 introduced ktime_get_seconds
+#
+AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
+LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
+ktime_get_seconds, [
+ #include <linux/ktime.h>
+],[
+ time64_t now;
+
+ now = ktime_get_seconds();
+],[
+ AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
+ ['ktime_get_seconds' is available])
+])
+]) # LIBCFS_KTIME_GET_SECONDS
+
+#
+# Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
+# introduced the helper function ktime_ms_delta.
+#
+AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
+LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
+ktime_ms_delta, [
+ #include <linux/ktime.h>
+],[
+ ktime_t start = ktime_set(0, 0);
+ ktime_t end = start;
+
+ ktime_ms_delta(start, end);
+],[
+ AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
+ ['ktime_ms_delta' is available])
+])
+]) # LIBCFS_KTIME_MS_DELTA
+
+#
+# Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
+# create per module locks which added kernel_param_[un]lock(). Older
+# kernels you have to use __kernel_param_[un]lock(). In that case its
+# a global lock for all modules but that is okay since its a rare event.
+#
+AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
+LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
+kernel_param_lock, [
+ #include <linux/moduleparam.h>
+],[
+ kernel_param_lock(NULL);
+ kernel_param_unlock(NULL);
+],[
+ AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
+ ['kernel_param_[un]lock' is available])
+])
+]) # LIBCFS_KERNEL_PARAM_LOCK
+
+#
+# Kernel version 4.2 changed topology_thread_cpumask
+# to topology_sibling_cpumask
+#
+AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
+LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
+topology_sibling_cpumask, [
+ #include <linux/topology.h>
+],[
+ const struct cpumask *mask;
+
+ mask = topology_sibling_cpumask(0);
+],[
+ AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
+ [topology_sibling_cpumask is available])
+])
+]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
+
+#
+# Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
+# header file i387.h was renamed to fpu/api.h
+#
+AC_DEFUN([LIBCFS_FPU_API], [
+LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
+ AC_DEFINE(HAVE_FPU_API_HEADER, 1,
+ [fpu/api.h is present])])
+]) # LIBCFS_FPU_API
+
+#
+# Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
+# introduced kstrtobool and kstrtobool_from_user.
+#
+AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
+LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
+kstrtobool_from_user, [
+ #include <linux/kernel.h>
+],[
+ bool result;
+ return kstrtobool_from_user(NULL, 0, &result);
+],[
+ AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
+ [kernel has kstrtobool_from_user])
+])
+]) # LIBCFS_KSTRTOBOOL_FROM_USER
+
+#
+# Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
+# added crypto hash helpers
+#
+AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
+LB_CHECK_COMPILE([does crypto hash helper functions exist],
+crypto_hash_helpers, [
+ #include <crypto/hash.h>
+],[
+ crypto_ahash_alg_name(NULL);
+ crypto_ahash_driver_name(NULL);
+],[
+ AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
+ [crypto hash helper functions are available])
+])
+]) # LIBCFS_CRYPTO_HASH_HELPERS
+
+#
+# Kernel version 4.5-rc1 commit 3502cad73c4bbf8f6365d539e814159275252c59
+# introduced rhashtable_replace_fast
+#
+AC_DEFUN([LIBCFS_RHASHTABLE_REPLACE], [
+LB_CHECK_COMPILE([if 'rhashtable_replace_fast' exists],
+rhashtable_replace_fast, [
+ #include <linux/rhashtable.h>
+],[
+ const struct rhashtable_params params = { 0 };
+
+ rhashtable_replace_fast(NULL, NULL, NULL, params);
+],[
+ AC_DEFINE(HAVE_RHASHTABLE_REPLACE, 1,
+ [rhashtable_replace_fast() is available])
+])
+]) # LIBCFS_RHASHTABLE_REPLACE
+
+#
+# Kernel version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
+# made kset_find_obj() exportable to modules
+#
+AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
+LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
+ [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
+ [kset_find_obj is exported by the kernel])])
+]) # LIBCFS_EXPORT_KSET_FIND_OBJ
+
+#
+# Kernel version 4.6+ commit ef703f49a6c5b909a85149bb6625c4ed0d697186
+# fixed the brokenness of hash_64(). The fix removed GOLDEN_RATIO_PRIME_64
+# since it was a poor prime value.
+#
+AC_DEFUN([LIBCFS_BROKEN_HASH_64], [
+LB_CHECK_COMPILE([kernel has fixed hash_64()],
+broken_hash_64, [
+ #include <linux/hash.h>
+],[
+ int tmp = GOLDEN_RATIO_PRIME_64;
+],[
+ AC_DEFINE(HAVE_BROKEN_HASH_64, 1, [kernel hash_64() is broken])
+])
+]) # LIBCFS_BROKEN_HASH_64
+
+#
+# LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
+#
+# linux 4.6 kernel changed stacktrace_ops address to return an int
+#
+AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
+LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
+stacktrace_ops_address_return_int, [
+ #include <asm/stacktrace.h>
+],[
+ int rc;
+
+ rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
+],[
+ AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
+ ['struct stacktrace_ops' address function returns an int])
+])
+]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
+
+#
+# Kernel version 4.6 removed both struct task_struct and struct mm_struct
+# arguments to get_user_pages
+#
+AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
+LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
+get_user_pages_6arg, [
+ #include <linux/mm.h>
+],[
+ int rc;
+
+ rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
+],[
+ AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
+ [get_user_pages takes 6 arguments])
+])
+]) # LIBCFS_GET_USER_PAGES_6ARG
+
+#
+# LIBCFS_STRINGHASH
+#
+# 4.6 kernel created stringhash.h which moved stuff out of dcache.h
+# commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
+#
+AC_DEFUN([LIBCFS_STRINGHASH], [
+LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
+ AC_DEFINE(HAVE_STRINGHASH, 1,
+ [stringhash.h is present])])
+]) # LIBCFS_STRINGHASH
+
+#
+# LIBCFS_RHASHTABLE_INSERT_FAST
+#
+# 4.7+ kernel commit 5ca8cc5bf11faed257c762018aea9106d529232f
+# changed __rhashtable_insert_fast to support the new function
+# rhashtable_lookup_get_insert_key().
+#
+AC_DEFUN([LIBCFS_RHASHTABLE_INSERT_FAST], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if internal '__rhashtable_insert_fast()' returns int],
+rhashtable_insert_fast, [
+ #include <linux/rhashtable.h>
+],[
+ const struct rhashtable_params params = { 0 };
+ int rc;
+
+ rc = __rhashtable_insert_fast(NULL, NULL, NULL, params);
+],[
+ AC_DEFINE(HAVE_HASHTABLE_INSERT_FAST_RETURN_INT, 1,
+ ['__rhashtable_insert_fast()' returns int])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LIBCFS_RHASHTABLE_INSERT_FAST
+
+#
+# Kernel version 4.7-rc1 commit 8f6fd83c6c5ec66a4a70c728535ddcdfef4f3697
+# added 3rd arg to rhashtable_walk_init
+#
+AC_DEFUN([LIBCFS_RHASHTABLE_WALK_INIT_3ARG], [
+LB_CHECK_COMPILE([if 'rhashtable_walk_init' has 3 args],
+rhashtable_walk_init, [
+ #include <linux/gfp.h>
+ #include <linux/rhashtable.h>
+],[
+ rhashtable_walk_init(NULL, NULL, GFP_KERNEL);
+],[
+ AC_DEFINE(HAVE_3ARG_RHASHTABLE_WALK_INIT, 1,
+ [rhashtable_walk_init() has 3 args])