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
41 SPL_AC_PUT_TASK_STRUCT
42 SPL_AC_5ARGS_PROC_HANDLER
44 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
45 SPL_AC_KERNEL_FALLOCATE
47 SPL_AC_CONFIG_ZLIB_INFLATE
48 SPL_AC_CONFIG_ZLIB_DEFLATE
49 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
50 SPL_AC_SHRINK_CONTROL_STRUCT
51 SPL_AC_RWSEM_SPINLOCK_IS_RAW
52 SPL_AC_SCHED_RT_HEADER
53 SPL_AC_2ARGS_VFS_GETATTR
55 SPL_AC_KMEM_CACHE_ALLOCFLAGS
59 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
60 modpost=$LINUX/scripts/Makefile.modpost
61 AC_MSG_CHECKING([kernel file name for module symbols])
62 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
63 if grep -q Modules.symvers $modpost; then
64 LINUX_SYMBOLS=Modules.symvers
66 LINUX_SYMBOLS=Module.symvers
69 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
71 *** Please make sure the kernel devel package for your distribution
72 *** is installed. If you are building with a custom kernel, make sure the
73 *** kernel is configured, built, and the '--with-linux=PATH' configure
74 *** option refers to the location of the kernel source.])
79 AC_MSG_RESULT($LINUX_SYMBOLS)
80 AC_SUBST(LINUX_SYMBOLS)
83 AC_DEFUN([SPL_AC_KERNEL], [
85 AS_HELP_STRING([--with-linux=PATH],
86 [Path to kernel source]),
87 [kernelsrc="$withval"])
89 AC_ARG_WITH([linux-obj],
90 AS_HELP_STRING([--with-linux-obj=PATH],
91 [Path to kernel build objects]),
92 [kernelbuild="$withval"])
94 AC_MSG_CHECKING([kernel source directory])
95 if test -z "$kernelsrc"; then
96 if test -e "/lib/modules/$(uname -r)/source"; then
97 headersdir="/lib/modules/$(uname -r)/source"
98 sourcelink=$(readlink -f "$headersdir")
99 elif test -e "/lib/modules/$(uname -r)/build"; then
100 headersdir="/lib/modules/$(uname -r)/build"
101 sourcelink=$(readlink -f "$headersdir")
103 sourcelink=$(ls -1d /usr/src/kernels/* \
105 2>/dev/null | grep -v obj | tail -1)
108 if test -n "$sourcelink" && test -e ${sourcelink}; then
109 kernelsrc=`readlink -f ${sourcelink}`
111 kernelsrc="[Not found]"
114 if test "$kernelsrc" = "NONE"; then
119 AC_MSG_RESULT([$kernelsrc])
120 if test ! -d "$kernelsrc"; then
122 *** Please make sure the kernel devel package for your distribution
123 *** is installed and then try again. If that fails, you can specify the
124 *** location of the kernel source with the '--with-linux=PATH' option.])
127 AC_MSG_CHECKING([kernel build directory])
128 if test -z "$kernelbuild"; then
129 if test -e "/lib/modules/$(uname -r)/build"; then
130 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
131 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
132 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
133 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
134 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
135 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
136 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
138 kernelbuild=${kernelsrc}
141 AC_MSG_RESULT([$kernelbuild])
143 AC_MSG_CHECKING([kernel source version])
144 utsrelease1=$kernelbuild/include/linux/version.h
145 utsrelease2=$kernelbuild/include/linux/utsrelease.h
146 utsrelease3=$kernelbuild/include/generated/utsrelease.h
147 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
148 utsrelease=linux/version.h
149 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
150 utsrelease=linux/utsrelease.h
151 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
152 utsrelease=generated/utsrelease.h
155 if test "$utsrelease"; then
156 kernsrcver=`(echo "#include <$utsrelease>";
157 echo "kernsrcver=UTS_RELEASE") |
158 cpp -I $kernelbuild/include |
159 grep "^kernsrcver=" | cut -d \" -f 2`
161 if test -z "$kernsrcver"; then
162 AC_MSG_RESULT([Not found])
163 AC_MSG_ERROR([*** Cannot determine kernel version.])
166 AC_MSG_RESULT([Not found])
167 if test "x$enable_linux_builtin" != xyes; then
168 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
171 *** Cannot find UTS_RELEASE definition.
172 *** Please run 'make prepare' inside the kernel source tree.])
176 AC_MSG_RESULT([$kernsrcver])
179 LINUX_OBJ=${kernelbuild}
180 LINUX_VERSION=${kernsrcver}
184 AC_SUBST(LINUX_VERSION)
186 SPL_AC_MODULE_SYMVERS
190 dnl # Default SPL user configuration
192 AC_DEFUN([SPL_AC_CONFIG_USER], [])
195 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
196 dnl # are missing, it is non-fatal, but you will not be able to build
197 dnl # RPM packages and will be warned if you try too.
199 dnl # By default, the generic spec file will be used because it requires
200 dnl # minimal dependencies. Distribution specific spec files can be
201 dnl # placed under the 'rpm/<distribution>' directory and enabled using
202 dnl # the --with-spec=<distribution> configure option.
204 AC_DEFUN([SPL_AC_RPM], [
208 AC_MSG_CHECKING([whether $RPM is available])
209 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
210 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
212 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
215 AC_MSG_RESULT([$HAVE_RPM])
218 AC_MSG_CHECKING([whether $RPMBUILD is available])
219 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
220 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
222 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
225 AC_MSG_RESULT([$HAVE_RPMBUILD])
228 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
230 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
233 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
238 RPM_SPEC_DIR="rpm/generic"
240 AS_HELP_STRING([--with-spec=SPEC],
241 [Spec files 'generic|fedora']),
242 [RPM_SPEC_DIR="rpm/$withval"])
244 AC_MSG_CHECKING([whether spec files are available])
245 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
249 AC_SUBST(RPM_VERSION)
251 AC_SUBST(HAVE_RPMBUILD)
253 AC_SUBST(RPMBUILD_VERSION)
255 AC_SUBST(RPM_SPEC_DIR)
256 AC_SUBST(RPM_DEFINE_UTIL)
257 AC_SUBST(RPM_DEFINE_KMOD)
258 AC_SUBST(RPM_DEFINE_DKMS)
259 AC_SUBST(RPM_DEFINE_COMMON)
260 AC_SUBST(SRPM_DEFINE_UTIL)
261 AC_SUBST(SRPM_DEFINE_KMOD)
262 AC_SUBST(SRPM_DEFINE_DKMS)
263 AC_SUBST(SRPM_DEFINE_COMMON)
267 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
268 dnl # tools are missing it is non-fatal but you will not be able to build
269 dnl # DEB packages and will be warned if you try too.
271 AC_DEFUN([SPL_AC_DPKG], [
273 DPKGBUILD=dpkg-buildpackage
275 AC_MSG_CHECKING([whether $DPKG is available])
276 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
277 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
279 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
282 AC_MSG_RESULT([$HAVE_DPKG])
285 AC_MSG_CHECKING([whether $DPKGBUILD is available])
286 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
287 DPKGBUILD_VERSION=$(echo $tmp | \
288 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
290 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
293 AC_MSG_RESULT([$HAVE_DPKGBUILD])
298 AC_SUBST(DPKG_VERSION)
300 AC_SUBST(HAVE_DPKGBUILD)
302 AC_SUBST(DPKGBUILD_VERSION)
306 dnl # Until native packaging for various different packing systems
307 dnl # can be added the least we can do is attempt to use alien to
308 dnl # convert the RPM packages to the needed package type. This is
309 dnl # a hack but so far it has worked reasonable well.
311 AC_DEFUN([SPL_AC_ALIEN], [
314 AC_MSG_CHECKING([whether $ALIEN is available])
315 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
316 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
318 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
321 AC_MSG_RESULT([$HAVE_ALIEN])
326 AC_SUBST(ALIEN_VERSION)
330 dnl # Using the VENDOR tag from config.guess set the default
331 dnl # package type for 'make pkg': (rpm | deb | tgz)
333 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
334 AC_MSG_CHECKING([linux distribution])
335 if test -f /etc/toss-release ; then
337 elif test -f /etc/fedora-release ; then
339 elif test -f /etc/redhat-release ; then
341 elif test -f /etc/gentoo-release ; then
343 elif test -f /etc/arch-release ; then
345 elif test -f /etc/SuSE-release ; then
347 elif test -f /etc/slackware-version ; then
349 elif test -f /etc/lunar.release ; then
351 elif test -f /etc/lsb-release ; then
353 elif test -f /etc/debian_version ; then
358 AC_MSG_RESULT([$VENDOR])
361 AC_MSG_CHECKING([default package type])
363 toss) DEFAULT_PACKAGE=rpm ;;
364 redhat) DEFAULT_PACKAGE=rpm ;;
365 fedora) DEFAULT_PACKAGE=rpm ;;
366 gentoo) DEFAULT_PACKAGE=tgz ;;
367 arch) DEFAULT_PACKAGE=tgz ;;
368 sles) DEFAULT_PACKAGE=rpm ;;
369 slackware) DEFAULT_PACKAGE=tgz ;;
370 lunar) DEFAULT_PACKAGE=tgz ;;
371 ubuntu) DEFAULT_PACKAGE=deb ;;
372 debian) DEFAULT_PACKAGE=deb ;;
373 *) DEFAULT_PACKAGE=rpm ;;
376 AC_MSG_RESULT([$DEFAULT_PACKAGE])
377 AC_SUBST(DEFAULT_PACKAGE)
381 dnl # Default SPL user configuration
383 AC_DEFUN([SPL_AC_PACKAGE], [
384 SPL_AC_DEFAULT_PACKAGE
390 AC_DEFUN([SPL_AC_LICENSE], [
391 AC_MSG_CHECKING([spl author])
392 AC_MSG_RESULT([$SPL_META_AUTHOR])
394 AC_MSG_CHECKING([spl license])
395 AC_MSG_RESULT([$SPL_META_LICENSE])
398 AC_DEFUN([SPL_AC_CONFIG], [
400 AC_ARG_WITH([config],
401 AS_HELP_STRING([--with-config=CONFIG],
402 [Config file 'kernel|user|all|srpm']),
403 [SPL_CONFIG="$withval"])
404 AC_ARG_ENABLE([linux-builtin],
405 [AC_HELP_STRING([--enable-linux-builtin],
406 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
408 [enable_linux_builtin=no])
410 AC_MSG_CHECKING([spl config])
411 AC_MSG_RESULT([$SPL_CONFIG]);
414 case "$SPL_CONFIG" in
415 kernel) SPL_AC_CONFIG_KERNEL ;;
416 user) SPL_AC_CONFIG_USER ;;
417 all) SPL_AC_CONFIG_KERNEL
418 SPL_AC_CONFIG_USER ;;
421 AC_MSG_RESULT([Error!])
422 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
423 user kernel|user|all|srpm]) ;;
426 AM_CONDITIONAL([CONFIG_USER],
427 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
428 AM_CONDITIONAL([CONFIG_KERNEL],
429 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
430 [test "x$enable_linux_builtin" != xyes ])
434 dnl # Enable if the SPL should be compiled with internal debugging enabled.
435 dnl # By default this support is disabled.
437 AC_DEFUN([SPL_AC_DEBUG], [
438 AC_MSG_CHECKING([whether debugging is enabled])
439 AC_ARG_ENABLE([debug],
440 [AS_HELP_STRING([--enable-debug],
441 [Enable generic debug support @<:@default=no@:>@])],
445 AS_IF([test "x$enable_debug" = xyes],
447 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
448 DEBUG_CFLAGS="-DDEBUG -Werror"
449 DEBUG_SPL="_with_debug"
451 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
452 DEBUG_CFLAGS="-DNDEBUG"
453 DEBUG_SPL="_without_debug"
456 AC_SUBST(DEBUG_CFLAGS)
458 AC_MSG_RESULT([$enable_debug])
462 dnl # Enabled by default it provides a basic debug log infrastructure.
463 dnl # Each subsystem registers itself with a name and logs messages
464 dnl # using predefined types. If the debug mask it set to allow the
465 dnl # message type it will be written to the internal log. The log
466 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
467 dnl # after dumping the log it must be decoded using the spl utility.
469 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
470 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
472 AC_DEFUN([SPL_AC_DEBUG_LOG], [
473 AC_ARG_ENABLE([debug-log],
474 [AS_HELP_STRING([--enable-debug-log],
475 [Enable basic debug logging @<:@default=yes@:>@])],
477 [enable_debug_log=yes])
479 AS_IF([test "x$enable_debug_log" = xyes],
481 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
482 DEBUG_LOG="_with_debug_log"
483 AC_DEFINE([DEBUG_LOG], [1],
484 [Define to 1 to enable basic debug logging])
486 DEBUG_LOG="_without_debug_log"
490 AC_MSG_CHECKING([whether basic debug logging is enabled])
491 AC_MSG_RESULT([$enable_debug_log])
495 dnl # Enabled by default it provides a minimal level of memory tracking.
496 dnl # A total count of bytes allocated is kept for each alloc and free.
497 dnl # Then at module unload time a report to the console will be printed
498 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
499 dnl # and provide an easy way to inspect the kmem based slab.
501 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
502 AC_ARG_ENABLE([debug-kmem],
503 [AS_HELP_STRING([--enable-debug-kmem],
504 [Enable basic kmem accounting @<:@default=yes@:>@])],
506 [enable_debug_kmem=yes])
508 AS_IF([test "x$enable_debug_kmem" = xyes],
510 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
511 DEBUG_KMEM="_with_debug_kmem"
512 AC_DEFINE([DEBUG_KMEM], [1],
513 [Define to 1 to enable basic kmem accounting])
515 DEBUG_KMEM="_without_debug_kmem"
519 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
520 AC_MSG_RESULT([$enable_debug_kmem])
524 dnl # Disabled by default it provides detailed memory tracking. This
525 dnl # feature also requires --enable-debug-kmem to be set. When enabled
526 dnl # not only will total bytes be tracked but also the location of every
527 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
528 dnl # addresses and where they were allocated will be dumped to the console.
529 dnl # Enabling this feature has a significant impact on performance but it
530 dnl # makes finding memory leaks pretty straight forward.
532 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
533 AC_ARG_ENABLE([debug-kmem-tracking],
534 [AS_HELP_STRING([--enable-debug-kmem-tracking],
535 [Enable detailed kmem tracking @<:@default=no@:>@])],
537 [enable_debug_kmem_tracking=no])
539 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
541 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
542 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
543 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
544 [Define to 1 to enable detailed kmem tracking])
546 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
549 AC_SUBST(DEBUG_KMEM_TRACKING)
550 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
551 AC_MSG_RESULT([$enable_debug_kmem_tracking])
555 dnl # SPL_LINUX_CONFTEST
557 AC_DEFUN([SPL_LINUX_CONFTEST], [
558 cat confdefs.h - <<_ACEOF >conftest.c
564 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
566 m4_define([SPL_LANG_PROGRAM], [
571 dnl Do *not* indent the following line: there may be CPP directives.
572 dnl Don't move the `;' right after for the same reason.
580 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
582 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
583 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
584 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
585 echo "obj-m := conftest.o" >build/Makefile
587 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
589 [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])],
591 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
597 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
599 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
600 [SPL_LINUX_COMPILE_IFELSE(
601 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
603 [test -s build/conftest.o],
608 dnl # SPL_CHECK_SYMBOL_EXPORT
609 dnl # check symbol exported or not
611 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
612 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
613 $LINUX_OBJ/Module*.symvers 2>/dev/null
615 if test $rc -ne 0; then
618 grep -q -E "EXPORT_SYMBOL.*($1)" \
619 "$LINUX_OBJ/$file" 2>/dev/null
621 if test $rc -eq 0; then
626 if test $export -eq 0; then :
637 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
638 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
639 dnl # is called if not compiling for builtin
641 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
642 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
643 if test $rc -ne 0; then :
646 if test "x$enable_linux_builtin" != xyes; then
647 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
649 if test $rc -ne 0; then :
658 dnl # SPL_CHECK_SYMBOL_HEADER
659 dnl # check if a symbol prototype is defined in listed headers.
661 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
662 AC_MSG_CHECKING([whether symbol $1 exists in header])
665 grep -q "$2" "$LINUX/$file" 2>/dev/null
667 if test $rc -eq 0; then
672 if test $header -eq 0; then
682 dnl # SPL_CHECK_HEADER
683 dnl # check whether header exists and define HAVE_$2_HEADER
685 AC_DEFUN([SPL_CHECK_HEADER],
686 [AC_MSG_CHECKING([whether header $1 exists])
687 SPL_LINUX_TRY_COMPILE([
692 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
702 dnl # Basic toolchain sanity check. Verify that kernel modules can
703 dnl # be built and which symbols can be used.
705 AC_DEFUN([SPL_AC_TEST_MODULE],
706 [AC_MSG_CHECKING([whether modules can be built])
707 SPL_LINUX_TRY_COMPILE([],[],[
711 if test "x$enable_linux_builtin" != xyes; then
712 AC_MSG_ERROR([*** Unable to build an empty module.])
715 *** Unable to build an empty module.
716 *** Please run 'make scripts' inside the kernel source tree.])
722 #include "$LINUX/include/linux/license.h"
724 return !license_is_gpl_compatible("$SPL_META_LICENSE");
727 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
728 [Define to 1 if GPL-only symbols can be used])
734 dnl # Use the atomic implemenation based on global spinlocks. This
735 dnl # should only be needed by 32-bit kernels which do not provide
736 dnl # the atomic64_* API. It may be optionally enabled as a fallback
737 dnl # if problems are observed with the direct mapping to the native
738 dnl # Linux atomic operations. You may not disable atomic spinlocks
739 dnl # if you kernel does not an atomic64_* API.
741 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
742 AC_ARG_ENABLE([atomic-spinlocks],
743 [AS_HELP_STRING([--enable-atomic-spinlocks],
744 [Atomic types use spinlocks @<:@default=check@:>@])],
746 [enable_atomic_spinlocks=check])
748 SPL_LINUX_TRY_COMPILE([
749 #include <linux/fs.h>
751 atomic64_t *ptr __attribute__ ((unused));
754 AC_DEFINE(HAVE_ATOMIC64_T, 1,
755 [kernel defines atomic64_t])
760 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
761 AS_IF([test "x$have_atomic64_t" = xyes], [
762 enable_atomic_spinlocks=no
764 enable_atomic_spinlocks=yes
768 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
769 AC_DEFINE([ATOMIC_SPINLOCK], [1],
770 [Atomic types use spinlocks])
772 AS_IF([test "x$have_atomic64_t" = xno], [
774 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
778 AC_MSG_CHECKING([whether atomic types use spinlocks])
779 AC_MSG_RESULT([$enable_atomic_spinlocks])
781 AC_MSG_CHECKING([whether kernel defines atomic64_t])
782 AC_MSG_RESULT([$have_atomic64_t])
785 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
786 tmp_flags="$EXTRA_KCFLAGS"
787 EXTRA_KCFLAGS="-Werror"
789 dnl # 2.6.23 to 2.6.34 API change
790 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
792 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
793 SPL_LINUX_TRY_COMPILE([
794 #include <linux/mm.h>
796 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
798 struct shrinker cache_shrinker = {
799 .shrink = shrinker_cb,
800 .seeks = DEFAULT_SEEKS,
802 register_shrinker(&cache_shrinker);
805 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
806 [old shrinker callback wants 2 args])
810 dnl # 2.6.35 - 2.6.39 API change
811 dnl # ->shrink(struct shrinker *,
812 dnl # int nr_to_scan, gfp_t gfp_mask)
814 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
815 SPL_LINUX_TRY_COMPILE([
816 #include <linux/mm.h>
818 int shrinker_cb(struct shrinker *, int nr_to_scan,
821 struct shrinker cache_shrinker = {
822 .shrink = shrinker_cb,
823 .seeks = DEFAULT_SEEKS,
825 register_shrinker(&cache_shrinker);
828 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
829 [old shrinker callback wants 3 args])
833 dnl # 3.0 - 3.11 API change
834 dnl # ->shrink(struct shrinker *,
835 dnl # struct shrink_control *sc)
838 [whether new 2-argument shrinker exists])
839 SPL_LINUX_TRY_COMPILE([
840 #include <linux/mm.h>
842 int shrinker_cb(struct shrinker *,
843 struct shrink_control *sc);
845 struct shrinker cache_shrinker = {
846 .shrink = shrinker_cb,
847 .seeks = DEFAULT_SEEKS,
849 register_shrinker(&cache_shrinker);
852 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
853 [new shrinker callback wants 2 args])
857 dnl # 3.12 API change,
858 dnl # ->shrink() is logically split in to
859 dnl # ->count_objects() and ->scan_objects()
862 [whether ->count_objects callback exists])
863 SPL_LINUX_TRY_COMPILE([
864 #include <linux/mm.h>
866 unsigned long shrinker_cb(
868 struct shrink_control *sc);
870 struct shrinker cache_shrinker = {
871 .count_objects = shrinker_cb,
872 .scan_objects = shrinker_cb,
873 .seeks = DEFAULT_SEEKS,
875 register_shrinker(&cache_shrinker);
878 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
879 1, [->count_objects exists])
886 EXTRA_KCFLAGS="$tmp_flags"
890 dnl # 2.6.33 API change,
891 dnl # Removed .ctl_name from struct ctl_table.
893 AC_DEFUN([SPL_AC_CTL_NAME], [
894 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
895 SPL_LINUX_TRY_COMPILE([
896 #include <linux/sysctl.h>
898 struct ctl_table ctl __attribute__ ((unused));
902 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
909 dnl # 2.6.29 API change,
910 dnl # Adaptive mutexs were introduced which track the mutex owner. The
911 dnl # mutex wrappers leverage this functionality to avoid tracking the
912 dnl # owner multipe times.
914 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
915 AC_MSG_CHECKING([whether struct mutex has owner])
916 SPL_LINUX_TRY_COMPILE([
917 #include <linux/mutex.h>
919 struct mutex mtx __attribute__ ((unused));
923 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
930 dnl # 2.6.39 API change,
931 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
932 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
933 dnl # was defined. As of 2.6.39 this was changed to a task_struct
934 dnl # pointer which frankly makes a lot more sense.
936 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
937 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
938 tmp_flags="$EXTRA_KCFLAGS"
939 EXTRA_KCFLAGS="-Werror"
940 SPL_LINUX_TRY_COMPILE([
941 #include <linux/mutex.h>
942 #include <linux/sched.h>
944 struct mutex mtx __attribute__ ((unused));
948 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
949 [struct mutex owner is a task_struct])
953 EXTRA_KCFLAGS="$tmp_flags"
957 dnl # 3.10 API change,
958 dnl # PDE is replaced by PDE_DATA
960 AC_DEFUN([SPL_AC_PDE_DATA], [
961 AC_MSG_CHECKING([whether PDE_DATA() is available])
962 SPL_LINUX_TRY_COMPILE_SYMBOL([
963 #include <linux/proc_fs.h>
968 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
976 dnl # set_fs_pwd takes const struct path *
978 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
979 tmp_flags="$EXTRA_KCFLAGS"
980 EXTRA_KCFLAGS="-Werror"
981 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
982 SPL_LINUX_TRY_COMPILE([
983 #include <linux/spinlock.h>
984 #include <linux/fs_struct.h>
985 #include <linux/path.h>
986 void (*const set_fs_pwd_func)
987 (struct fs_struct *, const struct path *)
993 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
994 [set_fs_pwd() needs const path *])
996 SPL_LINUX_TRY_COMPILE([
997 #include <linux/spinlock.h>
998 #include <linux/fs_struct.h>
999 #include <linux/path.h>
1000 void (*const set_fs_pwd_func)
1001 (struct fs_struct *, struct path *)
1008 AC_MSG_ERROR(unknown)
1011 EXTRA_KCFLAGS="$tmp_flags"
1014 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1015 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/fs.h>
1019 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1022 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1023 [vfs_unlink() wants 2 args])
1027 dnl # Linux 3.13 API change
1028 dnl # Added delegated inode
1030 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1031 SPL_LINUX_TRY_COMPILE([
1032 #include <linux/fs.h>
1034 vfs_unlink((struct inode *) NULL,
1035 (struct dentry *) NULL,
1036 (struct inode **) NULL);
1039 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1040 [vfs_unlink() wants 3 args])
1048 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1049 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1050 SPL_LINUX_TRY_COMPILE([
1051 #include <linux/fs.h>
1053 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1054 (struct inode *) NULL, (struct dentry *) NULL);
1057 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1058 [vfs_rename() wants 4 args])
1062 dnl # Linux 3.13 API change
1063 dnl # Added delegated inode
1065 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1066 SPL_LINUX_TRY_COMPILE([
1067 #include <linux/fs.h>
1069 vfs_rename((struct inode *) NULL,
1070 (struct dentry *) NULL,
1071 (struct inode *) NULL,
1072 (struct dentry *) NULL,
1073 (struct inode **) NULL);
1076 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1077 [vfs_rename() wants 5 args])
1081 dnl # Linux 3.15 API change
1084 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1085 SPL_LINUX_TRY_COMPILE([
1086 #include <linux/fs.h>
1088 vfs_rename((struct inode *) NULL,
1089 (struct dentry *) NULL,
1090 (struct inode *) NULL,
1091 (struct dentry *) NULL,
1092 (struct inode **) NULL,
1096 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1097 [vfs_rename() wants 6 args])
1106 dnl # 2.6.36 API change,
1107 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1108 dnl # a spinlock_t to improve the fastpath performance.
1110 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1111 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1112 tmp_flags="$EXTRA_KCFLAGS"
1113 EXTRA_KCFLAGS="-Werror"
1114 SPL_LINUX_TRY_COMPILE([
1115 #include <linux/sched.h>
1116 #include <linux/fs_struct.h>
1118 struct fs_struct fs;
1119 spin_lock_init(&fs.lock);
1122 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1123 [struct fs_struct uses spinlock_t])
1127 EXTRA_KCFLAGS="$tmp_flags"
1131 dnl # 2.6.29 API change,
1132 dnl # check whether 'struct cred' exists
1134 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1135 AC_MSG_CHECKING([whether struct cred exists])
1136 SPL_LINUX_TRY_COMPILE([
1137 #include <linux/cred.h>
1139 struct cred *cr __attribute__ ((unused));
1143 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1151 dnl # User namespaces, use kuid_t in place of uid_t
1152 dnl # where available. Not strictly a user namespaces thing
1153 dnl # but it should prevent surprises
1155 AC_DEFUN([SPL_AC_KUIDGID_T], [
1156 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1157 SPL_LINUX_TRY_COMPILE([
1158 #include <linux/uidgid.h>
1160 kuid_t userid = KUIDT_INIT(0);
1161 kgid_t groupid = KGIDT_INIT(0);
1163 SPL_LINUX_TRY_COMPILE([
1164 #include <linux/uidgid.h>
1169 AC_MSG_RESULT(yes; optional)
1171 AC_MSG_RESULT(yes; mandatory)
1172 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1180 dnl # Custom SPL patch may export this symbol.
1182 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1183 [AC_MSG_CHECKING([whether groups_search() is available])
1184 SPL_LINUX_TRY_COMPILE_SYMBOL([
1185 #include <linux/cred.h>
1186 #ifdef HAVE_KUIDGID_T
1187 #include <linux/uidgid.h>
1190 #ifdef HAVE_KUIDGID_T
1191 groups_search(NULL, KGIDT_INIT(0));
1193 groups_search(NULL, 0);
1195 ], [groups_search], [], [
1197 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1204 dnl # 2.6.x API change,
1205 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1207 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1208 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1209 SPL_LINUX_TRY_COMPILE_SYMBOL([
1210 #include <linux/sched.h>
1212 __put_task_struct(NULL);
1213 ], [__put_task_struct], [], [
1215 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1216 [__put_task_struct() is available])
1223 dnl # 2.6.32 API change,
1224 dnl # Unused 'struct file *' removed from prototype.
1226 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1227 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1228 SPL_LINUX_TRY_COMPILE([
1229 #include <linux/sysctl.h>
1231 proc_dostring(NULL, 0, NULL, NULL, NULL);
1234 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1235 [proc_handler() wants 5 args])
1242 dnl # 2.6.x API change,
1243 dnl # kvasprintf() function added.
1245 AC_DEFUN([SPL_AC_KVASPRINTF],
1246 [AC_MSG_CHECKING([whether kvasprintf() is available])
1247 SPL_LINUX_TRY_COMPILE_SYMBOL([
1248 #include <linux/kernel.h>
1250 kvasprintf(0, NULL, *((va_list*)NULL));
1251 ], [kvasprintf], [], [
1253 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1260 dnl # 2.6.29 API change,
1261 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1263 AC_DEFUN([SPL_AC_VFS_FSYNC],
1264 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1265 SPL_LINUX_TRY_COMPILE_SYMBOL([
1266 #include <linux/fs.h>
1269 ], [vfs_fsync], [fs/sync.c], [
1271 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1278 dnl # 2.6.35 API change,
1279 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1281 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1282 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1283 SPL_LINUX_TRY_COMPILE([
1284 #include <linux/fs.h>
1289 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1296 dnl # 3.5 API change,
1297 dnl # inode_operations.truncate_range removed
1299 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1300 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1301 SPL_LINUX_TRY_COMPILE([
1302 #include <linux/fs.h>
1304 struct inode_operations ops;
1305 ops.truncate_range = NULL;
1308 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1309 [truncate_range() inode operation is available])
1316 dnl # Linux 2.6.38 - 3.x API
1318 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1319 AC_MSG_CHECKING([whether fops->fallocate() exists])
1320 SPL_LINUX_TRY_COMPILE([
1321 #include <linux/fs.h>
1323 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1324 struct file_operations fops __attribute__ ((unused)) = {
1325 .fallocate = fallocate,
1329 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1336 dnl # Linux 2.6.x - 2.6.37 API
1338 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1339 AC_MSG_CHECKING([whether iops->fallocate() exists])
1340 SPL_LINUX_TRY_COMPILE([
1341 #include <linux/fs.h>
1343 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1344 struct inode_operations fops __attribute__ ((unused)) = {
1345 .fallocate = fallocate,
1349 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1356 dnl # PaX Linux 2.6.38 - 3.x API
1358 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1359 AC_MSG_CHECKING([whether fops->fallocate() exists])
1360 SPL_LINUX_TRY_COMPILE([
1361 #include <linux/fs.h>
1363 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1364 struct file_operations_no_const fops __attribute__ ((unused)) = {
1365 .fallocate = fallocate,
1369 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1376 dnl # The fallocate callback was moved from the inode_operations
1377 dnl # structure to the file_operations structure.
1379 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1380 SPL_AC_KERNEL_FILE_FALLOCATE
1381 SPL_AC_KERNEL_INODE_FALLOCATE
1382 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1386 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1387 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1388 dnl # condition. The fixed version is exported as a symbol. The race
1389 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1390 dnl # call that version while holding sem->wait_lock.
1392 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1393 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1394 SPL_LINUX_TRY_COMPILE_SYMBOL([
1395 #include <linux/rwsem.h>
1396 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1397 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1399 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1400 [rwsem_is_locked() acquires sem->wait_lock])
1407 dnl # 2.6.28 API change
1408 dnl # The kern_path() function has been introduced. We adopt it as the new way
1409 dnl # of looking up paths. When it is not available, we emulate it using the
1410 dnl # older interfaces.
1412 AC_DEFUN([SPL_AC_KERN_PATH],
1413 [AC_MSG_CHECKING([whether kern_path() is available])
1414 SPL_LINUX_TRY_COMPILE_SYMBOL([
1415 #include <linux/namei.h>
1417 int r = kern_path(NULL, 0, NULL);
1418 ], [kern_path], [fs/namei.c], [
1420 AC_DEFINE(HAVE_KERN_PATH, 1,
1421 [kern_path() is available])
1424 AC_MSG_CHECKING([whether path_lookup() is available])
1425 SPL_LINUX_TRY_COMPILE_SYMBOL([
1426 #include <linux/namei.h>
1428 int r = path_lookup(NULL, 0, NULL);
1429 ], [path_lookup], [fs/namei.c], [
1431 AC_DEFINE(HAVE_KERN_PATH, 1,
1432 [kern_path() is available])
1436 *** Neither kern_path() nor path_lookup() is available.
1437 *** Please file an issue:
1438 *** https://github.com/zfsonlinux/spl/issues/new])
1445 dnl # zlib inflate compat,
1446 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1448 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1449 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1450 SPL_LINUX_TRY_COMPILE([
1451 #if !defined(CONFIG_ZLIB_INFLATE) && \
1452 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1453 #error CONFIG_ZLIB_INFLATE not defined
1456 AC_MSG_RESULT([yes])
1460 *** This kernel does not include the required zlib inflate support.
1461 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1466 dnl # zlib deflate compat,
1467 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1469 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1470 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1471 SPL_LINUX_TRY_COMPILE([
1472 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1473 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1474 #error CONFIG_ZLIB_DEFLATE not defined
1477 AC_MSG_RESULT([yes])
1481 *** This kernel does not include the required zlib deflate support.
1482 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1487 dnl # 2.6.39 API compat,
1488 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1489 dnl # This was done to avoid always having to allocate the maximum size
1490 dnl # workspace (268K). The caller can now specific the windowBits and
1491 dnl # memLevel compression parameters to get a smaller workspace.
1493 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1494 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1495 SPL_LINUX_TRY_COMPILE([
1496 #include <linux/zlib.h>
1498 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1501 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1502 [zlib_deflate_workspacesize() wants 2 args])
1509 dnl # 2.6.39 API change,
1510 dnl # Shrinker adjust to use common shrink_control structure.
1512 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1513 AC_MSG_CHECKING([whether struct shrink_control exists])
1514 SPL_LINUX_TRY_COMPILE([
1515 #include <linux/mm.h>
1517 struct shrink_control sc __attribute__ ((unused));
1520 sc.gfp_mask = GFP_KERNEL;
1523 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1524 [struct shrink_control exists])
1531 dnl # 3.1 API Change
1533 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1534 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1536 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1537 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1538 tmp_flags="$EXTRA_KCFLAGS"
1539 EXTRA_KCFLAGS="-Werror"
1540 SPL_LINUX_TRY_COMPILE([
1541 #include <linux/rwsem.h>
1543 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1544 raw_spinlock_t dummy_lock __attribute__ ((unused));
1545 dummy_semaphore.wait_lock = dummy_lock;
1548 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1549 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1553 EXTRA_KCFLAGS="$tmp_flags"
1557 dnl # 3.9 API change,
1558 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1560 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1561 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1562 SPL_LINUX_TRY_COMPILE([
1563 #include <linux/sched.h>
1564 #include <linux/sched/rt.h>
1568 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1576 dnl # 3.9 API change,
1577 dnl # vfs_getattr() uses 2 args
1578 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1580 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1581 AC_MSG_CHECKING([whether vfs_getattr() wants])
1582 SPL_LINUX_TRY_COMPILE([
1583 #include <linux/fs.h>
1585 vfs_getattr((struct path *) NULL,
1586 (struct kstat *)NULL);
1588 AC_MSG_RESULT(2 args)
1589 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1590 [vfs_getattr wants 2 args])
1592 SPL_LINUX_TRY_COMPILE([
1593 #include <linux/fs.h>
1595 vfs_getattr((struct vfsmount *)NULL,
1596 (struct dentry *)NULL,
1597 (struct kstat *)NULL);
1599 AC_MSG_RESULT(3 args)
1601 AC_MSG_ERROR(unknown)
1607 dnl # 2.6.36 API compatibility.
1608 dnl # Added usleep_range timer.
1609 dnl # usleep_range is a finer precision implementation of msleep
1610 dnl # designed to be a drop-in replacement for udelay where a precise
1611 dnl # sleep / busy-wait is unnecessary.
1613 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1614 AC_MSG_CHECKING([whether usleep_range() is available])
1615 SPL_LINUX_TRY_COMPILE([
1616 #include <linux/delay.h>
1621 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1622 [usleep_range is available])
1629 dnl # 2.6.35 API change,
1630 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1631 dnl # private allocation flags which are applied when allocating a new slab
1632 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1633 dnl # non-default flags.
1635 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1636 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1637 SPL_LINUX_TRY_COMPILE([
1638 #include <linux/slab.h>
1640 struct kmem_cache cachep __attribute__ ((unused));
1641 cachep.allocflags = GFP_KERNEL;
1644 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1645 [struct kmem_cache has allocflags])
1649 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1650 SPL_LINUX_TRY_COMPILE([
1651 #include <linux/slab.h>
1653 struct kmem_cache cachep __attribute__ ((unused));
1654 cachep.gfpflags = GFP_KERNEL;
1657 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1658 [struct kmem_cache has gfpflags])
1666 dnl # 3.17 API change,
1667 dnl # wait_on_bit() no longer requires an action argument. The former
1668 dnl # "wait_on_bit" interface required an 'action' function to be provided
1669 dnl # which does the actual waiting. There were over 20 such functions in the
1670 dnl # kernel, many of them identical, though most cases can be satisfied by one
1671 dnl # of just two functions: one which uses io_schedule() and one which just
1672 dnl # uses schedule(). This API change was made to consolidate all of those
1673 dnl # redundant wait functions.
1675 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1676 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1677 SPL_LINUX_TRY_COMPILE([
1678 #include <linux/wait.h>
1680 int (*action)(void *) = NULL;
1681 wait_on_bit(NULL, 0, action, 0);
1684 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])