1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_SHRINKER_CALLBACK
34 SPL_AC_MUTEX_OWNER_TASK_STRUCT
35 SPL_AC_MUTEX_LOCK_NESTED
36 SPL_AC_3ARGS_ON_EACH_CPU
37 SPL_AC_KALLSYMS_LOOKUP_NAME
38 SPL_AC_GET_VMALLOC_INFO
40 SPL_AC_FIRST_ONLINE_PGDAT
41 SPL_AC_NEXT_ONLINE_PGDAT
44 SPL_AC_GLOBAL_PAGE_STATE
45 SPL_AC_ZONE_STAT_ITEM_FREE
46 SPL_AC_ZONE_STAT_ITEM_INACTIVE
47 SPL_AC_ZONE_STAT_ITEM_ACTIVE
48 SPL_AC_GET_ZONE_COUNTS
51 SPL_AC_SET_FS_PWD_WITH_CONST
52 SPL_AC_2ARGS_VFS_UNLINK
53 SPL_AC_4ARGS_VFS_RENAME
55 SPL_AC_2ARGS_VFS_FSYNC
56 SPL_AC_INODE_TRUNCATE_RANGE
57 SPL_AC_FS_STRUCT_SPINLOCK
61 SPL_AC_PUT_TASK_STRUCT
62 SPL_AC_5ARGS_PROC_HANDLER
64 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
65 SPL_AC_KERNEL_FALLOCATE
66 SPL_AC_SHRINK_DCACHE_MEMORY
67 SPL_AC_SHRINK_ICACHE_MEMORY
69 SPL_AC_CONFIG_KALLSYMS
70 SPL_AC_CONFIG_ZLIB_INFLATE
71 SPL_AC_CONFIG_ZLIB_DEFLATE
72 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
73 SPL_AC_SHRINK_CONTROL_STRUCT
74 SPL_AC_RWSEM_SPINLOCK_IS_RAW
75 SPL_AC_SCHED_RT_HEADER
76 SPL_AC_2ARGS_VFS_GETATTR
78 SPL_AC_KMEM_CACHE_ALLOCFLAGS
82 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
83 modpost=$LINUX/scripts/Makefile.modpost
84 AC_MSG_CHECKING([kernel file name for module symbols])
85 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
86 if grep -q Modules.symvers $modpost; then
87 LINUX_SYMBOLS=Modules.symvers
89 LINUX_SYMBOLS=Module.symvers
92 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
94 *** Please make sure the kernel devel package for your distribution
95 *** is installed. If you are building with a custom kernel, make sure the
96 *** kernel is configured, built, and the '--with-linux=PATH' configure
97 *** option refers to the location of the kernel source.])
102 AC_MSG_RESULT($LINUX_SYMBOLS)
103 AC_SUBST(LINUX_SYMBOLS)
106 AC_DEFUN([SPL_AC_KERNEL], [
108 AS_HELP_STRING([--with-linux=PATH],
109 [Path to kernel source]),
110 [kernelsrc="$withval"])
112 AC_ARG_WITH([linux-obj],
113 AS_HELP_STRING([--with-linux-obj=PATH],
114 [Path to kernel build objects]),
115 [kernelbuild="$withval"])
117 AC_MSG_CHECKING([kernel source directory])
118 if test -z "$kernelsrc"; then
119 if test -e "/lib/modules/$(uname -r)/source"; then
120 headersdir="/lib/modules/$(uname -r)/source"
121 sourcelink=$(readlink -f "$headersdir")
122 elif test -e "/lib/modules/$(uname -r)/build"; then
123 headersdir="/lib/modules/$(uname -r)/build"
124 sourcelink=$(readlink -f "$headersdir")
126 sourcelink=$(ls -1d /usr/src/kernels/* \
128 2>/dev/null | grep -v obj | tail -1)
131 if test -n "$sourcelink" && test -e ${sourcelink}; then
132 kernelsrc=`readlink -f ${sourcelink}`
134 kernelsrc="[Not found]"
137 if test "$kernelsrc" = "NONE"; then
142 AC_MSG_RESULT([$kernelsrc])
143 if test ! -d "$kernelsrc"; then
145 *** Please make sure the kernel devel package for your distribution
146 *** is installed and then try again. If that fails, you can specify the
147 *** location of the kernel source with the '--with-linux=PATH' option.])
150 AC_MSG_CHECKING([kernel build directory])
151 if test -z "$kernelbuild"; then
152 if test -e "/lib/modules/$(uname -r)/build"; then
153 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
154 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
155 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
156 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
157 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
158 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
159 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
161 kernelbuild=${kernelsrc}
164 AC_MSG_RESULT([$kernelbuild])
166 AC_MSG_CHECKING([kernel source version])
167 utsrelease1=$kernelbuild/include/linux/version.h
168 utsrelease2=$kernelbuild/include/linux/utsrelease.h
169 utsrelease3=$kernelbuild/include/generated/utsrelease.h
170 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
171 utsrelease=linux/version.h
172 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
173 utsrelease=linux/utsrelease.h
174 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
175 utsrelease=generated/utsrelease.h
178 if test "$utsrelease"; then
179 kernsrcver=`(echo "#include <$utsrelease>";
180 echo "kernsrcver=UTS_RELEASE") |
181 cpp -I $kernelbuild/include |
182 grep "^kernsrcver=" | cut -d \" -f 2`
184 if test -z "$kernsrcver"; then
185 AC_MSG_RESULT([Not found])
186 AC_MSG_ERROR([*** Cannot determine kernel version.])
189 AC_MSG_RESULT([Not found])
190 if test "x$enable_linux_builtin" != xyes; then
191 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
194 *** Cannot find UTS_RELEASE definition.
195 *** Please run 'make prepare' inside the kernel source tree.])
199 AC_MSG_RESULT([$kernsrcver])
202 LINUX_OBJ=${kernelbuild}
203 LINUX_VERSION=${kernsrcver}
207 AC_SUBST(LINUX_VERSION)
209 SPL_AC_MODULE_SYMVERS
213 dnl # Default SPL user configuration
215 AC_DEFUN([SPL_AC_CONFIG_USER], [])
218 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
219 dnl # are missing, it is non-fatal, but you will not be able to build
220 dnl # RPM packages and will be warned if you try too.
222 dnl # By default, the generic spec file will be used because it requires
223 dnl # minimal dependencies. Distribution specific spec files can be
224 dnl # placed under the 'rpm/<distribution>' directory and enabled using
225 dnl # the --with-spec=<distribution> configure option.
227 AC_DEFUN([SPL_AC_RPM], [
231 AC_MSG_CHECKING([whether $RPM is available])
232 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
233 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
235 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
238 AC_MSG_RESULT([$HAVE_RPM])
241 AC_MSG_CHECKING([whether $RPMBUILD is available])
242 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
243 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
245 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
248 AC_MSG_RESULT([$HAVE_RPMBUILD])
251 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
253 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
256 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
261 RPM_SPEC_DIR="rpm/generic"
263 AS_HELP_STRING([--with-spec=SPEC],
264 [Spec files 'generic|fedora']),
265 [RPM_SPEC_DIR="rpm/$withval"])
267 AC_MSG_CHECKING([whether spec files are available])
268 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
272 AC_SUBST(RPM_VERSION)
274 AC_SUBST(HAVE_RPMBUILD)
276 AC_SUBST(RPMBUILD_VERSION)
278 AC_SUBST(RPM_SPEC_DIR)
279 AC_SUBST(RPM_DEFINE_UTIL)
280 AC_SUBST(RPM_DEFINE_KMOD)
281 AC_SUBST(RPM_DEFINE_DKMS)
282 AC_SUBST(RPM_DEFINE_COMMON)
283 AC_SUBST(SRPM_DEFINE_UTIL)
284 AC_SUBST(SRPM_DEFINE_KMOD)
285 AC_SUBST(SRPM_DEFINE_DKMS)
286 AC_SUBST(SRPM_DEFINE_COMMON)
290 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
291 dnl # tools are missing it is non-fatal but you will not be able to build
292 dnl # DEB packages and will be warned if you try too.
294 AC_DEFUN([SPL_AC_DPKG], [
296 DPKGBUILD=dpkg-buildpackage
298 AC_MSG_CHECKING([whether $DPKG is available])
299 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
300 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
302 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
305 AC_MSG_RESULT([$HAVE_DPKG])
308 AC_MSG_CHECKING([whether $DPKGBUILD is available])
309 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
310 DPKGBUILD_VERSION=$(echo $tmp | \
311 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
313 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
316 AC_MSG_RESULT([$HAVE_DPKGBUILD])
321 AC_SUBST(DPKG_VERSION)
323 AC_SUBST(HAVE_DPKGBUILD)
325 AC_SUBST(DPKGBUILD_VERSION)
329 dnl # Until native packaging for various different packing systems
330 dnl # can be added the least we can do is attempt to use alien to
331 dnl # convert the RPM packages to the needed package type. This is
332 dnl # a hack but so far it has worked reasonable well.
334 AC_DEFUN([SPL_AC_ALIEN], [
337 AC_MSG_CHECKING([whether $ALIEN is available])
338 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
339 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
341 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
344 AC_MSG_RESULT([$HAVE_ALIEN])
349 AC_SUBST(ALIEN_VERSION)
353 dnl # Using the VENDOR tag from config.guess set the default
354 dnl # package type for 'make pkg': (rpm | deb | tgz)
356 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
357 AC_MSG_CHECKING([linux distribution])
358 if test -f /etc/toss-release ; then
360 elif test -f /etc/fedora-release ; then
362 elif test -f /etc/redhat-release ; then
364 elif test -f /etc/gentoo-release ; then
366 elif test -f /etc/arch-release ; then
368 elif test -f /etc/SuSE-release ; then
370 elif test -f /etc/slackware-version ; then
372 elif test -f /etc/lunar.release ; then
374 elif test -f /etc/lsb-release ; then
376 elif test -f /etc/debian_version ; then
381 AC_MSG_RESULT([$VENDOR])
384 AC_MSG_CHECKING([default package type])
386 toss) DEFAULT_PACKAGE=rpm ;;
387 redhat) DEFAULT_PACKAGE=rpm ;;
388 fedora) DEFAULT_PACKAGE=rpm ;;
389 gentoo) DEFAULT_PACKAGE=tgz ;;
390 arch) DEFAULT_PACKAGE=tgz ;;
391 sles) DEFAULT_PACKAGE=rpm ;;
392 slackware) DEFAULT_PACKAGE=tgz ;;
393 lunar) DEFAULT_PACKAGE=tgz ;;
394 ubuntu) DEFAULT_PACKAGE=deb ;;
395 debian) DEFAULT_PACKAGE=deb ;;
396 *) DEFAULT_PACKAGE=rpm ;;
399 AC_MSG_RESULT([$DEFAULT_PACKAGE])
400 AC_SUBST(DEFAULT_PACKAGE)
404 dnl # Default SPL user configuration
406 AC_DEFUN([SPL_AC_PACKAGE], [
407 SPL_AC_DEFAULT_PACKAGE
413 AC_DEFUN([SPL_AC_LICENSE], [
414 AC_MSG_CHECKING([spl author])
415 AC_MSG_RESULT([$SPL_META_AUTHOR])
417 AC_MSG_CHECKING([spl license])
418 AC_MSG_RESULT([$SPL_META_LICENSE])
421 AC_DEFUN([SPL_AC_CONFIG], [
423 AC_ARG_WITH([config],
424 AS_HELP_STRING([--with-config=CONFIG],
425 [Config file 'kernel|user|all|srpm']),
426 [SPL_CONFIG="$withval"])
427 AC_ARG_ENABLE([linux-builtin],
428 [AC_HELP_STRING([--enable-linux-builtin],
429 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
431 [enable_linux_builtin=no])
433 AC_MSG_CHECKING([spl config])
434 AC_MSG_RESULT([$SPL_CONFIG]);
437 case "$SPL_CONFIG" in
438 kernel) SPL_AC_CONFIG_KERNEL ;;
439 user) SPL_AC_CONFIG_USER ;;
440 all) SPL_AC_CONFIG_KERNEL
441 SPL_AC_CONFIG_USER ;;
444 AC_MSG_RESULT([Error!])
445 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
446 user kernel|user|all|srpm]) ;;
449 AM_CONDITIONAL([CONFIG_USER],
450 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
451 AM_CONDITIONAL([CONFIG_KERNEL],
452 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
453 [test "x$enable_linux_builtin" != xyes ])
457 dnl # Enable if the SPL should be compiled with internal debugging enabled.
458 dnl # By default this support is disabled.
460 AC_DEFUN([SPL_AC_DEBUG], [
461 AC_MSG_CHECKING([whether debugging is enabled])
462 AC_ARG_ENABLE([debug],
463 [AS_HELP_STRING([--enable-debug],
464 [Enable generic debug support @<:@default=no@:>@])],
468 AS_IF([test "x$enable_debug" = xyes],
470 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
471 DEBUG_CFLAGS="-DDEBUG -Werror"
472 DEBUG_SPL="_with_debug"
474 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
475 DEBUG_CFLAGS="-DNDEBUG"
476 DEBUG_SPL="_without_debug"
479 AC_SUBST(DEBUG_CFLAGS)
481 AC_MSG_RESULT([$enable_debug])
485 dnl # Enabled by default it provides a basic debug log infrastructure.
486 dnl # Each subsystem registers itself with a name and logs messages
487 dnl # using predefined types. If the debug mask it set to allow the
488 dnl # message type it will be written to the internal log. The log
489 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
490 dnl # after dumping the log it must be decoded using the spl utility.
492 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
493 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
495 AC_DEFUN([SPL_AC_DEBUG_LOG], [
496 AC_ARG_ENABLE([debug-log],
497 [AS_HELP_STRING([--enable-debug-log],
498 [Enable basic debug logging @<:@default=yes@:>@])],
500 [enable_debug_log=yes])
502 AS_IF([test "x$enable_debug_log" = xyes],
504 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
505 DEBUG_LOG="_with_debug_log"
506 AC_DEFINE([DEBUG_LOG], [1],
507 [Define to 1 to enable basic debug logging])
509 DEBUG_LOG="_without_debug_log"
513 AC_MSG_CHECKING([whether basic debug logging is enabled])
514 AC_MSG_RESULT([$enable_debug_log])
518 dnl # Enabled by default it provides a minimal level of memory tracking.
519 dnl # A total count of bytes allocated is kept for each alloc and free.
520 dnl # Then at module unload time a report to the console will be printed
521 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
522 dnl # and provide an easy way to inspect the kmem based slab.
524 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
525 AC_ARG_ENABLE([debug-kmem],
526 [AS_HELP_STRING([--enable-debug-kmem],
527 [Enable basic kmem accounting @<:@default=yes@:>@])],
529 [enable_debug_kmem=yes])
531 AS_IF([test "x$enable_debug_kmem" = xyes],
533 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
534 DEBUG_KMEM="_with_debug_kmem"
535 AC_DEFINE([DEBUG_KMEM], [1],
536 [Define to 1 to enable basic kmem accounting])
538 DEBUG_KMEM="_without_debug_kmem"
542 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
543 AC_MSG_RESULT([$enable_debug_kmem])
547 dnl # Disabled by default it provides detailed memory tracking. This
548 dnl # feature also requires --enable-debug-kmem to be set. When enabled
549 dnl # not only will total bytes be tracked but also the location of every
550 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
551 dnl # addresses and where they were allocated will be dumped to the console.
552 dnl # Enabling this feature has a significant impact on performance but it
553 dnl # makes finding memory leaks pretty straight forward.
555 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
556 AC_ARG_ENABLE([debug-kmem-tracking],
557 [AS_HELP_STRING([--enable-debug-kmem-tracking],
558 [Enable detailed kmem tracking @<:@default=no@:>@])],
560 [enable_debug_kmem_tracking=no])
562 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
564 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
565 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
566 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
567 [Define to 1 to enable detailed kmem tracking])
569 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
572 AC_SUBST(DEBUG_KMEM_TRACKING)
573 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
574 AC_MSG_RESULT([$enable_debug_kmem_tracking])
578 dnl # SPL_LINUX_CONFTEST
580 AC_DEFUN([SPL_LINUX_CONFTEST], [
581 cat confdefs.h - <<_ACEOF >conftest.c
587 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
589 m4_define([SPL_LANG_PROGRAM], [
594 dnl Do *not* indent the following line: there may be CPP directives.
595 dnl Don't move the `;' right after for the same reason.
603 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
605 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
606 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
607 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
608 echo "obj-m := conftest.o" >build/Makefile
610 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
612 [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])],
614 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
620 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
622 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
623 [SPL_LINUX_COMPILE_IFELSE(
624 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
626 [test -s build/conftest.o],
631 dnl # SPL_CHECK_SYMBOL_EXPORT
632 dnl # check symbol exported or not
634 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
635 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
636 $LINUX_OBJ/Module*.symvers 2>/dev/null
638 if test $rc -ne 0; then
641 grep -q -E "EXPORT_SYMBOL.*($1)" \
642 "$LINUX_OBJ/$file" 2>/dev/null
644 if test $rc -eq 0; then
649 if test $export -eq 0; then :
660 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
661 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
662 dnl # is called if not compiling for builtin
664 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
665 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
666 if test $rc -ne 0; then :
669 if test "x$enable_linux_builtin" != xyes; then
670 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
672 if test $rc -ne 0; then :
681 dnl # SPL_CHECK_SYMBOL_HEADER
682 dnl # check if a symbol prototype is defined in listed headers.
684 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
685 AC_MSG_CHECKING([whether symbol $1 exists in header])
688 grep -q "$2" "$LINUX/$file" 2>/dev/null
690 if test $rc -eq 0; then
695 if test $header -eq 0; then
705 dnl # SPL_CHECK_HEADER
706 dnl # check whether header exists and define HAVE_$2_HEADER
708 AC_DEFUN([SPL_CHECK_HEADER],
709 [AC_MSG_CHECKING([whether header $1 exists])
710 SPL_LINUX_TRY_COMPILE([
715 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
725 dnl # Basic toolchain sanity check. Verify that kernel modules can
726 dnl # be built and which symbols can be used.
728 AC_DEFUN([SPL_AC_TEST_MODULE],
729 [AC_MSG_CHECKING([whether modules can be built])
730 SPL_LINUX_TRY_COMPILE([],[],[
734 if test "x$enable_linux_builtin" != xyes; then
735 AC_MSG_ERROR([*** Unable to build an empty module.])
738 *** Unable to build an empty module.
739 *** Please run 'make scripts' inside the kernel source tree.])
745 #include "$LINUX/include/linux/license.h"
747 return !license_is_gpl_compatible("$SPL_META_LICENSE");
750 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
751 [Define to 1 if GPL-only symbols can be used])
757 dnl # Use the atomic implemenation based on global spinlocks. This
758 dnl # should only be needed by 32-bit kernels which do not provide
759 dnl # the atomic64_* API. It may be optionally enabled as a fallback
760 dnl # if problems are observed with the direct mapping to the native
761 dnl # Linux atomic operations. You may not disable atomic spinlocks
762 dnl # if you kernel does not an atomic64_* API.
764 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
765 AC_ARG_ENABLE([atomic-spinlocks],
766 [AS_HELP_STRING([--enable-atomic-spinlocks],
767 [Atomic types use spinlocks @<:@default=check@:>@])],
769 [enable_atomic_spinlocks=check])
771 SPL_LINUX_TRY_COMPILE([
772 #include <linux/fs.h>
774 atomic64_t *ptr __attribute__ ((unused));
777 AC_DEFINE(HAVE_ATOMIC64_T, 1,
778 [kernel defines atomic64_t])
783 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
784 AS_IF([test "x$have_atomic64_t" = xyes], [
785 enable_atomic_spinlocks=no
787 enable_atomic_spinlocks=yes
791 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
792 AC_DEFINE([ATOMIC_SPINLOCK], [1],
793 [Atomic types use spinlocks])
795 AS_IF([test "x$have_atomic64_t" = xno], [
797 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
801 AC_MSG_CHECKING([whether atomic types use spinlocks])
802 AC_MSG_RESULT([$enable_atomic_spinlocks])
804 AC_MSG_CHECKING([whether kernel defines atomic64_t])
805 AC_MSG_RESULT([$have_atomic64_t])
808 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
809 tmp_flags="$EXTRA_KCFLAGS"
810 EXTRA_KCFLAGS="-Werror"
812 dnl # 2.6.23 to 2.6.34 API change
813 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
815 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
816 SPL_LINUX_TRY_COMPILE([
817 #include <linux/mm.h>
819 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
821 struct shrinker cache_shrinker = {
822 .shrink = shrinker_cb,
823 .seeks = DEFAULT_SEEKS,
825 register_shrinker(&cache_shrinker);
828 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
829 [old shrinker callback wants 2 args])
833 dnl # 2.6.35 - 2.6.39 API change
834 dnl # ->shrink(struct shrinker *,
835 dnl # int nr_to_scan, gfp_t gfp_mask)
837 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
838 SPL_LINUX_TRY_COMPILE([
839 #include <linux/mm.h>
841 int shrinker_cb(struct shrinker *, int nr_to_scan,
844 struct shrinker cache_shrinker = {
845 .shrink = shrinker_cb,
846 .seeks = DEFAULT_SEEKS,
848 register_shrinker(&cache_shrinker);
851 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
852 [old shrinker callback wants 3 args])
856 dnl # 3.0 - 3.11 API change
857 dnl # ->shrink(struct shrinker *,
858 dnl # struct shrink_control *sc)
861 [whether new 2-argument shrinker exists])
862 SPL_LINUX_TRY_COMPILE([
863 #include <linux/mm.h>
865 int shrinker_cb(struct shrinker *,
866 struct shrink_control *sc);
868 struct shrinker cache_shrinker = {
869 .shrink = shrinker_cb,
870 .seeks = DEFAULT_SEEKS,
872 register_shrinker(&cache_shrinker);
875 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
876 [new shrinker callback wants 2 args])
880 dnl # 3.12 API change,
881 dnl # ->shrink() is logically split in to
882 dnl # ->count_objects() and ->scan_objects()
885 [whether ->count_objects callback exists])
886 SPL_LINUX_TRY_COMPILE([
887 #include <linux/mm.h>
889 unsigned long shrinker_cb(
891 struct shrink_control *sc);
893 struct shrinker cache_shrinker = {
894 .count_objects = shrinker_cb,
895 .scan_objects = shrinker_cb,
896 .seeks = DEFAULT_SEEKS,
898 register_shrinker(&cache_shrinker);
901 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
902 1, [->count_objects exists])
909 EXTRA_KCFLAGS="$tmp_flags"
913 dnl # 2.6.33 API change,
914 dnl # Removed .ctl_name from struct ctl_table.
916 AC_DEFUN([SPL_AC_CTL_NAME], [
917 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
918 SPL_LINUX_TRY_COMPILE([
919 #include <linux/sysctl.h>
921 struct ctl_table ctl __attribute__ ((unused));
925 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
932 dnl # 2.6.18 API change,
933 dnl # added linux/uaccess.h
935 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
936 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
940 dnl # 2.6.12 API change,
941 dnl # check whether 'kmalloc_node()' is available.
943 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
944 AC_MSG_CHECKING([whether kmalloc_node() is available])
945 SPL_LINUX_TRY_COMPILE([
946 #include <linux/slab.h>
948 void *a __attribute__ ((unused));
949 a = kmalloc_node(1, GFP_KERNEL, 0);
952 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
959 dnl # 2.6.16 API change,
960 dnl # check whether 'struct inode' has i_mutex
962 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
963 AC_MSG_CHECKING([whether struct inode has i_mutex])
964 SPL_LINUX_TRY_COMPILE([
965 #include <linux/fs.h>
966 #include <linux/mutex.h>
969 mutex_init(&i.i_mutex);
972 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
979 dnl # 2.6.29 API change,
980 dnl # Adaptive mutexs were introduced which track the mutex owner. The
981 dnl # mutex wrappers leverage this functionality to avoid tracking the
982 dnl # owner multipe times.
984 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
985 AC_MSG_CHECKING([whether struct mutex has owner])
986 SPL_LINUX_TRY_COMPILE([
987 #include <linux/mutex.h>
989 struct mutex mtx __attribute__ ((unused));
993 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1000 dnl # 2.6.39 API change,
1001 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1002 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1003 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1004 dnl # pointer which frankly makes a lot more sense.
1006 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1007 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1008 tmp_flags="$EXTRA_KCFLAGS"
1009 EXTRA_KCFLAGS="-Werror"
1010 SPL_LINUX_TRY_COMPILE([
1011 #include <linux/mutex.h>
1012 #include <linux/sched.h>
1014 struct mutex mtx __attribute__ ((unused));
1015 mtx.owner = current;
1018 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1019 [struct mutex owner is a task_struct])
1023 EXTRA_KCFLAGS="$tmp_flags"
1027 dnl # 2.6.18 API change,
1028 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1029 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1030 dnl # if the mutex validator is disabled or otherwise unavailable.
1032 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1033 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1034 SPL_LINUX_TRY_COMPILE([
1035 #include <linux/mutex.h>
1039 mutex_lock_nested(&mutex, 0);
1042 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1043 [mutex_lock_nested() is available])
1050 dnl # 2.6.27 API change,
1051 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1053 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1054 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1055 SPL_LINUX_TRY_COMPILE([
1056 #include <linux/interrupt.h>
1057 #include <linux/smp.h>
1059 void on_each_cpu_func(void *data) { return; }
1061 on_each_cpu(on_each_cpu_func, NULL, 0);
1064 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1065 [on_each_cpu wants 3 args])
1072 dnl # 2.6.18 API change,
1073 dnl # kallsyms_lookup_name no longer exported
1075 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1076 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1077 SPL_LINUX_TRY_COMPILE_SYMBOL([
1078 #include <linux/kallsyms.h>
1080 kallsyms_lookup_name(NULL);
1081 ], [kallsyms_lookup_name], [], [
1083 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1084 [kallsyms_lookup_name() is available])
1091 dnl # Proposed API change,
1092 dnl # This symbol is not available in stock kernels. You may build a
1093 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1094 dnl # these symbols for use. If your already rolling a custom kernel for
1095 dnl # your environment this is recommended.
1097 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1098 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1099 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1101 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1102 [get_vmalloc_info() is available])
1109 dnl # 3.10 API change,
1110 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1112 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1113 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1114 SPL_LINUX_TRY_COMPILE([
1115 #include <linux/vmalloc.h>
1116 struct vmalloc_info { void *a; };
1123 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1128 dnl # 3.10 API change,
1129 dnl # PDE is replaced by PDE_DATA
1131 AC_DEFUN([SPL_AC_PDE_DATA], [
1132 AC_MSG_CHECKING([whether PDE_DATA() is available])
1133 SPL_LINUX_TRY_COMPILE_SYMBOL([
1134 #include <linux/proc_fs.h>
1137 ], [PDE_DATA], [], [
1139 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1146 dnl # 2.6.17 API change
1147 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1148 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1149 dnl # were exported in 2.6.17 for use by modules which was consistent with
1150 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1151 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1152 dnl # were dropped entirely leaving modules no way to directly iterate over
1153 dnl # the zone list. Because we need access to the zone helpers we check
1154 dnl # if the kernel contains the old or new implementation. Then we check
1155 dnl # to see if the symbols we need for each version are available. If they
1156 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1158 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1159 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1160 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1162 if test $rc -eq 0; then
1163 AC_MSG_RESULT([yes])
1164 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1171 dnl # Proposed API change,
1172 dnl # This symbol is not available in stock kernels. You may build a
1173 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1174 dnl # these symbols for use. If your already rolling a custom kernel for
1175 dnl # your environment this is recommended.
1177 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1178 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1179 SPL_LINUX_TRY_COMPILE_SYMBOL([
1180 #include <linux/mmzone.h>
1182 first_online_pgdat();
1183 ], [first_online_pgdat], [], [
1185 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1186 [first_online_pgdat() is available])
1193 dnl # Proposed API change,
1194 dnl # This symbol is not available in stock kernels. You may build a
1195 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1196 dnl # these symbols for use. If your already rolling a custom kernel for
1197 dnl # your environment this is recommended.
1199 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1200 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1201 SPL_LINUX_TRY_COMPILE_SYMBOL([
1202 #include <linux/mmzone.h>
1204 next_online_pgdat(NULL);
1205 ], [next_online_pgdat], [], [
1207 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1208 [next_online_pgdat() is available])
1215 dnl # Proposed API change,
1216 dnl # This symbol is not available in stock kernels. You may build a
1217 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1218 dnl # these symbols for use. If your already rolling a custom kernel for
1219 dnl # your environment this is recommended.
1221 AC_DEFUN([SPL_AC_NEXT_ZONE],
1222 [AC_MSG_CHECKING([whether next_zone() is available])
1223 SPL_LINUX_TRY_COMPILE_SYMBOL([
1224 #include <linux/mmzone.h>
1227 ], [next_zone], [], [
1229 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1236 dnl # 2.6.17 API change,
1237 dnl # See SPL_AC_PGDAT_HELPERS for details.
1239 AC_DEFUN([SPL_AC_PGDAT_LIST],
1240 [AC_MSG_CHECKING([whether pgdat_list is available])
1241 SPL_LINUX_TRY_COMPILE_SYMBOL([
1242 #include <linux/topology.h>
1243 pg_data_t *tmp = pgdat_list;
1244 ], [], [pgdat_list], [], [
1246 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1253 dnl # 2.6.18 API change,
1254 dnl # First introduced global_page_state() support as an inline.
1256 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1257 AC_MSG_CHECKING([whether global_page_state() is available])
1258 SPL_LINUX_TRY_COMPILE([
1259 #include <linux/mm.h>
1261 unsigned long state __attribute__ ((unused));
1262 state = global_page_state(0);
1265 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1266 [global_page_state() is available])
1273 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1274 dnl # Public global zone stats now include a free page count. However
1275 dnl # the enumerated names of the counters have changed since this API
1276 dnl # was introduced. We need to deduce the corrent name to use. This
1277 dnl # replaces the priviate get_zone_counts() interface.
1279 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1280 dnl # is 2.6.30 as of when this was written.
1282 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1283 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1284 SPL_LINUX_TRY_COMPILE([
1285 #include <linux/mm.h>
1287 enum zone_stat_item zsi __attribute__ ((unused));
1288 zsi = NR_FREE_PAGES;
1291 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1292 [Page state NR_FREE_PAGES is available])
1299 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1300 dnl # Public global zone stats now include an inactive page count. However
1301 dnl # the enumerated names of the counters have changed since this API
1302 dnl # was introduced. We need to deduce the corrent name to use. This
1303 dnl # replaces the priviate get_zone_counts() interface.
1305 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1306 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1307 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1309 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1310 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1311 SPL_LINUX_TRY_COMPILE([
1312 #include <linux/mm.h>
1314 enum zone_stat_item zsi __attribute__ ((unused));
1318 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1319 [Page state NR_INACTIVE is available])
1324 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1325 SPL_LINUX_TRY_COMPILE([
1326 #include <linux/mm.h>
1328 enum zone_stat_item zsi __attribute__ ((unused));
1329 zsi = NR_INACTIVE_ANON;
1332 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1333 [Page state NR_INACTIVE_ANON is available])
1338 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1339 SPL_LINUX_TRY_COMPILE([
1340 #include <linux/mm.h>
1342 enum zone_stat_item zsi __attribute__ ((unused));
1343 zsi = NR_INACTIVE_FILE;
1346 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1347 [Page state NR_INACTIVE_FILE is available])
1354 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1355 dnl # Public global zone stats now include an active page count. However
1356 dnl # the enumerated names of the counters have changed since this API
1357 dnl # was introduced. We need to deduce the corrent name to use. This
1358 dnl # replaces the priviate get_zone_counts() interface.
1360 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1361 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1362 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1364 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1365 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1366 SPL_LINUX_TRY_COMPILE([
1367 #include <linux/mm.h>
1369 enum zone_stat_item zsi __attribute__ ((unused));
1373 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1374 [Page state NR_ACTIVE is available])
1379 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1380 SPL_LINUX_TRY_COMPILE([
1381 #include <linux/mm.h>
1383 enum zone_stat_item zsi __attribute__ ((unused));
1384 zsi = NR_ACTIVE_ANON;
1387 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1388 [Page state NR_ACTIVE_ANON is available])
1393 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1394 SPL_LINUX_TRY_COMPILE([
1395 #include <linux/mm.h>
1397 enum zone_stat_item zsi __attribute__ ((unused));
1398 zsi = NR_ACTIVE_FILE;
1401 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1402 [Page state NR_ACTIVE_FILE is available])
1409 dnl # Proposed API change for legacy kernels.
1410 dnl # This symbol is not available in older kernels. For kernels post
1411 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1412 dnl # page state information. This symbol is only used in legacy kernels
1413 dnl # any only as a last resort.
1415 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1416 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1417 SPL_LINUX_TRY_COMPILE([
1419 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1420 #error "global_page_state needs NR_FREE_PAGES"
1423 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1424 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1425 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1426 #error "global_page_state needs NR_ACTIVE*"
1429 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1430 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1431 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1432 #error "global_page_state needs NR_INACTIVE*"
1438 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1439 [get_zone_counts() is needed])
1441 AC_MSG_CHECKING([whether get_zone_counts() is available])
1442 SPL_LINUX_TRY_COMPILE_SYMBOL([
1443 #include <linux/mmzone.h>
1445 get_zone_counts(NULL, NULL, NULL);
1446 ], [get_zone_counts], [], [
1448 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1449 [get_zone_counts() is available])
1457 dnl # 2.6.27 API change,
1458 dnl # The user_path_dir() replaces __user_walk()
1460 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1461 [AC_MSG_CHECKING([whether user_path_dir() is available])
1462 SPL_LINUX_TRY_COMPILE_SYMBOL([
1463 #include <linux/fcntl.h>
1464 #include <linux/namei.h>
1466 user_path_dir(NULL, NULL);
1467 ], [user_path_at], [], [
1469 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1476 dnl # Symbol available in RHEL kernels not in stock kernels.
1478 AC_DEFUN([SPL_AC_SET_FS_PWD],
1479 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1480 SPL_LINUX_TRY_COMPILE_SYMBOL([
1481 #include <linux/spinlock.h>
1482 #include <linux/fs_struct.h>
1485 ], [set_fs_pwd], [], [
1487 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1494 dnl # 3.9 API change
1495 dnl # set_fs_pwd takes const struct path *
1497 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1498 tmp_flags="$EXTRA_KCFLAGS"
1499 EXTRA_KCFLAGS="-Werror"
1500 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1501 SPL_LINUX_TRY_COMPILE([
1502 #include <linux/spinlock.h>
1503 #include <linux/fs_struct.h>
1504 #include <linux/path.h>
1505 void (*const set_fs_pwd_func)
1506 (struct fs_struct *, const struct path *)
1512 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1513 [set_fs_pwd() needs const path *])
1515 SPL_LINUX_TRY_COMPILE([
1516 #include <linux/spinlock.h>
1517 #include <linux/fs_struct.h>
1518 #include <linux/path.h>
1519 void (*const set_fs_pwd_func)
1520 (struct fs_struct *, struct path *)
1527 AC_MSG_ERROR(unknown)
1530 EXTRA_KCFLAGS="$tmp_flags"
1533 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1534 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1535 SPL_LINUX_TRY_COMPILE([
1536 #include <linux/fs.h>
1538 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1541 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1542 [vfs_unlink() wants 2 args])
1546 dnl # Linux 3.13 API change
1547 dnl # Added delegated inode
1549 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1550 SPL_LINUX_TRY_COMPILE([
1551 #include <linux/fs.h>
1553 vfs_unlink((struct inode *) NULL,
1554 (struct dentry *) NULL,
1555 (struct inode **) NULL);
1558 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1559 [vfs_unlink() wants 3 args])
1567 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1568 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1569 SPL_LINUX_TRY_COMPILE([
1570 #include <linux/fs.h>
1572 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1573 (struct inode *) NULL, (struct dentry *) NULL);
1576 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1577 [vfs_rename() wants 4 args])
1581 dnl # Linux 3.13 API change
1582 dnl # Added delegated inode
1584 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1585 SPL_LINUX_TRY_COMPILE([
1586 #include <linux/fs.h>
1588 vfs_rename((struct inode *) NULL,
1589 (struct dentry *) NULL,
1590 (struct inode *) NULL,
1591 (struct dentry *) NULL,
1592 (struct inode **) NULL);
1595 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1596 [vfs_rename() wants 5 args])
1600 dnl # Linux 3.15 API change
1603 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1604 SPL_LINUX_TRY_COMPILE([
1605 #include <linux/fs.h>
1607 vfs_rename((struct inode *) NULL,
1608 (struct dentry *) NULL,
1609 (struct inode *) NULL,
1610 (struct dentry *) NULL,
1611 (struct inode **) NULL,
1615 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1616 [vfs_rename() wants 6 args])
1625 dnl # 2.6.36 API change,
1626 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1627 dnl # a spinlock_t to improve the fastpath performance.
1629 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1630 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1631 tmp_flags="$EXTRA_KCFLAGS"
1632 EXTRA_KCFLAGS="-Werror"
1633 SPL_LINUX_TRY_COMPILE([
1634 #include <linux/sched.h>
1635 #include <linux/fs_struct.h>
1637 struct fs_struct fs;
1638 spin_lock_init(&fs.lock);
1641 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1642 [struct fs_struct uses spinlock_t])
1646 EXTRA_KCFLAGS="$tmp_flags"
1650 dnl # 2.6.29 API change,
1651 dnl # check whether 'struct cred' exists
1653 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1654 AC_MSG_CHECKING([whether struct cred exists])
1655 SPL_LINUX_TRY_COMPILE([
1656 #include <linux/cred.h>
1658 struct cred *cr __attribute__ ((unused));
1662 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1670 dnl # User namespaces, use kuid_t in place of uid_t
1671 dnl # where available. Not strictly a user namespaces thing
1672 dnl # but it should prevent surprises
1674 AC_DEFUN([SPL_AC_KUIDGID_T], [
1675 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1676 SPL_LINUX_TRY_COMPILE([
1677 #include <linux/uidgid.h>
1679 kuid_t userid = KUIDT_INIT(0);
1680 kgid_t groupid = KGIDT_INIT(0);
1682 SPL_LINUX_TRY_COMPILE([
1683 #include <linux/uidgid.h>
1688 AC_MSG_RESULT(yes; optional)
1690 AC_MSG_RESULT(yes; mandatory)
1691 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1699 dnl # Custom SPL patch may export this symbol.
1701 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1702 [AC_MSG_CHECKING([whether groups_search() is available])
1703 SPL_LINUX_TRY_COMPILE_SYMBOL([
1704 #include <linux/cred.h>
1705 #ifdef HAVE_KUIDGID_T
1706 #include <linux/uidgid.h>
1709 #ifdef HAVE_KUIDGID_T
1710 groups_search(NULL, KGIDT_INIT(0));
1712 groups_search(NULL, 0);
1714 ], [groups_search], [], [
1716 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1723 dnl # 2.6.x API change,
1724 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1726 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1727 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1728 SPL_LINUX_TRY_COMPILE_SYMBOL([
1729 #include <linux/sched.h>
1731 __put_task_struct(NULL);
1732 ], [__put_task_struct], [], [
1734 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1735 [__put_task_struct() is available])
1742 dnl # 2.6.32 API change,
1743 dnl # Unused 'struct file *' removed from prototype.
1745 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1746 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1747 SPL_LINUX_TRY_COMPILE([
1748 #include <linux/sysctl.h>
1750 proc_dostring(NULL, 0, NULL, NULL, NULL);
1753 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1754 [proc_handler() wants 5 args])
1761 dnl # 2.6.x API change,
1762 dnl # kvasprintf() function added.
1764 AC_DEFUN([SPL_AC_KVASPRINTF],
1765 [AC_MSG_CHECKING([whether kvasprintf() is available])
1766 SPL_LINUX_TRY_COMPILE_SYMBOL([
1767 #include <linux/kernel.h>
1769 kvasprintf(0, NULL, *((va_list*)NULL));
1770 ], [kvasprintf], [], [
1772 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1779 dnl # 2.6.29 API change,
1780 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1782 AC_DEFUN([SPL_AC_VFS_FSYNC],
1783 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1784 SPL_LINUX_TRY_COMPILE_SYMBOL([
1785 #include <linux/fs.h>
1788 ], [vfs_fsync], [fs/sync.c], [
1790 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1797 dnl # 2.6.35 API change,
1798 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1800 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1801 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1802 SPL_LINUX_TRY_COMPILE([
1803 #include <linux/fs.h>
1808 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1815 dnl # 3.5 API change,
1816 dnl # inode_operations.truncate_range removed
1818 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1819 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1820 SPL_LINUX_TRY_COMPILE([
1821 #include <linux/fs.h>
1823 struct inode_operations ops;
1824 ops.truncate_range = NULL;
1827 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1828 [truncate_range() inode operation is available])
1835 dnl # Linux 2.6.38 - 3.x API
1837 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1838 AC_MSG_CHECKING([whether fops->fallocate() exists])
1839 SPL_LINUX_TRY_COMPILE([
1840 #include <linux/fs.h>
1842 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1843 struct file_operations fops __attribute__ ((unused)) = {
1844 .fallocate = fallocate,
1848 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1855 dnl # Linux 2.6.x - 2.6.37 API
1857 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1858 AC_MSG_CHECKING([whether iops->fallocate() exists])
1859 SPL_LINUX_TRY_COMPILE([
1860 #include <linux/fs.h>
1862 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1863 struct inode_operations fops __attribute__ ((unused)) = {
1864 .fallocate = fallocate,
1868 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1875 dnl # PaX Linux 2.6.38 - 3.x API
1877 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1878 AC_MSG_CHECKING([whether fops->fallocate() exists])
1879 SPL_LINUX_TRY_COMPILE([
1880 #include <linux/fs.h>
1882 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1883 struct file_operations_no_const fops __attribute__ ((unused)) = {
1884 .fallocate = fallocate,
1888 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1895 dnl # The fallocate callback was moved from the inode_operations
1896 dnl # structure to the file_operations structure.
1898 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1899 SPL_AC_KERNEL_FILE_FALLOCATE
1900 SPL_AC_KERNEL_INODE_FALLOCATE
1901 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1905 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1906 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1907 dnl # condition. The fixed version is exported as a symbol. The race
1908 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1909 dnl # call that version while holding sem->wait_lock.
1911 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1912 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1913 SPL_LINUX_TRY_COMPILE_SYMBOL([
1914 #include <linux/rwsem.h>
1915 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1916 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1918 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1919 [rwsem_is_locked() acquires sem->wait_lock])
1926 dnl # 2.6.xx API compat,
1927 dnl # There currently exists no exposed API to partially shrink the dcache.
1928 dnl # The expected mechanism to shrink the cache is a registered shrinker
1929 dnl # which is called during memory pressure.
1931 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
1932 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
1933 SPL_LINUX_TRY_COMPILE_SYMBOL([
1934 #include <linux/dcache.h>
1936 shrink_dcache_memory(0, 0);
1937 ], [shrink_dcache_memory], [fs/dcache.c], [
1939 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1940 [shrink_dcache_memory() is available])
1947 dnl # 2.6.xx API compat,
1948 dnl # There currently exists no exposed API to partially shrink the icache.
1949 dnl # The expected mechanism to shrink the cache is a registered shrinker
1950 dnl # which is called during memory pressure.
1952 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
1953 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
1954 SPL_LINUX_TRY_COMPILE_SYMBOL([
1955 #include <linux/dcache.h>
1957 shrink_icache_memory(0, 0);
1958 ], [shrink_icache_memory], [fs/inode.c], [
1960 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1961 [shrink_icache_memory() is available])
1968 dnl # 2.6.28 API change
1969 dnl # The kern_path() function has been introduced. We adopt it as the new way
1970 dnl # of looking up paths. When it is not available, we emulate it using the
1971 dnl # older interfaces.
1973 AC_DEFUN([SPL_AC_KERN_PATH],
1974 [AC_MSG_CHECKING([whether kern_path() is available])
1975 SPL_LINUX_TRY_COMPILE_SYMBOL([
1976 #include <linux/namei.h>
1978 int r = kern_path(NULL, 0, NULL);
1979 ], [kern_path], [fs/namei.c], [
1981 AC_DEFINE(HAVE_KERN_PATH, 1,
1982 [kern_path() is available])
1985 AC_MSG_CHECKING([whether path_lookup() is available])
1986 SPL_LINUX_TRY_COMPILE_SYMBOL([
1987 #include <linux/namei.h>
1989 int r = path_lookup(NULL, 0, NULL);
1990 ], [path_lookup], [fs/namei.c], [
1992 AC_DEFINE(HAVE_KERN_PATH, 1,
1993 [kern_path() is available])
1997 *** Neither kern_path() nor path_lookup() is available.
1998 *** Please file an issue:
1999 *** https://github.com/zfsonlinux/spl/issues/new])
2006 dnl # /proc/kallsyms support,
2007 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2009 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2010 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2011 SPL_LINUX_TRY_COMPILE([
2012 #if !defined(CONFIG_KALLSYMS)
2013 #error CONFIG_KALLSYMS not defined
2016 AC_MSG_RESULT([yes])
2020 *** This kernel does not include the required kallsyms support.
2021 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2026 dnl # zlib inflate compat,
2027 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2029 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2030 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2031 SPL_LINUX_TRY_COMPILE([
2032 #if !defined(CONFIG_ZLIB_INFLATE) && \
2033 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2034 #error CONFIG_ZLIB_INFLATE not defined
2037 AC_MSG_RESULT([yes])
2041 *** This kernel does not include the required zlib inflate support.
2042 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2047 dnl # zlib deflate compat,
2048 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2050 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2051 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2052 SPL_LINUX_TRY_COMPILE([
2053 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2054 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2055 #error CONFIG_ZLIB_DEFLATE not defined
2058 AC_MSG_RESULT([yes])
2062 *** This kernel does not include the required zlib deflate support.
2063 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2068 dnl # 2.6.39 API compat,
2069 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2070 dnl # This was done to avoid always having to allocate the maximum size
2071 dnl # workspace (268K). The caller can now specific the windowBits and
2072 dnl # memLevel compression parameters to get a smaller workspace.
2074 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2075 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2076 SPL_LINUX_TRY_COMPILE([
2077 #include <linux/zlib.h>
2079 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2082 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2083 [zlib_deflate_workspacesize() wants 2 args])
2090 dnl # 2.6.39 API change,
2091 dnl # Shrinker adjust to use common shrink_control structure.
2093 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2094 AC_MSG_CHECKING([whether struct shrink_control exists])
2095 SPL_LINUX_TRY_COMPILE([
2096 #include <linux/mm.h>
2098 struct shrink_control sc __attribute__ ((unused));
2101 sc.gfp_mask = GFP_KERNEL;
2104 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2105 [struct shrink_control exists])
2112 dnl # 3.1 API Change
2114 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2115 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2117 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2118 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2119 tmp_flags="$EXTRA_KCFLAGS"
2120 EXTRA_KCFLAGS="-Werror"
2121 SPL_LINUX_TRY_COMPILE([
2122 #include <linux/rwsem.h>
2124 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2125 raw_spinlock_t dummy_lock __attribute__ ((unused));
2126 dummy_semaphore.wait_lock = dummy_lock;
2129 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2130 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2134 EXTRA_KCFLAGS="$tmp_flags"
2138 dnl # 3.9 API change,
2139 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2141 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2142 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2143 SPL_LINUX_TRY_COMPILE([
2144 #include <linux/sched.h>
2145 #include <linux/sched/rt.h>
2149 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2157 dnl # 3.9 API change,
2158 dnl # vfs_getattr() uses 2 args
2159 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2161 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2162 AC_MSG_CHECKING([whether vfs_getattr() wants])
2163 SPL_LINUX_TRY_COMPILE([
2164 #include <linux/fs.h>
2166 vfs_getattr((struct path *) NULL,
2167 (struct kstat *)NULL);
2169 AC_MSG_RESULT(2 args)
2170 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2171 [vfs_getattr wants 2 args])
2173 SPL_LINUX_TRY_COMPILE([
2174 #include <linux/fs.h>
2176 vfs_getattr((struct vfsmount *)NULL,
2177 (struct dentry *)NULL,
2178 (struct kstat *)NULL);
2180 AC_MSG_RESULT(3 args)
2182 AC_MSG_ERROR(unknown)
2188 dnl # 2.6.36 API compatibility.
2189 dnl # Added usleep_range timer.
2190 dnl # usleep_range is a finer precision implementation of msleep
2191 dnl # designed to be a drop-in replacement for udelay where a precise
2192 dnl # sleep / busy-wait is unnecessary.
2194 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2195 AC_MSG_CHECKING([whether usleep_range() is available])
2196 SPL_LINUX_TRY_COMPILE([
2197 #include <linux/delay.h>
2202 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2203 [usleep_range is available])
2210 dnl # 2.6.35 API change,
2211 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2212 dnl # private allocation flags which are applied when allocating a new slab
2213 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2214 dnl # non-default flags.
2216 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2217 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2218 SPL_LINUX_TRY_COMPILE([
2219 #include <linux/slab.h>
2221 struct kmem_cache cachep __attribute__ ((unused));
2222 cachep.allocflags = GFP_KERNEL;
2225 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2226 [struct kmem_cache has allocflags])
2230 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2231 SPL_LINUX_TRY_COMPILE([
2232 #include <linux/slab.h>
2234 struct kmem_cache cachep __attribute__ ((unused));
2235 cachep.gfpflags = GFP_KERNEL;
2238 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2239 [struct kmem_cache has gfpflags])
2247 dnl # 3.17 API change,
2248 dnl # wait_on_bit() no longer requires an action argument. The former
2249 dnl # "wait_on_bit" interface required an 'action' function to be provided
2250 dnl # which does the actual waiting. There were over 20 such functions in the
2251 dnl # kernel, many of them identical, though most cases can be satisfied by one
2252 dnl # of just two functions: one which uses io_schedule() and one which just
2253 dnl # uses schedule(). This API change was made to consolidate all of those
2254 dnl # redundant wait functions.
2256 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2257 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2258 SPL_LINUX_TRY_COMPILE([
2259 #include <linux/wait.h>
2261 int (*action)(void *) = NULL;
2262 wait_on_bit(NULL, 0, action, 0);
2265 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])