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_SHRINKER_CALLBACK
30 SPL_AC_MUTEX_OWNER_TASK_STRUCT
31 SPL_AC_SET_FS_PWD_WITH_CONST
32 SPL_AC_2ARGS_VFS_UNLINK
33 SPL_AC_4ARGS_VFS_RENAME
35 SPL_AC_2ARGS_VFS_FSYNC
36 SPL_AC_INODE_TRUNCATE_RANGE
37 SPL_AC_FS_STRUCT_SPINLOCK
39 SPL_AC_PUT_TASK_STRUCT
40 SPL_AC_5ARGS_PROC_HANDLER
42 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
43 SPL_AC_KERNEL_FALLOCATE
45 SPL_AC_CONFIG_ZLIB_INFLATE
46 SPL_AC_CONFIG_ZLIB_DEFLATE
47 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
48 SPL_AC_SHRINK_CONTROL_STRUCT
49 SPL_AC_RWSEM_SPINLOCK_IS_RAW
50 SPL_AC_SCHED_RT_HEADER
51 SPL_AC_2ARGS_VFS_GETATTR
53 SPL_AC_KMEM_CACHE_ALLOCFLAGS
57 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
58 modpost=$LINUX/scripts/Makefile.modpost
59 AC_MSG_CHECKING([kernel file name for module symbols])
60 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
61 if grep -q Modules.symvers $modpost; then
62 LINUX_SYMBOLS=Modules.symvers
64 LINUX_SYMBOLS=Module.symvers
67 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
69 *** Please make sure the kernel devel package for your distribution
70 *** is installed. If you are building with a custom kernel, make sure the
71 *** kernel is configured, built, and the '--with-linux=PATH' configure
72 *** option refers to the location of the kernel source.])
77 AC_MSG_RESULT($LINUX_SYMBOLS)
78 AC_SUBST(LINUX_SYMBOLS)
81 AC_DEFUN([SPL_AC_KERNEL], [
83 AS_HELP_STRING([--with-linux=PATH],
84 [Path to kernel source]),
85 [kernelsrc="$withval"])
87 AC_ARG_WITH([linux-obj],
88 AS_HELP_STRING([--with-linux-obj=PATH],
89 [Path to kernel build objects]),
90 [kernelbuild="$withval"])
92 AC_MSG_CHECKING([kernel source directory])
93 if test -z "$kernelsrc"; then
94 if test -e "/lib/modules/$(uname -r)/source"; then
95 headersdir="/lib/modules/$(uname -r)/source"
96 sourcelink=$(readlink -f "$headersdir")
97 elif test -e "/lib/modules/$(uname -r)/build"; then
98 headersdir="/lib/modules/$(uname -r)/build"
99 sourcelink=$(readlink -f "$headersdir")
101 sourcelink=$(ls -1d /usr/src/kernels/* \
103 2>/dev/null | grep -v obj | tail -1)
106 if test -n "$sourcelink" && test -e ${sourcelink}; then
107 kernelsrc=`readlink -f ${sourcelink}`
109 kernelsrc="[Not found]"
112 if test "$kernelsrc" = "NONE"; then
117 AC_MSG_RESULT([$kernelsrc])
118 if test ! -d "$kernelsrc"; then
120 *** Please make sure the kernel devel package for your distribution
121 *** is installed and then try again. If that fails, you can specify the
122 *** location of the kernel source with the '--with-linux=PATH' option.])
125 AC_MSG_CHECKING([kernel build directory])
126 if test -z "$kernelbuild"; then
127 if test -e "/lib/modules/$(uname -r)/build"; then
128 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
129 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
130 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
131 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
132 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
133 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
134 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
136 kernelbuild=${kernelsrc}
139 AC_MSG_RESULT([$kernelbuild])
141 AC_MSG_CHECKING([kernel source version])
142 utsrelease1=$kernelbuild/include/linux/version.h
143 utsrelease2=$kernelbuild/include/linux/utsrelease.h
144 utsrelease3=$kernelbuild/include/generated/utsrelease.h
145 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
146 utsrelease=linux/version.h
147 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
148 utsrelease=linux/utsrelease.h
149 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
150 utsrelease=generated/utsrelease.h
153 if test "$utsrelease"; then
154 kernsrcver=`(echo "#include <$utsrelease>";
155 echo "kernsrcver=UTS_RELEASE") |
156 cpp -I $kernelbuild/include |
157 grep "^kernsrcver=" | cut -d \" -f 2`
159 if test -z "$kernsrcver"; then
160 AC_MSG_RESULT([Not found])
161 AC_MSG_ERROR([*** Cannot determine kernel version.])
164 AC_MSG_RESULT([Not found])
165 if test "x$enable_linux_builtin" != xyes; then
166 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
169 *** Cannot find UTS_RELEASE definition.
170 *** Please run 'make prepare' inside the kernel source tree.])
174 AC_MSG_RESULT([$kernsrcver])
177 LINUX_OBJ=${kernelbuild}
178 LINUX_VERSION=${kernsrcver}
182 AC_SUBST(LINUX_VERSION)
184 SPL_AC_MODULE_SYMVERS
188 dnl # Default SPL user configuration
190 AC_DEFUN([SPL_AC_CONFIG_USER], [])
193 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
194 dnl # are missing, it is non-fatal, but you will not be able to build
195 dnl # RPM packages and will be warned if you try too.
197 dnl # By default, the generic spec file will be used because it requires
198 dnl # minimal dependencies. Distribution specific spec files can be
199 dnl # placed under the 'rpm/<distribution>' directory and enabled using
200 dnl # the --with-spec=<distribution> configure option.
202 AC_DEFUN([SPL_AC_RPM], [
206 AC_MSG_CHECKING([whether $RPM is available])
207 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
208 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
210 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
213 AC_MSG_RESULT([$HAVE_RPM])
216 AC_MSG_CHECKING([whether $RPMBUILD is available])
217 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
218 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
220 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
223 AC_MSG_RESULT([$HAVE_RPMBUILD])
226 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
228 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
231 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
236 RPM_SPEC_DIR="rpm/generic"
238 AS_HELP_STRING([--with-spec=SPEC],
239 [Spec files 'generic|fedora']),
240 [RPM_SPEC_DIR="rpm/$withval"])
242 AC_MSG_CHECKING([whether spec files are available])
243 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
247 AC_SUBST(RPM_VERSION)
249 AC_SUBST(HAVE_RPMBUILD)
251 AC_SUBST(RPMBUILD_VERSION)
253 AC_SUBST(RPM_SPEC_DIR)
254 AC_SUBST(RPM_DEFINE_UTIL)
255 AC_SUBST(RPM_DEFINE_KMOD)
256 AC_SUBST(RPM_DEFINE_DKMS)
257 AC_SUBST(RPM_DEFINE_COMMON)
258 AC_SUBST(SRPM_DEFINE_UTIL)
259 AC_SUBST(SRPM_DEFINE_KMOD)
260 AC_SUBST(SRPM_DEFINE_DKMS)
261 AC_SUBST(SRPM_DEFINE_COMMON)
265 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
266 dnl # tools are missing it is non-fatal but you will not be able to build
267 dnl # DEB packages and will be warned if you try too.
269 AC_DEFUN([SPL_AC_DPKG], [
271 DPKGBUILD=dpkg-buildpackage
273 AC_MSG_CHECKING([whether $DPKG is available])
274 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
275 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
277 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
280 AC_MSG_RESULT([$HAVE_DPKG])
283 AC_MSG_CHECKING([whether $DPKGBUILD is available])
284 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
285 DPKGBUILD_VERSION=$(echo $tmp | \
286 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
288 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
291 AC_MSG_RESULT([$HAVE_DPKGBUILD])
296 AC_SUBST(DPKG_VERSION)
298 AC_SUBST(HAVE_DPKGBUILD)
300 AC_SUBST(DPKGBUILD_VERSION)
304 dnl # Until native packaging for various different packing systems
305 dnl # can be added the least we can do is attempt to use alien to
306 dnl # convert the RPM packages to the needed package type. This is
307 dnl # a hack but so far it has worked reasonable well.
309 AC_DEFUN([SPL_AC_ALIEN], [
312 AC_MSG_CHECKING([whether $ALIEN is available])
313 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
314 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
316 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
319 AC_MSG_RESULT([$HAVE_ALIEN])
324 AC_SUBST(ALIEN_VERSION)
328 dnl # Using the VENDOR tag from config.guess set the default
329 dnl # package type for 'make pkg': (rpm | deb | tgz)
331 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
332 AC_MSG_CHECKING([linux distribution])
333 if test -f /etc/toss-release ; then
335 elif test -f /etc/fedora-release ; then
337 elif test -f /etc/redhat-release ; then
339 elif test -f /etc/gentoo-release ; then
341 elif test -f /etc/arch-release ; then
343 elif test -f /etc/SuSE-release ; then
345 elif test -f /etc/slackware-version ; then
347 elif test -f /etc/lunar.release ; then
349 elif test -f /etc/lsb-release ; then
351 elif test -f /etc/debian_version ; then
356 AC_MSG_RESULT([$VENDOR])
359 AC_MSG_CHECKING([default package type])
361 toss) DEFAULT_PACKAGE=rpm ;;
362 redhat) DEFAULT_PACKAGE=rpm ;;
363 fedora) DEFAULT_PACKAGE=rpm ;;
364 gentoo) DEFAULT_PACKAGE=tgz ;;
365 arch) DEFAULT_PACKAGE=tgz ;;
366 sles) DEFAULT_PACKAGE=rpm ;;
367 slackware) DEFAULT_PACKAGE=tgz ;;
368 lunar) DEFAULT_PACKAGE=tgz ;;
369 ubuntu) DEFAULT_PACKAGE=deb ;;
370 debian) DEFAULT_PACKAGE=deb ;;
371 *) DEFAULT_PACKAGE=rpm ;;
374 AC_MSG_RESULT([$DEFAULT_PACKAGE])
375 AC_SUBST(DEFAULT_PACKAGE)
379 dnl # Default SPL user configuration
381 AC_DEFUN([SPL_AC_PACKAGE], [
382 SPL_AC_DEFAULT_PACKAGE
388 AC_DEFUN([SPL_AC_LICENSE], [
389 AC_MSG_CHECKING([spl author])
390 AC_MSG_RESULT([$SPL_META_AUTHOR])
392 AC_MSG_CHECKING([spl license])
393 AC_MSG_RESULT([$SPL_META_LICENSE])
396 AC_DEFUN([SPL_AC_CONFIG], [
398 AC_ARG_WITH([config],
399 AS_HELP_STRING([--with-config=CONFIG],
400 [Config file 'kernel|user|all|srpm']),
401 [SPL_CONFIG="$withval"])
402 AC_ARG_ENABLE([linux-builtin],
403 [AC_HELP_STRING([--enable-linux-builtin],
404 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
406 [enable_linux_builtin=no])
408 AC_MSG_CHECKING([spl config])
409 AC_MSG_RESULT([$SPL_CONFIG]);
412 case "$SPL_CONFIG" in
413 kernel) SPL_AC_CONFIG_KERNEL ;;
414 user) SPL_AC_CONFIG_USER ;;
415 all) SPL_AC_CONFIG_KERNEL
416 SPL_AC_CONFIG_USER ;;
419 AC_MSG_RESULT([Error!])
420 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
421 user kernel|user|all|srpm]) ;;
424 AM_CONDITIONAL([CONFIG_USER],
425 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
426 AM_CONDITIONAL([CONFIG_KERNEL],
427 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
428 [test "x$enable_linux_builtin" != xyes ])
432 dnl # Enable if the SPL should be compiled with internal debugging enabled.
433 dnl # By default this support is disabled.
435 AC_DEFUN([SPL_AC_DEBUG], [
436 AC_MSG_CHECKING([whether debugging is enabled])
437 AC_ARG_ENABLE([debug],
438 [AS_HELP_STRING([--enable-debug],
439 [Enable generic debug support @<:@default=no@:>@])],
443 AS_IF([test "x$enable_debug" = xyes],
445 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
446 DEBUG_CFLAGS="-DDEBUG -Werror"
447 DEBUG_SPL="_with_debug"
449 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
450 DEBUG_CFLAGS="-DNDEBUG"
451 DEBUG_SPL="_without_debug"
454 AC_SUBST(DEBUG_CFLAGS)
456 AC_MSG_RESULT([$enable_debug])
460 dnl # Enabled by default it provides a basic debug log infrastructure.
461 dnl # Each subsystem registers itself with a name and logs messages
462 dnl # using predefined types. If the debug mask it set to allow the
463 dnl # message type it will be written to the internal log. The log
464 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
465 dnl # after dumping the log it must be decoded using the spl utility.
467 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
468 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
470 AC_DEFUN([SPL_AC_DEBUG_LOG], [
471 AC_ARG_ENABLE([debug-log],
472 [AS_HELP_STRING([--enable-debug-log],
473 [Enable basic debug logging @<:@default=yes@:>@])],
475 [enable_debug_log=yes])
477 AS_IF([test "x$enable_debug_log" = xyes],
479 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
480 DEBUG_LOG="_with_debug_log"
481 AC_DEFINE([DEBUG_LOG], [1],
482 [Define to 1 to enable basic debug logging])
484 DEBUG_LOG="_without_debug_log"
488 AC_MSG_CHECKING([whether basic debug logging is enabled])
489 AC_MSG_RESULT([$enable_debug_log])
493 dnl # Enabled by default it provides a minimal level of memory tracking.
494 dnl # A total count of bytes allocated is kept for each alloc and free.
495 dnl # Then at module unload time a report to the console will be printed
496 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
497 dnl # and provide an easy way to inspect the kmem based slab.
499 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
500 AC_ARG_ENABLE([debug-kmem],
501 [AS_HELP_STRING([--enable-debug-kmem],
502 [Enable basic kmem accounting @<:@default=yes@:>@])],
504 [enable_debug_kmem=yes])
506 AS_IF([test "x$enable_debug_kmem" = xyes],
508 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
509 DEBUG_KMEM="_with_debug_kmem"
510 AC_DEFINE([DEBUG_KMEM], [1],
511 [Define to 1 to enable basic kmem accounting])
513 DEBUG_KMEM="_without_debug_kmem"
517 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
518 AC_MSG_RESULT([$enable_debug_kmem])
522 dnl # Disabled by default it provides detailed memory tracking. This
523 dnl # feature also requires --enable-debug-kmem to be set. When enabled
524 dnl # not only will total bytes be tracked but also the location of every
525 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
526 dnl # addresses and where they were allocated will be dumped to the console.
527 dnl # Enabling this feature has a significant impact on performance but it
528 dnl # makes finding memory leaks pretty straight forward.
530 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
531 AC_ARG_ENABLE([debug-kmem-tracking],
532 [AS_HELP_STRING([--enable-debug-kmem-tracking],
533 [Enable detailed kmem tracking @<:@default=no@:>@])],
535 [enable_debug_kmem_tracking=no])
537 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
539 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
540 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
541 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
542 [Define to 1 to enable detailed kmem tracking])
544 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
547 AC_SUBST(DEBUG_KMEM_TRACKING)
548 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
549 AC_MSG_RESULT([$enable_debug_kmem_tracking])
553 dnl # SPL_LINUX_CONFTEST
555 AC_DEFUN([SPL_LINUX_CONFTEST], [
556 cat confdefs.h - <<_ACEOF >conftest.c
562 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
564 m4_define([SPL_LANG_PROGRAM], [
569 dnl Do *not* indent the following line: there may be CPP directives.
570 dnl Don't move the `;' right after for the same reason.
578 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
580 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
581 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
582 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
583 echo "obj-m := conftest.o" >build/Makefile
585 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
587 [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])],
589 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
595 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
597 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
598 [SPL_LINUX_COMPILE_IFELSE(
599 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
601 [test -s build/conftest.o],
606 dnl # SPL_CHECK_SYMBOL_EXPORT
607 dnl # check symbol exported or not
609 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
610 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
611 $LINUX_OBJ/Module*.symvers 2>/dev/null
613 if test $rc -ne 0; then
616 grep -q -E "EXPORT_SYMBOL.*($1)" \
617 "$LINUX_OBJ/$file" 2>/dev/null
619 if test $rc -eq 0; then
624 if test $export -eq 0; then :
635 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
636 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
637 dnl # is called if not compiling for builtin
639 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
640 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
641 if test $rc -ne 0; then :
644 if test "x$enable_linux_builtin" != xyes; then
645 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
647 if test $rc -ne 0; then :
656 dnl # SPL_CHECK_SYMBOL_HEADER
657 dnl # check if a symbol prototype is defined in listed headers.
659 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
660 AC_MSG_CHECKING([whether symbol $1 exists in header])
663 grep -q "$2" "$LINUX/$file" 2>/dev/null
665 if test $rc -eq 0; then
670 if test $header -eq 0; then
680 dnl # SPL_CHECK_HEADER
681 dnl # check whether header exists and define HAVE_$2_HEADER
683 AC_DEFUN([SPL_CHECK_HEADER],
684 [AC_MSG_CHECKING([whether header $1 exists])
685 SPL_LINUX_TRY_COMPILE([
690 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
700 dnl # Basic toolchain sanity check. Verify that kernel modules can
701 dnl # be built and which symbols can be used.
703 AC_DEFUN([SPL_AC_TEST_MODULE],
704 [AC_MSG_CHECKING([whether modules can be built])
705 SPL_LINUX_TRY_COMPILE([],[],[
709 if test "x$enable_linux_builtin" != xyes; then
710 AC_MSG_ERROR([*** Unable to build an empty module.])
713 *** Unable to build an empty module.
714 *** Please run 'make scripts' inside the kernel source tree.])
720 #include "$LINUX/include/linux/license.h"
722 return !license_is_gpl_compatible("$SPL_META_LICENSE");
725 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
726 [Define to 1 if GPL-only symbols can be used])
732 dnl # Use the atomic implemenation based on global spinlocks. This
733 dnl # should only be needed by 32-bit kernels which do not provide
734 dnl # the atomic64_* API. It may be optionally enabled as a fallback
735 dnl # if problems are observed with the direct mapping to the native
736 dnl # Linux atomic operations. You may not disable atomic spinlocks
737 dnl # if you kernel does not an atomic64_* API.
739 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
740 AC_ARG_ENABLE([atomic-spinlocks],
741 [AS_HELP_STRING([--enable-atomic-spinlocks],
742 [Atomic types use spinlocks @<:@default=check@:>@])],
744 [enable_atomic_spinlocks=check])
746 SPL_LINUX_TRY_COMPILE([
747 #include <linux/fs.h>
749 atomic64_t *ptr __attribute__ ((unused));
752 AC_DEFINE(HAVE_ATOMIC64_T, 1,
753 [kernel defines atomic64_t])
758 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
759 AS_IF([test "x$have_atomic64_t" = xyes], [
760 enable_atomic_spinlocks=no
762 enable_atomic_spinlocks=yes
766 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
767 AC_DEFINE([ATOMIC_SPINLOCK], [1],
768 [Atomic types use spinlocks])
770 AS_IF([test "x$have_atomic64_t" = xno], [
772 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
776 AC_MSG_CHECKING([whether atomic types use spinlocks])
777 AC_MSG_RESULT([$enable_atomic_spinlocks])
779 AC_MSG_CHECKING([whether kernel defines atomic64_t])
780 AC_MSG_RESULT([$have_atomic64_t])
783 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
784 tmp_flags="$EXTRA_KCFLAGS"
785 EXTRA_KCFLAGS="-Werror"
787 dnl # 2.6.23 to 2.6.34 API change
788 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
790 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
791 SPL_LINUX_TRY_COMPILE([
792 #include <linux/mm.h>
794 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
796 struct shrinker cache_shrinker = {
797 .shrink = shrinker_cb,
798 .seeks = DEFAULT_SEEKS,
800 register_shrinker(&cache_shrinker);
803 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
804 [old shrinker callback wants 2 args])
808 dnl # 2.6.35 - 2.6.39 API change
809 dnl # ->shrink(struct shrinker *,
810 dnl # int nr_to_scan, gfp_t gfp_mask)
812 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
813 SPL_LINUX_TRY_COMPILE([
814 #include <linux/mm.h>
816 int shrinker_cb(struct shrinker *, int nr_to_scan,
819 struct shrinker cache_shrinker = {
820 .shrink = shrinker_cb,
821 .seeks = DEFAULT_SEEKS,
823 register_shrinker(&cache_shrinker);
826 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
827 [old shrinker callback wants 3 args])
831 dnl # 3.0 - 3.11 API change
832 dnl # ->shrink(struct shrinker *,
833 dnl # struct shrink_control *sc)
836 [whether new 2-argument shrinker exists])
837 SPL_LINUX_TRY_COMPILE([
838 #include <linux/mm.h>
840 int shrinker_cb(struct shrinker *,
841 struct shrink_control *sc);
843 struct shrinker cache_shrinker = {
844 .shrink = shrinker_cb,
845 .seeks = DEFAULT_SEEKS,
847 register_shrinker(&cache_shrinker);
850 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
851 [new shrinker callback wants 2 args])
855 dnl # 3.12 API change,
856 dnl # ->shrink() is logically split in to
857 dnl # ->count_objects() and ->scan_objects()
860 [whether ->count_objects callback exists])
861 SPL_LINUX_TRY_COMPILE([
862 #include <linux/mm.h>
864 unsigned long shrinker_cb(
866 struct shrink_control *sc);
868 struct shrinker cache_shrinker = {
869 .count_objects = shrinker_cb,
870 .scan_objects = shrinker_cb,
871 .seeks = DEFAULT_SEEKS,
873 register_shrinker(&cache_shrinker);
876 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
877 1, [->count_objects exists])
884 EXTRA_KCFLAGS="$tmp_flags"
888 dnl # 2.6.33 API change,
889 dnl # Removed .ctl_name from struct ctl_table.
891 AC_DEFUN([SPL_AC_CTL_NAME], [
892 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
893 SPL_LINUX_TRY_COMPILE([
894 #include <linux/sysctl.h>
896 struct ctl_table ctl __attribute__ ((unused));
900 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
907 dnl # 2.6.29 API change,
908 dnl # Adaptive mutexs were introduced which track the mutex owner. The
909 dnl # mutex wrappers leverage this functionality to avoid tracking the
910 dnl # owner multipe times.
912 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
913 AC_MSG_CHECKING([whether struct mutex has owner])
914 SPL_LINUX_TRY_COMPILE([
915 #include <linux/mutex.h>
917 struct mutex mtx __attribute__ ((unused));
921 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
928 dnl # 2.6.39 API change,
929 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
930 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
931 dnl # was defined. As of 2.6.39 this was changed to a task_struct
932 dnl # pointer which frankly makes a lot more sense.
934 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
935 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
936 tmp_flags="$EXTRA_KCFLAGS"
937 EXTRA_KCFLAGS="-Werror"
938 SPL_LINUX_TRY_COMPILE([
939 #include <linux/mutex.h>
940 #include <linux/sched.h>
942 struct mutex mtx __attribute__ ((unused));
946 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
947 [struct mutex owner is a task_struct])
951 EXTRA_KCFLAGS="$tmp_flags"
955 dnl # 3.10 API change,
956 dnl # PDE is replaced by PDE_DATA
958 AC_DEFUN([SPL_AC_PDE_DATA], [
959 AC_MSG_CHECKING([whether PDE_DATA() is available])
960 SPL_LINUX_TRY_COMPILE_SYMBOL([
961 #include <linux/proc_fs.h>
966 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
974 dnl # set_fs_pwd takes const struct path *
976 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
977 tmp_flags="$EXTRA_KCFLAGS"
978 EXTRA_KCFLAGS="-Werror"
979 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
980 SPL_LINUX_TRY_COMPILE([
981 #include <linux/spinlock.h>
982 #include <linux/fs_struct.h>
983 #include <linux/path.h>
984 void (*const set_fs_pwd_func)
985 (struct fs_struct *, const struct path *)
991 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
992 [set_fs_pwd() needs const path *])
994 SPL_LINUX_TRY_COMPILE([
995 #include <linux/spinlock.h>
996 #include <linux/fs_struct.h>
997 #include <linux/path.h>
998 void (*const set_fs_pwd_func)
999 (struct fs_struct *, struct path *)
1006 AC_MSG_ERROR(unknown)
1009 EXTRA_KCFLAGS="$tmp_flags"
1013 dnl # 3.13 API change
1014 dnl # vfs_unlink() updated to take a third delegated_inode argument.
1016 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1017 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1018 SPL_LINUX_TRY_COMPILE([
1019 #include <linux/fs.h>
1021 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1024 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1025 [vfs_unlink() wants 2 args])
1029 dnl # Linux 3.13 API change
1030 dnl # Added delegated inode
1032 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1033 SPL_LINUX_TRY_COMPILE([
1034 #include <linux/fs.h>
1036 vfs_unlink((struct inode *) NULL,
1037 (struct dentry *) NULL,
1038 (struct inode **) NULL);
1041 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1042 [vfs_unlink() wants 3 args])
1051 dnl # 3.13 and 3.15 API changes
1052 dnl # Added delegated inode and flags argument.
1054 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1055 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1056 SPL_LINUX_TRY_COMPILE([
1057 #include <linux/fs.h>
1059 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1060 (struct inode *) NULL, (struct dentry *) NULL);
1063 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1064 [vfs_rename() wants 4 args])
1068 dnl # Linux 3.13 API change
1069 dnl # Added delegated inode
1071 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1072 SPL_LINUX_TRY_COMPILE([
1073 #include <linux/fs.h>
1075 vfs_rename((struct inode *) NULL,
1076 (struct dentry *) NULL,
1077 (struct inode *) NULL,
1078 (struct dentry *) NULL,
1079 (struct inode **) NULL);
1082 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1083 [vfs_rename() wants 5 args])
1087 dnl # Linux 3.15 API change
1090 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1091 SPL_LINUX_TRY_COMPILE([
1092 #include <linux/fs.h>
1094 vfs_rename((struct inode *) NULL,
1095 (struct dentry *) NULL,
1096 (struct inode *) NULL,
1097 (struct dentry *) NULL,
1098 (struct inode **) NULL,
1102 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1103 [vfs_rename() wants 6 args])
1112 dnl # 2.6.36 API change,
1113 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1114 dnl # a spinlock_t to improve the fastpath performance.
1116 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1117 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1118 tmp_flags="$EXTRA_KCFLAGS"
1119 EXTRA_KCFLAGS="-Werror"
1120 SPL_LINUX_TRY_COMPILE([
1121 #include <linux/sched.h>
1122 #include <linux/fs_struct.h>
1124 struct fs_struct fs;
1125 spin_lock_init(&fs.lock);
1128 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1129 [struct fs_struct uses spinlock_t])
1133 EXTRA_KCFLAGS="$tmp_flags"
1137 dnl # User namespaces, use kuid_t in place of uid_t
1138 dnl # where available. Not strictly a user namespaces thing
1139 dnl # but it should prevent surprises
1141 AC_DEFUN([SPL_AC_KUIDGID_T], [
1142 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1143 SPL_LINUX_TRY_COMPILE([
1144 #include <linux/uidgid.h>
1146 kuid_t userid = KUIDT_INIT(0);
1147 kgid_t groupid = KGIDT_INIT(0);
1149 SPL_LINUX_TRY_COMPILE([
1150 #include <linux/uidgid.h>
1155 AC_MSG_RESULT(yes; optional)
1157 AC_MSG_RESULT(yes; mandatory)
1158 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1166 dnl # 2.6.39 API change,
1167 dnl # __put_task_struct() was exported by the mainline kernel.
1169 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1170 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1171 SPL_LINUX_TRY_COMPILE_SYMBOL([
1172 #include <linux/sched.h>
1174 __put_task_struct(NULL);
1175 ], [__put_task_struct], [], [
1177 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1178 [__put_task_struct() is available])
1185 dnl # 2.6.32 API change,
1186 dnl # Unused 'struct file *' removed from prototype.
1188 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1189 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1190 SPL_LINUX_TRY_COMPILE([
1191 #include <linux/sysctl.h>
1193 proc_dostring(NULL, 0, NULL, NULL, NULL);
1196 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1197 [proc_handler() wants 5 args])
1204 dnl # 2.6.x API change,
1205 dnl # kvasprintf() function added.
1207 AC_DEFUN([SPL_AC_KVASPRINTF],
1208 [AC_MSG_CHECKING([whether kvasprintf() is available])
1209 SPL_LINUX_TRY_COMPILE_SYMBOL([
1210 #include <linux/kernel.h>
1212 kvasprintf(0, NULL, *((va_list*)NULL));
1213 ], [kvasprintf], [], [
1215 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1222 dnl # 2.6.29 API change,
1223 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1225 AC_DEFUN([SPL_AC_VFS_FSYNC],
1226 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1227 SPL_LINUX_TRY_COMPILE_SYMBOL([
1228 #include <linux/fs.h>
1231 ], [vfs_fsync], [fs/sync.c], [
1233 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1240 dnl # 2.6.35 API change,
1241 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1243 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1244 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1245 SPL_LINUX_TRY_COMPILE([
1246 #include <linux/fs.h>
1251 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1258 dnl # 3.5 API change,
1259 dnl # inode_operations.truncate_range removed
1261 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1262 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1263 SPL_LINUX_TRY_COMPILE([
1264 #include <linux/fs.h>
1266 struct inode_operations ops;
1267 ops.truncate_range = NULL;
1270 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1271 [truncate_range() inode operation is available])
1278 dnl # Linux 2.6.38 - 3.x API
1280 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1281 AC_MSG_CHECKING([whether fops->fallocate() exists])
1282 SPL_LINUX_TRY_COMPILE([
1283 #include <linux/fs.h>
1285 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1286 struct file_operations fops __attribute__ ((unused)) = {
1287 .fallocate = fallocate,
1291 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1298 dnl # Linux 2.6.x - 2.6.37 API
1300 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1301 AC_MSG_CHECKING([whether iops->fallocate() exists])
1302 SPL_LINUX_TRY_COMPILE([
1303 #include <linux/fs.h>
1305 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1306 struct inode_operations fops __attribute__ ((unused)) = {
1307 .fallocate = fallocate,
1311 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1318 dnl # PaX Linux 2.6.38 - 3.x API
1320 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1321 AC_MSG_CHECKING([whether fops->fallocate() exists])
1322 SPL_LINUX_TRY_COMPILE([
1323 #include <linux/fs.h>
1325 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1326 struct file_operations_no_const fops __attribute__ ((unused)) = {
1327 .fallocate = fallocate,
1331 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1338 dnl # The fallocate callback was moved from the inode_operations
1339 dnl # structure to the file_operations structure.
1341 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1342 SPL_AC_KERNEL_FILE_FALLOCATE
1343 SPL_AC_KERNEL_INODE_FALLOCATE
1344 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1348 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1349 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1350 dnl # condition. The fixed version is exported as a symbol. The race
1351 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1352 dnl # call that version while holding sem->wait_lock.
1354 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1355 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1356 SPL_LINUX_TRY_COMPILE_SYMBOL([
1357 #include <linux/rwsem.h>
1358 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1359 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1361 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1362 [rwsem_is_locked() acquires sem->wait_lock])
1369 dnl # 2.6.28 API change
1370 dnl # The kern_path() function has been introduced. We adopt it as the new way
1371 dnl # of looking up paths. When it is not available, we emulate it using the
1372 dnl # older interfaces.
1374 AC_DEFUN([SPL_AC_KERN_PATH],
1375 [AC_MSG_CHECKING([whether kern_path() is available])
1376 SPL_LINUX_TRY_COMPILE_SYMBOL([
1377 #include <linux/namei.h>
1379 int r = kern_path(NULL, 0, NULL);
1380 ], [kern_path], [fs/namei.c], [
1382 AC_DEFINE(HAVE_KERN_PATH, 1,
1383 [kern_path() is available])
1386 AC_MSG_CHECKING([whether path_lookup() is available])
1387 SPL_LINUX_TRY_COMPILE_SYMBOL([
1388 #include <linux/namei.h>
1390 int r = path_lookup(NULL, 0, NULL);
1391 ], [path_lookup], [fs/namei.c], [
1393 AC_DEFINE(HAVE_KERN_PATH, 1,
1394 [kern_path() is available])
1398 *** Neither kern_path() nor path_lookup() is available.
1399 *** Please file an issue:
1400 *** https://github.com/zfsonlinux/spl/issues/new])
1407 dnl # zlib inflate compat,
1408 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1410 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1411 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1412 SPL_LINUX_TRY_COMPILE([
1413 #if !defined(CONFIG_ZLIB_INFLATE) && \
1414 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1415 #error CONFIG_ZLIB_INFLATE not defined
1418 AC_MSG_RESULT([yes])
1422 *** This kernel does not include the required zlib inflate support.
1423 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1428 dnl # zlib deflate compat,
1429 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1431 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1432 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1433 SPL_LINUX_TRY_COMPILE([
1434 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1435 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1436 #error CONFIG_ZLIB_DEFLATE not defined
1439 AC_MSG_RESULT([yes])
1443 *** This kernel does not include the required zlib deflate support.
1444 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1449 dnl # 2.6.39 API compat,
1450 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1451 dnl # This was done to avoid always having to allocate the maximum size
1452 dnl # workspace (268K). The caller can now specific the windowBits and
1453 dnl # memLevel compression parameters to get a smaller workspace.
1455 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1456 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1457 SPL_LINUX_TRY_COMPILE([
1458 #include <linux/zlib.h>
1460 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1463 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1464 [zlib_deflate_workspacesize() wants 2 args])
1471 dnl # 2.6.39 API change,
1472 dnl # Shrinker adjust to use common shrink_control structure.
1474 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1475 AC_MSG_CHECKING([whether struct shrink_control exists])
1476 SPL_LINUX_TRY_COMPILE([
1477 #include <linux/mm.h>
1479 struct shrink_control sc __attribute__ ((unused));
1482 sc.gfp_mask = GFP_KERNEL;
1485 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1486 [struct shrink_control exists])
1493 dnl # 3.1 API Change
1495 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1496 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1498 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1499 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1500 tmp_flags="$EXTRA_KCFLAGS"
1501 EXTRA_KCFLAGS="-Werror"
1502 SPL_LINUX_TRY_COMPILE([
1503 #include <linux/rwsem.h>
1505 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1506 raw_spinlock_t dummy_lock __attribute__ ((unused));
1507 dummy_semaphore.wait_lock = dummy_lock;
1510 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1511 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1515 EXTRA_KCFLAGS="$tmp_flags"
1519 dnl # 3.9 API change,
1520 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1522 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1523 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1524 SPL_LINUX_TRY_COMPILE([
1525 #include <linux/sched.h>
1526 #include <linux/sched/rt.h>
1530 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1538 dnl # 3.9 API change,
1539 dnl # vfs_getattr() uses 2 args
1540 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1542 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1543 AC_MSG_CHECKING([whether vfs_getattr() wants])
1544 SPL_LINUX_TRY_COMPILE([
1545 #include <linux/fs.h>
1547 vfs_getattr((struct path *) NULL,
1548 (struct kstat *)NULL);
1550 AC_MSG_RESULT(2 args)
1551 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1552 [vfs_getattr wants 2 args])
1554 SPL_LINUX_TRY_COMPILE([
1555 #include <linux/fs.h>
1557 vfs_getattr((struct vfsmount *)NULL,
1558 (struct dentry *)NULL,
1559 (struct kstat *)NULL);
1561 AC_MSG_RESULT(3 args)
1563 AC_MSG_ERROR(unknown)
1569 dnl # 2.6.36 API compatibility.
1570 dnl # Added usleep_range timer.
1571 dnl # usleep_range is a finer precision implementation of msleep
1572 dnl # designed to be a drop-in replacement for udelay where a precise
1573 dnl # sleep / busy-wait is unnecessary.
1575 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1576 AC_MSG_CHECKING([whether usleep_range() is available])
1577 SPL_LINUX_TRY_COMPILE([
1578 #include <linux/delay.h>
1583 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1584 [usleep_range is available])
1591 dnl # 2.6.35 API change,
1592 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1593 dnl # private allocation flags which are applied when allocating a new slab
1594 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1595 dnl # non-default flags.
1597 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1598 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1599 SPL_LINUX_TRY_COMPILE([
1600 #include <linux/slab.h>
1602 struct kmem_cache cachep __attribute__ ((unused));
1603 cachep.allocflags = GFP_KERNEL;
1606 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1607 [struct kmem_cache has allocflags])
1611 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1612 SPL_LINUX_TRY_COMPILE([
1613 #include <linux/slab.h>
1615 struct kmem_cache cachep __attribute__ ((unused));
1616 cachep.gfpflags = GFP_KERNEL;
1619 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1620 [struct kmem_cache has gfpflags])
1628 dnl # 3.17 API change,
1629 dnl # wait_on_bit() no longer requires an action argument. The former
1630 dnl # "wait_on_bit" interface required an 'action' function to be provided
1631 dnl # which does the actual waiting. There were over 20 such functions in the
1632 dnl # kernel, many of them identical, though most cases can be satisfied by one
1633 dnl # of just two functions: one which uses io_schedule() and one which just
1634 dnl # uses schedule(). This API change was made to consolidate all of those
1635 dnl # redundant wait functions.
1637 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1638 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1639 SPL_LINUX_TRY_COMPILE([
1640 #include <linux/wait.h>
1642 int (*action)(void *) = NULL;
1643 wait_on_bit(NULL, 0, action, 0);
1646 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])