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_SHRINKER_CALLBACK
34 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
35 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
39 SPL_AC_MONOTONIC_CLOCK
42 SPL_AC_MUTEX_OWNER_TASK_STRUCT
43 SPL_AC_MUTEX_LOCK_NESTED
44 SPL_AC_3ARGS_ON_EACH_CPU
45 SPL_AC_KALLSYMS_LOOKUP_NAME
46 SPL_AC_GET_VMALLOC_INFO
48 SPL_AC_FIRST_ONLINE_PGDAT
49 SPL_AC_NEXT_ONLINE_PGDAT
52 SPL_AC_GLOBAL_PAGE_STATE
53 SPL_AC_ZONE_STAT_ITEM_FREE
54 SPL_AC_ZONE_STAT_ITEM_INACTIVE
55 SPL_AC_ZONE_STAT_ITEM_ACTIVE
56 SPL_AC_GET_ZONE_COUNTS
59 SPL_AC_SET_FS_PWD_WITH_CONST
60 SPL_AC_2ARGS_VFS_UNLINK
61 SPL_AC_4ARGS_VFS_RENAME
63 SPL_AC_2ARGS_VFS_FSYNC
64 SPL_AC_INODE_TRUNCATE_RANGE
65 SPL_AC_FS_STRUCT_SPINLOCK
69 SPL_AC_PUT_TASK_STRUCT
70 SPL_AC_5ARGS_PROC_HANDLER
72 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
73 SPL_AC_KERNEL_FALLOCATE
74 SPL_AC_SHRINK_DCACHE_MEMORY
75 SPL_AC_SHRINK_ICACHE_MEMORY
77 SPL_AC_CONFIG_KALLSYMS
78 SPL_AC_CONFIG_ZLIB_INFLATE
79 SPL_AC_CONFIG_ZLIB_DEFLATE
80 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
81 SPL_AC_SHRINK_CONTROL_STRUCT
82 SPL_AC_RWSEM_SPINLOCK_IS_RAW
83 SPL_AC_SCHED_RT_HEADER
84 SPL_AC_2ARGS_VFS_GETATTR
86 SPL_AC_KMEM_CACHE_ALLOCFLAGS
90 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
91 modpost=$LINUX/scripts/Makefile.modpost
92 AC_MSG_CHECKING([kernel file name for module symbols])
93 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
94 if grep -q Modules.symvers $modpost; then
95 LINUX_SYMBOLS=Modules.symvers
97 LINUX_SYMBOLS=Module.symvers
100 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
102 *** Please make sure the kernel devel package for your distribution
103 *** is installed. If you are building with a custom kernel, make sure the
104 *** kernel is configured, built, and the '--with-linux=PATH' configure
105 *** option refers to the location of the kernel source.])
110 AC_MSG_RESULT($LINUX_SYMBOLS)
111 AC_SUBST(LINUX_SYMBOLS)
114 AC_DEFUN([SPL_AC_KERNEL], [
116 AS_HELP_STRING([--with-linux=PATH],
117 [Path to kernel source]),
118 [kernelsrc="$withval"])
120 AC_ARG_WITH([linux-obj],
121 AS_HELP_STRING([--with-linux-obj=PATH],
122 [Path to kernel build objects]),
123 [kernelbuild="$withval"])
125 AC_MSG_CHECKING([kernel source directory])
126 if test -z "$kernelsrc"; then
127 if test -e "/lib/modules/$(uname -r)/source"; then
128 headersdir="/lib/modules/$(uname -r)/source"
129 sourcelink=$(readlink -f "$headersdir")
130 elif test -e "/lib/modules/$(uname -r)/build"; then
131 headersdir="/lib/modules/$(uname -r)/build"
132 sourcelink=$(readlink -f "$headersdir")
134 sourcelink=$(ls -1d /usr/src/kernels/* \
136 2>/dev/null | grep -v obj | tail -1)
139 if test -n "$sourcelink" && test -e ${sourcelink}; then
140 kernelsrc=`readlink -f ${sourcelink}`
142 kernelsrc="[Not found]"
145 if test "$kernelsrc" = "NONE"; then
150 AC_MSG_RESULT([$kernelsrc])
151 if test ! -d "$kernelsrc"; then
153 *** Please make sure the kernel devel package for your distribution
154 *** is installed and then try again. If that fails, you can specify the
155 *** location of the kernel source with the '--with-linux=PATH' option.])
158 AC_MSG_CHECKING([kernel build directory])
159 if test -z "$kernelbuild"; then
160 if test -e "/lib/modules/$(uname -r)/build"; then
161 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
162 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
163 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
164 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
165 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
166 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
167 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
169 kernelbuild=${kernelsrc}
172 AC_MSG_RESULT([$kernelbuild])
174 AC_MSG_CHECKING([kernel source version])
175 utsrelease1=$kernelbuild/include/linux/version.h
176 utsrelease2=$kernelbuild/include/linux/utsrelease.h
177 utsrelease3=$kernelbuild/include/generated/utsrelease.h
178 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
179 utsrelease=linux/version.h
180 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
181 utsrelease=linux/utsrelease.h
182 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
183 utsrelease=generated/utsrelease.h
186 if test "$utsrelease"; then
187 kernsrcver=`(echo "#include <$utsrelease>";
188 echo "kernsrcver=UTS_RELEASE") |
189 cpp -I $kernelbuild/include |
190 grep "^kernsrcver=" | cut -d \" -f 2`
192 if test -z "$kernsrcver"; then
193 AC_MSG_RESULT([Not found])
194 AC_MSG_ERROR([*** Cannot determine kernel version.])
197 AC_MSG_RESULT([Not found])
198 if test "x$enable_linux_builtin" != xyes; then
199 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
202 *** Cannot find UTS_RELEASE definition.
203 *** Please run 'make prepare' inside the kernel source tree.])
207 AC_MSG_RESULT([$kernsrcver])
210 LINUX_OBJ=${kernelbuild}
211 LINUX_VERSION=${kernsrcver}
215 AC_SUBST(LINUX_VERSION)
217 SPL_AC_MODULE_SYMVERS
221 dnl # Default SPL user configuration
223 AC_DEFUN([SPL_AC_CONFIG_USER], [])
226 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
227 dnl # are missing, it is non-fatal, but you will not be able to build
228 dnl # RPM packages and will be warned if you try too.
230 dnl # By default, the generic spec file will be used because it requires
231 dnl # minimal dependencies. Distribution specific spec files can be
232 dnl # placed under the 'rpm/<distribution>' directory and enabled using
233 dnl # the --with-spec=<distribution> configure option.
235 AC_DEFUN([SPL_AC_RPM], [
239 AC_MSG_CHECKING([whether $RPM is available])
240 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
241 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
243 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
246 AC_MSG_RESULT([$HAVE_RPM])
249 AC_MSG_CHECKING([whether $RPMBUILD is available])
250 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
251 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
253 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
256 AC_MSG_RESULT([$HAVE_RPMBUILD])
259 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
261 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
264 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
269 RPM_SPEC_DIR="rpm/generic"
271 AS_HELP_STRING([--with-spec=SPEC],
272 [Spec files 'generic|fedora']),
273 [RPM_SPEC_DIR="rpm/$withval"])
275 AC_MSG_CHECKING([whether spec files are available])
276 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
280 AC_SUBST(RPM_VERSION)
282 AC_SUBST(HAVE_RPMBUILD)
284 AC_SUBST(RPMBUILD_VERSION)
286 AC_SUBST(RPM_SPEC_DIR)
287 AC_SUBST(RPM_DEFINE_UTIL)
288 AC_SUBST(RPM_DEFINE_KMOD)
289 AC_SUBST(RPM_DEFINE_DKMS)
290 AC_SUBST(RPM_DEFINE_COMMON)
291 AC_SUBST(SRPM_DEFINE_UTIL)
292 AC_SUBST(SRPM_DEFINE_KMOD)
293 AC_SUBST(SRPM_DEFINE_DKMS)
294 AC_SUBST(SRPM_DEFINE_COMMON)
298 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
299 dnl # tools are missing it is non-fatal but you will not be able to build
300 dnl # DEB packages and will be warned if you try too.
302 AC_DEFUN([SPL_AC_DPKG], [
304 DPKGBUILD=dpkg-buildpackage
306 AC_MSG_CHECKING([whether $DPKG is available])
307 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
308 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
310 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
313 AC_MSG_RESULT([$HAVE_DPKG])
316 AC_MSG_CHECKING([whether $DPKGBUILD is available])
317 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
318 DPKGBUILD_VERSION=$(echo $tmp | \
319 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
321 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
324 AC_MSG_RESULT([$HAVE_DPKGBUILD])
329 AC_SUBST(DPKG_VERSION)
331 AC_SUBST(HAVE_DPKGBUILD)
333 AC_SUBST(DPKGBUILD_VERSION)
337 dnl # Until native packaging for various different packing systems
338 dnl # can be added the least we can do is attempt to use alien to
339 dnl # convert the RPM packages to the needed package type. This is
340 dnl # a hack but so far it has worked reasonable well.
342 AC_DEFUN([SPL_AC_ALIEN], [
345 AC_MSG_CHECKING([whether $ALIEN is available])
346 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
347 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
349 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
352 AC_MSG_RESULT([$HAVE_ALIEN])
357 AC_SUBST(ALIEN_VERSION)
361 dnl # Using the VENDOR tag from config.guess set the default
362 dnl # package type for 'make pkg': (rpm | deb | tgz)
364 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
365 AC_MSG_CHECKING([linux distribution])
366 if test -f /etc/toss-release ; then
368 elif test -f /etc/fedora-release ; then
370 elif test -f /etc/redhat-release ; then
372 elif test -f /etc/gentoo-release ; then
374 elif test -f /etc/arch-release ; then
376 elif test -f /etc/SuSE-release ; then
378 elif test -f /etc/slackware-version ; then
380 elif test -f /etc/lunar.release ; then
382 elif test -f /etc/lsb-release ; then
384 elif test -f /etc/debian_version ; then
389 AC_MSG_RESULT([$VENDOR])
392 AC_MSG_CHECKING([default package type])
394 toss) DEFAULT_PACKAGE=rpm ;;
395 redhat) DEFAULT_PACKAGE=rpm ;;
396 fedora) DEFAULT_PACKAGE=rpm ;;
397 gentoo) DEFAULT_PACKAGE=tgz ;;
398 arch) DEFAULT_PACKAGE=tgz ;;
399 sles) DEFAULT_PACKAGE=rpm ;;
400 slackware) DEFAULT_PACKAGE=tgz ;;
401 lunar) DEFAULT_PACKAGE=tgz ;;
402 ubuntu) DEFAULT_PACKAGE=deb ;;
403 debian) DEFAULT_PACKAGE=deb ;;
404 *) DEFAULT_PACKAGE=rpm ;;
407 AC_MSG_RESULT([$DEFAULT_PACKAGE])
408 AC_SUBST(DEFAULT_PACKAGE)
412 dnl # Default SPL user configuration
414 AC_DEFUN([SPL_AC_PACKAGE], [
415 SPL_AC_DEFAULT_PACKAGE
421 AC_DEFUN([SPL_AC_LICENSE], [
422 AC_MSG_CHECKING([spl author])
423 AC_MSG_RESULT([$SPL_META_AUTHOR])
425 AC_MSG_CHECKING([spl license])
426 AC_MSG_RESULT([$SPL_META_LICENSE])
429 AC_DEFUN([SPL_AC_CONFIG], [
431 AC_ARG_WITH([config],
432 AS_HELP_STRING([--with-config=CONFIG],
433 [Config file 'kernel|user|all|srpm']),
434 [SPL_CONFIG="$withval"])
435 AC_ARG_ENABLE([linux-builtin],
436 [AC_HELP_STRING([--enable-linux-builtin],
437 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
439 [enable_linux_builtin=no])
441 AC_MSG_CHECKING([spl config])
442 AC_MSG_RESULT([$SPL_CONFIG]);
445 case "$SPL_CONFIG" in
446 kernel) SPL_AC_CONFIG_KERNEL ;;
447 user) SPL_AC_CONFIG_USER ;;
448 all) SPL_AC_CONFIG_KERNEL
449 SPL_AC_CONFIG_USER ;;
452 AC_MSG_RESULT([Error!])
453 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
454 user kernel|user|all|srpm]) ;;
457 AM_CONDITIONAL([CONFIG_USER],
458 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
459 AM_CONDITIONAL([CONFIG_KERNEL],
460 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
461 [test "x$enable_linux_builtin" != xyes ])
465 dnl # Enable if the SPL should be compiled with internal debugging enabled.
466 dnl # By default this support is disabled.
468 AC_DEFUN([SPL_AC_DEBUG], [
469 AC_MSG_CHECKING([whether debugging is enabled])
470 AC_ARG_ENABLE([debug],
471 [AS_HELP_STRING([--enable-debug],
472 [Enable generic debug support @<:@default=no@:>@])],
476 AS_IF([test "x$enable_debug" = xyes],
478 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
479 DEBUG_CFLAGS="-DDEBUG -Werror"
480 DEBUG_SPL="_with_debug"
482 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
483 DEBUG_CFLAGS="-DNDEBUG"
484 DEBUG_SPL="_without_debug"
487 AC_SUBST(DEBUG_CFLAGS)
489 AC_MSG_RESULT([$enable_debug])
493 dnl # Enabled by default it provides a basic debug log infrastructure.
494 dnl # Each subsystem registers itself with a name and logs messages
495 dnl # using predefined types. If the debug mask it set to allow the
496 dnl # message type it will be written to the internal log. The log
497 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
498 dnl # after dumping the log it must be decoded using the spl utility.
500 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
501 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
503 AC_DEFUN([SPL_AC_DEBUG_LOG], [
504 AC_ARG_ENABLE([debug-log],
505 [AS_HELP_STRING([--enable-debug-log],
506 [Enable basic debug logging @<:@default=yes@:>@])],
508 [enable_debug_log=yes])
510 AS_IF([test "x$enable_debug_log" = xyes],
512 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
513 DEBUG_LOG="_with_debug_log"
514 AC_DEFINE([DEBUG_LOG], [1],
515 [Define to 1 to enable basic debug logging])
517 DEBUG_LOG="_without_debug_log"
521 AC_MSG_CHECKING([whether basic debug logging is enabled])
522 AC_MSG_RESULT([$enable_debug_log])
526 dnl # Enabled by default it provides a minimal level of memory tracking.
527 dnl # A total count of bytes allocated is kept for each alloc and free.
528 dnl # Then at module unload time a report to the console will be printed
529 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
530 dnl # and provide an easy way to inspect the kmem based slab.
532 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
533 AC_ARG_ENABLE([debug-kmem],
534 [AS_HELP_STRING([--enable-debug-kmem],
535 [Enable basic kmem accounting @<:@default=yes@:>@])],
537 [enable_debug_kmem=yes])
539 AS_IF([test "x$enable_debug_kmem" = xyes],
541 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
542 DEBUG_KMEM="_with_debug_kmem"
543 AC_DEFINE([DEBUG_KMEM], [1],
544 [Define to 1 to enable basic kmem accounting])
546 DEBUG_KMEM="_without_debug_kmem"
550 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
551 AC_MSG_RESULT([$enable_debug_kmem])
555 dnl # Disabled by default it provides detailed memory tracking. This
556 dnl # feature also requires --enable-debug-kmem to be set. When enabled
557 dnl # not only will total bytes be tracked but also the location of every
558 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
559 dnl # addresses and where they were allocated will be dumped to the console.
560 dnl # Enabling this feature has a significant impact on performance but it
561 dnl # makes finding memory leaks pretty straight forward.
563 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
564 AC_ARG_ENABLE([debug-kmem-tracking],
565 [AS_HELP_STRING([--enable-debug-kmem-tracking],
566 [Enable detailed kmem tracking @<:@default=no@:>@])],
568 [enable_debug_kmem_tracking=no])
570 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
572 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
573 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
574 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
575 [Define to 1 to enable detailed kmem tracking])
577 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
580 AC_SUBST(DEBUG_KMEM_TRACKING)
581 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
582 AC_MSG_RESULT([$enable_debug_kmem_tracking])
586 dnl # SPL_LINUX_CONFTEST
588 AC_DEFUN([SPL_LINUX_CONFTEST], [
589 cat confdefs.h - <<_ACEOF >conftest.c
595 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
597 m4_define([SPL_LANG_PROGRAM], [
602 dnl Do *not* indent the following line: there may be CPP directives.
603 dnl Don't move the `;' right after for the same reason.
611 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
613 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
614 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
615 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
616 echo "obj-m := conftest.o" >build/Makefile
618 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
620 [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])],
622 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
628 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
630 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
631 [SPL_LINUX_COMPILE_IFELSE(
632 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
634 [test -s build/conftest.o],
639 dnl # SPL_CHECK_SYMBOL_EXPORT
640 dnl # check symbol exported or not
642 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
643 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
644 $LINUX_OBJ/Module*.symvers 2>/dev/null
646 if test $rc -ne 0; then
649 grep -q -E "EXPORT_SYMBOL.*($1)" \
650 "$LINUX_OBJ/$file" 2>/dev/null
652 if test $rc -eq 0; then
657 if test $export -eq 0; then :
668 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
669 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
670 dnl # is called if not compiling for builtin
672 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
673 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
674 if test $rc -ne 0; then :
677 if test "x$enable_linux_builtin" != xyes; then
678 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
680 if test $rc -ne 0; then :
689 dnl # SPL_CHECK_SYMBOL_HEADER
690 dnl # check if a symbol prototype is defined in listed headers.
692 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
693 AC_MSG_CHECKING([whether symbol $1 exists in header])
696 grep -q "$2" "$LINUX/$file" 2>/dev/null
698 if test $rc -eq 0; then
703 if test $header -eq 0; then
713 dnl # SPL_CHECK_HEADER
714 dnl # check whether header exists and define HAVE_$2_HEADER
716 AC_DEFUN([SPL_CHECK_HEADER],
717 [AC_MSG_CHECKING([whether header $1 exists])
718 SPL_LINUX_TRY_COMPILE([
723 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
733 dnl # Basic toolchain sanity check. Verify that kernel modules can
734 dnl # be built and which symbols can be used.
736 AC_DEFUN([SPL_AC_TEST_MODULE],
737 [AC_MSG_CHECKING([whether modules can be built])
738 SPL_LINUX_TRY_COMPILE([],[],[
742 if test "x$enable_linux_builtin" != xyes; then
743 AC_MSG_ERROR([*** Unable to build an empty module.])
746 *** Unable to build an empty module.
747 *** Please run 'make scripts' inside the kernel source tree.])
753 #include "$LINUX/include/linux/license.h"
755 return !license_is_gpl_compatible("$SPL_META_LICENSE");
758 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
759 [Define to 1 if GPL-only symbols can be used])
765 dnl # Use the atomic implemenation based on global spinlocks. This
766 dnl # should only be needed by 32-bit kernels which do not provide
767 dnl # the atomic64_* API. It may be optionally enabled as a fallback
768 dnl # if problems are observed with the direct mapping to the native
769 dnl # Linux atomic operations. You may not disable atomic spinlocks
770 dnl # if you kernel does not an atomic64_* API.
772 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
773 AC_ARG_ENABLE([atomic-spinlocks],
774 [AS_HELP_STRING([--enable-atomic-spinlocks],
775 [Atomic types use spinlocks @<:@default=check@:>@])],
777 [enable_atomic_spinlocks=check])
779 SPL_LINUX_TRY_COMPILE([
780 #include <linux/fs.h>
782 atomic64_t *ptr __attribute__ ((unused));
785 AC_DEFINE(HAVE_ATOMIC64_T, 1,
786 [kernel defines atomic64_t])
791 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
792 AS_IF([test "x$have_atomic64_t" = xyes], [
793 enable_atomic_spinlocks=no
795 enable_atomic_spinlocks=yes
799 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
800 AC_DEFINE([ATOMIC_SPINLOCK], [1],
801 [Atomic types use spinlocks])
803 AS_IF([test "x$have_atomic64_t" = xno], [
805 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
809 AC_MSG_CHECKING([whether atomic types use spinlocks])
810 AC_MSG_RESULT([$enable_atomic_spinlocks])
812 AC_MSG_CHECKING([whether kernel defines atomic64_t])
813 AC_MSG_RESULT([$have_atomic64_t])
817 dnl # 2.6.24 API change,
818 dnl # check if atomic64_cmpxchg is defined
820 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
821 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
822 SPL_LINUX_TRY_COMPILE([
823 #include <linux/fs.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 <linux/fs.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])
873 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
874 tmp_flags="$EXTRA_KCFLAGS"
875 EXTRA_KCFLAGS="-Werror"
877 dnl # 2.6.23 to 2.6.34 API change
878 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
880 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
881 SPL_LINUX_TRY_COMPILE([
882 #include <linux/mm.h>
884 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
886 struct shrinker cache_shrinker = {
887 .shrink = shrinker_cb,
888 .seeks = DEFAULT_SEEKS,
890 register_shrinker(&cache_shrinker);
893 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
894 [old shrinker callback wants 2 args])
898 dnl # 2.6.35 - 2.6.39 API change
899 dnl # ->shrink(struct shrinker *,
900 dnl # int nr_to_scan, gfp_t gfp_mask)
902 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
903 SPL_LINUX_TRY_COMPILE([
904 #include <linux/mm.h>
906 int shrinker_cb(struct shrinker *, int nr_to_scan,
909 struct shrinker cache_shrinker = {
910 .shrink = shrinker_cb,
911 .seeks = DEFAULT_SEEKS,
913 register_shrinker(&cache_shrinker);
916 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
917 [old shrinker callback wants 3 args])
921 dnl # 3.0 - 3.11 API change
922 dnl # ->shrink(struct shrinker *,
923 dnl # struct shrink_control *sc)
926 [whether new 2-argument shrinker exists])
927 SPL_LINUX_TRY_COMPILE([
928 #include <linux/mm.h>
930 int shrinker_cb(struct shrinker *,
931 struct shrink_control *sc);
933 struct shrinker cache_shrinker = {
934 .shrink = shrinker_cb,
935 .seeks = DEFAULT_SEEKS,
937 register_shrinker(&cache_shrinker);
940 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
941 [new shrinker callback wants 2 args])
945 dnl # 3.12 API change,
946 dnl # ->shrink() is logically split in to
947 dnl # ->count_objects() and ->scan_objects()
950 [whether ->count_objects callback exists])
951 SPL_LINUX_TRY_COMPILE([
952 #include <linux/mm.h>
954 unsigned long shrinker_cb(
956 struct shrink_control *sc);
958 struct shrinker cache_shrinker = {
959 .count_objects = shrinker_cb,
960 .scan_objects = shrinker_cb,
961 .seeks = DEFAULT_SEEKS,
963 register_shrinker(&cache_shrinker);
966 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
967 1, [->count_objects exists])
974 EXTRA_KCFLAGS="$tmp_flags"
978 dnl # 2.6.33 API change,
979 dnl # Removed .ctl_name from struct ctl_table.
981 AC_DEFUN([SPL_AC_CTL_NAME], [
982 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
983 SPL_LINUX_TRY_COMPILE([
984 #include <linux/sysctl.h>
986 struct ctl_table ctl __attribute__ ((unused));
990 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
997 dnl # 2.6.16 API change.
998 dnl # Check if 'fls64()' is available
1000 AC_DEFUN([SPL_AC_FLS64],
1001 [AC_MSG_CHECKING([whether fls64() is available])
1002 SPL_LINUX_TRY_COMPILE([
1003 #include <linux/bitops.h>
1008 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1015 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1017 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1018 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1019 SPL_LINUX_TRY_COMPILE_SYMBOL([
1020 #include <linux/time.h>
1022 set_normalized_timespec(NULL, 0, 0);
1023 ], [set_normalized_timespec], [kernel/time.c], [
1025 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1026 [set_normalized_timespec() is available as export])
1033 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1034 dnl # previously it was available in time.h as an inline.
1036 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1037 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1038 SPL_LINUX_TRY_COMPILE([
1039 #include <linux/time.h>
1040 void set_normalized_timespec(struct timespec *ts,
1041 time_t sec, long nsec) { }
1048 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1049 [set_normalized_timespec() is available as inline])
1054 dnl # 2.6.18 API change,
1055 dnl # timespec_sub() inline function available in linux/time.h
1057 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1058 AC_MSG_CHECKING([whether timespec_sub() is available])
1059 SPL_LINUX_TRY_COMPILE([
1060 #include <linux/time.h>
1062 struct timespec a = { 0 };
1063 struct timespec b = { 0 };
1064 struct timespec c __attribute__ ((unused));
1065 c = timespec_sub(a, b);
1068 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1075 dnl # 2.6.18 API change,
1076 dnl # added linux/uaccess.h
1078 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1079 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1083 dnl # 2.6.12 API change,
1084 dnl # check whether 'kmalloc_node()' is available.
1086 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1087 AC_MSG_CHECKING([whether kmalloc_node() is available])
1088 SPL_LINUX_TRY_COMPILE([
1089 #include <linux/slab.h>
1091 void *a __attribute__ ((unused));
1092 a = kmalloc_node(1, GFP_KERNEL, 0);
1095 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1102 dnl # 2.6.9 API change,
1103 dnl # check whether 'monotonic_clock()' is available it may
1104 dnl # be available for some archs but not others.
1106 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1107 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1108 SPL_LINUX_TRY_COMPILE_SYMBOL([
1109 #include <linux/timex.h>
1112 ], [monotonic_clock], [], [
1114 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1115 [monotonic_clock() is available])
1122 dnl # 2.6.16 API change,
1123 dnl # check whether 'struct inode' has i_mutex
1125 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1126 AC_MSG_CHECKING([whether struct inode has i_mutex])
1127 SPL_LINUX_TRY_COMPILE([
1128 #include <linux/fs.h>
1129 #include <linux/mutex.h>
1132 mutex_init(&i.i_mutex);
1135 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1142 dnl # 2.6.29 API change,
1143 dnl # Adaptive mutexs were introduced which track the mutex owner. The
1144 dnl # mutex wrappers leverage this functionality to avoid tracking the
1145 dnl # owner multipe times.
1147 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1148 AC_MSG_CHECKING([whether struct mutex has owner])
1149 SPL_LINUX_TRY_COMPILE([
1150 #include <linux/mutex.h>
1152 struct mutex mtx __attribute__ ((unused));
1156 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1163 dnl # 2.6.39 API change,
1164 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1165 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1166 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1167 dnl # pointer which frankly makes a lot more sense.
1169 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1170 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1171 tmp_flags="$EXTRA_KCFLAGS"
1172 EXTRA_KCFLAGS="-Werror"
1173 SPL_LINUX_TRY_COMPILE([
1174 #include <linux/mutex.h>
1175 #include <linux/sched.h>
1177 struct mutex mtx __attribute__ ((unused));
1178 mtx.owner = current;
1181 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1182 [struct mutex owner is a task_struct])
1186 EXTRA_KCFLAGS="$tmp_flags"
1190 dnl # 2.6.18 API change,
1191 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1192 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1193 dnl # if the mutex validator is disabled or otherwise unavailable.
1195 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1196 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1197 SPL_LINUX_TRY_COMPILE([
1198 #include <linux/mutex.h>
1202 mutex_lock_nested(&mutex, 0);
1205 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1206 [mutex_lock_nested() is available])
1213 dnl # 2.6.27 API change,
1214 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1216 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1217 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1218 SPL_LINUX_TRY_COMPILE([
1219 #include <linux/interrupt.h>
1220 #include <linux/smp.h>
1222 void on_each_cpu_func(void *data) { return; }
1224 on_each_cpu(on_each_cpu_func, NULL, 0);
1227 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1228 [on_each_cpu wants 3 args])
1235 dnl # 2.6.18 API change,
1236 dnl # kallsyms_lookup_name no longer exported
1238 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1239 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1240 SPL_LINUX_TRY_COMPILE_SYMBOL([
1241 #include <linux/kallsyms.h>
1243 kallsyms_lookup_name(NULL);
1244 ], [kallsyms_lookup_name], [], [
1246 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1247 [kallsyms_lookup_name() is available])
1254 dnl # Proposed API change,
1255 dnl # This symbol is not available in stock kernels. You may build a
1256 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1257 dnl # these symbols for use. If your already rolling a custom kernel for
1258 dnl # your environment this is recommended.
1260 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1261 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1262 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1264 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1265 [get_vmalloc_info() is available])
1272 dnl # 3.10 API change,
1273 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1275 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1276 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1277 SPL_LINUX_TRY_COMPILE([
1278 #include <linux/vmalloc.h>
1279 struct vmalloc_info { void *a; };
1286 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1291 dnl # 3.10 API change,
1292 dnl # PDE is replaced by PDE_DATA
1294 AC_DEFUN([SPL_AC_PDE_DATA], [
1295 AC_MSG_CHECKING([whether PDE_DATA() is available])
1296 SPL_LINUX_TRY_COMPILE_SYMBOL([
1297 #include <linux/proc_fs.h>
1300 ], [PDE_DATA], [], [
1302 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1309 dnl # 2.6.17 API change
1310 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1311 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1312 dnl # were exported in 2.6.17 for use by modules which was consistent with
1313 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1314 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1315 dnl # were dropped entirely leaving modules no way to directly iterate over
1316 dnl # the zone list. Because we need access to the zone helpers we check
1317 dnl # if the kernel contains the old or new implementation. Then we check
1318 dnl # to see if the symbols we need for each version are available. If they
1319 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1321 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1322 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1323 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1325 if test $rc -eq 0; then
1326 AC_MSG_RESULT([yes])
1327 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1334 dnl # Proposed API change,
1335 dnl # This symbol is not available in stock kernels. You may build a
1336 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1337 dnl # these symbols for use. If your already rolling a custom kernel for
1338 dnl # your environment this is recommended.
1340 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1341 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1342 SPL_LINUX_TRY_COMPILE_SYMBOL([
1343 #include <linux/mmzone.h>
1345 first_online_pgdat();
1346 ], [first_online_pgdat], [], [
1348 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1349 [first_online_pgdat() is available])
1356 dnl # Proposed API change,
1357 dnl # This symbol is not available in stock kernels. You may build a
1358 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1359 dnl # these symbols for use. If your already rolling a custom kernel for
1360 dnl # your environment this is recommended.
1362 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1363 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1364 SPL_LINUX_TRY_COMPILE_SYMBOL([
1365 #include <linux/mmzone.h>
1367 next_online_pgdat(NULL);
1368 ], [next_online_pgdat], [], [
1370 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1371 [next_online_pgdat() is available])
1378 dnl # Proposed API change,
1379 dnl # This symbol is not available in stock kernels. You may build a
1380 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1381 dnl # these symbols for use. If your already rolling a custom kernel for
1382 dnl # your environment this is recommended.
1384 AC_DEFUN([SPL_AC_NEXT_ZONE],
1385 [AC_MSG_CHECKING([whether next_zone() is available])
1386 SPL_LINUX_TRY_COMPILE_SYMBOL([
1387 #include <linux/mmzone.h>
1390 ], [next_zone], [], [
1392 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1399 dnl # 2.6.17 API change,
1400 dnl # See SPL_AC_PGDAT_HELPERS for details.
1402 AC_DEFUN([SPL_AC_PGDAT_LIST],
1403 [AC_MSG_CHECKING([whether pgdat_list is available])
1404 SPL_LINUX_TRY_COMPILE_SYMBOL([
1405 #include <linux/topology.h>
1406 pg_data_t *tmp = pgdat_list;
1407 ], [], [pgdat_list], [], [
1409 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1416 dnl # 2.6.18 API change,
1417 dnl # First introduced global_page_state() support as an inline.
1419 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1420 AC_MSG_CHECKING([whether global_page_state() is available])
1421 SPL_LINUX_TRY_COMPILE([
1422 #include <linux/mm.h>
1424 unsigned long state __attribute__ ((unused));
1425 state = global_page_state(0);
1428 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1429 [global_page_state() is available])
1436 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1437 dnl # Public global zone stats now include a free page count. However
1438 dnl # the enumerated names of the counters have changed since this API
1439 dnl # was introduced. We need to deduce the corrent name to use. This
1440 dnl # replaces the priviate get_zone_counts() interface.
1442 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1443 dnl # is 2.6.30 as of when this was written.
1445 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1446 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1447 SPL_LINUX_TRY_COMPILE([
1448 #include <linux/mm.h>
1450 enum zone_stat_item zsi __attribute__ ((unused));
1451 zsi = NR_FREE_PAGES;
1454 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1455 [Page state NR_FREE_PAGES is available])
1462 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1463 dnl # Public global zone stats now include an inactive page count. However
1464 dnl # the enumerated names of the counters have changed since this API
1465 dnl # was introduced. We need to deduce the corrent name to use. This
1466 dnl # replaces the priviate get_zone_counts() interface.
1468 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1469 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1470 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1472 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1473 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1474 SPL_LINUX_TRY_COMPILE([
1475 #include <linux/mm.h>
1477 enum zone_stat_item zsi __attribute__ ((unused));
1481 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1482 [Page state NR_INACTIVE is available])
1487 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1488 SPL_LINUX_TRY_COMPILE([
1489 #include <linux/mm.h>
1491 enum zone_stat_item zsi __attribute__ ((unused));
1492 zsi = NR_INACTIVE_ANON;
1495 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1496 [Page state NR_INACTIVE_ANON is available])
1501 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1502 SPL_LINUX_TRY_COMPILE([
1503 #include <linux/mm.h>
1505 enum zone_stat_item zsi __attribute__ ((unused));
1506 zsi = NR_INACTIVE_FILE;
1509 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1510 [Page state NR_INACTIVE_FILE is available])
1517 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1518 dnl # Public global zone stats now include an active page count. However
1519 dnl # the enumerated names of the counters have changed since this API
1520 dnl # was introduced. We need to deduce the corrent name to use. This
1521 dnl # replaces the priviate get_zone_counts() interface.
1523 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1524 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1525 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1527 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1528 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1529 SPL_LINUX_TRY_COMPILE([
1530 #include <linux/mm.h>
1532 enum zone_stat_item zsi __attribute__ ((unused));
1536 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1537 [Page state NR_ACTIVE is available])
1542 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1543 SPL_LINUX_TRY_COMPILE([
1544 #include <linux/mm.h>
1546 enum zone_stat_item zsi __attribute__ ((unused));
1547 zsi = NR_ACTIVE_ANON;
1550 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1551 [Page state NR_ACTIVE_ANON is available])
1556 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1557 SPL_LINUX_TRY_COMPILE([
1558 #include <linux/mm.h>
1560 enum zone_stat_item zsi __attribute__ ((unused));
1561 zsi = NR_ACTIVE_FILE;
1564 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1565 [Page state NR_ACTIVE_FILE is available])
1572 dnl # Proposed API change for legacy kernels.
1573 dnl # This symbol is not available in older kernels. For kernels post
1574 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1575 dnl # page state information. This symbol is only used in legacy kernels
1576 dnl # any only as a last resort.
1578 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1579 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1580 SPL_LINUX_TRY_COMPILE([
1582 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1583 #error "global_page_state needs NR_FREE_PAGES"
1586 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1587 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1588 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1589 #error "global_page_state needs NR_ACTIVE*"
1592 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1593 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1594 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1595 #error "global_page_state needs NR_INACTIVE*"
1601 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1602 [get_zone_counts() is needed])
1604 AC_MSG_CHECKING([whether get_zone_counts() is available])
1605 SPL_LINUX_TRY_COMPILE_SYMBOL([
1606 #include <linux/mmzone.h>
1608 get_zone_counts(NULL, NULL, NULL);
1609 ], [get_zone_counts], [], [
1611 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1612 [get_zone_counts() is available])
1620 dnl # 2.6.27 API change,
1621 dnl # The user_path_dir() replaces __user_walk()
1623 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1624 [AC_MSG_CHECKING([whether user_path_dir() is available])
1625 SPL_LINUX_TRY_COMPILE_SYMBOL([
1626 #include <linux/fcntl.h>
1627 #include <linux/namei.h>
1629 user_path_dir(NULL, NULL);
1630 ], [user_path_at], [], [
1632 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1639 dnl # Symbol available in RHEL kernels not in stock kernels.
1641 AC_DEFUN([SPL_AC_SET_FS_PWD],
1642 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1643 SPL_LINUX_TRY_COMPILE_SYMBOL([
1644 #include <linux/spinlock.h>
1645 #include <linux/fs_struct.h>
1648 ], [set_fs_pwd], [], [
1650 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1657 dnl # 3.9 API change
1658 dnl # set_fs_pwd takes const struct path *
1660 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1661 tmp_flags="$EXTRA_KCFLAGS"
1662 EXTRA_KCFLAGS="-Werror"
1663 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1664 SPL_LINUX_TRY_COMPILE([
1665 #include <linux/spinlock.h>
1666 #include <linux/fs_struct.h>
1667 #include <linux/path.h>
1668 void (*const set_fs_pwd_func)
1669 (struct fs_struct *, const struct path *)
1675 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1676 [set_fs_pwd() needs const path *])
1678 SPL_LINUX_TRY_COMPILE([
1679 #include <linux/spinlock.h>
1680 #include <linux/fs_struct.h>
1681 #include <linux/path.h>
1682 void (*const set_fs_pwd_func)
1683 (struct fs_struct *, struct path *)
1690 AC_MSG_ERROR(unknown)
1693 EXTRA_KCFLAGS="$tmp_flags"
1696 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1697 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1698 SPL_LINUX_TRY_COMPILE([
1699 #include <linux/fs.h>
1701 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1704 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1705 [vfs_unlink() wants 2 args])
1709 dnl # Linux 3.13 API change
1710 dnl # Added delegated inode
1712 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1713 SPL_LINUX_TRY_COMPILE([
1714 #include <linux/fs.h>
1716 vfs_unlink((struct inode *) NULL,
1717 (struct dentry *) NULL,
1718 (struct inode **) NULL);
1721 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1722 [vfs_unlink() wants 3 args])
1730 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1731 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1732 SPL_LINUX_TRY_COMPILE([
1733 #include <linux/fs.h>
1735 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1736 (struct inode *) NULL, (struct dentry *) NULL);
1739 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1740 [vfs_rename() wants 4 args])
1744 dnl # Linux 3.13 API change
1745 dnl # Added delegated inode
1747 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1748 SPL_LINUX_TRY_COMPILE([
1749 #include <linux/fs.h>
1751 vfs_rename((struct inode *) NULL,
1752 (struct dentry *) NULL,
1753 (struct inode *) NULL,
1754 (struct dentry *) NULL,
1755 (struct inode **) NULL);
1758 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1759 [vfs_rename() wants 5 args])
1763 dnl # Linux 3.15 API change
1766 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1767 SPL_LINUX_TRY_COMPILE([
1768 #include <linux/fs.h>
1770 vfs_rename((struct inode *) NULL,
1771 (struct dentry *) NULL,
1772 (struct inode *) NULL,
1773 (struct dentry *) NULL,
1774 (struct inode **) NULL,
1778 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1779 [vfs_rename() wants 6 args])
1788 dnl # 2.6.36 API change,
1789 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1790 dnl # a spinlock_t to improve the fastpath performance.
1792 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1793 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1794 tmp_flags="$EXTRA_KCFLAGS"
1795 EXTRA_KCFLAGS="-Werror"
1796 SPL_LINUX_TRY_COMPILE([
1797 #include <linux/sched.h>
1798 #include <linux/fs_struct.h>
1800 struct fs_struct fs;
1801 spin_lock_init(&fs.lock);
1804 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1805 [struct fs_struct uses spinlock_t])
1809 EXTRA_KCFLAGS="$tmp_flags"
1813 dnl # 2.6.29 API change,
1814 dnl # check whether 'struct cred' exists
1816 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1817 AC_MSG_CHECKING([whether struct cred exists])
1818 SPL_LINUX_TRY_COMPILE([
1819 #include <linux/cred.h>
1821 struct cred *cr __attribute__ ((unused));
1825 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1833 dnl # User namespaces, use kuid_t in place of uid_t
1834 dnl # where available. Not strictly a user namespaces thing
1835 dnl # but it should prevent surprises
1837 AC_DEFUN([SPL_AC_KUIDGID_T], [
1838 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1839 SPL_LINUX_TRY_COMPILE([
1840 #include <linux/uidgid.h>
1842 kuid_t userid = KUIDT_INIT(0);
1843 kgid_t groupid = KGIDT_INIT(0);
1845 SPL_LINUX_TRY_COMPILE([
1846 #include <linux/uidgid.h>
1851 AC_MSG_RESULT(yes; optional)
1853 AC_MSG_RESULT(yes; mandatory)
1854 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1862 dnl # Custom SPL patch may export this symbol.
1864 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1865 [AC_MSG_CHECKING([whether groups_search() is available])
1866 SPL_LINUX_TRY_COMPILE_SYMBOL([
1867 #include <linux/cred.h>
1868 #ifdef HAVE_KUIDGID_T
1869 #include <linux/uidgid.h>
1872 #ifdef HAVE_KUIDGID_T
1873 groups_search(NULL, KGIDT_INIT(0));
1875 groups_search(NULL, 0);
1877 ], [groups_search], [], [
1879 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1886 dnl # 2.6.x API change,
1887 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1889 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1890 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1891 SPL_LINUX_TRY_COMPILE_SYMBOL([
1892 #include <linux/sched.h>
1894 __put_task_struct(NULL);
1895 ], [__put_task_struct], [], [
1897 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1898 [__put_task_struct() is available])
1905 dnl # 2.6.32 API change,
1906 dnl # Unused 'struct file *' removed from prototype.
1908 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1909 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1910 SPL_LINUX_TRY_COMPILE([
1911 #include <linux/sysctl.h>
1913 proc_dostring(NULL, 0, NULL, NULL, NULL);
1916 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1917 [proc_handler() wants 5 args])
1924 dnl # 2.6.x API change,
1925 dnl # kvasprintf() function added.
1927 AC_DEFUN([SPL_AC_KVASPRINTF],
1928 [AC_MSG_CHECKING([whether kvasprintf() is available])
1929 SPL_LINUX_TRY_COMPILE_SYMBOL([
1930 #include <linux/kernel.h>
1932 kvasprintf(0, NULL, *((va_list*)NULL));
1933 ], [kvasprintf], [], [
1935 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1942 dnl # 2.6.29 API change,
1943 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1945 AC_DEFUN([SPL_AC_VFS_FSYNC],
1946 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1947 SPL_LINUX_TRY_COMPILE_SYMBOL([
1948 #include <linux/fs.h>
1951 ], [vfs_fsync], [fs/sync.c], [
1953 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1960 dnl # 2.6.35 API change,
1961 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1963 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1964 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1965 SPL_LINUX_TRY_COMPILE([
1966 #include <linux/fs.h>
1971 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1978 dnl # 3.5 API change,
1979 dnl # inode_operations.truncate_range removed
1981 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1982 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1983 SPL_LINUX_TRY_COMPILE([
1984 #include <linux/fs.h>
1986 struct inode_operations ops;
1987 ops.truncate_range = NULL;
1990 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1991 [truncate_range() inode operation is available])
1998 dnl # Linux 2.6.38 - 3.x API
2000 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2001 AC_MSG_CHECKING([whether fops->fallocate() exists])
2002 SPL_LINUX_TRY_COMPILE([
2003 #include <linux/fs.h>
2005 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2006 struct file_operations fops __attribute__ ((unused)) = {
2007 .fallocate = fallocate,
2011 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2018 dnl # Linux 2.6.x - 2.6.37 API
2020 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2021 AC_MSG_CHECKING([whether iops->fallocate() exists])
2022 SPL_LINUX_TRY_COMPILE([
2023 #include <linux/fs.h>
2025 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2026 struct inode_operations fops __attribute__ ((unused)) = {
2027 .fallocate = fallocate,
2031 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2038 dnl # PaX Linux 2.6.38 - 3.x API
2040 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2041 AC_MSG_CHECKING([whether fops->fallocate() exists])
2042 SPL_LINUX_TRY_COMPILE([
2043 #include <linux/fs.h>
2045 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2046 struct file_operations_no_const fops __attribute__ ((unused)) = {
2047 .fallocate = fallocate,
2051 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2058 dnl # The fallocate callback was moved from the inode_operations
2059 dnl # structure to the file_operations structure.
2061 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2062 SPL_AC_KERNEL_FILE_FALLOCATE
2063 SPL_AC_KERNEL_INODE_FALLOCATE
2064 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2068 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2069 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2070 dnl # condition. The fixed version is exported as a symbol. The race
2071 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2072 dnl # call that version while holding sem->wait_lock.
2074 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2075 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2076 SPL_LINUX_TRY_COMPILE_SYMBOL([
2077 #include <linux/rwsem.h>
2078 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2079 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2081 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2082 [rwsem_is_locked() acquires sem->wait_lock])
2089 dnl # 2.6.xx API compat,
2090 dnl # There currently exists no exposed API to partially shrink the dcache.
2091 dnl # The expected mechanism to shrink the cache is a registered shrinker
2092 dnl # which is called during memory pressure.
2094 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2095 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2096 SPL_LINUX_TRY_COMPILE_SYMBOL([
2097 #include <linux/dcache.h>
2099 shrink_dcache_memory(0, 0);
2100 ], [shrink_dcache_memory], [fs/dcache.c], [
2102 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2103 [shrink_dcache_memory() is available])
2110 dnl # 2.6.xx API compat,
2111 dnl # There currently exists no exposed API to partially shrink the icache.
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_ICACHE_MEMORY],
2116 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2117 SPL_LINUX_TRY_COMPILE_SYMBOL([
2118 #include <linux/dcache.h>
2120 shrink_icache_memory(0, 0);
2121 ], [shrink_icache_memory], [fs/inode.c], [
2123 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2124 [shrink_icache_memory() is available])
2131 dnl # 2.6.28 API change
2132 dnl # The kern_path() function has been introduced. We adopt it as the new way
2133 dnl # of looking up paths. When it is not available, we emulate it using the
2134 dnl # older interfaces.
2136 AC_DEFUN([SPL_AC_KERN_PATH],
2137 [AC_MSG_CHECKING([whether kern_path() is available])
2138 SPL_LINUX_TRY_COMPILE_SYMBOL([
2139 #include <linux/namei.h>
2141 int r = kern_path(NULL, 0, NULL);
2142 ], [kern_path], [fs/namei.c], [
2144 AC_DEFINE(HAVE_KERN_PATH, 1,
2145 [kern_path() is available])
2148 AC_MSG_CHECKING([whether path_lookup() is available])
2149 SPL_LINUX_TRY_COMPILE_SYMBOL([
2150 #include <linux/namei.h>
2152 int r = path_lookup(NULL, 0, NULL);
2153 ], [path_lookup], [fs/namei.c], [
2155 AC_DEFINE(HAVE_KERN_PATH, 1,
2156 [kern_path() is available])
2160 *** Neither kern_path() nor path_lookup() is available.
2161 *** Please file an issue:
2162 *** https://github.com/zfsonlinux/spl/issues/new])
2169 dnl # /proc/kallsyms support,
2170 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2172 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2173 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2174 SPL_LINUX_TRY_COMPILE([
2175 #if !defined(CONFIG_KALLSYMS)
2176 #error CONFIG_KALLSYMS not defined
2179 AC_MSG_RESULT([yes])
2183 *** This kernel does not include the required kallsyms support.
2184 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2189 dnl # zlib inflate compat,
2190 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2192 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2193 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2194 SPL_LINUX_TRY_COMPILE([
2195 #if !defined(CONFIG_ZLIB_INFLATE) && \
2196 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2197 #error CONFIG_ZLIB_INFLATE not defined
2200 AC_MSG_RESULT([yes])
2204 *** This kernel does not include the required zlib inflate support.
2205 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2210 dnl # zlib deflate compat,
2211 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2213 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2214 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2215 SPL_LINUX_TRY_COMPILE([
2216 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2217 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2218 #error CONFIG_ZLIB_DEFLATE not defined
2221 AC_MSG_RESULT([yes])
2225 *** This kernel does not include the required zlib deflate support.
2226 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2231 dnl # 2.6.39 API compat,
2232 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2233 dnl # This was done to avoid always having to allocate the maximum size
2234 dnl # workspace (268K). The caller can now specific the windowBits and
2235 dnl # memLevel compression parameters to get a smaller workspace.
2237 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2238 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2239 SPL_LINUX_TRY_COMPILE([
2240 #include <linux/zlib.h>
2242 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2245 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2246 [zlib_deflate_workspacesize() wants 2 args])
2253 dnl # 2.6.39 API change,
2254 dnl # Shrinker adjust to use common shrink_control structure.
2256 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2257 AC_MSG_CHECKING([whether struct shrink_control exists])
2258 SPL_LINUX_TRY_COMPILE([
2259 #include <linux/mm.h>
2261 struct shrink_control sc __attribute__ ((unused));
2264 sc.gfp_mask = GFP_KERNEL;
2267 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2268 [struct shrink_control exists])
2275 dnl # 3.1 API Change
2277 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2278 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2280 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2281 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2282 tmp_flags="$EXTRA_KCFLAGS"
2283 EXTRA_KCFLAGS="-Werror"
2284 SPL_LINUX_TRY_COMPILE([
2285 #include <linux/rwsem.h>
2287 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2288 raw_spinlock_t dummy_lock __attribute__ ((unused));
2289 dummy_semaphore.wait_lock = dummy_lock;
2292 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2293 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2297 EXTRA_KCFLAGS="$tmp_flags"
2301 dnl # 3.9 API change,
2302 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2304 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2305 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2306 SPL_LINUX_TRY_COMPILE([
2307 #include <linux/sched.h>
2308 #include <linux/sched/rt.h>
2312 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2320 dnl # 3.9 API change,
2321 dnl # vfs_getattr() uses 2 args
2322 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2324 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2325 AC_MSG_CHECKING([whether vfs_getattr() wants])
2326 SPL_LINUX_TRY_COMPILE([
2327 #include <linux/fs.h>
2329 vfs_getattr((struct path *) NULL,
2330 (struct kstat *)NULL);
2332 AC_MSG_RESULT(2 args)
2333 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2334 [vfs_getattr wants 2 args])
2336 SPL_LINUX_TRY_COMPILE([
2337 #include <linux/fs.h>
2339 vfs_getattr((struct vfsmount *)NULL,
2340 (struct dentry *)NULL,
2341 (struct kstat *)NULL);
2343 AC_MSG_RESULT(3 args)
2345 AC_MSG_ERROR(unknown)
2351 dnl # 2.6.36 API compatibility.
2352 dnl # Added usleep_range timer.
2353 dnl # usleep_range is a finer precision implementation of msleep
2354 dnl # designed to be a drop-in replacement for udelay where a precise
2355 dnl # sleep / busy-wait is unnecessary.
2357 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2358 AC_MSG_CHECKING([whether usleep_range() is available])
2359 SPL_LINUX_TRY_COMPILE([
2360 #include <linux/delay.h>
2365 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2366 [usleep_range is available])
2373 dnl # 2.6.35 API change,
2374 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2375 dnl # private allocation flags which are applied when allocating a new slab
2376 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2377 dnl # non-default flags.
2379 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2380 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2381 SPL_LINUX_TRY_COMPILE([
2382 #include <linux/slab.h>
2384 struct kmem_cache cachep __attribute__ ((unused));
2385 cachep.allocflags = GFP_KERNEL;
2388 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2389 [struct kmem_cache has allocflags])
2393 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2394 SPL_LINUX_TRY_COMPILE([
2395 #include <linux/slab.h>
2397 struct kmem_cache cachep __attribute__ ((unused));
2398 cachep.gfpflags = GFP_KERNEL;
2401 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2402 [struct kmem_cache has gfpflags])
2410 dnl # 3.17 API change,
2411 dnl # wait_on_bit() no longer requires an action argument. The former
2412 dnl # "wait_on_bit" interface required an 'action' function to be provided
2413 dnl # which does the actual waiting. There were over 20 such functions in the
2414 dnl # kernel, many of them identical, though most cases can be satisfied by one
2415 dnl # of just two functions: one which uses io_schedule() and one which just
2416 dnl # uses schedule(). This API change was made to consolidate all of those
2417 dnl # redundant wait functions.
2419 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2420 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2421 SPL_LINUX_TRY_COMPILE([
2422 #include <linux/wait.h>
2424 int (*action)(void *) = NULL;
2425 wait_on_bit(NULL, 0, action, 0);
2428 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])