1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_SHRINKER_CALLBACK
37 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
38 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
43 SPL_AC_MONOTONIC_CLOCK
46 SPL_AC_MUTEX_OWNER_TASK_STRUCT
47 SPL_AC_MUTEX_LOCK_NESTED
48 SPL_AC_3ARGS_ON_EACH_CPU
49 SPL_AC_KALLSYMS_LOOKUP_NAME
50 SPL_AC_GET_VMALLOC_INFO
52 SPL_AC_FIRST_ONLINE_PGDAT
53 SPL_AC_NEXT_ONLINE_PGDAT
56 SPL_AC_GLOBAL_PAGE_STATE
57 SPL_AC_ZONE_STAT_ITEM_FREE
58 SPL_AC_ZONE_STAT_ITEM_INACTIVE
59 SPL_AC_ZONE_STAT_ITEM_ACTIVE
60 SPL_AC_GET_ZONE_COUNTS
63 SPL_AC_SET_FS_PWD_WITH_CONST
64 SPL_AC_2ARGS_VFS_UNLINK
65 SPL_AC_4ARGS_VFS_RENAME
67 SPL_AC_2ARGS_VFS_FSYNC
68 SPL_AC_INODE_TRUNCATE_RANGE
69 SPL_AC_FS_STRUCT_SPINLOCK
73 SPL_AC_PUT_TASK_STRUCT
74 SPL_AC_5ARGS_PROC_HANDLER
76 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
77 SPL_AC_KERNEL_FALLOCATE
78 SPL_AC_SHRINK_DCACHE_MEMORY
79 SPL_AC_SHRINK_ICACHE_MEMORY
81 SPL_AC_CONFIG_KALLSYMS
82 SPL_AC_CONFIG_ZLIB_INFLATE
83 SPL_AC_CONFIG_ZLIB_DEFLATE
84 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
85 SPL_AC_SHRINK_CONTROL_STRUCT
86 SPL_AC_RWSEM_SPINLOCK_IS_RAW
87 SPL_AC_SCHED_RT_HEADER
88 SPL_AC_2ARGS_VFS_GETATTR
90 SPL_AC_KMEM_CACHE_ALLOCFLAGS
94 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
95 modpost=$LINUX/scripts/Makefile.modpost
96 AC_MSG_CHECKING([kernel file name for module symbols])
97 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
98 if grep -q Modules.symvers $modpost; then
99 LINUX_SYMBOLS=Modules.symvers
101 LINUX_SYMBOLS=Module.symvers
104 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
106 *** Please make sure the kernel devel package for your distribution
107 *** is installed. If you are building with a custom kernel, make sure the
108 *** kernel is configured, built, and the '--with-linux=PATH' configure
109 *** option refers to the location of the kernel source.])
114 AC_MSG_RESULT($LINUX_SYMBOLS)
115 AC_SUBST(LINUX_SYMBOLS)
118 AC_DEFUN([SPL_AC_KERNEL], [
120 AS_HELP_STRING([--with-linux=PATH],
121 [Path to kernel source]),
122 [kernelsrc="$withval"])
124 AC_ARG_WITH([linux-obj],
125 AS_HELP_STRING([--with-linux-obj=PATH],
126 [Path to kernel build objects]),
127 [kernelbuild="$withval"])
129 AC_MSG_CHECKING([kernel source directory])
130 if test -z "$kernelsrc"; then
131 if test -e "/lib/modules/$(uname -r)/source"; then
132 headersdir="/lib/modules/$(uname -r)/source"
133 sourcelink=$(readlink -f "$headersdir")
134 elif test -e "/lib/modules/$(uname -r)/build"; then
135 headersdir="/lib/modules/$(uname -r)/build"
136 sourcelink=$(readlink -f "$headersdir")
138 sourcelink=$(ls -1d /usr/src/kernels/* \
140 2>/dev/null | grep -v obj | tail -1)
143 if test -n "$sourcelink" && test -e ${sourcelink}; then
144 kernelsrc=`readlink -f ${sourcelink}`
146 kernelsrc="[Not found]"
149 if test "$kernelsrc" = "NONE"; then
154 AC_MSG_RESULT([$kernelsrc])
155 if test ! -d "$kernelsrc"; then
157 *** Please make sure the kernel devel package for your distribution
158 *** is installed and then try again. If that fails, you can specify the
159 *** location of the kernel source with the '--with-linux=PATH' option.])
162 AC_MSG_CHECKING([kernel build directory])
163 if test -z "$kernelbuild"; then
164 if test -e "/lib/modules/$(uname -r)/build"; then
165 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
166 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
167 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
168 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
169 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
170 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
171 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
173 kernelbuild=${kernelsrc}
176 AC_MSG_RESULT([$kernelbuild])
178 AC_MSG_CHECKING([kernel source version])
179 utsrelease1=$kernelbuild/include/linux/version.h
180 utsrelease2=$kernelbuild/include/linux/utsrelease.h
181 utsrelease3=$kernelbuild/include/generated/utsrelease.h
182 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
183 utsrelease=linux/version.h
184 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
185 utsrelease=linux/utsrelease.h
186 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
187 utsrelease=generated/utsrelease.h
190 if test "$utsrelease"; then
191 kernsrcver=`(echo "#include <$utsrelease>";
192 echo "kernsrcver=UTS_RELEASE") |
193 cpp -I $kernelbuild/include |
194 grep "^kernsrcver=" | cut -d \" -f 2`
196 if test -z "$kernsrcver"; then
197 AC_MSG_RESULT([Not found])
198 AC_MSG_ERROR([*** Cannot determine kernel version.])
201 AC_MSG_RESULT([Not found])
202 if test "x$enable_linux_builtin" != xyes; then
203 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
206 *** Cannot find UTS_RELEASE definition.
207 *** Please run 'make prepare' inside the kernel source tree.])
211 AC_MSG_RESULT([$kernsrcver])
214 LINUX_OBJ=${kernelbuild}
215 LINUX_VERSION=${kernsrcver}
219 AC_SUBST(LINUX_VERSION)
221 SPL_AC_MODULE_SYMVERS
225 dnl # Default SPL user configuration
227 AC_DEFUN([SPL_AC_CONFIG_USER], [])
230 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
231 dnl # are missing, it is non-fatal, but you will not be able to build
232 dnl # RPM packages and will be warned if you try too.
234 dnl # By default, the generic spec file will be used because it requires
235 dnl # minimal dependencies. Distribution specific spec files can be
236 dnl # placed under the 'rpm/<distribution>' directory and enabled using
237 dnl # the --with-spec=<distribution> configure option.
239 AC_DEFUN([SPL_AC_RPM], [
243 AC_MSG_CHECKING([whether $RPM is available])
244 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
245 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
247 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
250 AC_MSG_RESULT([$HAVE_RPM])
253 AC_MSG_CHECKING([whether $RPMBUILD is available])
254 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
255 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
257 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
260 AC_MSG_RESULT([$HAVE_RPMBUILD])
263 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
265 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
268 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
273 RPM_SPEC_DIR="rpm/generic"
275 AS_HELP_STRING([--with-spec=SPEC],
276 [Spec files 'generic|fedora']),
277 [RPM_SPEC_DIR="rpm/$withval"])
279 AC_MSG_CHECKING([whether spec files are available])
280 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
284 AC_SUBST(RPM_VERSION)
286 AC_SUBST(HAVE_RPMBUILD)
288 AC_SUBST(RPMBUILD_VERSION)
290 AC_SUBST(RPM_SPEC_DIR)
291 AC_SUBST(RPM_DEFINE_UTIL)
292 AC_SUBST(RPM_DEFINE_KMOD)
293 AC_SUBST(RPM_DEFINE_DKMS)
294 AC_SUBST(RPM_DEFINE_COMMON)
295 AC_SUBST(SRPM_DEFINE_UTIL)
296 AC_SUBST(SRPM_DEFINE_KMOD)
297 AC_SUBST(SRPM_DEFINE_DKMS)
298 AC_SUBST(SRPM_DEFINE_COMMON)
302 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
303 dnl # tools are missing it is non-fatal but you will not be able to build
304 dnl # DEB packages and will be warned if you try too.
306 AC_DEFUN([SPL_AC_DPKG], [
308 DPKGBUILD=dpkg-buildpackage
310 AC_MSG_CHECKING([whether $DPKG is available])
311 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
312 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
314 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
317 AC_MSG_RESULT([$HAVE_DPKG])
320 AC_MSG_CHECKING([whether $DPKGBUILD is available])
321 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
322 DPKGBUILD_VERSION=$(echo $tmp | \
323 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
325 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
328 AC_MSG_RESULT([$HAVE_DPKGBUILD])
333 AC_SUBST(DPKG_VERSION)
335 AC_SUBST(HAVE_DPKGBUILD)
337 AC_SUBST(DPKGBUILD_VERSION)
341 dnl # Until native packaging for various different packing systems
342 dnl # can be added the least we can do is attempt to use alien to
343 dnl # convert the RPM packages to the needed package type. This is
344 dnl # a hack but so far it has worked reasonable well.
346 AC_DEFUN([SPL_AC_ALIEN], [
349 AC_MSG_CHECKING([whether $ALIEN is available])
350 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
351 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
353 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
356 AC_MSG_RESULT([$HAVE_ALIEN])
361 AC_SUBST(ALIEN_VERSION)
365 dnl # Using the VENDOR tag from config.guess set the default
366 dnl # package type for 'make pkg': (rpm | deb | tgz)
368 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
369 AC_MSG_CHECKING([linux distribution])
370 if test -f /etc/toss-release ; then
372 elif test -f /etc/fedora-release ; then
374 elif test -f /etc/redhat-release ; then
376 elif test -f /etc/gentoo-release ; then
378 elif test -f /etc/arch-release ; then
380 elif test -f /etc/SuSE-release ; then
382 elif test -f /etc/slackware-version ; then
384 elif test -f /etc/lunar.release ; then
386 elif test -f /etc/lsb-release ; then
388 elif test -f /etc/debian_version ; then
393 AC_MSG_RESULT([$VENDOR])
396 AC_MSG_CHECKING([default package type])
398 toss) DEFAULT_PACKAGE=rpm ;;
399 redhat) DEFAULT_PACKAGE=rpm ;;
400 fedora) DEFAULT_PACKAGE=rpm ;;
401 gentoo) DEFAULT_PACKAGE=tgz ;;
402 arch) DEFAULT_PACKAGE=tgz ;;
403 sles) DEFAULT_PACKAGE=rpm ;;
404 slackware) DEFAULT_PACKAGE=tgz ;;
405 lunar) DEFAULT_PACKAGE=tgz ;;
406 ubuntu) DEFAULT_PACKAGE=deb ;;
407 debian) DEFAULT_PACKAGE=deb ;;
408 *) DEFAULT_PACKAGE=rpm ;;
411 AC_MSG_RESULT([$DEFAULT_PACKAGE])
412 AC_SUBST(DEFAULT_PACKAGE)
416 dnl # Default SPL user configuration
418 AC_DEFUN([SPL_AC_PACKAGE], [
419 SPL_AC_DEFAULT_PACKAGE
425 AC_DEFUN([SPL_AC_LICENSE], [
426 AC_MSG_CHECKING([spl author])
427 AC_MSG_RESULT([$SPL_META_AUTHOR])
429 AC_MSG_CHECKING([spl license])
430 AC_MSG_RESULT([$SPL_META_LICENSE])
433 AC_DEFUN([SPL_AC_CONFIG], [
435 AC_ARG_WITH([config],
436 AS_HELP_STRING([--with-config=CONFIG],
437 [Config file 'kernel|user|all|srpm']),
438 [SPL_CONFIG="$withval"])
439 AC_ARG_ENABLE([linux-builtin],
440 [AC_HELP_STRING([--enable-linux-builtin],
441 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
443 [enable_linux_builtin=no])
445 AC_MSG_CHECKING([spl config])
446 AC_MSG_RESULT([$SPL_CONFIG]);
449 case "$SPL_CONFIG" in
450 kernel) SPL_AC_CONFIG_KERNEL ;;
451 user) SPL_AC_CONFIG_USER ;;
452 all) SPL_AC_CONFIG_KERNEL
453 SPL_AC_CONFIG_USER ;;
456 AC_MSG_RESULT([Error!])
457 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
458 user kernel|user|all|srpm]) ;;
461 AM_CONDITIONAL([CONFIG_USER],
462 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
463 AM_CONDITIONAL([CONFIG_KERNEL],
464 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
465 [test "x$enable_linux_builtin" != xyes ])
469 dnl # Enable if the SPL should be compiled with internal debugging enabled.
470 dnl # By default this support is disabled.
472 AC_DEFUN([SPL_AC_DEBUG], [
473 AC_MSG_CHECKING([whether debugging is enabled])
474 AC_ARG_ENABLE([debug],
475 [AS_HELP_STRING([--enable-debug],
476 [Enable generic debug support @<:@default=no@:>@])],
480 AS_IF([test "x$enable_debug" = xyes],
482 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
483 DEBUG_CFLAGS="-DDEBUG -Werror"
484 DEBUG_SPL="_with_debug"
486 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
487 DEBUG_CFLAGS="-DNDEBUG"
488 DEBUG_SPL="_without_debug"
491 AC_SUBST(DEBUG_CFLAGS)
493 AC_MSG_RESULT([$enable_debug])
497 dnl # Enabled by default it provides a basic debug log infrastructure.
498 dnl # Each subsystem registers itself with a name and logs messages
499 dnl # using predefined types. If the debug mask it set to allow the
500 dnl # message type it will be written to the internal log. The log
501 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
502 dnl # after dumping the log it must be decoded using the spl utility.
504 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
505 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
507 AC_DEFUN([SPL_AC_DEBUG_LOG], [
508 AC_ARG_ENABLE([debug-log],
509 [AS_HELP_STRING([--enable-debug-log],
510 [Enable basic debug logging @<:@default=yes@:>@])],
512 [enable_debug_log=yes])
514 AS_IF([test "x$enable_debug_log" = xyes],
516 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
517 DEBUG_LOG="_with_debug_log"
518 AC_DEFINE([DEBUG_LOG], [1],
519 [Define to 1 to enable basic debug logging])
521 DEBUG_LOG="_without_debug_log"
525 AC_MSG_CHECKING([whether basic debug logging is enabled])
526 AC_MSG_RESULT([$enable_debug_log])
530 dnl # Enabled by default it provides a minimal level of memory tracking.
531 dnl # A total count of bytes allocated is kept for each alloc and free.
532 dnl # Then at module unload time a report to the console will be printed
533 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
534 dnl # and provide an easy way to inspect the kmem based slab.
536 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
537 AC_ARG_ENABLE([debug-kmem],
538 [AS_HELP_STRING([--enable-debug-kmem],
539 [Enable basic kmem accounting @<:@default=yes@:>@])],
541 [enable_debug_kmem=yes])
543 AS_IF([test "x$enable_debug_kmem" = xyes],
545 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
546 DEBUG_KMEM="_with_debug_kmem"
547 AC_DEFINE([DEBUG_KMEM], [1],
548 [Define to 1 to enable basic kmem accounting])
550 DEBUG_KMEM="_without_debug_kmem"
554 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
555 AC_MSG_RESULT([$enable_debug_kmem])
559 dnl # Disabled by default it provides detailed memory tracking. This
560 dnl # feature also requires --enable-debug-kmem to be set. When enabled
561 dnl # not only will total bytes be tracked but also the location of every
562 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
563 dnl # addresses and where they were allocated will be dumped to the console.
564 dnl # Enabling this feature has a significant impact on performance but it
565 dnl # makes finding memory leaks pretty straight forward.
567 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
568 AC_ARG_ENABLE([debug-kmem-tracking],
569 [AS_HELP_STRING([--enable-debug-kmem-tracking],
570 [Enable detailed kmem tracking @<:@default=no@:>@])],
572 [enable_debug_kmem_tracking=no])
574 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
576 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
577 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
578 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
579 [Define to 1 to enable detailed kmem tracking])
581 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
584 AC_SUBST(DEBUG_KMEM_TRACKING)
585 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
586 AC_MSG_RESULT([$enable_debug_kmem_tracking])
590 dnl # SPL_LINUX_CONFTEST
592 AC_DEFUN([SPL_LINUX_CONFTEST], [
593 cat confdefs.h - <<_ACEOF >conftest.c
599 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
601 m4_define([SPL_LANG_PROGRAM], [
606 dnl Do *not* indent the following line: there may be CPP directives.
607 dnl Don't move the `;' right after for the same reason.
615 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
617 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
618 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
619 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
620 echo "obj-m := conftest.o" >build/Makefile
622 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
624 [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])],
626 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
632 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
634 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
635 [SPL_LINUX_COMPILE_IFELSE(
636 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
638 [test -s build/conftest.o],
643 dnl # SPL_CHECK_SYMBOL_EXPORT
644 dnl # check symbol exported or not
646 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
647 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
648 $LINUX_OBJ/Module*.symvers 2>/dev/null
650 if test $rc -ne 0; then
653 grep -q -E "EXPORT_SYMBOL.*($1)" \
654 "$LINUX_OBJ/$file" 2>/dev/null
656 if test $rc -eq 0; then
661 if test $export -eq 0; then :
672 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
673 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
674 dnl # is called if not compiling for builtin
676 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
677 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
678 if test $rc -ne 0; then :
681 if test "x$enable_linux_builtin" != xyes; then
682 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
684 if test $rc -ne 0; then :
693 dnl # SPL_CHECK_SYMBOL_HEADER
694 dnl # check if a symbol prototype is defined in listed headers.
696 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
697 AC_MSG_CHECKING([whether symbol $1 exists in header])
700 grep -q "$2" "$LINUX/$file" 2>/dev/null
702 if test $rc -eq 0; then
707 if test $header -eq 0; then
717 dnl # SPL_CHECK_HEADER
718 dnl # check whether header exists and define HAVE_$2_HEADER
720 AC_DEFUN([SPL_CHECK_HEADER],
721 [AC_MSG_CHECKING([whether header $1 exists])
722 SPL_LINUX_TRY_COMPILE([
727 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
737 dnl # Basic toolchain sanity check. Verify that kernel modules can
738 dnl # be built and which symbols can be used.
740 AC_DEFUN([SPL_AC_TEST_MODULE],
741 [AC_MSG_CHECKING([whether modules can be built])
742 SPL_LINUX_TRY_COMPILE([],[],[
746 if test "x$enable_linux_builtin" != xyes; then
747 AC_MSG_ERROR([*** Unable to build an empty module.])
750 *** Unable to build an empty module.
751 *** Please run 'make scripts' inside the kernel source tree.])
757 #include "$LINUX/include/linux/license.h"
759 return !license_is_gpl_compatible("$SPL_META_LICENSE");
762 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
763 [Define to 1 if GPL-only symbols can be used])
769 dnl # Use the atomic implemenation based on global spinlocks. This
770 dnl # should only be needed by 32-bit kernels which do not provide
771 dnl # the atomic64_* API. It may be optionally enabled as a fallback
772 dnl # if problems are observed with the direct mapping to the native
773 dnl # Linux atomic operations. You may not disable atomic spinlocks
774 dnl # if you kernel does not an atomic64_* API.
776 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
777 AC_ARG_ENABLE([atomic-spinlocks],
778 [AS_HELP_STRING([--enable-atomic-spinlocks],
779 [Atomic types use spinlocks @<:@default=check@:>@])],
781 [enable_atomic_spinlocks=check])
783 SPL_LINUX_TRY_COMPILE([
784 #include <linux/fs.h>
786 atomic64_t *ptr __attribute__ ((unused));
789 AC_DEFINE(HAVE_ATOMIC64_T, 1,
790 [kernel defines atomic64_t])
795 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
796 AS_IF([test "x$have_atomic64_t" = xyes], [
797 enable_atomic_spinlocks=no
799 enable_atomic_spinlocks=yes
803 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
804 AC_DEFINE([ATOMIC_SPINLOCK], [1],
805 [Atomic types use spinlocks])
807 AS_IF([test "x$have_atomic64_t" = xno], [
809 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
813 AC_MSG_CHECKING([whether atomic types use spinlocks])
814 AC_MSG_RESULT([$enable_atomic_spinlocks])
816 AC_MSG_CHECKING([whether kernel defines atomic64_t])
817 AC_MSG_RESULT([$have_atomic64_t])
821 dnl # 2.6.24 API change,
822 dnl # check if atomic64_cmpxchg is defined
824 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
825 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
826 SPL_LINUX_TRY_COMPILE([
827 #include <linux/fs.h>
829 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
832 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
833 [kernel defines atomic64_cmpxchg])
840 dnl # 2.6.24 API change,
841 dnl # check if atomic64_xchg is defined
843 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
844 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
845 SPL_LINUX_TRY_COMPILE([
846 #include <linux/fs.h>
848 atomic64_xchg((atomic64_t *)NULL, 0);
851 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
852 [kernel defines atomic64_xchg])
859 dnl # 2.6.24 API change,
860 dnl # check if uintptr_t typedef is defined
862 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
863 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
864 SPL_LINUX_TRY_COMPILE([
865 #include <linux/types.h>
867 uintptr_t *ptr __attribute__ ((unused));
870 AC_DEFINE(HAVE_UINTPTR_T, 1,
871 [kernel defines uintptr_t])
878 dnl # 2.6.21 API change,
879 dnl # 'register_sysctl_table' use only one argument instead of two
881 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
882 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
883 SPL_LINUX_TRY_COMPILE([
884 #include <linux/sysctl.h>
886 (void) register_sysctl_table(NULL, 0);
889 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
890 [register_sysctl_table() wants 2 args])
896 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
897 tmp_flags="$EXTRA_KCFLAGS"
898 EXTRA_KCFLAGS="-Werror"
900 dnl # 2.6.23 to 2.6.34 API change
901 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
903 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
904 SPL_LINUX_TRY_COMPILE([
905 #include <linux/mm.h>
907 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
909 struct shrinker cache_shrinker = {
910 .shrink = shrinker_cb,
911 .seeks = DEFAULT_SEEKS,
913 register_shrinker(&cache_shrinker);
916 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
917 [old shrinker callback wants 2 args])
921 dnl # 2.6.35 - 2.6.39 API change
922 dnl # ->shrink(struct shrinker *,
923 dnl # int nr_to_scan, gfp_t gfp_mask)
925 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
926 SPL_LINUX_TRY_COMPILE([
927 #include <linux/mm.h>
929 int shrinker_cb(struct shrinker *, int nr_to_scan,
932 struct shrinker cache_shrinker = {
933 .shrink = shrinker_cb,
934 .seeks = DEFAULT_SEEKS,
936 register_shrinker(&cache_shrinker);
939 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
940 [old shrinker callback wants 3 args])
944 dnl # 3.0 - 3.11 API change
945 dnl # ->shrink(struct shrinker *,
946 dnl # struct shrink_control *sc)
949 [whether new 2-argument shrinker exists])
950 SPL_LINUX_TRY_COMPILE([
951 #include <linux/mm.h>
953 int shrinker_cb(struct shrinker *,
954 struct shrink_control *sc);
956 struct shrinker cache_shrinker = {
957 .shrink = shrinker_cb,
958 .seeks = DEFAULT_SEEKS,
960 register_shrinker(&cache_shrinker);
963 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
964 [new shrinker callback wants 2 args])
968 dnl # 3.12 API change,
969 dnl # ->shrink() is logically split in to
970 dnl # ->count_objects() and ->scan_objects()
973 [whether ->count_objects callback exists])
974 SPL_LINUX_TRY_COMPILE([
975 #include <linux/mm.h>
977 unsigned long shrinker_cb(
979 struct shrink_control *sc);
981 struct shrinker cache_shrinker = {
982 .count_objects = shrinker_cb,
983 .scan_objects = shrinker_cb,
984 .seeks = DEFAULT_SEEKS,
986 register_shrinker(&cache_shrinker);
989 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
990 1, [->count_objects exists])
997 EXTRA_KCFLAGS="$tmp_flags"
1001 dnl # Custom SPL patch may export this system it is not required
1003 AC_DEFUN([SPL_AC_TASK_CURR],
1004 [AC_MSG_CHECKING([whether task_curr() is available])
1005 SPL_LINUX_TRY_COMPILE_SYMBOL([
1006 #include <linux/sched.h>
1009 ], [task_curr], [kernel/sched.c], [
1011 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1018 dnl # 2.6.19 API change,
1019 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1021 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1022 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1023 SPL_LINUX_TRY_COMPILE([
1024 #include <linux/sysctl.h>
1026 #ifndef CTL_UNNUMBERED
1027 #error CTL_UNNUMBERED undefined
1031 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1032 [unnumbered sysctl support exists])
1039 dnl # 2.6.33 API change,
1040 dnl # Removed .ctl_name from struct ctl_table.
1042 AC_DEFUN([SPL_AC_CTL_NAME], [
1043 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1044 SPL_LINUX_TRY_COMPILE([
1045 #include <linux/sysctl.h>
1047 struct ctl_table ctl __attribute__ ((unused));
1051 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1058 dnl # 2.6.16 API change.
1059 dnl # Check if 'fls64()' is available
1061 AC_DEFUN([SPL_AC_FLS64],
1062 [AC_MSG_CHECKING([whether fls64() is available])
1063 SPL_LINUX_TRY_COMPILE([
1064 #include <linux/bitops.h>
1069 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1076 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1078 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1079 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1080 SPL_LINUX_TRY_COMPILE_SYMBOL([
1081 #include <linux/time.h>
1083 set_normalized_timespec(NULL, 0, 0);
1084 ], [set_normalized_timespec], [kernel/time.c], [
1086 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1087 [set_normalized_timespec() is available as export])
1094 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1095 dnl # previously it was available in time.h as an inline.
1097 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1098 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1099 SPL_LINUX_TRY_COMPILE([
1100 #include <linux/time.h>
1101 void set_normalized_timespec(struct timespec *ts,
1102 time_t sec, long nsec) { }
1109 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1110 [set_normalized_timespec() is available as inline])
1115 dnl # 2.6.18 API change,
1116 dnl # timespec_sub() inline function available in linux/time.h
1118 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1119 AC_MSG_CHECKING([whether timespec_sub() is available])
1120 SPL_LINUX_TRY_COMPILE([
1121 #include <linux/time.h>
1123 struct timespec a = { 0 };
1124 struct timespec b = { 0 };
1125 struct timespec c __attribute__ ((unused));
1126 c = timespec_sub(a, b);
1129 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1136 dnl # 2.6.19 API change,
1137 dnl # check if init_utsname() is available in linux/utsname.h
1139 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1140 AC_MSG_CHECKING([whether init_utsname() is available])
1141 SPL_LINUX_TRY_COMPILE([
1142 #include <linux/utsname.h>
1144 struct new_utsname *a __attribute__ ((unused));
1148 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1155 dnl # 2.6.18 API change,
1156 dnl # added linux/uaccess.h
1158 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1159 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1163 dnl # 2.6.12 API change,
1164 dnl # check whether 'kmalloc_node()' is available.
1166 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1167 AC_MSG_CHECKING([whether kmalloc_node() is available])
1168 SPL_LINUX_TRY_COMPILE([
1169 #include <linux/slab.h>
1171 void *a __attribute__ ((unused));
1172 a = kmalloc_node(1, GFP_KERNEL, 0);
1175 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1182 dnl # 2.6.9 API change,
1183 dnl # check whether 'monotonic_clock()' is available it may
1184 dnl # be available for some archs but not others.
1186 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1187 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1188 SPL_LINUX_TRY_COMPILE_SYMBOL([
1189 #include <linux/timex.h>
1192 ], [monotonic_clock], [], [
1194 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1195 [monotonic_clock() is available])
1202 dnl # 2.6.16 API change,
1203 dnl # check whether 'struct inode' has i_mutex
1205 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1206 AC_MSG_CHECKING([whether struct inode has i_mutex])
1207 SPL_LINUX_TRY_COMPILE([
1208 #include <linux/fs.h>
1209 #include <linux/mutex.h>
1212 mutex_init(&i.i_mutex);
1215 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1222 dnl # 2.6.29 API change,
1223 dnl # Adaptive mutexs introduced.
1225 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1226 AC_MSG_CHECKING([whether struct mutex has owner])
1227 SPL_LINUX_TRY_COMPILE([
1228 #include <linux/mutex.h>
1230 struct mutex mtx __attribute__ ((unused));
1234 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1241 dnl # 2.6.39 API change,
1242 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1243 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1244 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1245 dnl # pointer which frankly makes a lot more sense.
1247 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1248 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1249 tmp_flags="$EXTRA_KCFLAGS"
1250 EXTRA_KCFLAGS="-Werror"
1251 SPL_LINUX_TRY_COMPILE([
1252 #include <linux/mutex.h>
1253 #include <linux/sched.h>
1255 struct mutex mtx __attribute__ ((unused));
1256 mtx.owner = current;
1259 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1260 [struct mutex owner is a task_struct])
1264 EXTRA_KCFLAGS="$tmp_flags"
1268 dnl # 2.6.18 API change,
1269 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1270 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1271 dnl # if the mutex validator is disabled or otherwise unavailable.
1273 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1274 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1275 SPL_LINUX_TRY_COMPILE([
1276 #include <linux/mutex.h>
1280 mutex_lock_nested(&mutex, 0);
1283 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1284 [mutex_lock_nested() is available])
1291 dnl # 2.6.27 API change,
1292 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1294 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1295 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1296 SPL_LINUX_TRY_COMPILE([
1297 #include <linux/interrupt.h>
1298 #include <linux/smp.h>
1300 void on_each_cpu_func(void *data) { return; }
1302 on_each_cpu(on_each_cpu_func, NULL, 0);
1305 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1306 [on_each_cpu wants 3 args])
1313 dnl # 2.6.18 API change,
1314 dnl # kallsyms_lookup_name no longer exported
1316 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1317 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1318 SPL_LINUX_TRY_COMPILE_SYMBOL([
1319 #include <linux/kallsyms.h>
1321 kallsyms_lookup_name(NULL);
1322 ], [kallsyms_lookup_name], [], [
1324 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1325 [kallsyms_lookup_name() is available])
1332 dnl # Proposed API change,
1333 dnl # This symbol is not available in stock kernels. You may build a
1334 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1335 dnl # these symbols for use. If your already rolling a custom kernel for
1336 dnl # your environment this is recommended.
1338 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1339 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1340 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1342 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1343 [get_vmalloc_info() is available])
1350 dnl # 3.10 API change,
1351 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1353 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1354 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1355 SPL_LINUX_TRY_COMPILE([
1356 #include <linux/vmalloc.h>
1357 struct vmalloc_info { void *a; };
1364 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1369 dnl # 3.10 API change,
1370 dnl # PDE is replaced by PDE_DATA
1372 AC_DEFUN([SPL_AC_PDE_DATA], [
1373 AC_MSG_CHECKING([whether PDE_DATA() is available])
1374 SPL_LINUX_TRY_COMPILE_SYMBOL([
1375 #include <linux/proc_fs.h>
1378 ], [PDE_DATA], [], [
1380 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1387 dnl # 2.6.17 API change
1388 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1389 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1390 dnl # were exported in 2.6.17 for use by modules which was consistent with
1391 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1392 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1393 dnl # were dropped entirely leaving modules no way to directly iterate over
1394 dnl # the zone list. Because we need access to the zone helpers we check
1395 dnl # if the kernel contains the old or new implementation. Then we check
1396 dnl # to see if the symbols we need for each version are available. If they
1397 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1399 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1400 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1401 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1403 if test $rc -eq 0; then
1404 AC_MSG_RESULT([yes])
1405 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1412 dnl # Proposed API change,
1413 dnl # This symbol is not available in stock kernels. You may build a
1414 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1415 dnl # these symbols for use. If your already rolling a custom kernel for
1416 dnl # your environment this is recommended.
1418 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1419 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1420 SPL_LINUX_TRY_COMPILE_SYMBOL([
1421 #include <linux/mmzone.h>
1423 first_online_pgdat();
1424 ], [first_online_pgdat], [], [
1426 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1427 [first_online_pgdat() is available])
1434 dnl # Proposed API change,
1435 dnl # This symbol is not available in stock kernels. You may build a
1436 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1437 dnl # these symbols for use. If your already rolling a custom kernel for
1438 dnl # your environment this is recommended.
1440 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1441 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1442 SPL_LINUX_TRY_COMPILE_SYMBOL([
1443 #include <linux/mmzone.h>
1445 next_online_pgdat(NULL);
1446 ], [next_online_pgdat], [], [
1448 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1449 [next_online_pgdat() is available])
1456 dnl # Proposed API change,
1457 dnl # This symbol is not available in stock kernels. You may build a
1458 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1459 dnl # these symbols for use. If your already rolling a custom kernel for
1460 dnl # your environment this is recommended.
1462 AC_DEFUN([SPL_AC_NEXT_ZONE],
1463 [AC_MSG_CHECKING([whether next_zone() is available])
1464 SPL_LINUX_TRY_COMPILE_SYMBOL([
1465 #include <linux/mmzone.h>
1468 ], [next_zone], [], [
1470 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1477 dnl # 2.6.17 API change,
1478 dnl # See SPL_AC_PGDAT_HELPERS for details.
1480 AC_DEFUN([SPL_AC_PGDAT_LIST],
1481 [AC_MSG_CHECKING([whether pgdat_list is available])
1482 SPL_LINUX_TRY_COMPILE_SYMBOL([
1483 #include <linux/topology.h>
1484 pg_data_t *tmp = pgdat_list;
1485 ], [], [pgdat_list], [], [
1487 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1494 dnl # 2.6.18 API change,
1495 dnl # First introduced global_page_state() support as an inline.
1497 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1498 AC_MSG_CHECKING([whether global_page_state() is available])
1499 SPL_LINUX_TRY_COMPILE([
1500 #include <linux/mm.h>
1502 unsigned long state __attribute__ ((unused));
1503 state = global_page_state(0);
1506 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1507 [global_page_state() is available])
1514 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1515 dnl # Public global zone stats now include a free page count. However
1516 dnl # the enumerated names of the counters have changed since this API
1517 dnl # was introduced. We need to deduce the corrent name to use. This
1518 dnl # replaces the priviate get_zone_counts() interface.
1520 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1521 dnl # is 2.6.30 as of when this was written.
1523 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1524 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1525 SPL_LINUX_TRY_COMPILE([
1526 #include <linux/mm.h>
1528 enum zone_stat_item zsi __attribute__ ((unused));
1529 zsi = NR_FREE_PAGES;
1532 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1533 [Page state NR_FREE_PAGES is available])
1540 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1541 dnl # Public global zone stats now include an inactive page count. However
1542 dnl # the enumerated names of the counters have changed since this API
1543 dnl # was introduced. We need to deduce the corrent name to use. This
1544 dnl # replaces the priviate get_zone_counts() interface.
1546 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1547 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1548 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1550 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1551 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1552 SPL_LINUX_TRY_COMPILE([
1553 #include <linux/mm.h>
1555 enum zone_stat_item zsi __attribute__ ((unused));
1559 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1560 [Page state NR_INACTIVE is available])
1565 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1566 SPL_LINUX_TRY_COMPILE([
1567 #include <linux/mm.h>
1569 enum zone_stat_item zsi __attribute__ ((unused));
1570 zsi = NR_INACTIVE_ANON;
1573 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1574 [Page state NR_INACTIVE_ANON is available])
1579 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1580 SPL_LINUX_TRY_COMPILE([
1581 #include <linux/mm.h>
1583 enum zone_stat_item zsi __attribute__ ((unused));
1584 zsi = NR_INACTIVE_FILE;
1587 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1588 [Page state NR_INACTIVE_FILE is available])
1595 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1596 dnl # Public global zone stats now include an active page count. However
1597 dnl # the enumerated names of the counters have changed since this API
1598 dnl # was introduced. We need to deduce the corrent name to use. This
1599 dnl # replaces the priviate get_zone_counts() interface.
1601 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1602 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1603 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1605 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1606 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1607 SPL_LINUX_TRY_COMPILE([
1608 #include <linux/mm.h>
1610 enum zone_stat_item zsi __attribute__ ((unused));
1614 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1615 [Page state NR_ACTIVE is available])
1620 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1621 SPL_LINUX_TRY_COMPILE([
1622 #include <linux/mm.h>
1624 enum zone_stat_item zsi __attribute__ ((unused));
1625 zsi = NR_ACTIVE_ANON;
1628 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1629 [Page state NR_ACTIVE_ANON is available])
1634 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1635 SPL_LINUX_TRY_COMPILE([
1636 #include <linux/mm.h>
1638 enum zone_stat_item zsi __attribute__ ((unused));
1639 zsi = NR_ACTIVE_FILE;
1642 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1643 [Page state NR_ACTIVE_FILE is available])
1650 dnl # Proposed API change for legacy kernels.
1651 dnl # This symbol is not available in older kernels. For kernels post
1652 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1653 dnl # page state information. This symbol is only used in legacy kernels
1654 dnl # any only as a last resort.
1656 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1657 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1658 SPL_LINUX_TRY_COMPILE([
1660 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1661 #error "global_page_state needs NR_FREE_PAGES"
1664 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1665 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1666 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1667 #error "global_page_state needs NR_ACTIVE*"
1670 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1671 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1672 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1673 #error "global_page_state needs NR_INACTIVE*"
1679 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1680 [get_zone_counts() is needed])
1682 AC_MSG_CHECKING([whether get_zone_counts() is available])
1683 SPL_LINUX_TRY_COMPILE_SYMBOL([
1684 #include <linux/mmzone.h>
1686 get_zone_counts(NULL, NULL, NULL);
1687 ], [get_zone_counts], [], [
1689 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1690 [get_zone_counts() is available])
1698 dnl # 2.6.27 API change,
1699 dnl # The user_path_dir() replaces __user_walk()
1701 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1702 [AC_MSG_CHECKING([whether user_path_dir() is available])
1703 SPL_LINUX_TRY_COMPILE_SYMBOL([
1704 #include <linux/fcntl.h>
1705 #include <linux/namei.h>
1707 user_path_dir(NULL, NULL);
1708 ], [user_path_at], [], [
1710 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1717 dnl # Symbol available in RHEL kernels not in stock kernels.
1719 AC_DEFUN([SPL_AC_SET_FS_PWD],
1720 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1721 SPL_LINUX_TRY_COMPILE_SYMBOL([
1722 #include <linux/spinlock.h>
1723 #include <linux/fs_struct.h>
1726 ], [set_fs_pwd], [], [
1728 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1735 dnl # 3.9 API change
1736 dnl # set_fs_pwd takes const struct path *
1738 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1739 tmp_flags="$EXTRA_KCFLAGS"
1740 EXTRA_KCFLAGS="-Werror"
1741 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1742 SPL_LINUX_TRY_COMPILE([
1743 #include <linux/spinlock.h>
1744 #include <linux/fs_struct.h>
1745 #include <linux/path.h>
1746 void (*const set_fs_pwd_func)
1747 (struct fs_struct *, const struct path *)
1753 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1754 [set_fs_pwd() needs const path *])
1756 SPL_LINUX_TRY_COMPILE([
1757 #include <linux/spinlock.h>
1758 #include <linux/fs_struct.h>
1759 #include <linux/path.h>
1760 void (*const set_fs_pwd_func)
1761 (struct fs_struct *, struct path *)
1768 AC_MSG_ERROR(unknown)
1771 EXTRA_KCFLAGS="$tmp_flags"
1774 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1775 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1776 SPL_LINUX_TRY_COMPILE([
1777 #include <linux/fs.h>
1779 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1782 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1783 [vfs_unlink() wants 2 args])
1787 dnl # Linux 3.13 API change
1788 dnl # Added delegated inode
1790 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1791 SPL_LINUX_TRY_COMPILE([
1792 #include <linux/fs.h>
1794 vfs_unlink((struct inode *) NULL,
1795 (struct dentry *) NULL,
1796 (struct inode **) NULL);
1799 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1800 [vfs_unlink() wants 3 args])
1808 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1809 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1810 SPL_LINUX_TRY_COMPILE([
1811 #include <linux/fs.h>
1813 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1814 (struct inode *) NULL, (struct dentry *) NULL);
1817 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1818 [vfs_rename() wants 4 args])
1822 dnl # Linux 3.13 API change
1823 dnl # Added delegated inode
1825 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1826 SPL_LINUX_TRY_COMPILE([
1827 #include <linux/fs.h>
1829 vfs_rename((struct inode *) NULL,
1830 (struct dentry *) NULL,
1831 (struct inode *) NULL,
1832 (struct dentry *) NULL,
1833 (struct inode **) NULL);
1836 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1837 [vfs_rename() wants 5 args])
1841 dnl # Linux 3.15 API change
1844 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1845 SPL_LINUX_TRY_COMPILE([
1846 #include <linux/fs.h>
1848 vfs_rename((struct inode *) NULL,
1849 (struct dentry *) NULL,
1850 (struct inode *) NULL,
1851 (struct dentry *) NULL,
1852 (struct inode **) NULL,
1856 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1857 [vfs_rename() wants 6 args])
1866 dnl # 2.6.36 API change,
1867 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1868 dnl # a spinlock_t to improve the fastpath performance.
1870 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1871 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1872 tmp_flags="$EXTRA_KCFLAGS"
1873 EXTRA_KCFLAGS="-Werror"
1874 SPL_LINUX_TRY_COMPILE([
1875 #include <linux/sched.h>
1876 #include <linux/fs_struct.h>
1878 struct fs_struct fs;
1879 spin_lock_init(&fs.lock);
1882 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1883 [struct fs_struct uses spinlock_t])
1887 EXTRA_KCFLAGS="$tmp_flags"
1891 dnl # 2.6.29 API change,
1892 dnl # check whether 'struct cred' exists
1894 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1895 AC_MSG_CHECKING([whether struct cred exists])
1896 SPL_LINUX_TRY_COMPILE([
1897 #include <linux/cred.h>
1899 struct cred *cr __attribute__ ((unused));
1903 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1911 dnl # User namespaces, use kuid_t in place of uid_t
1912 dnl # where available. Not strictly a user namespaces thing
1913 dnl # but it should prevent surprises
1915 AC_DEFUN([SPL_AC_KUIDGID_T], [
1916 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1917 SPL_LINUX_TRY_COMPILE([
1918 #include <linux/uidgid.h>
1920 kuid_t userid = KUIDT_INIT(0);
1921 kgid_t groupid = KGIDT_INIT(0);
1923 SPL_LINUX_TRY_COMPILE([
1924 #include <linux/uidgid.h>
1929 AC_MSG_RESULT(yes; optional)
1931 AC_MSG_RESULT(yes; mandatory)
1932 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1940 dnl # Custom SPL patch may export this symbol.
1942 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1943 [AC_MSG_CHECKING([whether groups_search() is available])
1944 SPL_LINUX_TRY_COMPILE_SYMBOL([
1945 #include <linux/cred.h>
1946 #ifdef HAVE_KUIDGID_T
1947 #include <linux/uidgid.h>
1950 #ifdef HAVE_KUIDGID_T
1951 groups_search(NULL, KGIDT_INIT(0));
1953 groups_search(NULL, 0);
1955 ], [groups_search], [], [
1957 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1964 dnl # 2.6.x API change,
1965 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1967 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1968 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1969 SPL_LINUX_TRY_COMPILE_SYMBOL([
1970 #include <linux/sched.h>
1972 __put_task_struct(NULL);
1973 ], [__put_task_struct], [], [
1975 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1976 [__put_task_struct() is available])
1983 dnl # 2.6.32 API change,
1984 dnl # Unused 'struct file *' removed from prototype.
1986 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1987 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1988 SPL_LINUX_TRY_COMPILE([
1989 #include <linux/sysctl.h>
1991 proc_dostring(NULL, 0, NULL, NULL, NULL);
1994 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1995 [proc_handler() wants 5 args])
2002 dnl # 2.6.x API change,
2003 dnl # kvasprintf() function added.
2005 AC_DEFUN([SPL_AC_KVASPRINTF],
2006 [AC_MSG_CHECKING([whether kvasprintf() is available])
2007 SPL_LINUX_TRY_COMPILE_SYMBOL([
2008 #include <linux/kernel.h>
2010 kvasprintf(0, NULL, *((va_list*)NULL));
2011 ], [kvasprintf], [], [
2013 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
2020 dnl # 2.6.29 API change,
2021 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
2023 AC_DEFUN([SPL_AC_VFS_FSYNC],
2024 [AC_MSG_CHECKING([whether vfs_fsync() is available])
2025 SPL_LINUX_TRY_COMPILE_SYMBOL([
2026 #include <linux/fs.h>
2029 ], [vfs_fsync], [fs/sync.c], [
2031 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2038 dnl # 2.6.35 API change,
2039 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2041 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2042 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2043 SPL_LINUX_TRY_COMPILE([
2044 #include <linux/fs.h>
2049 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2056 dnl # 3.5 API change,
2057 dnl # inode_operations.truncate_range removed
2059 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2060 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2061 SPL_LINUX_TRY_COMPILE([
2062 #include <linux/fs.h>
2064 struct inode_operations ops;
2065 ops.truncate_range = NULL;
2068 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2069 [truncate_range() inode operation is available])
2076 dnl # Linux 2.6.38 - 3.x API
2078 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2079 AC_MSG_CHECKING([whether fops->fallocate() exists])
2080 SPL_LINUX_TRY_COMPILE([
2081 #include <linux/fs.h>
2083 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2084 struct file_operations fops __attribute__ ((unused)) = {
2085 .fallocate = fallocate,
2089 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2096 dnl # Linux 2.6.x - 2.6.37 API
2098 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2099 AC_MSG_CHECKING([whether iops->fallocate() exists])
2100 SPL_LINUX_TRY_COMPILE([
2101 #include <linux/fs.h>
2103 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2104 struct inode_operations fops __attribute__ ((unused)) = {
2105 .fallocate = fallocate,
2109 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2116 dnl # PaX Linux 2.6.38 - 3.x API
2118 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2119 AC_MSG_CHECKING([whether fops->fallocate() exists])
2120 SPL_LINUX_TRY_COMPILE([
2121 #include <linux/fs.h>
2123 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2124 struct file_operations_no_const fops __attribute__ ((unused)) = {
2125 .fallocate = fallocate,
2129 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2136 dnl # The fallocate callback was moved from the inode_operations
2137 dnl # structure to the file_operations structure.
2139 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2140 SPL_AC_KERNEL_FILE_FALLOCATE
2141 SPL_AC_KERNEL_INODE_FALLOCATE
2142 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2146 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2147 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2148 dnl # condition. The fixed version is exported as a symbol. The race
2149 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2150 dnl # call that version while holding sem->wait_lock.
2152 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2153 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2154 SPL_LINUX_TRY_COMPILE_SYMBOL([
2155 #include <linux/rwsem.h>
2156 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2157 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2159 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2160 [rwsem_is_locked() acquires sem->wait_lock])
2167 dnl # 2.6.xx API compat,
2168 dnl # There currently exists no exposed API to partially shrink the dcache.
2169 dnl # The expected mechanism to shrink the cache is a registered shrinker
2170 dnl # which is called during memory pressure.
2172 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2173 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2174 SPL_LINUX_TRY_COMPILE_SYMBOL([
2175 #include <linux/dcache.h>
2177 shrink_dcache_memory(0, 0);
2178 ], [shrink_dcache_memory], [fs/dcache.c], [
2180 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2181 [shrink_dcache_memory() is available])
2188 dnl # 2.6.xx API compat,
2189 dnl # There currently exists no exposed API to partially shrink the icache.
2190 dnl # The expected mechanism to shrink the cache is a registered shrinker
2191 dnl # which is called during memory pressure.
2193 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2194 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2195 SPL_LINUX_TRY_COMPILE_SYMBOL([
2196 #include <linux/dcache.h>
2198 shrink_icache_memory(0, 0);
2199 ], [shrink_icache_memory], [fs/inode.c], [
2201 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2202 [shrink_icache_memory() is available])
2209 dnl # 2.6.28 API change
2210 dnl # The kern_path() function has been introduced. We adopt it as the new way
2211 dnl # of looking up paths. When it is not available, we emulate it using the
2212 dnl # older interfaces.
2214 AC_DEFUN([SPL_AC_KERN_PATH],
2215 [AC_MSG_CHECKING([whether kern_path() is available])
2216 SPL_LINUX_TRY_COMPILE_SYMBOL([
2217 #include <linux/namei.h>
2219 int r = kern_path(NULL, 0, NULL);
2220 ], [kern_path], [fs/namei.c], [
2222 AC_DEFINE(HAVE_KERN_PATH, 1,
2223 [kern_path() is available])
2226 AC_MSG_CHECKING([whether path_lookup() is available])
2227 SPL_LINUX_TRY_COMPILE_SYMBOL([
2228 #include <linux/namei.h>
2230 int r = path_lookup(NULL, 0, NULL);
2231 ], [path_lookup], [fs/namei.c], [
2233 AC_DEFINE(HAVE_KERN_PATH, 1,
2234 [kern_path() is available])
2238 *** Neither kern_path() nor path_lookup() is available.
2239 *** Please file an issue:
2240 *** https://github.com/zfsonlinux/spl/issues/new])
2247 dnl # /proc/kallsyms support,
2248 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2250 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2251 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2252 SPL_LINUX_TRY_COMPILE([
2253 #if !defined(CONFIG_KALLSYMS)
2254 #error CONFIG_KALLSYMS not defined
2257 AC_MSG_RESULT([yes])
2261 *** This kernel does not include the required kallsyms support.
2262 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2267 dnl # zlib inflate compat,
2268 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2270 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2271 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2272 SPL_LINUX_TRY_COMPILE([
2273 #if !defined(CONFIG_ZLIB_INFLATE) && \
2274 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2275 #error CONFIG_ZLIB_INFLATE not defined
2278 AC_MSG_RESULT([yes])
2282 *** This kernel does not include the required zlib inflate support.
2283 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2288 dnl # zlib deflate compat,
2289 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2291 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2292 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2293 SPL_LINUX_TRY_COMPILE([
2294 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2295 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2296 #error CONFIG_ZLIB_DEFLATE not defined
2299 AC_MSG_RESULT([yes])
2303 *** This kernel does not include the required zlib deflate support.
2304 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2309 dnl # 2.6.39 API compat,
2310 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2311 dnl # This was done to avoid always having to allocate the maximum size
2312 dnl # workspace (268K). The caller can now specific the windowBits and
2313 dnl # memLevel compression parameters to get a smaller workspace.
2315 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2316 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2317 SPL_LINUX_TRY_COMPILE([
2318 #include <linux/zlib.h>
2320 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2323 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2324 [zlib_deflate_workspacesize() wants 2 args])
2331 dnl # 2.6.39 API change,
2332 dnl # Shrinker adjust to use common shrink_control structure.
2334 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2335 AC_MSG_CHECKING([whether struct shrink_control exists])
2336 SPL_LINUX_TRY_COMPILE([
2337 #include <linux/mm.h>
2339 struct shrink_control sc __attribute__ ((unused));
2342 sc.gfp_mask = GFP_KERNEL;
2345 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2346 [struct shrink_control exists])
2353 dnl # 3.1 API Change
2355 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2356 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2358 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2359 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2360 tmp_flags="$EXTRA_KCFLAGS"
2361 EXTRA_KCFLAGS="-Werror"
2362 SPL_LINUX_TRY_COMPILE([
2363 #include <linux/rwsem.h>
2365 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2366 raw_spinlock_t dummy_lock __attribute__ ((unused));
2367 dummy_semaphore.wait_lock = dummy_lock;
2370 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2371 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2375 EXTRA_KCFLAGS="$tmp_flags"
2379 dnl # 3.9 API change,
2380 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2382 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2383 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2384 SPL_LINUX_TRY_COMPILE([
2385 #include <linux/sched.h>
2386 #include <linux/sched/rt.h>
2390 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2398 dnl # 3.9 API change,
2399 dnl # vfs_getattr() uses 2 args
2400 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2402 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2403 AC_MSG_CHECKING([whether vfs_getattr() wants])
2404 SPL_LINUX_TRY_COMPILE([
2405 #include <linux/fs.h>
2407 vfs_getattr((struct path *) NULL,
2408 (struct kstat *)NULL);
2410 AC_MSG_RESULT(2 args)
2411 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2412 [vfs_getattr wants 2 args])
2414 SPL_LINUX_TRY_COMPILE([
2415 #include <linux/fs.h>
2417 vfs_getattr((struct vfsmount *)NULL,
2418 (struct dentry *)NULL,
2419 (struct kstat *)NULL);
2421 AC_MSG_RESULT(3 args)
2423 AC_MSG_ERROR(unknown)
2429 dnl # 2.6.36 API compatibility.
2430 dnl # Added usleep_range timer.
2431 dnl # usleep_range is a finer precision implementation of msleep
2432 dnl # designed to be a drop-in replacement for udelay where a precise
2433 dnl # sleep / busy-wait is unnecessary.
2435 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2436 AC_MSG_CHECKING([whether usleep_range() is available])
2437 SPL_LINUX_TRY_COMPILE([
2438 #include <linux/delay.h>
2443 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2444 [usleep_range is available])
2451 dnl # 2.6.35 API change,
2452 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2453 dnl # private allocation flags which are applied when allocating a new slab
2454 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2455 dnl # non-default flags.
2457 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2458 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2459 SPL_LINUX_TRY_COMPILE([
2460 #include <linux/slab.h>
2462 struct kmem_cache cachep __attribute__ ((unused));
2463 cachep.allocflags = GFP_KERNEL;
2466 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2467 [struct kmem_cache has allocflags])
2471 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2472 SPL_LINUX_TRY_COMPILE([
2473 #include <linux/slab.h>
2475 struct kmem_cache cachep __attribute__ ((unused));
2476 cachep.gfpflags = GFP_KERNEL;
2479 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2480 [struct kmem_cache has gfpflags])
2488 dnl # 3.17 API change,
2489 dnl # wait_on_bit() no longer requires an action argument. The former
2490 dnl # "wait_on_bit" interface required an 'action' function to be provided
2491 dnl # which does the actual waiting. There were over 20 such functions in the
2492 dnl # kernel, many of them identical, though most cases can be satisfied by one
2493 dnl # of just two functions: one which uses io_schedule() and one which just
2494 dnl # uses schedule(). This API change was made to consolidate all of those
2495 dnl # redundant wait functions.
2497 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2498 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2499 SPL_LINUX_TRY_COMPILE([
2500 #include <linux/wait.h>
2502 int (*action)(void *) = NULL;
2503 wait_on_bit(NULL, 0, action, 0);
2506 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])