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
69 SPL_AC_FS_STRUCT_SPINLOCK
72 SPL_AC_PUT_TASK_STRUCT
73 SPL_AC_5ARGS_PROC_HANDLER
75 SPL_AC_3ARGS_FILE_FSYNC
76 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
79 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
80 modpost=$LINUX/scripts/Makefile.modpost
81 AC_MSG_CHECKING([kernel file name for module symbols])
82 if test -f "$modpost"; then
83 if grep -q Modules.symvers $modpost; then
84 LINUX_SYMBOLS=Modules.symvers
86 LINUX_SYMBOLS=Module.symvers
91 AC_MSG_RESULT($LINUX_SYMBOLS)
92 AC_SUBST(LINUX_SYMBOLS)
95 AC_DEFUN([SPL_AC_KERNEL], [
97 AS_HELP_STRING([--with-linux=PATH],
98 [Path to kernel source]),
99 [kernelsrc="$withval"])
101 AC_ARG_WITH([linux-obj],
102 AS_HELP_STRING([--with-linux-obj=PATH],
103 [Path to kernel build objects]),
104 [kernelbuild="$withval"])
106 AC_MSG_CHECKING([kernel source directory])
107 if test -z "$kernelsrc"; then
108 headersdir="/lib/modules/$(uname -r)/build"
109 if test -e "$headersdir"; then
110 sourcelink=$(readlink -f "$headersdir")
112 sourcelink=$(ls -1d /usr/src/kernels/* \
114 2>/dev/null | grep -v obj | tail -1)
117 if test -n "$sourcelink" && test -e ${sourcelink}; then
118 kernelsrc=`readlink -f ${sourcelink}`
120 AC_MSG_RESULT([Not found])
122 *** Please make sure the kernel devel package for your distribution
123 *** is installed then try again. If that fails you can specify the
124 *** location of the kernel source with the '--with-linux=PATH' option.])
127 if test "$kernelsrc" = "NONE"; then
132 AC_MSG_RESULT([$kernelsrc])
133 AC_MSG_CHECKING([kernel build directory])
134 if test -z "$kernelbuild"; then
135 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
136 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
137 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
138 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
139 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
140 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
142 kernelbuild=${kernelsrc}
145 AC_MSG_RESULT([$kernelbuild])
147 AC_MSG_CHECKING([kernel source version])
148 utsrelease1=$kernelbuild/include/linux/version.h
149 utsrelease2=$kernelbuild/include/linux/utsrelease.h
150 utsrelease3=$kernelbuild/include/generated/utsrelease.h
151 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
152 utsrelease=linux/version.h
153 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
154 utsrelease=linux/utsrelease.h
155 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
156 utsrelease=generated/utsrelease.h
159 if test "$utsrelease"; then
160 kernsrcver=`(echo "#include <$utsrelease>";
161 echo "kernsrcver=UTS_RELEASE") |
162 cpp -I $kernelbuild/include |
163 grep "^kernsrcver=" | cut -d \" -f 2`
165 if test -z "$kernsrcver"; then
166 AC_MSG_RESULT([Not found])
167 AC_MSG_ERROR([*** Cannot determine kernel version.])
170 AC_MSG_RESULT([Not found])
171 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
174 AC_MSG_RESULT([$kernsrcver])
177 LINUX_OBJ=${kernelbuild}
178 LINUX_VERSION=${kernsrcver}
182 AC_SUBST(LINUX_VERSION)
184 SPL_AC_MODULE_SYMVERS
188 dnl # Explicitly check for gawk, we require it for the the usermode
189 dnl # helper. For some reason the standard awk command does not
190 dnl # behave correctly when invoked from the usermode helper.
192 AC_DEFUN([SPL_AC_GAWK], [
193 AS_IF([test "x$AWK" != xgawk], [
195 *** Required util gawk missing. Please install the required
196 *** gawk package for your distribution and try again.])
201 dnl # Default SPL user configuration
203 AC_DEFUN([SPL_AC_CONFIG_USER], [
208 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
209 dnl # are missing it is non-fatal but you will not be able to build
210 dnl # RPM packages and will be warned if you try too.
212 AC_DEFUN([SPL_AC_RPM], [
216 AC_MSG_CHECKING([whether $RPM is available])
217 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
218 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
220 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
223 AC_MSG_RESULT([$HAVE_RPM])
226 AC_MSG_CHECKING([whether $RPMBUILD is available])
227 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
228 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
230 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
233 AC_MSG_RESULT([$HAVE_RPMBUILD])
238 AC_SUBST(RPM_VERSION)
240 AC_SUBST(HAVE_RPMBUILD)
242 AC_SUBST(RPMBUILD_VERSION)
246 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
247 dnl # tools are missing it is non-fatal but you will not be able to build
248 dnl # DEB packages and will be warned if you try too.
250 AC_DEFUN([SPL_AC_DPKG], [
252 DPKGBUILD=dpkg-buildpackage
254 AC_MSG_CHECKING([whether $DPKG is available])
255 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
256 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
258 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
261 AC_MSG_RESULT([$HAVE_DPKG])
264 AC_MSG_CHECKING([whether $DPKGBUILD is available])
265 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
266 DPKGBUILD_VERSION=$(echo $tmp | \
267 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
269 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
272 AC_MSG_RESULT([$HAVE_DPKGBUILD])
277 AC_SUBST(DPKG_VERSION)
279 AC_SUBST(HAVE_DPKGBUILD)
281 AC_SUBST(DPKGBUILD_VERSION)
285 dnl # Until native packaging for various different packing systems
286 dnl # can be added the least we can do is attempt to use alien to
287 dnl # convert the RPM packages to the needed package type. This is
288 dnl # a hack but so far it has worked reasonable well.
290 AC_DEFUN([SPL_AC_ALIEN], [
293 AC_MSG_CHECKING([whether $ALIEN is available])
294 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
295 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
297 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
300 AC_MSG_RESULT([$HAVE_ALIEN])
305 AC_SUBST(ALIEN_VERSION)
309 dnl # Using the VENDOR tag from config.guess set the default
310 dnl # package type for 'make pkg': (rpm | deb | tgz)
312 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
313 AC_MSG_CHECKING([linux distribution])
314 if test -f /etc/redhat-release ; then
316 elif test -f /etc/fedora-release ; then
318 elif test -f /etc/lsb-release ; then
320 elif test -f /etc/debian_version ; then
322 elif test -f /etc/SuSE-release ; then
324 elif test -f /etc/slackware-version ; then
326 elif test -f /etc/gentoo-release ; then
331 AC_MSG_RESULT([$VENDOR])
334 AC_MSG_CHECKING([default package type])
336 fedora) DEFAULT_PACKAGE=rpm ;;
337 redhat) DEFAULT_PACKAGE=rpm ;;
338 sles) DEFAULT_PACKAGE=rpm ;;
339 ubuntu) DEFAULT_PACKAGE=deb ;;
340 debian) DEFAULT_PACKAGE=deb ;;
341 slackware) DEFAULT_PACKAGE=tgz ;;
342 *) DEFAULT_PACKAGE=rpm ;;
345 AC_MSG_RESULT([$DEFAULT_PACKAGE])
346 AC_SUBST(DEFAULT_PACKAGE)
350 dnl # Default SPL user configuration
352 AC_DEFUN([SPL_AC_PACKAGE], [
356 SPL_AC_DEFAULT_PACKAGE
359 AC_DEFUN([SPL_AC_LICENSE], [
360 AC_MSG_CHECKING([spl license])
362 AC_MSG_RESULT([$LICENSE])
363 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
367 AC_DEFUN([SPL_AC_CONFIG], [
369 AC_ARG_WITH([config],
370 AS_HELP_STRING([--with-config=CONFIG],
371 [Config file 'kernel|user|all|srpm']),
372 [SPL_CONFIG="$withval"])
374 AC_MSG_CHECKING([spl config])
375 AC_MSG_RESULT([$SPL_CONFIG]);
378 case "$SPL_CONFIG" in
379 kernel) SPL_AC_CONFIG_KERNEL ;;
380 user) SPL_AC_CONFIG_USER ;;
381 all) SPL_AC_CONFIG_KERNEL
382 SPL_AC_CONFIG_USER ;;
385 AC_MSG_RESULT([Error!])
386 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
387 user kernel|user|all|srpm]) ;;
390 AM_CONDITIONAL([CONFIG_USER],
391 [test "$SPL_CONFIG" = user] ||
392 [test "$SPL_CONFIG" = all])
393 AM_CONDITIONAL([CONFIG_KERNEL],
394 [test "$SPL_CONFIG" = kernel] ||
395 [test "$SPL_CONFIG" = all])
399 dnl # Enable if the SPL should be compiled with internal debugging enabled.
400 dnl # By default this support is disabled.
402 AC_DEFUN([SPL_AC_DEBUG], [
403 AC_MSG_CHECKING([whether debugging is enabled])
404 AC_ARG_ENABLE([debug],
405 [AS_HELP_STRING([--enable-debug],
406 [Enable generic debug support @<:@default=no@:>@])],
410 AS_IF([test "x$enable_debug" = xyes],
412 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
413 DEBUG_CFLAGS="-DDEBUG -Werror"
416 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
417 DEBUG_CFLAGS="-DNDEBUG"
420 AC_SUBST(DEBUG_CFLAGS)
421 AC_MSG_RESULT([$enable_debug])
425 dnl # Enabled by default it provides a minimal level of memory tracking.
426 dnl # A total count of bytes allocated is kept for each alloc and free.
427 dnl # Then at module unload time a report to the console will be printed
428 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
429 dnl # and provide an easy way to inspect the kmem based slab.
431 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
432 AC_ARG_ENABLE([debug-kmem],
433 [AS_HELP_STRING([--enable-debug-kmem],
434 [Enable basic kmem accounting @<:@default=yes@:>@])],
436 [enable_debug_kmem=yes])
438 AS_IF([test "x$enable_debug_kmem" = xyes],
439 [AC_DEFINE([DEBUG_KMEM], [1],
440 [Define to 1 to enable basic kmem accounting])
441 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
443 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
444 AC_MSG_RESULT([$enable_debug_kmem])
448 dnl # Disabled by default it provides detailed memory tracking. This
449 dnl # feature also requires --enable-debug-kmem to be set. When enabled
450 dnl # not only will total bytes be tracked but also the location of every
451 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
452 dnl # addresses and where they were allocated will be dumped to the console.
453 dnl # Enabling this feature has a significant impact on performance but it
454 dnl # makes finding memory leaks pretty straight forward.
456 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
457 AC_ARG_ENABLE([debug-kmem-tracking],
458 [AS_HELP_STRING([--enable-debug-kmem-tracking],
459 [Enable detailed kmem tracking @<:@default=no@:>@])],
461 [enable_debug_kmem_tracking=no])
463 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
464 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
465 [Define to 1 to enable detailed kmem tracking])
466 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
468 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
469 AC_MSG_RESULT([$enable_debug_kmem_tracking])
473 dnl # SPL_LINUX_CONFTEST
475 AC_DEFUN([SPL_LINUX_CONFTEST], [
476 cat confdefs.h - <<_ACEOF >conftest.c
482 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
484 m4_define([SPL_LANG_PROGRAM], [
489 dnl Do *not* indent the following line: there may be CPP directives.
490 dnl Don't move the `;' right after for the same reason.
498 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
500 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
501 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
502 rm -Rf build && mkdir -p build
503 echo "obj-m := conftest.o" >build/Makefile
505 [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])],
507 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
513 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
515 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
516 [SPL_LINUX_COMPILE_IFELSE(
517 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
519 [test -s build/conftest.o],
524 dnl # SPL_LINUX_CONFIG
526 AC_DEFUN([SPL_LINUX_CONFIG],
527 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
528 SPL_LINUX_TRY_COMPILE([
529 #ifndef AUTOCONF_INCLUDED
530 #include <linux/config.h>
534 #error CONFIG_$1 not #defined
546 dnl # SPL_CHECK_SYMBOL_EXPORT
547 dnl # check symbol exported or not
549 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
550 [AC_MSG_CHECKING([whether symbol $1 is exported])
551 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
552 $LINUX_OBJ/Module*.symvers 2>/dev/null
554 if test $rc -ne 0; then
557 grep -q -E "EXPORT_SYMBOL.*($1)" \
558 "$LINUX_OBJ/$file" 2>/dev/null
560 if test $rc -eq 0; then
565 if test $export -eq 0; then
579 dnl # SPL_CHECK_HEADER
580 dnl # check whether header exists and define HAVE_$2_HEADER
582 AC_DEFUN([SPL_CHECK_HEADER],
583 [AC_MSG_CHECKING([whether header $1 exists])
584 SPL_LINUX_TRY_COMPILE([
589 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
599 dnl # Use the atomic implemenation based on global spinlocks. This
600 dnl # should only be needed by 32-bit kernels which do not provide
601 dnl # the atomic64_* API. It may be optionally enabled as a fallback
602 dnl # if problems are observed with the direct mapping to the native
603 dnl # Linux atomic operations. You may not disable atomic spinlocks
604 dnl # if you kernel does not an atomic64_* API.
606 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
607 AC_ARG_ENABLE([atomic-spinlocks],
608 [AS_HELP_STRING([--enable-atomic-spinlocks],
609 [Atomic types use spinlocks @<:@default=check@:>@])],
611 [enable_atomic_spinlocks=check])
613 SPL_LINUX_TRY_COMPILE([
614 #include <asm/atomic.h>
619 AC_DEFINE(HAVE_ATOMIC64_T, 1,
620 [kernel defines atomic64_t])
625 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
626 AS_IF([test "x$have_atomic64_t" = xyes], [
627 enable_atomic_spinlocks=no
629 enable_atomic_spinlocks=yes
633 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
634 AC_DEFINE([ATOMIC_SPINLOCK], [1],
635 [Atomic types use spinlocks])
637 AS_IF([test "x$have_atomic64_t" = xno], [
639 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
643 AC_MSG_CHECKING([whether atomic types use spinlocks])
644 AC_MSG_RESULT([$enable_atomic_spinlocks])
646 AC_MSG_CHECKING([whether kernel defines atomic64_t])
647 AC_MSG_RESULT([$have_atomic64_t])
651 dnl # 2.6.24 API change,
652 dnl # check if atomic64_cmpxchg is defined
654 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
655 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
656 SPL_LINUX_TRY_COMPILE([
657 #include <asm/atomic.h>
658 #include <asm/system.h>
660 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
663 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
664 [kernel defines atomic64_cmpxchg])
671 dnl # 2.6.24 API change,
672 dnl # check if atomic64_xchg is defined
674 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
675 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
676 SPL_LINUX_TRY_COMPILE([
677 #include <asm/atomic.h>
679 atomic64_xchg((atomic64_t *)NULL, 0);
682 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
683 [kernel defines atomic64_xchg])
690 dnl # 2.6.24 API change,
691 dnl # check if uintptr_t typedef is defined
693 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
694 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
695 SPL_LINUX_TRY_COMPILE([
696 #include <linux/types.h>
701 AC_DEFINE(HAVE_UINTPTR_T, 1,
702 [kernel defines uintptr_t])
709 dnl # 2.6.20 API change,
710 dnl # INIT_WORK use 2 args and not store data inside
712 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
713 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
714 SPL_LINUX_TRY_COMPILE([
715 #include <linux/workqueue.h>
717 struct work_struct work;
718 INIT_WORK(&work, NULL, NULL);
721 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
722 [INIT_WORK wants 3 args])
729 dnl # 2.6.21 API change,
730 dnl # 'register_sysctl_table' use only one argument instead of two
732 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
733 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
734 SPL_LINUX_TRY_COMPILE([
735 #include <linux/sysctl.h>
737 return register_sysctl_table(NULL,0);
740 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
741 [register_sysctl_table() wants 2 args])
748 dnl # 2.6.23 API change
749 dnl # Old set_shrinker API replaced with register_shrinker
751 AC_DEFUN([SPL_AC_SET_SHRINKER], [
752 AC_MSG_CHECKING([whether set_shrinker() available])
753 SPL_LINUX_TRY_COMPILE([
754 #include <linux/mm.h>
756 return set_shrinker(DEFAULT_SEEKS, NULL);
759 AC_DEFINE(HAVE_SET_SHRINKER, 1,
760 [set_shrinker() available])
767 dnl # 2.6.35 API change,
768 dnl # Add context to shrinker callback
770 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
771 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
772 tmp_flags="$EXTRA_KCFLAGS"
773 EXTRA_KCFLAGS="-Werror"
774 SPL_LINUX_TRY_COMPILE([
775 #include <linux/mm.h>
777 int shrinker_cb(struct shrinker *, int, unsigned int);
779 struct shrinker cache_shrinker = {
780 .shrink = shrinker_cb,
781 .seeks = DEFAULT_SEEKS,
783 register_shrinker(&cache_shrinker);
786 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
787 [shrinker callback wants 3 args])
791 EXTRA_KCFLAGS="$tmp_flags"
795 dnl # 2.6.25 API change,
796 dnl # struct path entry added to struct nameidata
798 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
799 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
800 SPL_LINUX_TRY_COMPILE([
801 #include <linux/namei.h>
806 nd.path.dentry = NULL;
809 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
810 [struct path used in struct nameidata])
817 dnl # Custom SPL patch may export this system it is not required
819 AC_DEFUN([SPL_AC_TASK_CURR], [
820 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
821 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
826 dnl # 2.6.19 API change,
827 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
829 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
830 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
831 SPL_LINUX_TRY_COMPILE([
832 #include <linux/sysctl.h>
834 #ifndef CTL_UNNUMBERED
835 #error CTL_UNNUMBERED undefined
839 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
840 [unnumbered sysctl support exists])
847 dnl # 2.6.33 API change,
848 dnl # Removed .ctl_name from struct ctl_table.
850 AC_DEFUN([SPL_AC_CTL_NAME], [
851 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
852 SPL_LINUX_TRY_COMPILE([
853 #include <linux/sysctl.h>
855 struct ctl_table ctl;
859 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
866 dnl # 2.6.16 API change.
867 dnl # Check if 'fls64()' is available
869 AC_DEFUN([SPL_AC_FLS64],
870 [AC_MSG_CHECKING([whether fls64() is available])
871 SPL_LINUX_TRY_COMPILE([
872 #include <linux/bitops.h>
877 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
884 dnl # 2.6.18 API change, check whether device_create() is available.
885 dnl # Device_create() was introduced in 2.6.18 and depricated
886 dnl # class_device_create() which was fully removed in 2.6.26.
888 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
889 SPL_CHECK_SYMBOL_EXPORT(
891 [drivers/base/core.c],
892 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
893 [device_create() is available])],
898 dnl # 2.6.27 API change,
899 dnl # device_create() uses 5 args, new 'drvdata' argument.
901 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
902 AC_MSG_CHECKING([whether device_create() wants 5 args])
903 tmp_flags="$EXTRA_KCFLAGS"
904 EXTRA_KCFLAGS="-Werror"
905 SPL_LINUX_TRY_COMPILE([
906 #include <linux/device.h>
908 device_create(NULL, NULL, 0, NULL, "%d", 1);
911 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
912 [device_create wants 5 args])
916 EXTRA_KCFLAGS="$tmp_flags"
920 dnl # 2.6.13 API change, check whether class_device_create() is available.
921 dnl # Class_device_create() was introduced in 2.6.13 and depricated
922 dnl # class_simple_device_add() which was fully removed in 2.6.13.
924 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
925 SPL_CHECK_SYMBOL_EXPORT(
926 [class_device_create],
927 [drivers/base/class.c],
928 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
929 [class_device_create() is available])],
934 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
936 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
937 SPL_CHECK_SYMBOL_EXPORT(
938 [set_normalized_timespec],
940 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
941 [set_normalized_timespec() is available as export])],
946 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
947 dnl # previously it was available in time.h as an inline.
949 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
950 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
951 SPL_LINUX_TRY_COMPILE([
952 #include <linux/time.h>
953 void set_normalized_timespec(struct timespec *ts,
954 time_t sec, long nsec) { }
961 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
962 [set_normalized_timespec() is available as inline])
967 dnl # 2.6.18 API change,
968 dnl # timespec_sub() inline function available in linux/time.h
970 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
971 AC_MSG_CHECKING([whether timespec_sub() is available])
972 SPL_LINUX_TRY_COMPILE([
973 #include <linux/time.h>
975 struct timespec a, b, c = { 0 };
976 c = timespec_sub(a, b);
979 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
986 dnl # 2.6.19 API change,
987 dnl # check if init_utsname() is available in linux/utsname.h
989 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
990 AC_MSG_CHECKING([whether init_utsname() is available])
991 SPL_LINUX_TRY_COMPILE([
992 #include <linux/utsname.h>
994 struct new_utsname *a = init_utsname();
997 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1004 dnl # 2.6.26 API change,
1005 dnl # definition of struct fdtable relocated to linux/fdtable.h
1007 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1008 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1012 dnl # 2.6.14 API change,
1013 dnl # check whether 'files_fdtable()' exists
1015 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1016 AC_MSG_CHECKING([whether files_fdtable() is available])
1017 SPL_LINUX_TRY_COMPILE([
1018 #include <linux/sched.h>
1019 #include <linux/file.h>
1020 #ifdef HAVE_FDTABLE_HEADER
1021 #include <linux/fdtable.h>
1024 struct files_struct *files = current->files;
1025 struct fdtable *fdt = files_fdtable(files);
1028 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1035 dnl # 2.6.18 API change,
1036 dnl # added linux/uaccess.h
1038 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1039 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1043 dnl # 2.6.12 API change,
1044 dnl # check whether 'kmalloc_node()' is available.
1046 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1047 AC_MSG_CHECKING([whether kmalloc_node() is available])
1048 SPL_LINUX_TRY_COMPILE([
1049 #include <linux/slab.h>
1051 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1054 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1061 dnl # 2.6.9 API change,
1062 dnl # check whether 'monotonic_clock()' is available it may
1063 dnl # be available for some archs but not others.
1065 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1066 SPL_CHECK_SYMBOL_EXPORT(
1069 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1070 [monotonic_clock() is available])],
1075 dnl # 2.6.16 API change,
1076 dnl # check whether 'struct inode' has i_mutex
1078 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1079 AC_MSG_CHECKING([whether struct inode has i_mutex])
1080 SPL_LINUX_TRY_COMPILE([
1081 #include <linux/fs.h>
1082 #include <linux/mutex.h>
1085 mutex_init(&i.i_mutex);
1088 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1095 dnl # 2.6.29 API change,
1096 dnl # Adaptive mutexs introduced.
1098 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1099 AC_MSG_CHECKING([whether struct mutex has owner])
1100 SPL_LINUX_TRY_COMPILE([
1101 #include <linux/mutex.h>
1107 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1114 dnl # 2.6.18 API change,
1115 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1116 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1117 dnl # if the mutex validator is disabled or otherwise unavailable.
1119 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1120 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1121 SPL_LINUX_TRY_COMPILE([
1122 #include <linux/mutex.h>
1126 mutex_lock_nested(&mutex, 0);
1129 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1130 [mutex_lock_nested() is available])
1137 dnl # 2.6.27 API change,
1138 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1140 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1141 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1142 SPL_LINUX_TRY_COMPILE([
1143 #include <linux/smp.h>
1145 on_each_cpu(NULL, NULL, 0);
1148 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1149 [on_each_cpu wants 3 args])
1156 dnl # 2.6.18 API change,
1157 dnl # kallsyms_lookup_name no longer exported
1159 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1160 SPL_CHECK_SYMBOL_EXPORT(
1161 [kallsyms_lookup_name],
1163 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1164 [kallsyms_lookup_name() is available])],
1169 dnl # Proposed API change,
1170 dnl # This symbol is not available in stock kernels. You may build a
1171 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1172 dnl # these symbols for use. If your already rolling a custom kernel for
1173 dnl # your environment this is recommended.
1175 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1176 SPL_CHECK_SYMBOL_EXPORT(
1179 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1180 [get_vmalloc_info() is available])],
1185 dnl # 2.6.17 API change
1186 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1187 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1188 dnl # were exported in 2.6.17 for use by modules which was consistent with
1189 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1190 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1191 dnl # were dropped entirely leaving modules no way to directly iterate over
1192 dnl # the zone list. Because we need access to the zone helpers we check
1193 dnl # if the kernel contains the old or new implementation. Then we check
1194 dnl # to see if the symbols we need for each version are available. If they
1195 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1197 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1198 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1199 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1201 if test $rc -eq 0; then
1202 AC_MSG_RESULT([yes])
1203 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1210 dnl # Proposed API change,
1211 dnl # This symbol is not available in stock kernels. You may build a
1212 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1213 dnl # these symbols for use. If your already rolling a custom kernel for
1214 dnl # your environment this is recommended.
1216 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1217 SPL_CHECK_SYMBOL_EXPORT(
1218 [first_online_pgdat],
1220 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1221 [first_online_pgdat() is available])],
1226 dnl # Proposed API change,
1227 dnl # This symbol is not available in stock kernels. You may build a
1228 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1229 dnl # these symbols for use. If your already rolling a custom kernel for
1230 dnl # your environment this is recommended.
1232 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1233 SPL_CHECK_SYMBOL_EXPORT(
1234 [next_online_pgdat],
1236 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1237 [next_online_pgdat() is available])],
1242 dnl # Proposed API change,
1243 dnl # This symbol is not available in stock kernels. You may build a
1244 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1245 dnl # these symbols for use. If your already rolling a custom kernel for
1246 dnl # your environment this is recommended.
1248 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1249 SPL_CHECK_SYMBOL_EXPORT(
1252 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1253 [next_zone() is available])],
1258 dnl # 2.6.17 API change,
1259 dnl # See SPL_AC_PGDAT_HELPERS for details.
1261 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1262 SPL_CHECK_SYMBOL_EXPORT(
1265 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1266 [pgdat_list is available])],
1271 dnl # 2.6.18 API change,
1272 dnl # First introduced global_page_state() support as an inline.
1274 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1275 AC_MSG_CHECKING([whether global_page_state() is available])
1276 SPL_LINUX_TRY_COMPILE([
1277 #include <linux/mm.h>
1279 unsigned long state;
1280 state = global_page_state(0);
1283 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1284 [global_page_state() is available])
1291 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1292 dnl # Public global zone stats now include a free page count. However
1293 dnl # the enumerated names of the counters have changed since this API
1294 dnl # was introduced. We need to deduce the corrent name to use. This
1295 dnl # replaces the priviate get_zone_counts() interface.
1297 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1298 dnl # is 2.6.30 as of when this was written.
1300 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1301 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1302 SPL_LINUX_TRY_COMPILE([
1303 #include <linux/mm.h>
1305 enum zone_stat_item zsi;
1306 zsi = NR_FREE_PAGES;
1309 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1310 [Page state NR_FREE_PAGES is available])
1317 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1318 dnl # Public global zone stats now include an inactive page count. However
1319 dnl # the enumerated names of the counters have changed since this API
1320 dnl # was introduced. We need to deduce the corrent name to use. This
1321 dnl # replaces the priviate get_zone_counts() interface.
1323 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1324 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1325 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1327 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1328 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1329 SPL_LINUX_TRY_COMPILE([
1330 #include <linux/mm.h>
1332 enum zone_stat_item zsi;
1336 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1337 [Page state NR_INACTIVE is available])
1342 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1343 SPL_LINUX_TRY_COMPILE([
1344 #include <linux/mm.h>
1346 enum zone_stat_item zsi;
1347 zsi = NR_INACTIVE_ANON;
1350 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1351 [Page state NR_INACTIVE_ANON is available])
1356 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1357 SPL_LINUX_TRY_COMPILE([
1358 #include <linux/mm.h>
1360 enum zone_stat_item zsi;
1361 zsi = NR_INACTIVE_FILE;
1364 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1365 [Page state NR_INACTIVE_FILE is available])
1372 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1373 dnl # Public global zone stats now include an active page count. However
1374 dnl # the enumerated names of the counters have changed since this API
1375 dnl # was introduced. We need to deduce the corrent name to use. This
1376 dnl # replaces the priviate get_zone_counts() interface.
1378 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1379 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1380 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1382 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1383 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1384 SPL_LINUX_TRY_COMPILE([
1385 #include <linux/mm.h>
1387 enum zone_stat_item zsi;
1391 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1392 [Page state NR_ACTIVE is available])
1397 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1398 SPL_LINUX_TRY_COMPILE([
1399 #include <linux/mm.h>
1401 enum zone_stat_item zsi;
1402 zsi = NR_ACTIVE_ANON;
1405 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1406 [Page state NR_ACTIVE_ANON is available])
1411 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1412 SPL_LINUX_TRY_COMPILE([
1413 #include <linux/mm.h>
1415 enum zone_stat_item zsi;
1416 zsi = NR_ACTIVE_FILE;
1419 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1420 [Page state NR_ACTIVE_FILE is available])
1427 dnl # Proposed API change for legacy kernels.
1428 dnl # This symbol is not available in older kernels. For kernels post
1429 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1430 dnl # page state information. This symbol is only used in legacy kernels
1431 dnl # any only as a last resort.
1433 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1434 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1435 SPL_LINUX_TRY_COMPILE([
1437 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1438 #error "global_page_state needs NR_FREE_PAGES"
1441 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1442 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1443 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1444 #error "global_page_state needs NR_ACTIVE*"
1447 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1448 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1449 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1450 #error "global_page_state needs NR_INACTIVE*"
1456 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1457 [get_zone_counts() is needed])
1459 SPL_CHECK_SYMBOL_EXPORT(
1462 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1463 [get_zone_counts() is available])],
1469 dnl # 2.6.27 API change,
1470 dnl # The user_path_dir() replaces __user_walk()
1472 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1473 SPL_CHECK_SYMBOL_EXPORT(
1476 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1477 [user_path_dir() is available])],
1482 dnl # Symbol available in RHEL kernels not in stock kernels.
1484 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1485 SPL_CHECK_SYMBOL_EXPORT(
1488 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1489 [set_fs_pwd() is available])],
1494 dnl # 2.6.25 API change,
1495 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1497 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1498 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1499 SPL_LINUX_TRY_COMPILE([
1500 #include <linux/sched.h>
1501 #include <linux/fs_struct.h>
1503 set_fs_pwd(NULL, NULL);
1506 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1507 [set_fs_pwd() wants 2 args])
1514 dnl # SLES API change, never adopted in mainline,
1515 dnl # Third 'struct vfsmount *' argument removed.
1517 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1518 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1519 SPL_LINUX_TRY_COMPILE([
1520 #include <linux/fs.h>
1522 vfs_unlink(NULL, NULL);
1525 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1526 [vfs_unlink() wants 2 args])
1533 dnl # SLES API change, never adopted in mainline,
1534 dnl # Third and sixth 'struct vfsmount *' argument removed.
1536 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1537 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1538 SPL_LINUX_TRY_COMPILE([
1539 #include <linux/fs.h>
1541 vfs_rename(NULL, NULL, NULL, NULL);
1544 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1545 [vfs_rename() wants 4 args])
1552 dnl # 2.6.36 API change,
1553 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1554 dnl # a spinlock_t to improve the fastpath performance.
1556 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1557 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1558 SPL_LINUX_TRY_COMPILE([
1559 #include <linux/sched.h>
1560 #include <linux/fs_struct.h>
1562 struct fs_struct fs;
1563 spin_lock_init(&fs.lock);
1566 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1567 [struct fs_struct uses spinlock_t])
1574 dnl # 2.6.29 API change,
1575 dnl # check whether 'struct cred' exists
1577 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1578 AC_MSG_CHECKING([whether struct cred exists])
1579 SPL_LINUX_TRY_COMPILE([
1580 #include <linux/cred.h>
1586 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1593 dnl # Custom SPL patch may export this symbol.
1595 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1596 SPL_CHECK_SYMBOL_EXPORT(
1599 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1600 [groups_search() is available])],
1605 dnl # 2.6.x API change,
1606 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1608 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1609 SPL_CHECK_SYMBOL_EXPORT(
1610 [__put_task_struct],
1612 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1613 [__put_task_struct() is available])],
1618 dnl # 2.6.32 API change,
1619 dnl # Unused 'struct file *' removed from prototype.
1621 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1622 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1623 SPL_LINUX_TRY_COMPILE([
1624 #include <linux/sysctl.h>
1626 proc_dostring(NULL, 0, NULL, NULL, NULL);
1629 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1630 [proc_handler() wants 5 args])
1637 dnl # 2.6.x API change,
1638 dnl # kvasprintf() function added.
1640 AC_DEFUN([SPL_AC_KVASPRINTF], [
1641 SPL_CHECK_SYMBOL_EXPORT(
1644 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1645 [kvasprintf() is available])],
1650 dnl # 2.6.35 API change,
1651 dnl # Unused 'struct dentry *' removed from prototype.
1653 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1654 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1655 SPL_LINUX_TRY_COMPILE([
1656 #include <linux/buffer_head.h>
1658 file_fsync(NULL, NULL, 0);
1661 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1662 [file_fsync() wants 3 args])
1669 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1670 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1671 dnl # condition. The fixed version is exported as a symbol. The race
1672 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1673 dnl # call that version while holding sem->wait_lock.
1675 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1676 SPL_CHECK_SYMBOL_EXPORT(
1678 [lib/rwsem-spinlock.c],
1679 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1680 [rwsem_is_locked() acquires sem->wait_lock])],