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], [
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
16 AC_SUBST(KERNELMAKE_PARAMS)
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
24 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_3ARGS_INIT_WORK
30 SPL_AC_2ARGS_REGISTER_SYSCTL
32 SPL_AC_3ARGS_SHRINKER_CALLBACK
33 SPL_AC_PATH_IN_NAMEIDATA
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
47 SPL_AC_CLEAR_CLOSE_ON_EXEC
50 SPL_AC_MONOTONIC_CLOCK
53 SPL_AC_MUTEX_OWNER_TASK_STRUCT
54 SPL_AC_MUTEX_LOCK_NESTED
55 SPL_AC_3ARGS_ON_EACH_CPU
56 SPL_AC_KALLSYMS_LOOKUP_NAME
57 SPL_AC_GET_VMALLOC_INFO
59 SPL_AC_FIRST_ONLINE_PGDAT
60 SPL_AC_NEXT_ONLINE_PGDAT
63 SPL_AC_GLOBAL_PAGE_STATE
64 SPL_AC_ZONE_STAT_ITEM_FREE
65 SPL_AC_ZONE_STAT_ITEM_INACTIVE
66 SPL_AC_ZONE_STAT_ITEM_ACTIVE
67 SPL_AC_GET_ZONE_COUNTS
70 SPL_AC_2ARGS_SET_FS_PWD
71 SPL_AC_2ARGS_VFS_UNLINK
72 SPL_AC_4ARGS_VFS_RENAME
74 SPL_AC_2ARGS_VFS_FSYNC
75 SPL_AC_FS_STRUCT_SPINLOCK
78 SPL_AC_PUT_TASK_STRUCT
79 SPL_AC_5ARGS_PROC_HANDLER
81 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
82 SPL_AC_KERNEL_INVALIDATE_INODES
83 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
84 SPL_AC_SHRINK_DCACHE_MEMORY
85 SPL_AC_SHRINK_ICACHE_MEMORY
86 SPL_AC_KERN_PATH_PARENT_HEADER
87 SPL_AC_KERN_PATH_PARENT_SYMBOL
88 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
89 SPL_AC_SHRINK_CONTROL_STRUCT
90 SPL_AC_RWSEM_SPINLOCK_IS_RAW
91 SPL_AC_PMD_ALLOC_WITH_MASK
94 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
95 modpost=$LINUX/scripts/Makefile.modpost
96 AC_MSG_CHECKING([kernel file name for module symbols])
97 if test -f "$modpost"; then
98 if grep -q Modules.symvers $modpost; then
99 LINUX_SYMBOLS=Modules.symvers
101 LINUX_SYMBOLS=Module.symvers
104 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
106 *** Please make sure the kernel devel package for your distribution
107 *** is installed. If your building with a custom kernel make sure the
108 *** kernel is configured, built, and the '--with-linux=PATH' configure
109 *** option refers to the location of the kernel source.])
114 AC_MSG_RESULT($LINUX_SYMBOLS)
115 AC_SUBST(LINUX_SYMBOLS)
118 AC_DEFUN([SPL_AC_KERNEL], [
120 AS_HELP_STRING([--with-linux=PATH],
121 [Path to kernel source]),
122 [kernelsrc="$withval"])
124 AC_ARG_WITH([linux-obj],
125 AS_HELP_STRING([--with-linux-obj=PATH],
126 [Path to kernel build objects]),
127 [kernelbuild="$withval"])
129 AC_MSG_CHECKING([kernel source directory])
130 if test -z "$kernelsrc"; then
131 if test -e "/lib/modules/$(uname -r)/source"; then
132 headersdir="/lib/modules/$(uname -r)/source"
133 sourcelink=$(readlink -f "$headersdir")
134 elif test -e "/lib/modules/$(uname -r)/build"; then
135 headersdir="/lib/modules/$(uname -r)/build"
136 sourcelink=$(readlink -f "$headersdir")
138 sourcelink=$(ls -1d /usr/src/kernels/* \
140 2>/dev/null | grep -v obj | tail -1)
143 if test -n "$sourcelink" && test -e ${sourcelink}; then
144 kernelsrc=`readlink -f ${sourcelink}`
146 AC_MSG_RESULT([Not found])
148 *** Please make sure the kernel devel package for your distribution
149 *** is installed then try again. If that fails you can specify the
150 *** location of the kernel source with the '--with-linux=PATH' option.])
153 if test "$kernelsrc" = "NONE"; then
158 AC_MSG_RESULT([$kernelsrc])
159 AC_MSG_CHECKING([kernel build directory])
160 if test -z "$kernelbuild"; then
161 if test -e "/lib/modules/$(uname -r)/build"; then
162 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
163 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
164 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
165 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
166 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
167 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
168 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
170 kernelbuild=${kernelsrc}
173 AC_MSG_RESULT([$kernelbuild])
175 AC_MSG_CHECKING([kernel source version])
176 utsrelease1=$kernelbuild/include/linux/version.h
177 utsrelease2=$kernelbuild/include/linux/utsrelease.h
178 utsrelease3=$kernelbuild/include/generated/utsrelease.h
179 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
180 utsrelease=linux/version.h
181 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
182 utsrelease=linux/utsrelease.h
183 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
184 utsrelease=generated/utsrelease.h
187 if test "$utsrelease"; then
188 kernsrcver=`(echo "#include <$utsrelease>";
189 echo "kernsrcver=UTS_RELEASE") |
190 cpp -I $kernelbuild/include |
191 grep "^kernsrcver=" | cut -d \" -f 2`
193 if test -z "$kernsrcver"; then
194 AC_MSG_RESULT([Not found])
195 AC_MSG_ERROR([*** Cannot determine kernel version.])
198 AC_MSG_RESULT([Not found])
199 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
202 AC_MSG_RESULT([$kernsrcver])
205 LINUX_OBJ=${kernelbuild}
206 LINUX_VERSION=${kernsrcver}
210 AC_SUBST(LINUX_VERSION)
212 SPL_AC_MODULE_SYMVERS
215 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
216 SPL_LINUX_CONFIG([PREEMPT],
218 *** Kernel built with CONFIG_PREEMPT which is not supported.
219 ** You must rebuild your kernel without this option.]), [])
223 dnl # Default SPL user configuration
225 AC_DEFUN([SPL_AC_CONFIG_USER], [])
228 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
229 dnl # are missing it is non-fatal but you will not be able to build
230 dnl # RPM packages and will be warned if you try too.
232 AC_DEFUN([SPL_AC_RPM], [
236 AC_MSG_CHECKING([whether $RPM is available])
237 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
238 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
240 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
243 AC_MSG_RESULT([$HAVE_RPM])
246 AC_MSG_CHECKING([whether $RPMBUILD is available])
247 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
248 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
250 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
253 AC_MSG_RESULT([$HAVE_RPMBUILD])
258 AC_SUBST(RPM_VERSION)
260 AC_SUBST(HAVE_RPMBUILD)
262 AC_SUBST(RPMBUILD_VERSION)
266 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
267 dnl # tools are missing it is non-fatal but you will not be able to build
268 dnl # DEB packages and will be warned if you try too.
270 AC_DEFUN([SPL_AC_DPKG], [
272 DPKGBUILD=dpkg-buildpackage
274 AC_MSG_CHECKING([whether $DPKG is available])
275 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
276 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
278 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
281 AC_MSG_RESULT([$HAVE_DPKG])
284 AC_MSG_CHECKING([whether $DPKGBUILD is available])
285 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
286 DPKGBUILD_VERSION=$(echo $tmp | \
287 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
289 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
292 AC_MSG_RESULT([$HAVE_DPKGBUILD])
297 AC_SUBST(DPKG_VERSION)
299 AC_SUBST(HAVE_DPKGBUILD)
301 AC_SUBST(DPKGBUILD_VERSION)
305 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
306 dnl # tools are missing it is non-fatal but you will not be able to
307 dnl # build Arch Linux packages and will be warned if you try too.
309 AC_DEFUN([SPL_AC_PACMAN], [
313 AC_MSG_CHECKING([whether $PACMAN is available])
314 tmp=$($PACMAN --version 2>/dev/null)
315 AS_IF([test -n "$tmp"], [
316 PACMAN_VERSION=$(echo $tmp |
317 $AWK '/Pacman/ { print $[3] }' |
320 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
323 AC_MSG_RESULT([$HAVE_PACMAN])
326 AC_MSG_CHECKING([whether $MAKEPKG is available])
327 tmp=$($MAKEPKG --version 2>/dev/null)
328 AS_IF([test -n "$tmp"], [
329 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
331 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
334 AC_MSG_RESULT([$HAVE_MAKEPKG])
337 AC_SUBST(HAVE_PACMAN)
339 AC_SUBST(PACMAN_VERSION)
341 AC_SUBST(HAVE_MAKEPKG)
343 AC_SUBST(MAKEPKG_VERSION)
347 dnl # Until native packaging for various different packing systems
348 dnl # can be added the least we can do is attempt to use alien to
349 dnl # convert the RPM packages to the needed package type. This is
350 dnl # a hack but so far it has worked reasonable well.
352 AC_DEFUN([SPL_AC_ALIEN], [
355 AC_MSG_CHECKING([whether $ALIEN is available])
356 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
357 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
359 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
362 AC_MSG_RESULT([$HAVE_ALIEN])
367 AC_SUBST(ALIEN_VERSION)
371 dnl # Using the VENDOR tag from config.guess set the default
372 dnl # package type for 'make pkg': (rpm | deb | tgz)
374 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
375 AC_MSG_CHECKING([linux distribution])
376 if test -f /etc/toss-release ; then
378 elif test -f /etc/fedora-release ; then
380 elif test -f /etc/redhat-release ; then
382 elif test -f /etc/gentoo-release ; then
384 elif test -f /etc/arch-release ; then
386 elif test -f /etc/SuSE-release ; then
388 elif test -f /etc/slackware-version ; then
390 elif test -f /etc/lunar.release ; then
392 elif test -f /etc/lsb-release ; then
394 elif test -f /etc/debian_version ; then
399 AC_MSG_RESULT([$VENDOR])
402 AC_MSG_CHECKING([default package type])
404 toss) DEFAULT_PACKAGE=rpm ;;
405 redhat) DEFAULT_PACKAGE=rpm ;;
406 fedora) DEFAULT_PACKAGE=rpm ;;
407 gentoo) DEFAULT_PACKAGE=tgz ;;
408 arch) DEFAULT_PACKAGE=arch ;;
409 sles) DEFAULT_PACKAGE=rpm ;;
410 slackware) DEFAULT_PACKAGE=tgz ;;
411 lunar) DEFAULT_PACKAGE=tgz ;;
412 ubuntu) DEFAULT_PACKAGE=deb ;;
413 debian) DEFAULT_PACKAGE=deb ;;
414 *) DEFAULT_PACKAGE=rpm ;;
417 AC_MSG_RESULT([$DEFAULT_PACKAGE])
418 AC_SUBST(DEFAULT_PACKAGE)
422 dnl # Default SPL user configuration
424 AC_DEFUN([SPL_AC_PACKAGE], [
425 SPL_AC_DEFAULT_PACKAGE
430 AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
433 AC_DEFUN([SPL_AC_LICENSE], [
434 AC_MSG_CHECKING([spl license])
436 AC_MSG_RESULT([$LICENSE])
437 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
441 AC_DEFUN([SPL_AC_CONFIG], [
443 AC_ARG_WITH([config],
444 AS_HELP_STRING([--with-config=CONFIG],
445 [Config file 'kernel|user|all|srpm']),
446 [SPL_CONFIG="$withval"])
448 AC_MSG_CHECKING([spl config])
449 AC_MSG_RESULT([$SPL_CONFIG]);
452 case "$SPL_CONFIG" in
453 kernel) SPL_AC_CONFIG_KERNEL ;;
454 user) SPL_AC_CONFIG_USER ;;
455 all) SPL_AC_CONFIG_KERNEL
456 SPL_AC_CONFIG_USER ;;
459 AC_MSG_RESULT([Error!])
460 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
461 user kernel|user|all|srpm]) ;;
464 AM_CONDITIONAL([CONFIG_USER],
465 [test "$SPL_CONFIG" = user] ||
466 [test "$SPL_CONFIG" = all])
467 AM_CONDITIONAL([CONFIG_KERNEL],
468 [test "$SPL_CONFIG" = kernel] ||
469 [test "$SPL_CONFIG" = all])
473 dnl # Enable if the SPL should be compiled with internal debugging enabled.
474 dnl # By default this support is disabled.
476 AC_DEFUN([SPL_AC_DEBUG], [
477 AC_MSG_CHECKING([whether debugging is enabled])
478 AC_ARG_ENABLE([debug],
479 [AS_HELP_STRING([--enable-debug],
480 [Enable generic debug support @<:@default=no@:>@])],
484 AS_IF([test "x$enable_debug" = xyes],
486 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
487 DEBUG_CFLAGS="-DDEBUG -Werror"
488 DEBUG_SPL="_with_debug"
490 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
491 DEBUG_CFLAGS="-DNDEBUG"
492 DEBUG_SPL="_without_debug"
495 AC_SUBST(DEBUG_CFLAGS)
497 AC_MSG_RESULT([$enable_debug])
501 dnl # Enabled by default it provides a basic debug log infrastructure.
502 dnl # Each subsystem registers itself with a name and logs messages
503 dnl # using predefined types. If the debug mask it set to allow the
504 dnl # message type it will be written to the internal log. The log
505 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
506 dnl # after dumping the log it must be decoded using the spl utility.
508 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
509 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
511 AC_DEFUN([SPL_AC_DEBUG_LOG], [
512 AC_ARG_ENABLE([debug-log],
513 [AS_HELP_STRING([--enable-debug-log],
514 [Enable basic debug logging @<:@default=yes@:>@])],
516 [enable_debug_log=yes])
518 AS_IF([test "x$enable_debug_log" = xyes],
520 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
521 DEBUG_LOG="_with_debug_log"
522 AC_DEFINE([DEBUG_LOG], [1],
523 [Define to 1 to enable basic debug logging])
525 DEBUG_LOG="_without_debug_log"
529 AC_MSG_CHECKING([whether basic debug logging is enabled])
530 AC_MSG_RESULT([$enable_debug_log])
534 dnl # Enabled by default it provides a minimal level of memory tracking.
535 dnl # A total count of bytes allocated is kept for each alloc and free.
536 dnl # Then at module unload time a report to the console will be printed
537 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
538 dnl # and provide an easy way to inspect the kmem based slab.
540 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
541 AC_ARG_ENABLE([debug-kmem],
542 [AS_HELP_STRING([--enable-debug-kmem],
543 [Enable basic kmem accounting @<:@default=yes@:>@])],
545 [enable_debug_kmem=yes])
547 AS_IF([test "x$enable_debug_kmem" = xyes],
549 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
550 DEBUG_KMEM="_with_debug_kmem"
551 AC_DEFINE([DEBUG_KMEM], [1],
552 [Define to 1 to enable basic kmem accounting])
554 DEBUG_KMEM="_without_debug_kmem"
558 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
559 AC_MSG_RESULT([$enable_debug_kmem])
563 dnl # Disabled by default it provides detailed memory tracking. This
564 dnl # feature also requires --enable-debug-kmem to be set. When enabled
565 dnl # not only will total bytes be tracked but also the location of every
566 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
567 dnl # addresses and where they were allocated will be dumped to the console.
568 dnl # Enabling this feature has a significant impact on performance but it
569 dnl # makes finding memory leaks pretty straight forward.
571 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
572 AC_ARG_ENABLE([debug-kmem-tracking],
573 [AS_HELP_STRING([--enable-debug-kmem-tracking],
574 [Enable detailed kmem tracking @<:@default=no@:>@])],
576 [enable_debug_kmem_tracking=no])
578 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
580 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
581 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
582 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
583 [Define to 1 to enable detailed kmem tracking])
585 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
588 AC_SUBST(DEBUG_KMEM_TRACKING)
589 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
590 AC_MSG_RESULT([$enable_debug_kmem_tracking])
594 dnl # SPL_LINUX_CONFTEST
596 AC_DEFUN([SPL_LINUX_CONFTEST], [
597 cat confdefs.h - <<_ACEOF >conftest.c
603 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
605 m4_define([SPL_LANG_PROGRAM], [
610 dnl Do *not* indent the following line: there may be CPP directives.
611 dnl Don't move the `;' right after for the same reason.
619 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
621 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
622 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
623 rm -Rf build && mkdir -p build
624 echo "obj-m := conftest.o" >build/Makefile
626 [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])],
628 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
634 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
636 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
637 [SPL_LINUX_COMPILE_IFELSE(
638 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
640 [test -s build/conftest.o],
645 dnl # SPL_LINUX_CONFIG
647 AC_DEFUN([SPL_LINUX_CONFIG],
648 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
649 SPL_LINUX_TRY_COMPILE([
650 #include <linux/module.h>
653 #error CONFIG_$1 not #defined
665 dnl # SPL_CHECK_SYMBOL_EXPORT
666 dnl # check symbol exported or not
668 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
669 [AC_MSG_CHECKING([whether symbol $1 is exported])
670 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
671 $LINUX_OBJ/Module*.symvers 2>/dev/null
673 if test $rc -ne 0; then
676 grep -q -E "EXPORT_SYMBOL.*($1)" \
677 "$LINUX_OBJ/$file" 2>/dev/null
679 if test $rc -eq 0; then
684 if test $export -eq 0; then
698 dnl # SPL_CHECK_SYMBOL_HEADER
699 dnl # check if a symbol prototype is defined in listed headers.
701 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
702 AC_MSG_CHECKING([whether symbol $1 exists in header])
705 grep -q "$2" "$LINUX/$file" 2>/dev/null
707 if test $rc -eq 0; then
712 if test $header -eq 0; then
722 dnl # SPL_CHECK_HEADER
723 dnl # check whether header exists and define HAVE_$2_HEADER
725 AC_DEFUN([SPL_CHECK_HEADER],
726 [AC_MSG_CHECKING([whether header $1 exists])
727 SPL_LINUX_TRY_COMPILE([
732 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
742 dnl # Use the atomic implemenation based on global spinlocks. This
743 dnl # should only be needed by 32-bit kernels which do not provide
744 dnl # the atomic64_* API. It may be optionally enabled as a fallback
745 dnl # if problems are observed with the direct mapping to the native
746 dnl # Linux atomic operations. You may not disable atomic spinlocks
747 dnl # if you kernel does not an atomic64_* API.
749 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
750 AC_ARG_ENABLE([atomic-spinlocks],
751 [AS_HELP_STRING([--enable-atomic-spinlocks],
752 [Atomic types use spinlocks @<:@default=check@:>@])],
754 [enable_atomic_spinlocks=check])
756 SPL_LINUX_TRY_COMPILE([
757 #include <asm/atomic.h>
759 atomic64_t *ptr __attribute__ ((unused));
762 AC_DEFINE(HAVE_ATOMIC64_T, 1,
763 [kernel defines atomic64_t])
768 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
769 AS_IF([test "x$have_atomic64_t" = xyes], [
770 enable_atomic_spinlocks=no
772 enable_atomic_spinlocks=yes
776 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
777 AC_DEFINE([ATOMIC_SPINLOCK], [1],
778 [Atomic types use spinlocks])
780 AS_IF([test "x$have_atomic64_t" = xno], [
782 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
786 AC_MSG_CHECKING([whether atomic types use spinlocks])
787 AC_MSG_RESULT([$enable_atomic_spinlocks])
789 AC_MSG_CHECKING([whether kernel defines atomic64_t])
790 AC_MSG_RESULT([$have_atomic64_t])
794 dnl # 2.6.24 API change,
795 dnl # check if atomic64_cmpxchg is defined
797 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
798 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
799 SPL_LINUX_TRY_COMPILE([
800 #include <asm/atomic.h>
801 #include <asm/system.h>
803 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
806 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
807 [kernel defines atomic64_cmpxchg])
814 dnl # 2.6.24 API change,
815 dnl # check if atomic64_xchg is defined
817 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
818 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
819 SPL_LINUX_TRY_COMPILE([
820 #include <asm/atomic.h>
822 atomic64_xchg((atomic64_t *)NULL, 0);
825 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
826 [kernel defines atomic64_xchg])
833 dnl # 2.6.24 API change,
834 dnl # check if uintptr_t typedef is defined
836 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
837 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
838 SPL_LINUX_TRY_COMPILE([
839 #include <linux/types.h>
841 uintptr_t *ptr __attribute__ ((unused));
844 AC_DEFINE(HAVE_UINTPTR_T, 1,
845 [kernel defines uintptr_t])
852 dnl # 2.6.20 API change,
853 dnl # INIT_WORK use 2 args and not store data inside
855 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
856 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
857 SPL_LINUX_TRY_COMPILE([
858 #include <linux/workqueue.h>
860 struct work_struct work __attribute__ ((unused));
861 INIT_WORK(&work, NULL, NULL);
864 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
865 [INIT_WORK wants 3 args])
872 dnl # 2.6.21 API change,
873 dnl # 'register_sysctl_table' use only one argument instead of two
875 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
876 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
877 SPL_LINUX_TRY_COMPILE([
878 #include <linux/sysctl.h>
880 (void) register_sysctl_table(NULL, 0);
883 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
884 [register_sysctl_table() wants 2 args])
891 dnl # 2.6.23 API change
892 dnl # Old set_shrinker API replaced with register_shrinker
894 AC_DEFUN([SPL_AC_SET_SHRINKER], [
895 AC_MSG_CHECKING([whether set_shrinker() available])
896 SPL_LINUX_TRY_COMPILE([
897 #include <linux/mm.h>
899 return set_shrinker(DEFAULT_SEEKS, NULL);
902 AC_DEFINE(HAVE_SET_SHRINKER, 1,
903 [set_shrinker() available])
910 dnl # 2.6.35 API change,
911 dnl # Add context to shrinker callback
913 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
914 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
915 tmp_flags="$EXTRA_KCFLAGS"
916 EXTRA_KCFLAGS="-Werror"
917 SPL_LINUX_TRY_COMPILE([
918 #include <linux/mm.h>
920 int shrinker_cb(struct shrinker *, int, unsigned int);
922 struct shrinker cache_shrinker = {
923 .shrink = shrinker_cb,
924 .seeks = DEFAULT_SEEKS,
926 register_shrinker(&cache_shrinker);
929 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
930 [shrinker callback wants 3 args])
934 EXTRA_KCFLAGS="$tmp_flags"
938 dnl # 2.6.25 API change,
939 dnl # struct path entry added to struct nameidata
941 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
942 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
943 SPL_LINUX_TRY_COMPILE([
944 #include <linux/namei.h>
946 struct nameidata nd __attribute__ ((unused));
949 nd.path.dentry = NULL;
952 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
953 [struct path used in struct nameidata])
960 dnl # Custom SPL patch may export this system it is not required
962 AC_DEFUN([SPL_AC_TASK_CURR], [
963 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
964 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
969 dnl # 2.6.19 API change,
970 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
972 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
973 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
974 SPL_LINUX_TRY_COMPILE([
975 #include <linux/sysctl.h>
977 #ifndef CTL_UNNUMBERED
978 #error CTL_UNNUMBERED undefined
982 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
983 [unnumbered sysctl support exists])
990 dnl # 2.6.33 API change,
991 dnl # Removed .ctl_name from struct ctl_table.
993 AC_DEFUN([SPL_AC_CTL_NAME], [
994 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
995 SPL_LINUX_TRY_COMPILE([
996 #include <linux/sysctl.h>
998 struct ctl_table ctl __attribute__ ((unused));
1002 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1009 dnl # 2.6.16 API change.
1010 dnl # Check if 'fls64()' is available
1012 AC_DEFUN([SPL_AC_FLS64],
1013 [AC_MSG_CHECKING([whether fls64() is available])
1014 SPL_LINUX_TRY_COMPILE([
1015 #include <linux/bitops.h>
1020 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1027 dnl # 2.6.18 API change, check whether device_create() is available.
1028 dnl # Device_create() was introduced in 2.6.18 and depricated
1029 dnl # class_device_create() which was fully removed in 2.6.26.
1031 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
1032 SPL_CHECK_SYMBOL_EXPORT(
1034 [drivers/base/core.c],
1035 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1036 [device_create() is available])],
1041 dnl # 2.6.27 API change,
1042 dnl # device_create() uses 5 args, new 'drvdata' argument.
1044 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1045 AC_MSG_CHECKING([whether device_create() wants 5 args])
1046 tmp_flags="$EXTRA_KCFLAGS"
1047 EXTRA_KCFLAGS="-Werror"
1048 SPL_LINUX_TRY_COMPILE([
1049 #include <linux/device.h>
1051 device_create(NULL, NULL, 0, NULL, "%d", 1);
1054 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1055 [device_create wants 5 args])
1059 EXTRA_KCFLAGS="$tmp_flags"
1063 dnl # 2.6.13 API change, check whether class_device_create() is available.
1064 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1065 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1067 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
1068 SPL_CHECK_SYMBOL_EXPORT(
1069 [class_device_create],
1070 [drivers/base/class.c],
1071 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1072 [class_device_create() is available])],
1077 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1079 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
1080 SPL_CHECK_SYMBOL_EXPORT(
1081 [set_normalized_timespec],
1083 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1084 [set_normalized_timespec() is available as export])],
1089 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1090 dnl # previously it was available in time.h as an inline.
1092 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1093 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1094 SPL_LINUX_TRY_COMPILE([
1095 #include <linux/time.h>
1096 void set_normalized_timespec(struct timespec *ts,
1097 time_t sec, long nsec) { }
1104 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1105 [set_normalized_timespec() is available as inline])
1110 dnl # 2.6.18 API change,
1111 dnl # timespec_sub() inline function available in linux/time.h
1113 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1114 AC_MSG_CHECKING([whether timespec_sub() is available])
1115 SPL_LINUX_TRY_COMPILE([
1116 #include <linux/time.h>
1118 struct timespec a = { 0 };
1119 struct timespec b = { 0 };
1120 struct timespec c __attribute__ ((unused));
1121 c = timespec_sub(a, b);
1124 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1131 dnl # 2.6.19 API change,
1132 dnl # check if init_utsname() is available in linux/utsname.h
1134 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1135 AC_MSG_CHECKING([whether init_utsname() is available])
1136 SPL_LINUX_TRY_COMPILE([
1137 #include <linux/utsname.h>
1139 struct new_utsname *a __attribute__ ((unused));
1143 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1150 dnl # 2.6.26 API change,
1151 dnl # definition of struct fdtable relocated to linux/fdtable.h
1153 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1154 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1158 dnl # 2.6.14 API change,
1159 dnl # check whether 'files_fdtable()' exists
1161 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1162 AC_MSG_CHECKING([whether files_fdtable() is available])
1163 SPL_LINUX_TRY_COMPILE([
1164 #include <linux/sched.h>
1165 #include <linux/file.h>
1166 #ifdef HAVE_FDTABLE_HEADER
1167 #include <linux/fdtable.h>
1170 struct files_struct *files = current->files;
1171 struct fdtable *fdt __attribute__ ((unused));
1172 fdt = files_fdtable(files);
1175 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1182 dnl # 3.4.0 API change,
1183 dnl # check whether '__clear_close_on_exec()' exists
1185 AC_DEFUN([SPL_AC_CLEAR_CLOSE_ON_EXEC], [
1186 AC_MSG_CHECKING([whether __clear_close_on_exec() is available])
1187 SPL_LINUX_TRY_COMPILE([
1188 #include <linux/fdtable.h>
1190 struct fdtable *fdt = NULL;
1193 __clear_close_on_exec(fd, fdt);
1196 AC_DEFINE(HAVE_CLEAR_CLOSE_ON_EXEC, 1,
1197 [__clear_close_on_exec() is available])
1204 dnl # 2.6.18 API change,
1205 dnl # added linux/uaccess.h
1207 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1208 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1212 dnl # 2.6.12 API change,
1213 dnl # check whether 'kmalloc_node()' is available.
1215 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1216 AC_MSG_CHECKING([whether kmalloc_node() is available])
1217 SPL_LINUX_TRY_COMPILE([
1218 #include <linux/slab.h>
1220 void *a __attribute__ ((unused));
1221 a = kmalloc_node(1, GFP_KERNEL, 0);
1224 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1231 dnl # 2.6.9 API change,
1232 dnl # check whether 'monotonic_clock()' is available it may
1233 dnl # be available for some archs but not others.
1235 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1236 SPL_CHECK_SYMBOL_EXPORT(
1239 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1240 [monotonic_clock() is available])],
1245 dnl # 2.6.16 API change,
1246 dnl # check whether 'struct inode' has i_mutex
1248 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1249 AC_MSG_CHECKING([whether struct inode has i_mutex])
1250 SPL_LINUX_TRY_COMPILE([
1251 #include <linux/fs.h>
1252 #include <linux/mutex.h>
1255 mutex_init(&i.i_mutex);
1258 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1265 dnl # 2.6.29 API change,
1266 dnl # Adaptive mutexs introduced.
1268 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1269 AC_MSG_CHECKING([whether struct mutex has owner])
1270 SPL_LINUX_TRY_COMPILE([
1271 #include <linux/mutex.h>
1273 struct mutex mtx __attribute__ ((unused));
1277 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1284 dnl # 2.6.39 API change,
1285 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1286 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1287 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1288 dnl # pointer which frankly makes a lot more sense.
1290 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1291 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1292 tmp_flags="$EXTRA_KCFLAGS"
1293 EXTRA_KCFLAGS="-Werror"
1294 SPL_LINUX_TRY_COMPILE([
1295 #include <linux/mutex.h>
1297 struct mutex mtx __attribute__ ((unused));
1298 mtx.owner = current;
1301 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1302 [struct mutex owner is a task_struct])
1306 EXTRA_KCFLAGS="$tmp_flags"
1310 dnl # 2.6.18 API change,
1311 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1312 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1313 dnl # if the mutex validator is disabled or otherwise unavailable.
1315 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1316 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1317 SPL_LINUX_TRY_COMPILE([
1318 #include <linux/mutex.h>
1322 mutex_lock_nested(&mutex, 0);
1325 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1326 [mutex_lock_nested() is available])
1333 dnl # 2.6.27 API change,
1334 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1336 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1337 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1338 SPL_LINUX_TRY_COMPILE([
1339 #include <linux/smp.h>
1341 on_each_cpu(NULL, NULL, 0);
1344 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1345 [on_each_cpu wants 3 args])
1352 dnl # 2.6.18 API change,
1353 dnl # kallsyms_lookup_name no longer exported
1355 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1356 SPL_CHECK_SYMBOL_EXPORT(
1357 [kallsyms_lookup_name],
1359 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1360 [kallsyms_lookup_name() is available])],
1365 dnl # Proposed API change,
1366 dnl # This symbol is not available in stock kernels. You may build a
1367 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1368 dnl # these symbols for use. If your already rolling a custom kernel for
1369 dnl # your environment this is recommended.
1371 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1372 SPL_CHECK_SYMBOL_EXPORT(
1375 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1376 [get_vmalloc_info() is available])],
1381 dnl # 2.6.17 API change
1382 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1383 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1384 dnl # were exported in 2.6.17 for use by modules which was consistent with
1385 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1386 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1387 dnl # were dropped entirely leaving modules no way to directly iterate over
1388 dnl # the zone list. Because we need access to the zone helpers we check
1389 dnl # if the kernel contains the old or new implementation. Then we check
1390 dnl # to see if the symbols we need for each version are available. If they
1391 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1393 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1394 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1395 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1397 if test $rc -eq 0; then
1398 AC_MSG_RESULT([yes])
1399 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1406 dnl # Proposed API change,
1407 dnl # This symbol is not available in stock kernels. You may build a
1408 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1409 dnl # these symbols for use. If your already rolling a custom kernel for
1410 dnl # your environment this is recommended.
1412 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1413 SPL_CHECK_SYMBOL_EXPORT(
1414 [first_online_pgdat],
1416 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1417 [first_online_pgdat() is available])],
1422 dnl # Proposed API change,
1423 dnl # This symbol is not available in stock kernels. You may build a
1424 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1425 dnl # these symbols for use. If your already rolling a custom kernel for
1426 dnl # your environment this is recommended.
1428 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1429 SPL_CHECK_SYMBOL_EXPORT(
1430 [next_online_pgdat],
1432 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1433 [next_online_pgdat() is available])],
1438 dnl # Proposed API change,
1439 dnl # This symbol is not available in stock kernels. You may build a
1440 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1441 dnl # these symbols for use. If your already rolling a custom kernel for
1442 dnl # your environment this is recommended.
1444 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1445 SPL_CHECK_SYMBOL_EXPORT(
1448 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1449 [next_zone() is available])],
1454 dnl # 2.6.17 API change,
1455 dnl # See SPL_AC_PGDAT_HELPERS for details.
1457 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1458 SPL_CHECK_SYMBOL_EXPORT(
1461 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1462 [pgdat_list is available])],
1467 dnl # 2.6.18 API change,
1468 dnl # First introduced global_page_state() support as an inline.
1470 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1471 AC_MSG_CHECKING([whether global_page_state() is available])
1472 SPL_LINUX_TRY_COMPILE([
1473 #include <linux/mm.h>
1475 unsigned long state __attribute__ ((unused));
1476 state = global_page_state(0);
1479 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1480 [global_page_state() is available])
1487 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1488 dnl # Public global zone stats now include a free page count. However
1489 dnl # the enumerated names of the counters have changed since this API
1490 dnl # was introduced. We need to deduce the corrent name to use. This
1491 dnl # replaces the priviate get_zone_counts() interface.
1493 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1494 dnl # is 2.6.30 as of when this was written.
1496 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1497 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1498 SPL_LINUX_TRY_COMPILE([
1499 #include <linux/mm.h>
1501 enum zone_stat_item zsi __attribute__ ((unused));
1502 zsi = NR_FREE_PAGES;
1505 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1506 [Page state NR_FREE_PAGES is available])
1513 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1514 dnl # Public global zone stats now include an inactive page count. However
1515 dnl # the enumerated names of the counters have changed since this API
1516 dnl # was introduced. We need to deduce the corrent name to use. This
1517 dnl # replaces the priviate get_zone_counts() interface.
1519 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1520 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1521 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1523 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1524 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1525 SPL_LINUX_TRY_COMPILE([
1526 #include <linux/mm.h>
1528 enum zone_stat_item zsi __attribute__ ((unused));
1532 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1533 [Page state NR_INACTIVE is available])
1538 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1539 SPL_LINUX_TRY_COMPILE([
1540 #include <linux/mm.h>
1542 enum zone_stat_item zsi __attribute__ ((unused));
1543 zsi = NR_INACTIVE_ANON;
1546 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1547 [Page state NR_INACTIVE_ANON is available])
1552 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1553 SPL_LINUX_TRY_COMPILE([
1554 #include <linux/mm.h>
1556 enum zone_stat_item zsi __attribute__ ((unused));
1557 zsi = NR_INACTIVE_FILE;
1560 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1561 [Page state NR_INACTIVE_FILE is available])
1568 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1569 dnl # Public global zone stats now include an active page count. However
1570 dnl # the enumerated names of the counters have changed since this API
1571 dnl # was introduced. We need to deduce the corrent name to use. This
1572 dnl # replaces the priviate get_zone_counts() interface.
1574 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1575 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1576 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1578 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1579 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1580 SPL_LINUX_TRY_COMPILE([
1581 #include <linux/mm.h>
1583 enum zone_stat_item zsi __attribute__ ((unused));
1587 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1588 [Page state NR_ACTIVE is available])
1593 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1594 SPL_LINUX_TRY_COMPILE([
1595 #include <linux/mm.h>
1597 enum zone_stat_item zsi __attribute__ ((unused));
1598 zsi = NR_ACTIVE_ANON;
1601 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1602 [Page state NR_ACTIVE_ANON is available])
1607 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1608 SPL_LINUX_TRY_COMPILE([
1609 #include <linux/mm.h>
1611 enum zone_stat_item zsi __attribute__ ((unused));
1612 zsi = NR_ACTIVE_FILE;
1615 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1616 [Page state NR_ACTIVE_FILE is available])
1623 dnl # Proposed API change for legacy kernels.
1624 dnl # This symbol is not available in older kernels. For kernels post
1625 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1626 dnl # page state information. This symbol is only used in legacy kernels
1627 dnl # any only as a last resort.
1629 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1630 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1631 SPL_LINUX_TRY_COMPILE([
1633 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1634 #error "global_page_state needs NR_FREE_PAGES"
1637 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1638 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1639 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1640 #error "global_page_state needs NR_ACTIVE*"
1643 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1644 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1645 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1646 #error "global_page_state needs NR_INACTIVE*"
1652 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1653 [get_zone_counts() is needed])
1655 SPL_CHECK_SYMBOL_EXPORT(
1658 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1659 [get_zone_counts() is available])],
1665 dnl # 2.6.27 API change,
1666 dnl # The user_path_dir() replaces __user_walk()
1668 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1669 SPL_CHECK_SYMBOL_EXPORT(
1672 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1673 [user_path_dir() is available])],
1678 dnl # Symbol available in RHEL kernels not in stock kernels.
1680 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1681 SPL_CHECK_SYMBOL_EXPORT(
1684 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1685 [set_fs_pwd() is available])],
1690 dnl # 2.6.25 API change,
1691 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1693 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1694 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1695 SPL_LINUX_TRY_COMPILE([
1696 #include <linux/sched.h>
1697 #include <linux/fs_struct.h>
1699 set_fs_pwd(NULL, NULL);
1702 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1703 [set_fs_pwd() wants 2 args])
1710 dnl # SLES API change, never adopted in mainline,
1711 dnl # Third 'struct vfsmount *' argument removed.
1713 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1714 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1715 SPL_LINUX_TRY_COMPILE([
1716 #include <linux/fs.h>
1718 vfs_unlink(NULL, NULL);
1721 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1722 [vfs_unlink() wants 2 args])
1729 dnl # SLES API change, never adopted in mainline,
1730 dnl # Third and sixth 'struct vfsmount *' argument removed.
1732 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1733 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1734 SPL_LINUX_TRY_COMPILE([
1735 #include <linux/fs.h>
1737 vfs_rename(NULL, NULL, NULL, NULL);
1740 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1741 [vfs_rename() wants 4 args])
1748 dnl # 2.6.36 API change,
1749 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1750 dnl # a spinlock_t to improve the fastpath performance.
1752 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1753 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1754 tmp_flags="$EXTRA_KCFLAGS"
1755 EXTRA_KCFLAGS="-Werror"
1756 SPL_LINUX_TRY_COMPILE([
1757 #include <linux/sched.h>
1758 #include <linux/fs_struct.h>
1760 struct fs_struct fs;
1761 spin_lock_init(&fs.lock);
1764 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1765 [struct fs_struct uses spinlock_t])
1769 EXTRA_KCFLAGS="$tmp_flags"
1773 dnl # 2.6.29 API change,
1774 dnl # check whether 'struct cred' exists
1776 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1777 AC_MSG_CHECKING([whether struct cred exists])
1778 SPL_LINUX_TRY_COMPILE([
1779 #include <linux/cred.h>
1781 struct cred *cr __attribute__ ((unused));
1785 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1792 dnl # Custom SPL patch may export this symbol.
1794 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1795 SPL_CHECK_SYMBOL_EXPORT(
1798 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1799 [groups_search() is available])],
1804 dnl # 2.6.x API change,
1805 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1807 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1808 SPL_CHECK_SYMBOL_EXPORT(
1809 [__put_task_struct],
1811 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1812 [__put_task_struct() is available])],
1817 dnl # 2.6.32 API change,
1818 dnl # Unused 'struct file *' removed from prototype.
1820 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1821 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1822 SPL_LINUX_TRY_COMPILE([
1823 #include <linux/sysctl.h>
1825 proc_dostring(NULL, 0, NULL, NULL, NULL);
1828 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1829 [proc_handler() wants 5 args])
1836 dnl # 2.6.x API change,
1837 dnl # kvasprintf() function added.
1839 AC_DEFUN([SPL_AC_KVASPRINTF], [
1840 SPL_CHECK_SYMBOL_EXPORT(
1843 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1844 [kvasprintf() is available])],
1849 dnl # 2.6.29 API change,
1850 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1852 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1853 SPL_CHECK_SYMBOL_EXPORT(
1856 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1861 dnl # 2.6.35 API change,
1862 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1864 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1865 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1866 SPL_LINUX_TRY_COMPILE([
1867 #include <linux/fs.h>
1872 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1879 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1880 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1881 dnl # condition. The fixed version is exported as a symbol. The race
1882 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1883 dnl # call that version while holding sem->wait_lock.
1885 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1886 SPL_CHECK_SYMBOL_EXPORT(
1888 [lib/rwsem-spinlock.c],
1889 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1890 [rwsem_is_locked() acquires sem->wait_lock])],
1895 dnl # 2.6.37 API compat,
1896 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1897 dnl # The prototype however is still available which means it is safe
1898 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1900 dnl # The Proxmox VE kernel contains a patch which renames the function
1901 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1902 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1903 dnl # compatibility wrapper for legacy callers. Therefore, if either
1904 dnl # of these functions are exported invalidate_inodes() can be
1907 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1908 SPL_CHECK_SYMBOL_EXPORT(
1909 [invalidate_inodes],
1911 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1912 [invalidate_inodes() is available])],
1914 SPL_CHECK_SYMBOL_EXPORT(
1915 [invalidate_inodes_check],
1917 [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
1918 [invalidate_inodes_check() is available])],
1923 dnl # 2.6.39 API compat,
1924 dnl # The function invalidate_inodes() now take 2 arguments. The second
1925 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1926 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1927 dnl # otherwise they will be handled as busy.
1929 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1930 dnl # prototype so it's not easy to check how many arguments it takes.
1931 dnl # However, this change was done for the benefit of invalidate_device()
1932 dnl # which also added an argument. The invalidate_device() symbol does
1933 dnl # exist in the development headers so if it takes two arguments we
1934 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1935 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1937 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1938 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1939 SPL_LINUX_TRY_COMPILE([
1940 #include <linux/fs.h>
1942 return __invalidate_device(NULL, 0);
1945 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1946 [invalidate_inodes() wants 2 args])
1953 dnl # 2.6.xx API compat,
1954 dnl # There currently exists no exposed API to partially shrink the dcache.
1955 dnl # The expected mechanism to shrink the cache is a registered shrinker
1956 dnl # which is called during memory pressure.
1958 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1959 SPL_CHECK_SYMBOL_EXPORT(
1960 [shrink_dcache_memory],
1962 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1963 [shrink_dcache_memory() is available])],
1968 dnl # 2.6.xx API compat,
1969 dnl # There currently exists no exposed API to partially shrink the icache.
1970 dnl # The expected mechanism to shrink the cache is a registered shrinker
1971 dnl # which is called during memory pressure.
1973 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1974 SPL_CHECK_SYMBOL_EXPORT(
1975 [shrink_icache_memory],
1977 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1978 [shrink_icache_memory() is available])],
1983 dnl # 2.6.39 API compat,
1984 dnl # The path_lookup() function has been renamed to kern_path_parent()
1985 dnl # and the flags argument has been removed. The only behavior now
1986 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1987 dnl # this flag so dropping the flag does not impact us.
1989 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1990 SPL_CHECK_SYMBOL_HEADER(
1992 [int kern_path_parent(const char \*, struct nameidata \*)],
1993 [include/linux/namei.h],
1994 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1995 [kern_path_parent() is available])],
2000 dnl # 3.1 API compat,
2001 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2002 dnl # However, it remains the prefered interface and since we still have
2003 dnl # access to the prototype we dynamically lookup the required address.
2005 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
2006 SPL_CHECK_SYMBOL_EXPORT(
2009 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2010 [kern_path_parent() is available])],
2015 dnl # 2.6.39 API compat,
2016 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2017 dnl # This was done to avoid always having to allocate the maximum size
2018 dnl # workspace (268K). The caller can now specific the windowBits and
2019 dnl # memLevel compression parameters to get a smaller workspace.
2021 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2022 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2023 SPL_LINUX_TRY_COMPILE([
2024 #include <linux/zlib.h>
2026 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2029 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2030 [zlib_deflate_workspacesize() wants 2 args])
2037 dnl # 2.6.39 API change,
2038 dnl # Shrinker adjust to use common shrink_control structure.
2040 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2041 AC_MSG_CHECKING([whether struct shrink_control exists])
2042 SPL_LINUX_TRY_COMPILE([
2043 #include <linux/mm.h>
2045 struct shrink_control sc __attribute__ ((unused));
2048 sc.gfp_mask = GFP_KERNEL;
2051 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2052 [struct shrink_control exists])
2059 dnl # 3.1 API Change
2061 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2062 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2064 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2065 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2066 tmp_flags="$EXTRA_KCFLAGS"
2067 EXTRA_KCFLAGS="-Werror"
2068 SPL_LINUX_TRY_COMPILE([
2069 #include <linux/rwsem.h>
2071 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2072 raw_spinlock_t dummy_lock __attribute__ ((unused));
2073 dummy_semaphore.wait_lock = dummy_lock;
2076 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2077 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2081 EXTRA_KCFLAGS="$tmp_flags"
2085 dnl # Proposed VM Subsystem Bug Fix
2086 dnl # https://bugs.gentoo.org/show_bug.cgi?id=416685
2088 dnl # Make __pte_alloc_kernel() honor gfp flags passed to vmalloc()
2089 dnl # This is detected by checking a macro that is changed to support this.
2091 AC_DEFUN([SPL_AC_PMD_ALLOC_WITH_MASK], [
2092 AC_MSG_CHECKING([whether pmd_alloc_with_mask exists])
2093 SPL_LINUX_TRY_COMPILE([
2094 #if !defined(CONFIG_MMU)
2098 #if defined(RCH_HAS_4LEVEL_HACK)
2099 #undef RCH_HAS_4LEVEL_HACK
2102 #include <linux/mm.h>
2104 struct mm_struct init_mm;
2106 unsigned long addr = 0;
2107 gfp_t gfp_mask = GFP_KERNEL;
2109 pmd_alloc_with_mask(&init_mm, pud, addr, gfp_mask);
2112 AC_DEFINE(HAVE_PMD_ALLOC_WITH_MASK, 1,
2113 [pmd_alloc_with_mask exists])