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)
23 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_2ARGS_REGISTER_SYSCTL
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
46 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_MUTEX_OWNER_TASK_STRUCT
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
70 SPL_AC_2ARGS_VFS_FSYNC
71 SPL_AC_INODE_TRUNCATE_RANGE
72 SPL_AC_FS_STRUCT_SPINLOCK
75 SPL_AC_PUT_TASK_STRUCT
76 SPL_AC_5ARGS_PROC_HANDLER
78 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
79 SPL_AC_KERNEL_INVALIDATE_INODES
80 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
81 SPL_AC_KERNEL_FALLOCATE
82 SPL_AC_SHRINK_DCACHE_MEMORY
83 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_KERN_PATH_PARENT_HEADER
85 SPL_AC_KERN_PATH_PARENT_SYMBOL
86 SPL_AC_KERN_PATH_LOCKED
87 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
88 SPL_AC_SHRINK_CONTROL_STRUCT
89 SPL_AC_RWSEM_SPINLOCK_IS_RAW
92 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
93 modpost=$LINUX/scripts/Makefile.modpost
94 AC_MSG_CHECKING([kernel file name for module symbols])
95 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
96 if grep -q Modules.symvers $modpost; then
97 LINUX_SYMBOLS=Modules.symvers
99 LINUX_SYMBOLS=Module.symvers
102 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
104 *** Please make sure the kernel devel package for your distribution
105 *** is installed. If your building with a custom kernel make sure the
106 *** kernel is configured, built, and the '--with-linux=PATH' configure
107 *** option refers to the location of the kernel source.])
112 AC_MSG_RESULT($LINUX_SYMBOLS)
113 AC_SUBST(LINUX_SYMBOLS)
116 AC_DEFUN([SPL_AC_KERNEL], [
118 AS_HELP_STRING([--with-linux=PATH],
119 [Path to kernel source]),
120 [kernelsrc="$withval"])
122 AC_ARG_WITH([linux-obj],
123 AS_HELP_STRING([--with-linux-obj=PATH],
124 [Path to kernel build objects]),
125 [kernelbuild="$withval"])
127 AC_MSG_CHECKING([kernel source directory])
128 if test -z "$kernelsrc"; then
129 if test -e "/lib/modules/$(uname -r)/source"; then
130 headersdir="/lib/modules/$(uname -r)/source"
131 sourcelink=$(readlink -f "$headersdir")
132 elif test -e "/lib/modules/$(uname -r)/build"; then
133 headersdir="/lib/modules/$(uname -r)/build"
134 sourcelink=$(readlink -f "$headersdir")
136 sourcelink=$(ls -1d /usr/src/kernels/* \
138 2>/dev/null | grep -v obj | tail -1)
141 if test -n "$sourcelink" && test -e ${sourcelink}; then
142 kernelsrc=`readlink -f ${sourcelink}`
144 kernelsrc="[Not found]"
147 if test "$kernelsrc" = "NONE"; then
152 AC_MSG_RESULT([$kernelsrc])
153 if test ! -d "$kernelsrc"; then
155 *** Please make sure the kernel devel package for your distribution
156 *** is installed then try again. If that fails you can specify the
157 *** location of the kernel source with the '--with-linux=PATH' option.])
160 AC_MSG_CHECKING([kernel build directory])
161 if test -z "$kernelbuild"; then
162 if test -e "/lib/modules/$(uname -r)/build"; then
163 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
164 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
165 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
166 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
167 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
168 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
169 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
171 kernelbuild=${kernelsrc}
174 AC_MSG_RESULT([$kernelbuild])
176 AC_MSG_CHECKING([kernel source version])
177 utsrelease1=$kernelbuild/include/linux/version.h
178 utsrelease2=$kernelbuild/include/linux/utsrelease.h
179 utsrelease3=$kernelbuild/include/generated/utsrelease.h
180 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
181 utsrelease=linux/version.h
182 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
183 utsrelease=linux/utsrelease.h
184 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
185 utsrelease=generated/utsrelease.h
188 if test "$utsrelease"; then
189 kernsrcver=`(echo "#include <$utsrelease>";
190 echo "kernsrcver=UTS_RELEASE") |
191 cpp -I $kernelbuild/include |
192 grep "^kernsrcver=" | cut -d \" -f 2`
194 if test -z "$kernsrcver"; then
195 AC_MSG_RESULT([Not found])
196 AC_MSG_ERROR([*** Cannot determine kernel version.])
199 AC_MSG_RESULT([Not found])
200 if test "x$enable_linux_builtin" != xyes; then
201 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
204 *** Cannot find UTS_RELEASE definition.
205 *** Please run 'make prepare' inside the kernel source tree.])
209 AC_MSG_RESULT([$kernsrcver])
212 LINUX_OBJ=${kernelbuild}
213 LINUX_VERSION=${kernsrcver}
217 AC_SUBST(LINUX_VERSION)
219 SPL_AC_MODULE_SYMVERS
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"])
447 AC_ARG_ENABLE([linux-builtin],
448 [AC_HELP_STRING([--enable-linux-builtin],
449 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
451 [enable_linux_builtin=no])
453 AC_MSG_CHECKING([spl config])
454 AC_MSG_RESULT([$SPL_CONFIG]);
457 case "$SPL_CONFIG" in
458 kernel) SPL_AC_CONFIG_KERNEL ;;
459 user) SPL_AC_CONFIG_USER ;;
460 all) SPL_AC_CONFIG_KERNEL
461 SPL_AC_CONFIG_USER ;;
464 AC_MSG_RESULT([Error!])
465 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
466 user kernel|user|all|srpm]) ;;
469 AM_CONDITIONAL([CONFIG_USER],
470 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
471 AM_CONDITIONAL([CONFIG_KERNEL],
472 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
473 [test "x$enable_linux_builtin" != xyes ])
477 dnl # Enable if the SPL should be compiled with internal debugging enabled.
478 dnl # By default this support is disabled.
480 AC_DEFUN([SPL_AC_DEBUG], [
481 AC_MSG_CHECKING([whether debugging is enabled])
482 AC_ARG_ENABLE([debug],
483 [AS_HELP_STRING([--enable-debug],
484 [Enable generic debug support @<:@default=no@:>@])],
488 AS_IF([test "x$enable_debug" = xyes],
490 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
491 DEBUG_CFLAGS="-DDEBUG -Werror"
492 DEBUG_SPL="_with_debug"
494 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
495 DEBUG_CFLAGS="-DNDEBUG"
496 DEBUG_SPL="_without_debug"
499 AC_SUBST(DEBUG_CFLAGS)
501 AC_MSG_RESULT([$enable_debug])
505 dnl # Enabled by default it provides a basic debug log infrastructure.
506 dnl # Each subsystem registers itself with a name and logs messages
507 dnl # using predefined types. If the debug mask it set to allow the
508 dnl # message type it will be written to the internal log. The log
509 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
510 dnl # after dumping the log it must be decoded using the spl utility.
512 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
513 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
515 AC_DEFUN([SPL_AC_DEBUG_LOG], [
516 AC_ARG_ENABLE([debug-log],
517 [AS_HELP_STRING([--enable-debug-log],
518 [Enable basic debug logging @<:@default=yes@:>@])],
520 [enable_debug_log=yes])
522 AS_IF([test "x$enable_debug_log" = xyes],
524 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
525 DEBUG_LOG="_with_debug_log"
526 AC_DEFINE([DEBUG_LOG], [1],
527 [Define to 1 to enable basic debug logging])
529 DEBUG_LOG="_without_debug_log"
533 AC_MSG_CHECKING([whether basic debug logging is enabled])
534 AC_MSG_RESULT([$enable_debug_log])
538 dnl # Enabled by default it provides a minimal level of memory tracking.
539 dnl # A total count of bytes allocated is kept for each alloc and free.
540 dnl # Then at module unload time a report to the console will be printed
541 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
542 dnl # and provide an easy way to inspect the kmem based slab.
544 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
545 AC_ARG_ENABLE([debug-kmem],
546 [AS_HELP_STRING([--enable-debug-kmem],
547 [Enable basic kmem accounting @<:@default=yes@:>@])],
549 [enable_debug_kmem=yes])
551 AS_IF([test "x$enable_debug_kmem" = xyes],
553 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
554 DEBUG_KMEM="_with_debug_kmem"
555 AC_DEFINE([DEBUG_KMEM], [1],
556 [Define to 1 to enable basic kmem accounting])
558 DEBUG_KMEM="_without_debug_kmem"
562 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
563 AC_MSG_RESULT([$enable_debug_kmem])
567 dnl # Disabled by default it provides detailed memory tracking. This
568 dnl # feature also requires --enable-debug-kmem to be set. When enabled
569 dnl # not only will total bytes be tracked but also the location of every
570 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
571 dnl # addresses and where they were allocated will be dumped to the console.
572 dnl # Enabling this feature has a significant impact on performance but it
573 dnl # makes finding memory leaks pretty straight forward.
575 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
576 AC_ARG_ENABLE([debug-kmem-tracking],
577 [AS_HELP_STRING([--enable-debug-kmem-tracking],
578 [Enable detailed kmem tracking @<:@default=no@:>@])],
580 [enable_debug_kmem_tracking=no])
582 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
584 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
585 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
586 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
587 [Define to 1 to enable detailed kmem tracking])
589 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
592 AC_SUBST(DEBUG_KMEM_TRACKING)
593 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
594 AC_MSG_RESULT([$enable_debug_kmem_tracking])
598 dnl # SPL_LINUX_CONFTEST
600 AC_DEFUN([SPL_LINUX_CONFTEST], [
601 cat confdefs.h - <<_ACEOF >conftest.c
607 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
609 m4_define([SPL_LANG_PROGRAM], [
614 dnl Do *not* indent the following line: there may be CPP directives.
615 dnl Don't move the `;' right after for the same reason.
623 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
625 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
626 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
627 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
628 echo "obj-m := conftest.o" >build/Makefile
630 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
632 [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 $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
634 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
640 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
642 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
643 [SPL_LINUX_COMPILE_IFELSE(
644 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
646 [test -s build/conftest.o],
651 dnl # SPL_CHECK_SYMBOL_EXPORT
652 dnl # check symbol exported or not
654 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
655 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
656 $LINUX_OBJ/Module*.symvers 2>/dev/null
658 if test $rc -ne 0; then
661 grep -q -E "EXPORT_SYMBOL.*($1)" \
662 "$LINUX_OBJ/$file" 2>/dev/null
664 if test $rc -eq 0; then
669 if test $export -eq 0; then :
680 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
681 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
682 dnl # is called if not compiling for builtin
684 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
685 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
686 if test $rc -ne 0; then :
689 if test "x$enable_linux_builtin" != xyes; then
690 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
692 if test $rc -ne 0; then :
701 dnl # SPL_CHECK_SYMBOL_HEADER
702 dnl # check if a symbol prototype is defined in listed headers.
704 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
705 AC_MSG_CHECKING([whether symbol $1 exists in header])
708 grep -q "$2" "$LINUX/$file" 2>/dev/null
710 if test $rc -eq 0; then
715 if test $header -eq 0; then
725 dnl # SPL_CHECK_HEADER
726 dnl # check whether header exists and define HAVE_$2_HEADER
728 AC_DEFUN([SPL_CHECK_HEADER],
729 [AC_MSG_CHECKING([whether header $1 exists])
730 SPL_LINUX_TRY_COMPILE([
735 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
745 dnl # Basic toolchain sanity check.
747 AC_DEFUN([SPL_AC_TEST_MODULE],
748 [AC_MSG_CHECKING([whether modules can be built])
749 SPL_LINUX_TRY_COMPILE([],[],[
753 if test "x$enable_linux_builtin" != xyes; then
754 AC_MSG_ERROR([*** Unable to build an empty module.])
757 *** Unable to build an empty module.
758 *** Please run 'make scripts' inside the kernel source tree.])
764 dnl # Use the atomic implemenation based on global spinlocks. This
765 dnl # should only be needed by 32-bit kernels which do not provide
766 dnl # the atomic64_* API. It may be optionally enabled as a fallback
767 dnl # if problems are observed with the direct mapping to the native
768 dnl # Linux atomic operations. You may not disable atomic spinlocks
769 dnl # if you kernel does not an atomic64_* API.
771 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
772 AC_ARG_ENABLE([atomic-spinlocks],
773 [AS_HELP_STRING([--enable-atomic-spinlocks],
774 [Atomic types use spinlocks @<:@default=check@:>@])],
776 [enable_atomic_spinlocks=check])
778 SPL_LINUX_TRY_COMPILE([
779 #include <asm/atomic.h>
781 atomic64_t *ptr __attribute__ ((unused));
784 AC_DEFINE(HAVE_ATOMIC64_T, 1,
785 [kernel defines atomic64_t])
790 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
791 AS_IF([test "x$have_atomic64_t" = xyes], [
792 enable_atomic_spinlocks=no
794 enable_atomic_spinlocks=yes
798 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
799 AC_DEFINE([ATOMIC_SPINLOCK], [1],
800 [Atomic types use spinlocks])
802 AS_IF([test "x$have_atomic64_t" = xno], [
804 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
808 AC_MSG_CHECKING([whether atomic types use spinlocks])
809 AC_MSG_RESULT([$enable_atomic_spinlocks])
811 AC_MSG_CHECKING([whether kernel defines atomic64_t])
812 AC_MSG_RESULT([$have_atomic64_t])
816 dnl # 2.6.24 API change,
817 dnl # check if atomic64_cmpxchg is defined
819 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
820 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
821 SPL_LINUX_TRY_COMPILE([
822 #include <asm/atomic.h>
823 #include <asm/system.h>
825 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
828 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
829 [kernel defines atomic64_cmpxchg])
836 dnl # 2.6.24 API change,
837 dnl # check if atomic64_xchg is defined
839 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
840 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
841 SPL_LINUX_TRY_COMPILE([
842 #include <asm/atomic.h>
844 atomic64_xchg((atomic64_t *)NULL, 0);
847 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
848 [kernel defines atomic64_xchg])
855 dnl # 2.6.24 API change,
856 dnl # check if uintptr_t typedef is defined
858 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
859 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
860 SPL_LINUX_TRY_COMPILE([
861 #include <linux/types.h>
863 uintptr_t *ptr __attribute__ ((unused));
866 AC_DEFINE(HAVE_UINTPTR_T, 1,
867 [kernel defines uintptr_t])
874 dnl # 2.6.21 API change,
875 dnl # 'register_sysctl_table' use only one argument instead of two
877 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
878 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
879 SPL_LINUX_TRY_COMPILE([
880 #include <linux/sysctl.h>
882 (void) register_sysctl_table(NULL, 0);
885 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
886 [register_sysctl_table() wants 2 args])
893 dnl # 2.6.23 API change
894 dnl # Old set_shrinker API replaced with register_shrinker
896 AC_DEFUN([SPL_AC_SET_SHRINKER], [
897 AC_MSG_CHECKING([whether set_shrinker() available])
898 SPL_LINUX_TRY_COMPILE([
899 #include <linux/mm.h>
901 return set_shrinker(DEFAULT_SEEKS, NULL);
904 AC_DEFINE(HAVE_SET_SHRINKER, 1,
905 [set_shrinker() available])
912 dnl # 2.6.35 API change,
913 dnl # Add context to shrinker callback
915 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
916 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
917 tmp_flags="$EXTRA_KCFLAGS"
918 EXTRA_KCFLAGS="-Werror"
919 SPL_LINUX_TRY_COMPILE([
920 #include <linux/mm.h>
922 int shrinker_cb(struct shrinker *, int, unsigned int);
924 struct shrinker cache_shrinker = {
925 .shrink = shrinker_cb,
926 .seeks = DEFAULT_SEEKS,
928 register_shrinker(&cache_shrinker);
931 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
932 [shrinker callback wants 3 args])
936 EXTRA_KCFLAGS="$tmp_flags"
940 dnl # 2.6.25 API change,
941 dnl # struct path entry added to struct nameidata
943 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
944 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
945 SPL_LINUX_TRY_COMPILE([
946 #include <linux/namei.h>
948 struct nameidata nd __attribute__ ((unused));
951 nd.path.dentry = NULL;
954 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
955 [struct path used in struct nameidata])
962 dnl # Custom SPL patch may export this system it is not required
964 AC_DEFUN([SPL_AC_TASK_CURR],
965 [AC_MSG_CHECKING([whether task_curr() is available])
966 SPL_LINUX_TRY_COMPILE_SYMBOL([
967 #include <linux/sched.h>
970 ], [task_curr], [kernel/sched.c], [
972 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
979 dnl # 2.6.19 API change,
980 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
982 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
983 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
984 SPL_LINUX_TRY_COMPILE([
985 #include <linux/sysctl.h>
987 #ifndef CTL_UNNUMBERED
988 #error CTL_UNNUMBERED undefined
992 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
993 [unnumbered sysctl support exists])
1000 dnl # 2.6.33 API change,
1001 dnl # Removed .ctl_name from struct ctl_table.
1003 AC_DEFUN([SPL_AC_CTL_NAME], [
1004 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1005 SPL_LINUX_TRY_COMPILE([
1006 #include <linux/sysctl.h>
1008 struct ctl_table ctl __attribute__ ((unused));
1012 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1019 dnl # 2.6.16 API change.
1020 dnl # Check if 'fls64()' is available
1022 AC_DEFUN([SPL_AC_FLS64],
1023 [AC_MSG_CHECKING([whether fls64() is available])
1024 SPL_LINUX_TRY_COMPILE([
1025 #include <linux/bitops.h>
1030 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1037 dnl # 2.6.18 API change, check whether device_create() is available.
1038 dnl # Device_create() was introduced in 2.6.18 and depricated
1039 dnl # class_device_create() which was fully removed in 2.6.26.
1041 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1042 [AC_MSG_CHECKING([whether device_create() is available])
1043 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1045 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1046 [device_create() is available])
1053 dnl # 2.6.27 API change,
1054 dnl # device_create() uses 5 args, new 'drvdata' argument.
1056 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1057 AC_MSG_CHECKING([whether device_create() wants 5 args])
1058 tmp_flags="$EXTRA_KCFLAGS"
1059 EXTRA_KCFLAGS="-Werror"
1060 SPL_LINUX_TRY_COMPILE([
1061 #include <linux/device.h>
1063 device_create(NULL, NULL, 0, NULL, "%d", 1);
1066 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1067 [device_create wants 5 args])
1071 EXTRA_KCFLAGS="$tmp_flags"
1075 dnl # 2.6.13 API change, check whether class_device_create() is available.
1076 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1077 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1079 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1080 [AC_MSG_CHECKING([whether class_device_create() is available])
1081 SPL_LINUX_TRY_COMPILE_SYMBOL([
1082 #include <linux/device.h>
1084 class_device_create(NULL, NULL, 0, NULL, NULL);
1085 ], [class_device_create], [drivers/base/class.c], [
1087 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1088 [class_device_create() is available])
1095 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1097 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1098 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1099 SPL_LINUX_TRY_COMPILE_SYMBOL([
1100 #include <linux/time.h>
1102 set_normalized_timespec(NULL, 0, 0);
1103 ], [set_normalized_timespec], [kernel/time.c], [
1105 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1106 [set_normalized_timespec() is available as export])
1113 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1114 dnl # previously it was available in time.h as an inline.
1116 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1117 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1118 SPL_LINUX_TRY_COMPILE([
1119 #include <linux/time.h>
1120 void set_normalized_timespec(struct timespec *ts,
1121 time_t sec, long nsec) { }
1128 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1129 [set_normalized_timespec() is available as inline])
1134 dnl # 2.6.18 API change,
1135 dnl # timespec_sub() inline function available in linux/time.h
1137 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1138 AC_MSG_CHECKING([whether timespec_sub() is available])
1139 SPL_LINUX_TRY_COMPILE([
1140 #include <linux/time.h>
1142 struct timespec a = { 0 };
1143 struct timespec b = { 0 };
1144 struct timespec c __attribute__ ((unused));
1145 c = timespec_sub(a, b);
1148 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1155 dnl # 2.6.19 API change,
1156 dnl # check if init_utsname() is available in linux/utsname.h
1158 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1159 AC_MSG_CHECKING([whether init_utsname() is available])
1160 SPL_LINUX_TRY_COMPILE([
1161 #include <linux/utsname.h>
1163 struct new_utsname *a __attribute__ ((unused));
1167 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1174 dnl # 2.6.18 API change,
1175 dnl # added linux/uaccess.h
1177 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1178 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1182 dnl # 2.6.12 API change,
1183 dnl # check whether 'kmalloc_node()' is available.
1185 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1186 AC_MSG_CHECKING([whether kmalloc_node() is available])
1187 SPL_LINUX_TRY_COMPILE([
1188 #include <linux/slab.h>
1190 void *a __attribute__ ((unused));
1191 a = kmalloc_node(1, GFP_KERNEL, 0);
1194 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1201 dnl # 2.6.9 API change,
1202 dnl # check whether 'monotonic_clock()' is available it may
1203 dnl # be available for some archs but not others.
1205 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1206 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1207 SPL_LINUX_TRY_COMPILE_SYMBOL([
1208 #include <linux/timex.h>
1211 ], [monotonic_clock], [], [
1213 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1214 [monotonic_clock() is available])
1221 dnl # 2.6.16 API change,
1222 dnl # check whether 'struct inode' has i_mutex
1224 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1225 AC_MSG_CHECKING([whether struct inode has i_mutex])
1226 SPL_LINUX_TRY_COMPILE([
1227 #include <linux/fs.h>
1228 #include <linux/mutex.h>
1231 mutex_init(&i.i_mutex);
1234 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1241 dnl # 2.6.29 API change,
1242 dnl # Adaptive mutexs introduced.
1244 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1245 AC_MSG_CHECKING([whether struct mutex has owner])
1246 SPL_LINUX_TRY_COMPILE([
1247 #include <linux/mutex.h>
1249 struct mutex mtx __attribute__ ((unused));
1253 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1260 dnl # 2.6.39 API change,
1261 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1262 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1263 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1264 dnl # pointer which frankly makes a lot more sense.
1266 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1267 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1268 tmp_flags="$EXTRA_KCFLAGS"
1269 EXTRA_KCFLAGS="-Werror"
1270 SPL_LINUX_TRY_COMPILE([
1271 #include <linux/mutex.h>
1273 struct mutex mtx __attribute__ ((unused));
1274 mtx.owner = current;
1277 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1278 [struct mutex owner is a task_struct])
1282 EXTRA_KCFLAGS="$tmp_flags"
1286 dnl # 2.6.18 API change,
1287 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1288 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1289 dnl # if the mutex validator is disabled or otherwise unavailable.
1291 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1292 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1293 SPL_LINUX_TRY_COMPILE([
1294 #include <linux/mutex.h>
1298 mutex_lock_nested(&mutex, 0);
1301 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1302 [mutex_lock_nested() is available])
1309 dnl # 2.6.27 API change,
1310 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1312 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1313 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1314 SPL_LINUX_TRY_COMPILE([
1315 #include <linux/interrupt.h>
1316 #include <linux/smp.h>
1318 void on_each_cpu_func(void *data) { return; }
1320 on_each_cpu(on_each_cpu_func, NULL, 0);
1323 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1324 [on_each_cpu wants 3 args])
1331 dnl # 2.6.18 API change,
1332 dnl # kallsyms_lookup_name no longer exported
1334 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1335 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1336 SPL_LINUX_TRY_COMPILE_SYMBOL([
1337 #include <linux/kallsyms.h>
1339 kallsyms_lookup_name(NULL);
1340 ], [kallsyms_lookup_name], [], [
1342 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1343 [kallsyms_lookup_name() is available])
1350 dnl # Proposed API change,
1351 dnl # This symbol is not available in stock kernels. You may build a
1352 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1353 dnl # these symbols for use. If your already rolling a custom kernel for
1354 dnl # your environment this is recommended.
1356 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1357 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1358 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1360 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1361 [get_vmalloc_info() is available])
1368 dnl # 2.6.17 API change
1369 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1370 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1371 dnl # were exported in 2.6.17 for use by modules which was consistent with
1372 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1373 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1374 dnl # were dropped entirely leaving modules no way to directly iterate over
1375 dnl # the zone list. Because we need access to the zone helpers we check
1376 dnl # if the kernel contains the old or new implementation. Then we check
1377 dnl # to see if the symbols we need for each version are available. If they
1378 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1380 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1381 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1382 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1384 if test $rc -eq 0; then
1385 AC_MSG_RESULT([yes])
1386 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1393 dnl # Proposed API change,
1394 dnl # This symbol is not available in stock kernels. You may build a
1395 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1396 dnl # these symbols for use. If your already rolling a custom kernel for
1397 dnl # your environment this is recommended.
1399 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1400 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1401 SPL_LINUX_TRY_COMPILE_SYMBOL([
1402 #include <linux/mmzone.h>
1404 first_online_pgdat();
1405 ], [first_online_pgdat], [], [
1407 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1408 [first_online_pgdat() is available])
1415 dnl # Proposed API change,
1416 dnl # This symbol is not available in stock kernels. You may build a
1417 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1418 dnl # these symbols for use. If your already rolling a custom kernel for
1419 dnl # your environment this is recommended.
1421 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1422 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1423 SPL_LINUX_TRY_COMPILE_SYMBOL([
1424 #include <linux/mmzone.h>
1426 next_online_pgdat(NULL);
1427 ], [next_online_pgdat], [], [
1429 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1430 [next_online_pgdat() is available])
1437 dnl # Proposed API change,
1438 dnl # This symbol is not available in stock kernels. You may build a
1439 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1440 dnl # these symbols for use. If your already rolling a custom kernel for
1441 dnl # your environment this is recommended.
1443 AC_DEFUN([SPL_AC_NEXT_ZONE],
1444 [AC_MSG_CHECKING([whether next_zone() is available])
1445 SPL_LINUX_TRY_COMPILE_SYMBOL([
1446 #include <linux/mmzone.h>
1449 ], [next_zone], [], [
1451 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1458 dnl # 2.6.17 API change,
1459 dnl # See SPL_AC_PGDAT_HELPERS for details.
1461 AC_DEFUN([SPL_AC_PGDAT_LIST],
1462 [AC_MSG_CHECKING([whether pgdat_list is available])
1463 SPL_LINUX_TRY_COMPILE_SYMBOL([
1464 #include <linux/topology.h>
1465 pg_data_t *tmp = pgdat_list;
1466 ], [], [pgdat_list], [], [
1468 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1475 dnl # 2.6.18 API change,
1476 dnl # First introduced global_page_state() support as an inline.
1478 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1479 AC_MSG_CHECKING([whether global_page_state() is available])
1480 SPL_LINUX_TRY_COMPILE([
1481 #include <linux/mm.h>
1483 unsigned long state __attribute__ ((unused));
1484 state = global_page_state(0);
1487 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1488 [global_page_state() is available])
1495 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1496 dnl # Public global zone stats now include a free page count. However
1497 dnl # the enumerated names of the counters have changed since this API
1498 dnl # was introduced. We need to deduce the corrent name to use. This
1499 dnl # replaces the priviate get_zone_counts() interface.
1501 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1502 dnl # is 2.6.30 as of when this was written.
1504 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1505 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1506 SPL_LINUX_TRY_COMPILE([
1507 #include <linux/mm.h>
1509 enum zone_stat_item zsi __attribute__ ((unused));
1510 zsi = NR_FREE_PAGES;
1513 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1514 [Page state NR_FREE_PAGES is available])
1521 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1522 dnl # Public global zone stats now include an inactive page count. However
1523 dnl # the enumerated names of the counters have changed since this API
1524 dnl # was introduced. We need to deduce the corrent name to use. This
1525 dnl # replaces the priviate get_zone_counts() interface.
1527 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1528 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1529 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1531 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1532 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1533 SPL_LINUX_TRY_COMPILE([
1534 #include <linux/mm.h>
1536 enum zone_stat_item zsi __attribute__ ((unused));
1540 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1541 [Page state NR_INACTIVE is available])
1546 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1547 SPL_LINUX_TRY_COMPILE([
1548 #include <linux/mm.h>
1550 enum zone_stat_item zsi __attribute__ ((unused));
1551 zsi = NR_INACTIVE_ANON;
1554 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1555 [Page state NR_INACTIVE_ANON is available])
1560 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1561 SPL_LINUX_TRY_COMPILE([
1562 #include <linux/mm.h>
1564 enum zone_stat_item zsi __attribute__ ((unused));
1565 zsi = NR_INACTIVE_FILE;
1568 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1569 [Page state NR_INACTIVE_FILE is available])
1576 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1577 dnl # Public global zone stats now include an active page count. However
1578 dnl # the enumerated names of the counters have changed since this API
1579 dnl # was introduced. We need to deduce the corrent name to use. This
1580 dnl # replaces the priviate get_zone_counts() interface.
1582 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1583 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1584 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1586 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1587 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1588 SPL_LINUX_TRY_COMPILE([
1589 #include <linux/mm.h>
1591 enum zone_stat_item zsi __attribute__ ((unused));
1595 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1596 [Page state NR_ACTIVE is available])
1601 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1602 SPL_LINUX_TRY_COMPILE([
1603 #include <linux/mm.h>
1605 enum zone_stat_item zsi __attribute__ ((unused));
1606 zsi = NR_ACTIVE_ANON;
1609 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1610 [Page state NR_ACTIVE_ANON is available])
1615 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1616 SPL_LINUX_TRY_COMPILE([
1617 #include <linux/mm.h>
1619 enum zone_stat_item zsi __attribute__ ((unused));
1620 zsi = NR_ACTIVE_FILE;
1623 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1624 [Page state NR_ACTIVE_FILE is available])
1631 dnl # Proposed API change for legacy kernels.
1632 dnl # This symbol is not available in older kernels. For kernels post
1633 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1634 dnl # page state information. This symbol is only used in legacy kernels
1635 dnl # any only as a last resort.
1637 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1638 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1639 SPL_LINUX_TRY_COMPILE([
1641 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1642 #error "global_page_state needs NR_FREE_PAGES"
1645 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1646 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1647 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1648 #error "global_page_state needs NR_ACTIVE*"
1651 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1652 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1653 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1654 #error "global_page_state needs NR_INACTIVE*"
1660 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1661 [get_zone_counts() is needed])
1663 AC_MSG_CHECKING([whether get_zone_counts() is available])
1664 SPL_LINUX_TRY_COMPILE_SYMBOL([
1665 #include <linux/mmzone.h>
1667 get_zone_counts(NULL, NULL, NULL);
1668 ], [get_zone_counts], [], [
1670 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1671 [get_zone_counts() is available])
1679 dnl # 2.6.27 API change,
1680 dnl # The user_path_dir() replaces __user_walk()
1682 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1683 [AC_MSG_CHECKING([whether user_path_dir() is available])
1684 SPL_LINUX_TRY_COMPILE_SYMBOL([
1685 #include <linux/fcntl.h>
1686 #include <linux/namei.h>
1688 user_path_dir(NULL, NULL);
1689 ], [user_path_at], [], [
1691 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1698 dnl # Symbol available in RHEL kernels not in stock kernels.
1700 AC_DEFUN([SPL_AC_SET_FS_PWD],
1701 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1702 SPL_LINUX_TRY_COMPILE_SYMBOL([
1703 #include <linux/spinlock.h>
1704 #include <linux/fs_struct.h>
1707 ], [set_fs_pwd], [], [
1709 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1716 dnl # 2.6.25 API change,
1717 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1719 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1720 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1721 SPL_LINUX_TRY_COMPILE([
1722 #include <linux/sched.h>
1723 #include <linux/fs_struct.h>
1725 set_fs_pwd(NULL, NULL);
1728 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1729 [set_fs_pwd() wants 2 args])
1736 dnl # SLES API change, never adopted in mainline,
1737 dnl # Third 'struct vfsmount *' argument removed.
1739 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1740 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1741 SPL_LINUX_TRY_COMPILE([
1742 #include <linux/fs.h>
1744 vfs_unlink(NULL, NULL);
1747 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1748 [vfs_unlink() wants 2 args])
1755 dnl # SLES API change, never adopted in mainline,
1756 dnl # Third and sixth 'struct vfsmount *' argument removed.
1758 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1759 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1760 SPL_LINUX_TRY_COMPILE([
1761 #include <linux/fs.h>
1763 vfs_rename(NULL, NULL, NULL, NULL);
1766 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1767 [vfs_rename() wants 4 args])
1774 dnl # 2.6.36 API change,
1775 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1776 dnl # a spinlock_t to improve the fastpath performance.
1778 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1779 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1780 tmp_flags="$EXTRA_KCFLAGS"
1781 EXTRA_KCFLAGS="-Werror"
1782 SPL_LINUX_TRY_COMPILE([
1783 #include <linux/sched.h>
1784 #include <linux/fs_struct.h>
1786 struct fs_struct fs;
1787 spin_lock_init(&fs.lock);
1790 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1791 [struct fs_struct uses spinlock_t])
1795 EXTRA_KCFLAGS="$tmp_flags"
1799 dnl # 2.6.29 API change,
1800 dnl # check whether 'struct cred' exists
1802 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1803 AC_MSG_CHECKING([whether struct cred exists])
1804 SPL_LINUX_TRY_COMPILE([
1805 #include <linux/cred.h>
1807 struct cred *cr __attribute__ ((unused));
1811 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1818 dnl # Custom SPL patch may export this symbol.
1820 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1821 [AC_MSG_CHECKING([whether groups_search() is available])
1822 SPL_LINUX_TRY_COMPILE_SYMBOL([
1823 #include <linux/cred.h>
1825 groups_search(NULL, 0);
1826 ], [groups_search], [], [
1828 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1835 dnl # 2.6.x API change,
1836 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1838 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1839 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1840 SPL_LINUX_TRY_COMPILE_SYMBOL([
1841 #include <linux/sched.h>
1843 __put_task_struct(NULL);
1844 ], [__put_task_struct], [], [
1846 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1847 [__put_task_struct() is available])
1854 dnl # 2.6.32 API change,
1855 dnl # Unused 'struct file *' removed from prototype.
1857 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1858 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1859 SPL_LINUX_TRY_COMPILE([
1860 #include <linux/sysctl.h>
1862 proc_dostring(NULL, 0, NULL, NULL, NULL);
1865 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1866 [proc_handler() wants 5 args])
1873 dnl # 2.6.x API change,
1874 dnl # kvasprintf() function added.
1876 AC_DEFUN([SPL_AC_KVASPRINTF],
1877 [AC_MSG_CHECKING([whether kvasprintf() is available])
1878 SPL_LINUX_TRY_COMPILE_SYMBOL([
1879 #include <linux/kernel.h>
1881 kvasprintf(0, NULL, *((va_list*)NULL));
1882 ], [kvasprintf], [], [
1884 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1891 dnl # 2.6.29 API change,
1892 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1894 AC_DEFUN([SPL_AC_VFS_FSYNC],
1895 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1896 SPL_LINUX_TRY_COMPILE_SYMBOL([
1897 #include <linux/fs.h>
1900 ], [vfs_fsync], [fs/sync.c], [
1902 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1909 dnl # 2.6.35 API change,
1910 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1912 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1913 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1914 SPL_LINUX_TRY_COMPILE([
1915 #include <linux/fs.h>
1920 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1927 dnl # 3.5 API change,
1928 dnl # inode_operations.truncate_range removed
1930 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1931 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1932 SPL_LINUX_TRY_COMPILE([
1933 #include <linux/fs.h>
1935 struct inode_operations ops;
1936 ops.truncate_range = NULL;
1939 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1940 [truncate_range() inode operation is available])
1947 dnl # Linux 2.6.38 - 3.x API
1949 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1950 AC_MSG_CHECKING([whether fops->fallocate() exists])
1951 SPL_LINUX_TRY_COMPILE([
1952 #include <linux/fs.h>
1954 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1955 struct file_operations fops __attribute__ ((unused)) = {
1956 .fallocate = fallocate,
1960 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1967 dnl # Linux 2.6.x - 2.6.37 API
1969 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1970 AC_MSG_CHECKING([whether iops->fallocate() exists])
1971 SPL_LINUX_TRY_COMPILE([
1972 #include <linux/fs.h>
1974 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1975 struct inode_operations fops __attribute__ ((unused)) = {
1976 .fallocate = fallocate,
1980 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1987 dnl # PaX Linux 2.6.38 - 3.x API
1989 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1990 AC_MSG_CHECKING([whether fops->fallocate() exists])
1991 SPL_LINUX_TRY_COMPILE([
1992 #include <linux/fs.h>
1994 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1995 struct file_operations_no_const fops __attribute__ ((unused)) = {
1996 .fallocate = fallocate,
2000 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2007 dnl # The fallocate callback was moved from the inode_operations
2008 dnl # structure to the file_operations structure.
2010 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2011 SPL_AC_KERNEL_FILE_FALLOCATE
2012 SPL_AC_KERNEL_INODE_FALLOCATE
2013 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2017 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2018 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2019 dnl # condition. The fixed version is exported as a symbol. The race
2020 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2021 dnl # call that version while holding sem->wait_lock.
2023 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2024 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2025 SPL_LINUX_TRY_COMPILE_SYMBOL([
2026 #include <linux/rwsem.h>
2027 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2028 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2030 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2031 [rwsem_is_locked() acquires sem->wait_lock])
2038 dnl # 2.6.37 API compat,
2039 dnl # The function invalidate_inodes() is no longer exported by the kernel.
2040 dnl # The prototype however is still available which means it is safe
2041 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
2043 dnl # The Proxmox VE kernel contains a patch which renames the function
2044 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
2045 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
2046 dnl # compatibility wrapper for legacy callers. Therefore, if either
2047 dnl # of these functions are exported invalidate_inodes() can be
2050 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
2051 AC_MSG_CHECKING([whether invalidate_inodes() is available])
2052 SPL_LINUX_TRY_COMPILE_SYMBOL([
2053 #include <linux/fs.h>
2056 ], [invalidate_inodes], [], [
2058 AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
2059 [invalidate_inodes() is available])
2064 AC_MSG_CHECKING([whether invalidate_inodes_check() is available])
2065 SPL_LINUX_TRY_COMPILE_SYMBOL([
2066 #include <linux/fs.h>
2067 #ifndef invalidate_inodes
2068 #error invalidate_inodes is not a macro
2070 ], [ ], [invalidate_inodes_check], [], [
2072 AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
2073 [invalidate_inodes_check() is available])
2080 dnl # 2.6.39 API compat,
2081 dnl # The function invalidate_inodes() now take 2 arguments. The second
2082 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
2083 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
2084 dnl # otherwise they will be handled as busy.
2086 dnl # Unfortunately, we don't have access to the invalidate_inodes()
2087 dnl # prototype so it's not easy to check how many arguments it takes.
2088 dnl # However, this change was done for the benefit of invalidate_device()
2089 dnl # which also added an argument. The invalidate_device() symbol does
2090 dnl # exist in the development headers so if it takes two arguments we
2091 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
2092 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
2094 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
2095 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
2096 SPL_LINUX_TRY_COMPILE([
2097 #include <linux/fs.h>
2099 return __invalidate_device(NULL, 0);
2102 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
2103 [invalidate_inodes() wants 2 args])
2110 dnl # 2.6.xx API compat,
2111 dnl # There currently exists no exposed API to partially shrink the dcache.
2112 dnl # The expected mechanism to shrink the cache is a registered shrinker
2113 dnl # which is called during memory pressure.
2115 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2116 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2117 SPL_LINUX_TRY_COMPILE_SYMBOL([
2118 #include <linux/dcache.h>
2120 shrink_dcache_memory(0, 0);
2121 ], [shrink_dcache_memory], [fs/dcache.c], [
2123 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2124 [shrink_dcache_memory() is available])
2131 dnl # 2.6.xx API compat,
2132 dnl # There currently exists no exposed API to partially shrink the icache.
2133 dnl # The expected mechanism to shrink the cache is a registered shrinker
2134 dnl # which is called during memory pressure.
2136 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2137 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2138 SPL_LINUX_TRY_COMPILE_SYMBOL([
2139 #include <linux/dcache.h>
2141 shrink_icache_memory(0, 0);
2142 ], [shrink_icache_memory], [fs/inode.c], [
2144 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2145 [shrink_icache_memory() is available])
2152 dnl # 2.6.39 API compat,
2153 dnl # The path_lookup() function has been renamed to kern_path_parent()
2154 dnl # and the flags argument has been removed. The only behavior now
2155 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2156 dnl # this flag so dropping the flag does not impact us.
2158 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2159 SPL_CHECK_SYMBOL_HEADER(
2161 [int kern_path_parent(const char \*, struct nameidata \*)],
2162 [include/linux/namei.h],
2163 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2164 [kern_path_parent() is available])],
2169 dnl # 3.1 API compat,
2170 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2171 dnl # However, it remains the prefered interface and since we still have
2172 dnl # access to the prototype we dynamically lookup the required address.
2174 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2175 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2176 SPL_LINUX_TRY_COMPILE_SYMBOL([
2177 #include <linux/namei.h>
2179 kern_path_parent(NULL, NULL);
2180 ], [kern_path_parent], [fs/namei.c], [
2182 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2183 [kern_path_parent() is available])
2190 dnl # 3.6 API compat,
2191 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2192 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2194 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2195 SPL_CHECK_SYMBOL_HEADER(
2197 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2198 [include/linux/namei.h],
2199 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2200 [kern_path_locked() is available])],
2205 dnl # 2.6.39 API compat,
2206 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2207 dnl # This was done to avoid always having to allocate the maximum size
2208 dnl # workspace (268K). The caller can now specific the windowBits and
2209 dnl # memLevel compression parameters to get a smaller workspace.
2211 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2212 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2213 SPL_LINUX_TRY_COMPILE([
2214 #include <linux/zlib.h>
2216 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2219 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2220 [zlib_deflate_workspacesize() wants 2 args])
2227 dnl # 2.6.39 API change,
2228 dnl # Shrinker adjust to use common shrink_control structure.
2230 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2231 AC_MSG_CHECKING([whether struct shrink_control exists])
2232 SPL_LINUX_TRY_COMPILE([
2233 #include <linux/mm.h>
2235 struct shrink_control sc __attribute__ ((unused));
2238 sc.gfp_mask = GFP_KERNEL;
2241 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2242 [struct shrink_control exists])
2249 dnl # 3.1 API Change
2251 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2252 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2254 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2255 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2256 tmp_flags="$EXTRA_KCFLAGS"
2257 EXTRA_KCFLAGS="-Werror"
2258 SPL_LINUX_TRY_COMPILE([
2259 #include <linux/rwsem.h>
2261 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2262 raw_spinlock_t dummy_lock __attribute__ ((unused));
2263 dummy_semaphore.wait_lock = dummy_lock;
2266 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2267 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2271 EXTRA_KCFLAGS="$tmp_flags"