1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
22 SPL_AC_DEBUG_KMEM_TRACKING
23 SPL_AC_ATOMIC_SPINLOCK
24 SPL_AC_TYPE_ATOMIC64_CMPXCHG
25 SPL_AC_TYPE_ATOMIC64_XCHG
27 SPL_AC_3ARGS_INIT_WORK
28 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_3ARGS_SHRINKER_CALLBACK
31 SPL_AC_PATH_IN_NAMEIDATA
37 SPL_AC_5ARGS_DEVICE_CREATE
38 SPL_AC_CLASS_DEVICE_CREATE
39 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
40 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
47 SPL_AC_MONOTONIC_CLOCK
50 SPL_AC_MUTEX_LOCK_NESTED
51 SPL_AC_3ARGS_ON_EACH_CPU
52 SPL_AC_KALLSYMS_LOOKUP_NAME
53 SPL_AC_GET_VMALLOC_INFO
55 SPL_AC_FIRST_ONLINE_PGDAT
56 SPL_AC_NEXT_ONLINE_PGDAT
59 SPL_AC_GLOBAL_PAGE_STATE
60 SPL_AC_ZONE_STAT_ITEM_FREE
61 SPL_AC_ZONE_STAT_ITEM_INACTIVE
62 SPL_AC_ZONE_STAT_ITEM_ACTIVE
63 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_2ARGS_SET_FS_PWD
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_PUT_TASK_STRUCT
72 SPL_AC_5ARGS_PROC_HANDLER
74 SPL_AC_3ARGS_FILE_FSYNC
75 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
78 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
79 modpost=$LINUX/scripts/Makefile.modpost
80 AC_MSG_CHECKING([kernel file name for module symbols])
81 if test -f "$modpost"; then
82 if grep -q Modules.symvers $modpost; then
83 LINUX_SYMBOLS=Modules.symvers
85 LINUX_SYMBOLS=Module.symvers
90 AC_MSG_RESULT($LINUX_SYMBOLS)
91 AC_SUBST(LINUX_SYMBOLS)
94 AC_DEFUN([SPL_AC_KERNEL], [
96 AS_HELP_STRING([--with-linux=PATH],
97 [Path to kernel source]),
98 [kernelsrc="$withval"])
100 AC_ARG_WITH([linux-obj],
101 AS_HELP_STRING([--with-linux-obj=PATH],
102 [Path to kernel build objects]),
103 [kernelbuild="$withval"])
105 AC_MSG_CHECKING([kernel source directory])
106 if test -z "$kernelsrc"; then
107 headersdir="/lib/modules/$(uname -r)/build"
108 if test -e "$headersdir"; then
109 sourcelink=$(readlink -f "$headersdir")
111 sourcelink=$(ls -1d /usr/src/kernels/* \
113 2>/dev/null | grep -v obj | tail -1)
116 if test -n "$sourcelink" && test -e ${sourcelink}; then
117 kernelsrc=`readlink -f ${sourcelink}`
119 AC_MSG_RESULT([Not found])
121 *** Please make sure the kernel devel package for your distribution
122 *** is installed then try again. If that fails you can specify the
123 *** location of the kernel source with the '--with-linux=PATH' option.])
126 if test "$kernelsrc" = "NONE"; then
131 AC_MSG_RESULT([$kernelsrc])
132 AC_MSG_CHECKING([kernel build directory])
133 if test -z "$kernelbuild"; then
134 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
135 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
136 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
137 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
138 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
139 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
141 kernelbuild=${kernelsrc}
144 AC_MSG_RESULT([$kernelbuild])
146 AC_MSG_CHECKING([kernel source version])
147 utsrelease1=$kernelbuild/include/linux/version.h
148 utsrelease2=$kernelbuild/include/linux/utsrelease.h
149 utsrelease3=$kernelbuild/include/generated/utsrelease.h
150 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
151 utsrelease=linux/version.h
152 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
153 utsrelease=linux/utsrelease.h
154 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
155 utsrelease=generated/utsrelease.h
158 if test "$utsrelease"; then
159 kernsrcver=`(echo "#include <$utsrelease>";
160 echo "kernsrcver=UTS_RELEASE") |
161 cpp -I $kernelbuild/include |
162 grep "^kernsrcver=" | cut -d \" -f 2`
164 if test -z "$kernsrcver"; then
165 AC_MSG_RESULT([Not found])
166 AC_MSG_ERROR([*** Cannot determine kernel version.])
169 AC_MSG_RESULT([Not found])
170 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
173 AC_MSG_RESULT([$kernsrcver])
176 LINUX_OBJ=${kernelbuild}
177 LINUX_VERSION=${kernsrcver}
181 AC_SUBST(LINUX_VERSION)
183 SPL_AC_MODULE_SYMVERS
187 dnl # Explicitly check for gawk, we require it for the the usermode
188 dnl # helper. For some reason the standard awk command does not
189 dnl # behave correctly when invoked from the usermode helper.
191 AC_DEFUN([SPL_AC_GAWK], [
192 AS_IF([test "x$AWK" != xgawk], [
194 *** Required util gawk missing. Please install the required
195 *** gawk package for your distribution and try again.])
200 dnl # Default SPL user configuration
202 AC_DEFUN([SPL_AC_CONFIG_USER], [
207 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
208 dnl # are missing it is non-fatal but you will not be able to build
209 dnl # RPM packages and will be warned if you try too.
211 AC_DEFUN([SPL_AC_RPM], [
215 AC_MSG_CHECKING([whether $RPM is available])
216 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
217 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
219 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
222 AC_MSG_RESULT([$HAVE_RPM])
225 AC_MSG_CHECKING([whether $RPMBUILD is available])
226 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
227 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
229 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
232 AC_MSG_RESULT([$HAVE_RPMBUILD])
237 AC_SUBST(RPM_VERSION)
239 AC_SUBST(HAVE_RPMBUILD)
241 AC_SUBST(RPMBUILD_VERSION)
245 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
246 dnl # tools are missing it is non-fatal but you will not be able to build
247 dnl # DEB packages and will be warned if you try too.
249 AC_DEFUN([SPL_AC_DPKG], [
251 DPKGBUILD=dpkg-buildpackage
253 AC_MSG_CHECKING([whether $DPKG is available])
254 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
255 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
257 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
260 AC_MSG_RESULT([$HAVE_DPKG])
263 AC_MSG_CHECKING([whether $DPKGBUILD is available])
264 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
265 DPKGBUILD_VERSION=$(echo $tmp | \
266 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
268 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
271 AC_MSG_RESULT([$HAVE_DPKGBUILD])
276 AC_SUBST(DPKG_VERSION)
278 AC_SUBST(HAVE_DPKGBUILD)
280 AC_SUBST(DPKGBUILD_VERSION)
284 dnl # Until native packaging for various different packing systems
285 dnl # can be added the least we can do is attempt to use alien to
286 dnl # convert the RPM packages to the needed package type. This is
287 dnl # a hack but so far it has worked reasonable well.
289 AC_DEFUN([SPL_AC_ALIEN], [
292 AC_MSG_CHECKING([whether $ALIEN is available])
293 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
294 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
296 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
299 AC_MSG_RESULT([$HAVE_ALIEN])
304 AC_SUBST(ALIEN_VERSION)
308 dnl # Using the VENDOR tag from config.guess set the default
309 dnl # package type for 'make pkg': (rpm | deb | tgz)
311 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
312 AC_MSG_CHECKING([linux distribution])
313 if test -f /etc/redhat-release ; then
315 elif test -f /etc/fedora-release ; then
317 elif test -f /etc/lsb-release ; then
319 elif test -f /etc/debian_version ; then
321 elif test -f /etc/SuSE-release ; then
323 elif test -f /etc/slackware-version ; then
325 elif test -f /etc/gentoo-release ; then
330 AC_MSG_RESULT([$VENDOR])
333 AC_MSG_CHECKING([default package type])
335 fedora) DEFAULT_PACKAGE=rpm ;;
336 redhat) DEFAULT_PACKAGE=rpm ;;
337 sles) DEFAULT_PACKAGE=rpm ;;
338 ubuntu) DEFAULT_PACKAGE=deb ;;
339 debian) DEFAULT_PACKAGE=deb ;;
340 slackware) DEFAULT_PACKAGE=tgz ;;
341 *) DEFAULT_PACKAGE=rpm ;;
344 AC_MSG_RESULT([$DEFAULT_PACKAGE])
345 AC_SUBST(DEFAULT_PACKAGE)
349 dnl # Default SPL user configuration
351 AC_DEFUN([SPL_AC_PACKAGE], [
355 SPL_AC_DEFAULT_PACKAGE
358 AC_DEFUN([SPL_AC_LICENSE], [
359 AC_MSG_CHECKING([spl license])
361 AC_MSG_RESULT([$LICENSE])
362 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
366 AC_DEFUN([SPL_AC_CONFIG], [
368 AC_ARG_WITH([config],
369 AS_HELP_STRING([--with-config=CONFIG],
370 [Config file 'kernel|user|all|srpm']),
371 [SPL_CONFIG="$withval"])
373 AC_MSG_CHECKING([spl config])
374 AC_MSG_RESULT([$SPL_CONFIG]);
377 case "$SPL_CONFIG" in
378 kernel) SPL_AC_CONFIG_KERNEL ;;
379 user) SPL_AC_CONFIG_USER ;;
380 all) SPL_AC_CONFIG_KERNEL
381 SPL_AC_CONFIG_USER ;;
384 AC_MSG_RESULT([Error!])
385 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
386 user kernel|user|all|srpm]) ;;
389 AM_CONDITIONAL([CONFIG_USER],
390 [test "$SPL_CONFIG" = user] ||
391 [test "$SPL_CONFIG" = all])
392 AM_CONDITIONAL([CONFIG_KERNEL],
393 [test "$SPL_CONFIG" = kernel] ||
394 [test "$SPL_CONFIG" = all])
398 dnl # Enable if the SPL should be compiled with internal debugging enabled.
399 dnl # By default this support is disabled.
401 AC_DEFUN([SPL_AC_DEBUG], [
402 AC_MSG_CHECKING([whether debugging is enabled])
403 AC_ARG_ENABLE([debug],
404 [AS_HELP_STRING([--enable-debug],
405 [Enable generic debug support @<:@default=no@:>@])],
409 AS_IF([test "x$enable_debug" = xyes],
411 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
412 DEBUG_CFLAGS="-DDEBUG -Werror"
415 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
416 DEBUG_CFLAGS="-DNDEBUG"
419 AC_SUBST(DEBUG_CFLAGS)
420 AC_MSG_RESULT([$enable_debug])
424 dnl # Enabled by default it provides a minimal level of memory tracking.
425 dnl # A total count of bytes allocated is kept for each alloc and free.
426 dnl # Then at module unload time a report to the console will be printed
427 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
428 dnl # and provide an easy way to inspect the kmem based slab.
430 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
431 AC_ARG_ENABLE([debug-kmem],
432 [AS_HELP_STRING([--enable-debug-kmem],
433 [Enable basic kmem accounting @<:@default=yes@:>@])],
435 [enable_debug_kmem=yes])
437 AS_IF([test "x$enable_debug_kmem" = xyes],
438 [AC_DEFINE([DEBUG_KMEM], [1],
439 [Define to 1 to enable basic kmem accounting])
440 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
442 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
443 AC_MSG_RESULT([$enable_debug_kmem])
447 dnl # Disabled by default it provides detailed memory tracking. This
448 dnl # feature also requires --enable-debug-kmem to be set. When enabled
449 dnl # not only will total bytes be tracked but also the location of every
450 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
451 dnl # addresses and where they were allocated will be dumped to the console.
452 dnl # Enabling this feature has a significant impact on performance but it
453 dnl # makes finding memory leaks pretty straight forward.
455 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
456 AC_ARG_ENABLE([debug-kmem-tracking],
457 [AS_HELP_STRING([--enable-debug-kmem-tracking],
458 [Enable detailed kmem tracking @<:@default=no@:>@])],
460 [enable_debug_kmem_tracking=no])
462 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
463 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
464 [Define to 1 to enable detailed kmem tracking])
465 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
467 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
468 AC_MSG_RESULT([$enable_debug_kmem_tracking])
472 dnl # SPL_LINUX_CONFTEST
474 AC_DEFUN([SPL_LINUX_CONFTEST], [
475 cat confdefs.h - <<_ACEOF >conftest.c
481 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
483 m4_define([SPL_LANG_PROGRAM], [
488 dnl Do *not* indent the following line: there may be CPP directives.
489 dnl Don't move the `;' right after for the same reason.
497 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
499 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
500 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
501 rm -Rf build && mkdir -p build
502 echo "obj-m := conftest.o" >build/Makefile
504 [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
506 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
512 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
514 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
515 [SPL_LINUX_COMPILE_IFELSE(
516 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
518 [test -s build/conftest.o],
523 dnl # SPL_LINUX_CONFIG
525 AC_DEFUN([SPL_LINUX_CONFIG],
526 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
527 SPL_LINUX_TRY_COMPILE([
528 #ifndef AUTOCONF_INCLUDED
529 #include <linux/config.h>
533 #error CONFIG_$1 not #defined
545 dnl # SPL_CHECK_SYMBOL_EXPORT
546 dnl # check symbol exported or not
548 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
549 [AC_MSG_CHECKING([whether symbol $1 is exported])
550 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
551 $LINUX_OBJ/Module*.symvers 2>/dev/null
553 if test $rc -ne 0; then
556 grep -q -E "EXPORT_SYMBOL.*($1)" \
557 "$LINUX_OBJ/$file" 2>/dev/null
559 if test $rc -eq 0; then
564 if test $export -eq 0; then
578 dnl # SPL_CHECK_HEADER
579 dnl # check whether header exists and define HAVE_$2_HEADER
581 AC_DEFUN([SPL_CHECK_HEADER],
582 [AC_MSG_CHECKING([whether header $1 exists])
583 SPL_LINUX_TRY_COMPILE([
588 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
598 dnl # Use the atomic implemenation based on global spinlocks. This
599 dnl # should only be needed by 32-bit kernels which do not provide
600 dnl # the atomic64_* API. It may be optionally enabled as a fallback
601 dnl # if problems are observed with the direct mapping to the native
602 dnl # Linux atomic operations. You may not disable atomic spinlocks
603 dnl # if you kernel does not an atomic64_* API.
605 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
606 AC_ARG_ENABLE([atomic-spinlocks],
607 [AS_HELP_STRING([--enable-atomic-spinlocks],
608 [Atomic types use spinlocks @<:@default=check@:>@])],
610 [enable_atomic_spinlocks=check])
612 SPL_LINUX_TRY_COMPILE([
613 #include <asm/atomic.h>
618 AC_DEFINE(HAVE_ATOMIC64_T, 1,
619 [kernel defines atomic64_t])
624 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
625 AS_IF([test "x$have_atomic64_t" = xyes], [
626 enable_atomic_spinlocks=no
628 enable_atomic_spinlocks=yes
632 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
633 AC_DEFINE([ATOMIC_SPINLOCK], [1],
634 [Atomic types use spinlocks])
636 AS_IF([test "x$have_atomic64_t" = xno], [
638 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
642 AC_MSG_CHECKING([whether atomic types use spinlocks])
643 AC_MSG_RESULT([$enable_atomic_spinlocks])
645 AC_MSG_CHECKING([whether kernel defines atomic64_t])
646 AC_MSG_RESULT([$have_atomic64_t])
650 dnl # 2.6.24 API change,
651 dnl # check if atomic64_cmpxchg is defined
653 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
654 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
655 SPL_LINUX_TRY_COMPILE([
656 #include <asm/atomic.h>
657 #include <asm/system.h>
659 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
662 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
663 [kernel defines atomic64_cmpxchg])
670 dnl # 2.6.24 API change,
671 dnl # check if atomic64_xchg is defined
673 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
674 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
675 SPL_LINUX_TRY_COMPILE([
676 #include <asm/atomic.h>
678 atomic64_xchg((atomic64_t *)NULL, 0);
681 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
682 [kernel defines atomic64_xchg])
689 dnl # 2.6.24 API change,
690 dnl # check if uintptr_t typedef is defined
692 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
693 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
694 SPL_LINUX_TRY_COMPILE([
695 #include <linux/types.h>
700 AC_DEFINE(HAVE_UINTPTR_T, 1,
701 [kernel defines uintptr_t])
708 dnl # 2.6.20 API change,
709 dnl # INIT_WORK use 2 args and not store data inside
711 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
712 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
713 SPL_LINUX_TRY_COMPILE([
714 #include <linux/workqueue.h>
716 struct work_struct work;
717 INIT_WORK(&work, NULL, NULL);
720 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
721 [INIT_WORK wants 3 args])
728 dnl # 2.6.21 API change,
729 dnl # 'register_sysctl_table' use only one argument instead of two
731 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
732 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
733 SPL_LINUX_TRY_COMPILE([
734 #include <linux/sysctl.h>
736 return register_sysctl_table(NULL,0);
739 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
740 [register_sysctl_table() wants 2 args])
747 dnl # 2.6.23 API change
748 dnl # Old set_shrinker API replaced with register_shrinker
750 AC_DEFUN([SPL_AC_SET_SHRINKER], [
751 AC_MSG_CHECKING([whether set_shrinker() available])
752 SPL_LINUX_TRY_COMPILE([
753 #include <linux/mm.h>
755 return set_shrinker(DEFAULT_SEEKS, NULL);
758 AC_DEFINE(HAVE_SET_SHRINKER, 1,
759 [set_shrinker() available])
766 dnl # 2.6.35 API change,
767 dnl # Add context to shrinker callback
769 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
770 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
771 tmp_flags="$EXTRA_KCFLAGS"
772 EXTRA_KCFLAGS="-Werror"
773 SPL_LINUX_TRY_COMPILE([
774 #include <linux/mm.h>
776 int shrinker_cb(struct shrinker *, int, unsigned int);
778 struct shrinker cache_shrinker = {
779 .shrink = shrinker_cb,
780 .seeks = DEFAULT_SEEKS,
782 register_shrinker(&cache_shrinker);
785 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
786 [shrinker callback wants 3 args])
790 EXTRA_KCFLAGS="$tmp_flags"
794 dnl # 2.6.25 API change,
795 dnl # struct path entry added to struct nameidata
797 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
798 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
799 SPL_LINUX_TRY_COMPILE([
800 #include <linux/namei.h>
805 nd.path.dentry = NULL;
808 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
809 [struct path used in struct nameidata])
816 dnl # Custom SPL patch may export this system it is not required
818 AC_DEFUN([SPL_AC_TASK_CURR], [
819 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
820 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
825 dnl # 2.6.19 API change,
826 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
828 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
829 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
830 SPL_LINUX_TRY_COMPILE([
831 #include <linux/sysctl.h>
833 #ifndef CTL_UNNUMBERED
834 #error CTL_UNNUMBERED undefined
838 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
839 [unnumbered sysctl support exists])
846 dnl # 2.6.33 API change,
847 dnl # Removed .ctl_name from struct ctl_table.
849 AC_DEFUN([SPL_AC_CTL_NAME], [
850 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
851 SPL_LINUX_TRY_COMPILE([
852 #include <linux/sysctl.h>
854 struct ctl_table ctl;
858 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
865 dnl # 2.6.16 API change.
866 dnl # Check if 'fls64()' is available
868 AC_DEFUN([SPL_AC_FLS64],
869 [AC_MSG_CHECKING([whether fls64() is available])
870 SPL_LINUX_TRY_COMPILE([
871 #include <linux/bitops.h>
876 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
883 dnl # 2.6.18 API change, check whether device_create() is available.
884 dnl # Device_create() was introduced in 2.6.18 and depricated
885 dnl # class_device_create() which was fully removed in 2.6.26.
887 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
888 SPL_CHECK_SYMBOL_EXPORT(
890 [drivers/base/core.c],
891 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
892 [device_create() is available])],
897 dnl # 2.6.27 API change,
898 dnl # device_create() uses 5 args, new 'drvdata' argument.
900 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
901 AC_MSG_CHECKING([whether device_create() wants 5 args])
902 tmp_flags="$EXTRA_KCFLAGS"
903 EXTRA_KCFLAGS="-Werror"
904 SPL_LINUX_TRY_COMPILE([
905 #include <linux/device.h>
907 device_create(NULL, NULL, 0, NULL, "%d", 1);
910 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
911 [device_create wants 5 args])
915 EXTRA_KCFLAGS="$tmp_flags"
919 dnl # 2.6.13 API change, check whether class_device_create() is available.
920 dnl # Class_device_create() was introduced in 2.6.13 and depricated
921 dnl # class_simple_device_add() which was fully removed in 2.6.13.
923 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
924 SPL_CHECK_SYMBOL_EXPORT(
925 [class_device_create],
926 [drivers/base/class.c],
927 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
928 [class_device_create() is available])],
933 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
935 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
936 SPL_CHECK_SYMBOL_EXPORT(
937 [set_normalized_timespec],
939 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
940 [set_normalized_timespec() is available as export])],
945 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
946 dnl # previously it was available in time.h as an inline.
948 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
949 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
950 SPL_LINUX_TRY_COMPILE([
951 #include <linux/time.h>
952 void set_normalized_timespec(struct timespec *ts,
953 time_t sec, long nsec) { }
960 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
961 [set_normalized_timespec() is available as inline])
966 dnl # 2.6.18 API change,
967 dnl # timespec_sub() inline function available in linux/time.h
969 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
970 AC_MSG_CHECKING([whether timespec_sub() is available])
971 SPL_LINUX_TRY_COMPILE([
972 #include <linux/time.h>
974 struct timespec a, b, c = { 0 };
975 c = timespec_sub(a, b);
978 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
985 dnl # 2.6.19 API change,
986 dnl # check if init_utsname() is available in linux/utsname.h
988 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
989 AC_MSG_CHECKING([whether init_utsname() is available])
990 SPL_LINUX_TRY_COMPILE([
991 #include <linux/utsname.h>
993 struct new_utsname *a = init_utsname();
996 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1003 dnl # 2.6.26 API change,
1004 dnl # definition of struct fdtable relocated to linux/fdtable.h
1006 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1007 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1011 dnl # 2.6.14 API change,
1012 dnl # check whether 'files_fdtable()' exists
1014 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1015 AC_MSG_CHECKING([whether files_fdtable() is available])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/sched.h>
1018 #include <linux/file.h>
1019 #ifdef HAVE_FDTABLE_HEADER
1020 #include <linux/fdtable.h>
1023 struct files_struct *files = current->files;
1024 struct fdtable *fdt = files_fdtable(files);
1027 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1034 dnl # 2.6.18 API change,
1035 dnl # added linux/uaccess.h
1037 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1038 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1042 dnl # 2.6.12 API change,
1043 dnl # check whether 'kmalloc_node()' is available.
1045 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1046 AC_MSG_CHECKING([whether kmalloc_node() is available])
1047 SPL_LINUX_TRY_COMPILE([
1048 #include <linux/slab.h>
1050 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1053 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1060 dnl # 2.6.9 API change,
1061 dnl # check whether 'monotonic_clock()' is available it may
1062 dnl # be available for some archs but not others.
1064 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1065 SPL_CHECK_SYMBOL_EXPORT(
1068 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1069 [monotonic_clock() is available])],
1074 dnl # 2.6.16 API change,
1075 dnl # check whether 'struct inode' has i_mutex
1077 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1078 AC_MSG_CHECKING([whether struct inode has i_mutex])
1079 SPL_LINUX_TRY_COMPILE([
1080 #include <linux/fs.h>
1081 #include <linux/mutex.h>
1084 mutex_init(&i.i_mutex);
1087 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1094 dnl # 2.6.29 API change,
1095 dnl # Adaptive mutexs introduced.
1097 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1098 AC_MSG_CHECKING([whether struct mutex has owner])
1099 SPL_LINUX_TRY_COMPILE([
1100 #include <linux/mutex.h>
1106 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1113 dnl # 2.6.18 API change,
1114 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1115 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1116 dnl # if the mutex validator is disabled or otherwise unavailable.
1118 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1119 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1120 SPL_LINUX_TRY_COMPILE([
1121 #include <linux/mutex.h>
1125 mutex_lock_nested(&mutex, 0);
1128 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1129 [mutex_lock_nested() is available])
1136 dnl # 2.6.27 API change,
1137 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1139 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1140 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1141 SPL_LINUX_TRY_COMPILE([
1142 #include <linux/smp.h>
1144 on_each_cpu(NULL, NULL, 0);
1147 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1148 [on_each_cpu wants 3 args])
1155 dnl # 2.6.18 API change,
1156 dnl # kallsyms_lookup_name no longer exported
1158 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1159 SPL_CHECK_SYMBOL_EXPORT(
1160 [kallsyms_lookup_name],
1162 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1163 [kallsyms_lookup_name() is available])],
1168 dnl # Proposed API change,
1169 dnl # This symbol is not available in stock kernels. You may build a
1170 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1171 dnl # these symbols for use. If your already rolling a custom kernel for
1172 dnl # your environment this is recommended.
1174 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1175 SPL_CHECK_SYMBOL_EXPORT(
1178 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1179 [get_vmalloc_info() is available])],
1184 dnl # 2.6.17 API change
1185 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1186 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1187 dnl # were exported in 2.6.17 for use by modules which was consistent with
1188 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1189 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1190 dnl # were dropped entirely leaving modules no way to directly iterate over
1191 dnl # the zone list. Because we need access to the zone helpers we check
1192 dnl # if the kernel contains the old or new implementation. Then we check
1193 dnl # to see if the symbols we need for each version are available. If they
1194 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1196 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1197 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1198 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1200 if test $rc -eq 0; then
1201 AC_MSG_RESULT([yes])
1202 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1209 dnl # Proposed API change,
1210 dnl # This symbol is not available in stock kernels. You may build a
1211 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1212 dnl # these symbols for use. If your already rolling a custom kernel for
1213 dnl # your environment this is recommended.
1215 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1216 SPL_CHECK_SYMBOL_EXPORT(
1217 [first_online_pgdat],
1219 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1220 [first_online_pgdat() is available])],
1225 dnl # Proposed API change,
1226 dnl # This symbol is not available in stock kernels. You may build a
1227 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1228 dnl # these symbols for use. If your already rolling a custom kernel for
1229 dnl # your environment this is recommended.
1231 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1232 SPL_CHECK_SYMBOL_EXPORT(
1233 [next_online_pgdat],
1235 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1236 [next_online_pgdat() is available])],
1241 dnl # Proposed API change,
1242 dnl # This symbol is not available in stock kernels. You may build a
1243 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1244 dnl # these symbols for use. If your already rolling a custom kernel for
1245 dnl # your environment this is recommended.
1247 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1248 SPL_CHECK_SYMBOL_EXPORT(
1251 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1252 [next_zone() is available])],
1257 dnl # 2.6.17 API change,
1258 dnl # See SPL_AC_PGDAT_HELPERS for details.
1260 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1261 SPL_CHECK_SYMBOL_EXPORT(
1264 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1265 [pgdat_list is available])],
1270 dnl # 2.6.18 API change,
1271 dnl # First introduced global_page_state() support as an inline.
1273 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1274 AC_MSG_CHECKING([whether global_page_state() is available])
1275 SPL_LINUX_TRY_COMPILE([
1276 #include <linux/mm.h>
1278 unsigned long state;
1279 state = global_page_state(0);
1282 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1283 [global_page_state() is available])
1290 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1291 dnl # Public global zone stats now include a free page count. However
1292 dnl # the enumerated names of the counters have changed since this API
1293 dnl # was introduced. We need to deduce the corrent name to use. This
1294 dnl # replaces the priviate get_zone_counts() interface.
1296 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1297 dnl # is 2.6.30 as of when this was written.
1299 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1300 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1301 SPL_LINUX_TRY_COMPILE([
1302 #include <linux/mm.h>
1304 enum zone_stat_item zsi;
1305 zsi = NR_FREE_PAGES;
1308 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1309 [Page state NR_FREE_PAGES is available])
1316 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1317 dnl # Public global zone stats now include an inactive page count. However
1318 dnl # the enumerated names of the counters have changed since this API
1319 dnl # was introduced. We need to deduce the corrent name to use. This
1320 dnl # replaces the priviate get_zone_counts() interface.
1322 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1323 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1324 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1326 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1327 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1328 SPL_LINUX_TRY_COMPILE([
1329 #include <linux/mm.h>
1331 enum zone_stat_item zsi;
1335 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1336 [Page state NR_INACTIVE is available])
1341 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1342 SPL_LINUX_TRY_COMPILE([
1343 #include <linux/mm.h>
1345 enum zone_stat_item zsi;
1346 zsi = NR_INACTIVE_ANON;
1349 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1350 [Page state NR_INACTIVE_ANON is available])
1355 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1356 SPL_LINUX_TRY_COMPILE([
1357 #include <linux/mm.h>
1359 enum zone_stat_item zsi;
1360 zsi = NR_INACTIVE_FILE;
1363 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1364 [Page state NR_INACTIVE_FILE is available])
1371 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1372 dnl # Public global zone stats now include an active page count. However
1373 dnl # the enumerated names of the counters have changed since this API
1374 dnl # was introduced. We need to deduce the corrent name to use. This
1375 dnl # replaces the priviate get_zone_counts() interface.
1377 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1378 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1379 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1381 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1382 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1383 SPL_LINUX_TRY_COMPILE([
1384 #include <linux/mm.h>
1386 enum zone_stat_item zsi;
1390 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1391 [Page state NR_ACTIVE is available])
1396 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1397 SPL_LINUX_TRY_COMPILE([
1398 #include <linux/mm.h>
1400 enum zone_stat_item zsi;
1401 zsi = NR_ACTIVE_ANON;
1404 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1405 [Page state NR_ACTIVE_ANON is available])
1410 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1411 SPL_LINUX_TRY_COMPILE([
1412 #include <linux/mm.h>
1414 enum zone_stat_item zsi;
1415 zsi = NR_ACTIVE_FILE;
1418 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1419 [Page state NR_ACTIVE_FILE is available])
1426 dnl # Proposed API change for legacy kernels.
1427 dnl # This symbol is not available in older kernels. For kernels post
1428 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1429 dnl # page state information. This symbol is only used in legacy kernels
1430 dnl # any only as a last resort.
1432 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1433 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1434 SPL_LINUX_TRY_COMPILE([
1436 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1437 #error "global_page_state needs NR_FREE_PAGES"
1440 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1441 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1442 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1443 #error "global_page_state needs NR_ACTIVE*"
1446 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1447 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1448 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1449 #error "global_page_state needs NR_INACTIVE*"
1455 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1456 [get_zone_counts() is needed])
1458 SPL_CHECK_SYMBOL_EXPORT(
1461 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1462 [get_zone_counts() is available])],
1468 dnl # 2.6.27 API change,
1469 dnl # The user_path_dir() replaces __user_walk()
1471 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1472 SPL_CHECK_SYMBOL_EXPORT(
1475 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1476 [user_path_dir() is available])],
1481 dnl # Symbol available in RHEL kernels not in stock kernels.
1483 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1484 SPL_CHECK_SYMBOL_EXPORT(
1487 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1488 [set_fs_pwd() is available])],
1493 dnl # 2.6.25 API change,
1494 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1496 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1497 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1498 SPL_LINUX_TRY_COMPILE([
1499 #include <linux/sched.h>
1500 #include <linux/fs_struct.h>
1502 set_fs_pwd(NULL, NULL);
1505 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1506 [set_fs_pwd() wants 2 args])
1513 dnl # SLES API change, never adopted in mainline,
1514 dnl # Third 'struct vfsmount *' argument removed.
1516 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1517 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1518 SPL_LINUX_TRY_COMPILE([
1519 #include <linux/fs.h>
1521 vfs_unlink(NULL, NULL);
1524 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1525 [vfs_unlink() wants 2 args])
1532 dnl # SLES API change, never adopted in mainline,
1533 dnl # Third and sixth 'struct vfsmount *' argument removed.
1535 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1536 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1537 SPL_LINUX_TRY_COMPILE([
1538 #include <linux/fs.h>
1540 vfs_rename(NULL, NULL, NULL, NULL);
1543 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1544 [vfs_rename() wants 4 args])
1551 dnl # 2.6.29 API change,
1552 dnl # check whether 'struct cred' exists
1554 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1555 AC_MSG_CHECKING([whether struct cred exists])
1556 SPL_LINUX_TRY_COMPILE([
1557 #include <linux/cred.h>
1563 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1570 dnl # Custom SPL patch may export this symbol.
1572 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1573 SPL_CHECK_SYMBOL_EXPORT(
1576 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1577 [groups_search() is available])],
1582 dnl # 2.6.x API change,
1583 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1585 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1586 SPL_CHECK_SYMBOL_EXPORT(
1587 [__put_task_struct],
1589 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1590 [__put_task_struct() is available])],
1595 dnl # 2.6.32 API change,
1596 dnl # Unused 'struct file *' removed from prototype.
1598 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1599 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1600 SPL_LINUX_TRY_COMPILE([
1601 #include <linux/sysctl.h>
1603 proc_dostring(NULL, 0, NULL, NULL, NULL);
1606 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1607 [proc_handler() wants 5 args])
1614 dnl # 2.6.x API change,
1615 dnl # kvasprintf() function added.
1617 AC_DEFUN([SPL_AC_KVASPRINTF], [
1618 SPL_CHECK_SYMBOL_EXPORT(
1621 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1622 [kvasprintf() is available])],
1627 dnl # 2.6.35 API change,
1628 dnl # Unused 'struct dentry *' removed from prototype.
1630 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1631 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1632 SPL_LINUX_TRY_COMPILE([
1633 #include <linux/buffer_head.h>
1635 file_fsync(NULL, NULL, 0);
1638 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1639 [file_fsync() wants 3 args])
1646 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1647 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1648 dnl # condition. The fixed version is exported as a symbol. The race
1649 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1650 dnl # call that version while holding sem->wait_lock.
1652 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1653 SPL_CHECK_SYMBOL_EXPORT(
1655 [lib/rwsem-spinlock.c],
1656 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1657 [rwsem_is_locked() acquires sem->wait_lock])],