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
31 SPL_AC_PATH_IN_NAMEIDATA
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
47 SPL_AC_MONOTONIC_CLOCK
50 SPL_AC_MUTEX_OWNER_TASK_STRUCT
51 SPL_AC_MUTEX_LOCK_NESTED
52 SPL_AC_3ARGS_ON_EACH_CPU
53 SPL_AC_KALLSYMS_LOOKUP_NAME
54 SPL_AC_GET_VMALLOC_INFO
56 SPL_AC_FIRST_ONLINE_PGDAT
57 SPL_AC_NEXT_ONLINE_PGDAT
60 SPL_AC_GLOBAL_PAGE_STATE
61 SPL_AC_ZONE_STAT_ITEM_FREE
62 SPL_AC_ZONE_STAT_ITEM_INACTIVE
63 SPL_AC_ZONE_STAT_ITEM_ACTIVE
64 SPL_AC_GET_ZONE_COUNTS
67 SPL_AC_SET_FS_PWD_WITH_CONST
68 SPL_AC_2ARGS_VFS_UNLINK
69 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_2ARGS_VFS_FSYNC
72 SPL_AC_INODE_TRUNCATE_RANGE
73 SPL_AC_FS_STRUCT_SPINLOCK
77 SPL_AC_PUT_TASK_STRUCT
78 SPL_AC_5ARGS_PROC_HANDLER
80 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
81 SPL_AC_KERNEL_FALLOCATE
82 SPL_AC_SHRINK_DCACHE_MEMORY
83 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_KERN_PATH_PARENT_HEADER
85 SPL_AC_KERN_PATH_PARENT_SYMBOL
86 SPL_AC_KERN_PATH_LOCKED
87 SPL_AC_CONFIG_KALLSYMS
88 SPL_AC_CONFIG_ZLIB_INFLATE
89 SPL_AC_CONFIG_ZLIB_DEFLATE
90 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
91 SPL_AC_SHRINK_CONTROL_STRUCT
92 SPL_AC_RWSEM_SPINLOCK_IS_RAW
93 SPL_AC_SCHED_RT_HEADER
94 SPL_AC_2ARGS_VFS_GETATTR
96 SPL_AC_KMEM_CACHE_ALLOCFLAGS
100 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
101 modpost=$LINUX/scripts/Makefile.modpost
102 AC_MSG_CHECKING([kernel file name for module symbols])
103 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
104 if grep -q Modules.symvers $modpost; then
105 LINUX_SYMBOLS=Modules.symvers
107 LINUX_SYMBOLS=Module.symvers
110 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
112 *** Please make sure the kernel devel package for your distribution
113 *** is installed. If you are building with a custom kernel, make sure the
114 *** kernel is configured, built, and the '--with-linux=PATH' configure
115 *** option refers to the location of the kernel source.])
120 AC_MSG_RESULT($LINUX_SYMBOLS)
121 AC_SUBST(LINUX_SYMBOLS)
124 AC_DEFUN([SPL_AC_KERNEL], [
126 AS_HELP_STRING([--with-linux=PATH],
127 [Path to kernel source]),
128 [kernelsrc="$withval"])
130 AC_ARG_WITH([linux-obj],
131 AS_HELP_STRING([--with-linux-obj=PATH],
132 [Path to kernel build objects]),
133 [kernelbuild="$withval"])
135 AC_MSG_CHECKING([kernel source directory])
136 if test -z "$kernelsrc"; then
137 if test -e "/lib/modules/$(uname -r)/source"; then
138 headersdir="/lib/modules/$(uname -r)/source"
139 sourcelink=$(readlink -f "$headersdir")
140 elif test -e "/lib/modules/$(uname -r)/build"; then
141 headersdir="/lib/modules/$(uname -r)/build"
142 sourcelink=$(readlink -f "$headersdir")
144 sourcelink=$(ls -1d /usr/src/kernels/* \
146 2>/dev/null | grep -v obj | tail -1)
149 if test -n "$sourcelink" && test -e ${sourcelink}; then
150 kernelsrc=`readlink -f ${sourcelink}`
152 kernelsrc="[Not found]"
155 if test "$kernelsrc" = "NONE"; then
160 AC_MSG_RESULT([$kernelsrc])
161 if test ! -d "$kernelsrc"; then
163 *** Please make sure the kernel devel package for your distribution
164 *** is installed and then try again. If that fails, you can specify the
165 *** location of the kernel source with the '--with-linux=PATH' option.])
168 AC_MSG_CHECKING([kernel build directory])
169 if test -z "$kernelbuild"; then
170 if test -e "/lib/modules/$(uname -r)/build"; then
171 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
172 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
173 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
174 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
175 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
176 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
177 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
179 kernelbuild=${kernelsrc}
182 AC_MSG_RESULT([$kernelbuild])
184 AC_MSG_CHECKING([kernel source version])
185 utsrelease1=$kernelbuild/include/linux/version.h
186 utsrelease2=$kernelbuild/include/linux/utsrelease.h
187 utsrelease3=$kernelbuild/include/generated/utsrelease.h
188 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
189 utsrelease=linux/version.h
190 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
191 utsrelease=linux/utsrelease.h
192 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
193 utsrelease=generated/utsrelease.h
196 if test "$utsrelease"; then
197 kernsrcver=`(echo "#include <$utsrelease>";
198 echo "kernsrcver=UTS_RELEASE") |
199 cpp -I $kernelbuild/include |
200 grep "^kernsrcver=" | cut -d \" -f 2`
202 if test -z "$kernsrcver"; then
203 AC_MSG_RESULT([Not found])
204 AC_MSG_ERROR([*** Cannot determine kernel version.])
207 AC_MSG_RESULT([Not found])
208 if test "x$enable_linux_builtin" != xyes; then
209 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
212 *** Cannot find UTS_RELEASE definition.
213 *** Please run 'make prepare' inside the kernel source tree.])
217 AC_MSG_RESULT([$kernsrcver])
220 LINUX_OBJ=${kernelbuild}
221 LINUX_VERSION=${kernsrcver}
225 AC_SUBST(LINUX_VERSION)
227 SPL_AC_MODULE_SYMVERS
231 dnl # Default SPL user configuration
233 AC_DEFUN([SPL_AC_CONFIG_USER], [])
236 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
237 dnl # are missing, it is non-fatal, but you will not be able to build
238 dnl # RPM packages and will be warned if you try too.
240 dnl # By default, the generic spec file will be used because it requires
241 dnl # minimal dependencies. Distribution specific spec files can be
242 dnl # placed under the 'rpm/<distribution>' directory and enabled using
243 dnl # the --with-spec=<distribution> configure option.
245 AC_DEFUN([SPL_AC_RPM], [
249 AC_MSG_CHECKING([whether $RPM is available])
250 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
251 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
253 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
256 AC_MSG_RESULT([$HAVE_RPM])
259 AC_MSG_CHECKING([whether $RPMBUILD is available])
260 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
261 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
263 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
266 AC_MSG_RESULT([$HAVE_RPMBUILD])
269 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
271 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
274 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
279 RPM_SPEC_DIR="rpm/generic"
281 AS_HELP_STRING([--with-spec=SPEC],
282 [Spec files 'generic|fedora']),
283 [RPM_SPEC_DIR="rpm/$withval"])
285 AC_MSG_CHECKING([whether spec files are available])
286 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
290 AC_SUBST(RPM_VERSION)
292 AC_SUBST(HAVE_RPMBUILD)
294 AC_SUBST(RPMBUILD_VERSION)
296 AC_SUBST(RPM_SPEC_DIR)
297 AC_SUBST(RPM_DEFINE_UTIL)
298 AC_SUBST(RPM_DEFINE_KMOD)
299 AC_SUBST(RPM_DEFINE_DKMS)
300 AC_SUBST(RPM_DEFINE_COMMON)
301 AC_SUBST(SRPM_DEFINE_UTIL)
302 AC_SUBST(SRPM_DEFINE_KMOD)
303 AC_SUBST(SRPM_DEFINE_DKMS)
304 AC_SUBST(SRPM_DEFINE_COMMON)
308 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
309 dnl # tools are missing it is non-fatal but you will not be able to build
310 dnl # DEB packages and will be warned if you try too.
312 AC_DEFUN([SPL_AC_DPKG], [
314 DPKGBUILD=dpkg-buildpackage
316 AC_MSG_CHECKING([whether $DPKG is available])
317 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
318 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
320 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
323 AC_MSG_RESULT([$HAVE_DPKG])
326 AC_MSG_CHECKING([whether $DPKGBUILD is available])
327 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
328 DPKGBUILD_VERSION=$(echo $tmp | \
329 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
331 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
334 AC_MSG_RESULT([$HAVE_DPKGBUILD])
339 AC_SUBST(DPKG_VERSION)
341 AC_SUBST(HAVE_DPKGBUILD)
343 AC_SUBST(DPKGBUILD_VERSION)
347 dnl # Until native packaging for various different packing systems
348 dnl # can be added the least we can do is attempt to use alien to
349 dnl # convert the RPM packages to the needed package type. This is
350 dnl # a hack but so far it has worked reasonable well.
352 AC_DEFUN([SPL_AC_ALIEN], [
355 AC_MSG_CHECKING([whether $ALIEN is available])
356 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
357 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
359 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
362 AC_MSG_RESULT([$HAVE_ALIEN])
367 AC_SUBST(ALIEN_VERSION)
371 dnl # Using the VENDOR tag from config.guess set the default
372 dnl # package type for 'make pkg': (rpm | deb | tgz)
374 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
375 AC_MSG_CHECKING([linux distribution])
376 if test -f /etc/toss-release ; then
378 elif test -f /etc/fedora-release ; then
380 elif test -f /etc/redhat-release ; then
382 elif test -f /etc/gentoo-release ; then
384 elif test -f /etc/arch-release ; then
386 elif test -f /etc/SuSE-release ; then
388 elif test -f /etc/slackware-version ; then
390 elif test -f /etc/lunar.release ; then
392 elif test -f /etc/lsb-release ; then
394 elif test -f /etc/debian_version ; then
399 AC_MSG_RESULT([$VENDOR])
402 AC_MSG_CHECKING([default package type])
404 toss) DEFAULT_PACKAGE=rpm ;;
405 redhat) DEFAULT_PACKAGE=rpm ;;
406 fedora) DEFAULT_PACKAGE=rpm ;;
407 gentoo) DEFAULT_PACKAGE=tgz ;;
408 arch) DEFAULT_PACKAGE=tgz ;;
409 sles) DEFAULT_PACKAGE=rpm ;;
410 slackware) DEFAULT_PACKAGE=tgz ;;
411 lunar) DEFAULT_PACKAGE=tgz ;;
412 ubuntu) DEFAULT_PACKAGE=deb ;;
413 debian) DEFAULT_PACKAGE=deb ;;
414 *) DEFAULT_PACKAGE=rpm ;;
417 AC_MSG_RESULT([$DEFAULT_PACKAGE])
418 AC_SUBST(DEFAULT_PACKAGE)
422 dnl # Default SPL user configuration
424 AC_DEFUN([SPL_AC_PACKAGE], [
425 SPL_AC_DEFAULT_PACKAGE
431 AC_DEFUN([SPL_AC_LICENSE], [
432 AC_MSG_CHECKING([spl license])
434 AC_MSG_RESULT([$LICENSE])
435 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
439 AC_DEFUN([SPL_AC_CONFIG], [
441 AC_ARG_WITH([config],
442 AS_HELP_STRING([--with-config=CONFIG],
443 [Config file 'kernel|user|all|srpm']),
444 [SPL_CONFIG="$withval"])
445 AC_ARG_ENABLE([linux-builtin],
446 [AC_HELP_STRING([--enable-linux-builtin],
447 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
449 [enable_linux_builtin=no])
451 AC_MSG_CHECKING([spl config])
452 AC_MSG_RESULT([$SPL_CONFIG]);
455 case "$SPL_CONFIG" in
456 kernel) SPL_AC_CONFIG_KERNEL ;;
457 user) SPL_AC_CONFIG_USER ;;
458 all) SPL_AC_CONFIG_KERNEL
459 SPL_AC_CONFIG_USER ;;
462 AC_MSG_RESULT([Error!])
463 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
464 user kernel|user|all|srpm]) ;;
467 AM_CONDITIONAL([CONFIG_USER],
468 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
469 AM_CONDITIONAL([CONFIG_KERNEL],
470 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
471 [test "x$enable_linux_builtin" != xyes ])
475 dnl # Enable if the SPL should be compiled with internal debugging enabled.
476 dnl # By default this support is disabled.
478 AC_DEFUN([SPL_AC_DEBUG], [
479 AC_MSG_CHECKING([whether debugging is enabled])
480 AC_ARG_ENABLE([debug],
481 [AS_HELP_STRING([--enable-debug],
482 [Enable generic debug support @<:@default=no@:>@])],
486 AS_IF([test "x$enable_debug" = xyes],
488 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
489 DEBUG_CFLAGS="-DDEBUG -Werror"
490 DEBUG_SPL="_with_debug"
492 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
493 DEBUG_CFLAGS="-DNDEBUG"
494 DEBUG_SPL="_without_debug"
497 AC_SUBST(DEBUG_CFLAGS)
499 AC_MSG_RESULT([$enable_debug])
503 dnl # Enabled by default it provides a basic debug log infrastructure.
504 dnl # Each subsystem registers itself with a name and logs messages
505 dnl # using predefined types. If the debug mask it set to allow the
506 dnl # message type it will be written to the internal log. The log
507 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
508 dnl # after dumping the log it must be decoded using the spl utility.
510 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
511 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
513 AC_DEFUN([SPL_AC_DEBUG_LOG], [
514 AC_ARG_ENABLE([debug-log],
515 [AS_HELP_STRING([--enable-debug-log],
516 [Enable basic debug logging @<:@default=yes@:>@])],
518 [enable_debug_log=yes])
520 AS_IF([test "x$enable_debug_log" = xyes],
522 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
523 DEBUG_LOG="_with_debug_log"
524 AC_DEFINE([DEBUG_LOG], [1],
525 [Define to 1 to enable basic debug logging])
527 DEBUG_LOG="_without_debug_log"
531 AC_MSG_CHECKING([whether basic debug logging is enabled])
532 AC_MSG_RESULT([$enable_debug_log])
536 dnl # Enabled by default it provides a minimal level of memory tracking.
537 dnl # A total count of bytes allocated is kept for each alloc and free.
538 dnl # Then at module unload time a report to the console will be printed
539 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
540 dnl # and provide an easy way to inspect the kmem based slab.
542 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
543 AC_ARG_ENABLE([debug-kmem],
544 [AS_HELP_STRING([--enable-debug-kmem],
545 [Enable basic kmem accounting @<:@default=yes@:>@])],
547 [enable_debug_kmem=yes])
549 AS_IF([test "x$enable_debug_kmem" = xyes],
551 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
552 DEBUG_KMEM="_with_debug_kmem"
553 AC_DEFINE([DEBUG_KMEM], [1],
554 [Define to 1 to enable basic kmem accounting])
556 DEBUG_KMEM="_without_debug_kmem"
560 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
561 AC_MSG_RESULT([$enable_debug_kmem])
565 dnl # Disabled by default it provides detailed memory tracking. This
566 dnl # feature also requires --enable-debug-kmem to be set. When enabled
567 dnl # not only will total bytes be tracked but also the location of every
568 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
569 dnl # addresses and where they were allocated will be dumped to the console.
570 dnl # Enabling this feature has a significant impact on performance but it
571 dnl # makes finding memory leaks pretty straight forward.
573 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
574 AC_ARG_ENABLE([debug-kmem-tracking],
575 [AS_HELP_STRING([--enable-debug-kmem-tracking],
576 [Enable detailed kmem tracking @<:@default=no@:>@])],
578 [enable_debug_kmem_tracking=no])
580 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
582 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
583 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
584 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
585 [Define to 1 to enable detailed kmem tracking])
587 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
590 AC_SUBST(DEBUG_KMEM_TRACKING)
591 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
592 AC_MSG_RESULT([$enable_debug_kmem_tracking])
596 dnl # SPL_LINUX_CONFTEST
598 AC_DEFUN([SPL_LINUX_CONFTEST], [
599 cat confdefs.h - <<_ACEOF >conftest.c
605 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
607 m4_define([SPL_LANG_PROGRAM], [
612 dnl Do *not* indent the following line: there may be CPP directives.
613 dnl Don't move the `;' right after for the same reason.
621 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
623 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
624 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
625 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
626 echo "obj-m := conftest.o" >build/Makefile
628 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
630 [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])],
632 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
638 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
640 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
641 [SPL_LINUX_COMPILE_IFELSE(
642 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
644 [test -s build/conftest.o],
649 dnl # SPL_CHECK_SYMBOL_EXPORT
650 dnl # check symbol exported or not
652 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
653 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
654 $LINUX_OBJ/Module*.symvers 2>/dev/null
656 if test $rc -ne 0; then
659 grep -q -E "EXPORT_SYMBOL.*($1)" \
660 "$LINUX_OBJ/$file" 2>/dev/null
662 if test $rc -eq 0; then
667 if test $export -eq 0; then :
678 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
679 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
680 dnl # is called if not compiling for builtin
682 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
683 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
684 if test $rc -ne 0; then :
687 if test "x$enable_linux_builtin" != xyes; then
688 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
690 if test $rc -ne 0; then :
699 dnl # SPL_CHECK_SYMBOL_HEADER
700 dnl # check if a symbol prototype is defined in listed headers.
702 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
703 AC_MSG_CHECKING([whether symbol $1 exists in header])
706 grep -q "$2" "$LINUX/$file" 2>/dev/null
708 if test $rc -eq 0; then
713 if test $header -eq 0; then
723 dnl # SPL_CHECK_HEADER
724 dnl # check whether header exists and define HAVE_$2_HEADER
726 AC_DEFUN([SPL_CHECK_HEADER],
727 [AC_MSG_CHECKING([whether header $1 exists])
728 SPL_LINUX_TRY_COMPILE([
733 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
743 dnl # Basic toolchain sanity check.
745 AC_DEFUN([SPL_AC_TEST_MODULE],
746 [AC_MSG_CHECKING([whether modules can be built])
747 SPL_LINUX_TRY_COMPILE([],[],[
751 if test "x$enable_linux_builtin" != xyes; then
752 AC_MSG_ERROR([*** Unable to build an empty module.])
755 *** Unable to build an empty module.
756 *** Please run 'make scripts' inside the kernel source tree.])
762 dnl # Use the atomic implemenation based on global spinlocks. This
763 dnl # should only be needed by 32-bit kernels which do not provide
764 dnl # the atomic64_* API. It may be optionally enabled as a fallback
765 dnl # if problems are observed with the direct mapping to the native
766 dnl # Linux atomic operations. You may not disable atomic spinlocks
767 dnl # if you kernel does not an atomic64_* API.
769 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
770 AC_ARG_ENABLE([atomic-spinlocks],
771 [AS_HELP_STRING([--enable-atomic-spinlocks],
772 [Atomic types use spinlocks @<:@default=check@:>@])],
774 [enable_atomic_spinlocks=check])
776 SPL_LINUX_TRY_COMPILE([
777 #include <linux/fs.h>
779 atomic64_t *ptr __attribute__ ((unused));
782 AC_DEFINE(HAVE_ATOMIC64_T, 1,
783 [kernel defines atomic64_t])
788 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
789 AS_IF([test "x$have_atomic64_t" = xyes], [
790 enable_atomic_spinlocks=no
792 enable_atomic_spinlocks=yes
796 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
797 AC_DEFINE([ATOMIC_SPINLOCK], [1],
798 [Atomic types use spinlocks])
800 AS_IF([test "x$have_atomic64_t" = xno], [
802 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
806 AC_MSG_CHECKING([whether atomic types use spinlocks])
807 AC_MSG_RESULT([$enable_atomic_spinlocks])
809 AC_MSG_CHECKING([whether kernel defines atomic64_t])
810 AC_MSG_RESULT([$have_atomic64_t])
814 dnl # 2.6.24 API change,
815 dnl # check if atomic64_cmpxchg is defined
817 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
818 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
819 SPL_LINUX_TRY_COMPILE([
820 #include <linux/fs.h>
822 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
825 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
826 [kernel defines atomic64_cmpxchg])
833 dnl # 2.6.24 API change,
834 dnl # check if atomic64_xchg is defined
836 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
837 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
838 SPL_LINUX_TRY_COMPILE([
839 #include <linux/fs.h>
841 atomic64_xchg((atomic64_t *)NULL, 0);
844 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
845 [kernel defines atomic64_xchg])
852 dnl # 2.6.24 API change,
853 dnl # check if uintptr_t typedef is defined
855 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
856 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
857 SPL_LINUX_TRY_COMPILE([
858 #include <linux/types.h>
860 uintptr_t *ptr __attribute__ ((unused));
863 AC_DEFINE(HAVE_UINTPTR_T, 1,
864 [kernel defines uintptr_t])
871 dnl # 2.6.21 API change,
872 dnl # 'register_sysctl_table' use only one argument instead of two
874 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
875 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
876 SPL_LINUX_TRY_COMPILE([
877 #include <linux/sysctl.h>
879 (void) register_sysctl_table(NULL, 0);
882 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
883 [register_sysctl_table() wants 2 args])
889 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
890 tmp_flags="$EXTRA_KCFLAGS"
891 EXTRA_KCFLAGS="-Werror"
893 dnl # 2.6.23 to 2.6.34 API change
894 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
896 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
897 SPL_LINUX_TRY_COMPILE([
898 #include <linux/mm.h>
900 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
902 struct shrinker cache_shrinker = {
903 .shrink = shrinker_cb,
904 .seeks = DEFAULT_SEEKS,
906 register_shrinker(&cache_shrinker);
909 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
910 [old shrinker callback wants 2 args])
914 dnl # 2.6.35 - 2.6.39 API change
915 dnl # ->shrink(struct shrinker *,
916 dnl # int nr_to_scan, gfp_t gfp_mask)
918 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
919 SPL_LINUX_TRY_COMPILE([
920 #include <linux/mm.h>
922 int shrinker_cb(struct shrinker *, int nr_to_scan,
925 struct shrinker cache_shrinker = {
926 .shrink = shrinker_cb,
927 .seeks = DEFAULT_SEEKS,
929 register_shrinker(&cache_shrinker);
932 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
933 [old shrinker callback wants 3 args])
937 dnl # 3.0 - 3.11 API change
938 dnl # ->shrink(struct shrinker *,
939 dnl # struct shrink_control *sc)
942 [whether new 2-argument shrinker exists])
943 SPL_LINUX_TRY_COMPILE([
944 #include <linux/mm.h>
946 int shrinker_cb(struct shrinker *,
947 struct shrink_control *sc);
949 struct shrinker cache_shrinker = {
950 .shrink = shrinker_cb,
951 .seeks = DEFAULT_SEEKS,
953 register_shrinker(&cache_shrinker);
956 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
957 [new shrinker callback wants 2 args])
961 dnl # 3.12 API change,
962 dnl # ->shrink() is logically split in to
963 dnl # ->count_objects() and ->scan_objects()
966 [whether ->count_objects callback exists])
967 SPL_LINUX_TRY_COMPILE([
968 #include <linux/mm.h>
970 unsigned long shrinker_cb(
972 struct shrink_control *sc);
974 struct shrinker cache_shrinker = {
975 .count_objects = shrinker_cb,
976 .scan_objects = shrinker_cb,
977 .seeks = DEFAULT_SEEKS,
979 register_shrinker(&cache_shrinker);
982 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
983 1, [->count_objects exists])
990 EXTRA_KCFLAGS="$tmp_flags"
994 dnl # 2.6.25 API change,
995 dnl # struct path entry added to struct nameidata
997 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
998 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
999 SPL_LINUX_TRY_COMPILE([
1000 #include <linux/namei.h>
1002 struct nameidata nd __attribute__ ((unused));
1005 nd.path.dentry = NULL;
1008 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
1009 [struct path used in struct nameidata])
1016 dnl # Custom SPL patch may export this system it is not required
1018 AC_DEFUN([SPL_AC_TASK_CURR],
1019 [AC_MSG_CHECKING([whether task_curr() is available])
1020 SPL_LINUX_TRY_COMPILE_SYMBOL([
1021 #include <linux/sched.h>
1024 ], [task_curr], [kernel/sched.c], [
1026 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1033 dnl # 2.6.19 API change,
1034 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1036 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1037 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1038 SPL_LINUX_TRY_COMPILE([
1039 #include <linux/sysctl.h>
1041 #ifndef CTL_UNNUMBERED
1042 #error CTL_UNNUMBERED undefined
1046 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1047 [unnumbered sysctl support exists])
1054 dnl # 2.6.33 API change,
1055 dnl # Removed .ctl_name from struct ctl_table.
1057 AC_DEFUN([SPL_AC_CTL_NAME], [
1058 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1059 SPL_LINUX_TRY_COMPILE([
1060 #include <linux/sysctl.h>
1062 struct ctl_table ctl __attribute__ ((unused));
1066 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1073 dnl # 2.6.16 API change.
1074 dnl # Check if 'fls64()' is available
1076 AC_DEFUN([SPL_AC_FLS64],
1077 [AC_MSG_CHECKING([whether fls64() is available])
1078 SPL_LINUX_TRY_COMPILE([
1079 #include <linux/bitops.h>
1084 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1091 dnl # 2.6.18 API change, check whether device_create() is available.
1092 dnl # Device_create() was introduced in 2.6.18 and depricated
1093 dnl # class_device_create() which was fully removed in 2.6.26.
1095 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1096 [AC_MSG_CHECKING([whether device_create() is available])
1097 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1099 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1100 [device_create() is available])
1107 dnl # 2.6.27 API change,
1108 dnl # device_create() uses 5 args, new 'drvdata' argument.
1110 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1111 AC_MSG_CHECKING([whether device_create() wants 5 args])
1112 tmp_flags="$EXTRA_KCFLAGS"
1113 EXTRA_KCFLAGS="-Werror"
1114 SPL_LINUX_TRY_COMPILE([
1115 #include <linux/device.h>
1117 device_create(NULL, NULL, 0, NULL, "%d", 1);
1120 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1121 [device_create wants 5 args])
1125 EXTRA_KCFLAGS="$tmp_flags"
1129 dnl # 2.6.13 API change, check whether class_device_create() is available.
1130 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1131 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1133 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1134 [AC_MSG_CHECKING([whether class_device_create() is available])
1135 SPL_LINUX_TRY_COMPILE_SYMBOL([
1136 #include <linux/device.h>
1138 class_device_create(NULL, NULL, 0, NULL, NULL);
1139 ], [class_device_create], [drivers/base/class.c], [
1141 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1142 [class_device_create() is available])
1149 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1151 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1152 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1153 SPL_LINUX_TRY_COMPILE_SYMBOL([
1154 #include <linux/time.h>
1156 set_normalized_timespec(NULL, 0, 0);
1157 ], [set_normalized_timespec], [kernel/time.c], [
1159 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1160 [set_normalized_timespec() is available as export])
1167 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1168 dnl # previously it was available in time.h as an inline.
1170 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1171 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1172 SPL_LINUX_TRY_COMPILE([
1173 #include <linux/time.h>
1174 void set_normalized_timespec(struct timespec *ts,
1175 time_t sec, long nsec) { }
1182 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1183 [set_normalized_timespec() is available as inline])
1188 dnl # 2.6.18 API change,
1189 dnl # timespec_sub() inline function available in linux/time.h
1191 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1192 AC_MSG_CHECKING([whether timespec_sub() is available])
1193 SPL_LINUX_TRY_COMPILE([
1194 #include <linux/time.h>
1196 struct timespec a = { 0 };
1197 struct timespec b = { 0 };
1198 struct timespec c __attribute__ ((unused));
1199 c = timespec_sub(a, b);
1202 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1209 dnl # 2.6.19 API change,
1210 dnl # check if init_utsname() is available in linux/utsname.h
1212 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1213 AC_MSG_CHECKING([whether init_utsname() is available])
1214 SPL_LINUX_TRY_COMPILE([
1215 #include <linux/utsname.h>
1217 struct new_utsname *a __attribute__ ((unused));
1221 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1228 dnl # 2.6.18 API change,
1229 dnl # added linux/uaccess.h
1231 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1232 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1236 dnl # 2.6.12 API change,
1237 dnl # check whether 'kmalloc_node()' is available.
1239 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1240 AC_MSG_CHECKING([whether kmalloc_node() is available])
1241 SPL_LINUX_TRY_COMPILE([
1242 #include <linux/slab.h>
1244 void *a __attribute__ ((unused));
1245 a = kmalloc_node(1, GFP_KERNEL, 0);
1248 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1255 dnl # 2.6.9 API change,
1256 dnl # check whether 'monotonic_clock()' is available it may
1257 dnl # be available for some archs but not others.
1259 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1260 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1261 SPL_LINUX_TRY_COMPILE_SYMBOL([
1262 #include <linux/timex.h>
1265 ], [monotonic_clock], [], [
1267 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1268 [monotonic_clock() is available])
1275 dnl # 2.6.16 API change,
1276 dnl # check whether 'struct inode' has i_mutex
1278 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1279 AC_MSG_CHECKING([whether struct inode has i_mutex])
1280 SPL_LINUX_TRY_COMPILE([
1281 #include <linux/fs.h>
1282 #include <linux/mutex.h>
1285 mutex_init(&i.i_mutex);
1288 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1295 dnl # 2.6.29 API change,
1296 dnl # Adaptive mutexs introduced.
1298 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1299 AC_MSG_CHECKING([whether struct mutex has owner])
1300 SPL_LINUX_TRY_COMPILE([
1301 #include <linux/mutex.h>
1303 struct mutex mtx __attribute__ ((unused));
1307 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1314 dnl # 2.6.39 API change,
1315 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1316 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1317 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1318 dnl # pointer which frankly makes a lot more sense.
1320 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1321 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1322 tmp_flags="$EXTRA_KCFLAGS"
1323 EXTRA_KCFLAGS="-Werror"
1324 SPL_LINUX_TRY_COMPILE([
1325 #include <linux/mutex.h>
1326 #include <linux/sched.h>
1328 struct mutex mtx __attribute__ ((unused));
1329 mtx.owner = current;
1332 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1333 [struct mutex owner is a task_struct])
1337 EXTRA_KCFLAGS="$tmp_flags"
1341 dnl # 2.6.18 API change,
1342 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1343 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1344 dnl # if the mutex validator is disabled or otherwise unavailable.
1346 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1347 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1348 SPL_LINUX_TRY_COMPILE([
1349 #include <linux/mutex.h>
1353 mutex_lock_nested(&mutex, 0);
1356 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1357 [mutex_lock_nested() is available])
1364 dnl # 2.6.27 API change,
1365 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1367 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1368 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1369 SPL_LINUX_TRY_COMPILE([
1370 #include <linux/interrupt.h>
1371 #include <linux/smp.h>
1373 void on_each_cpu_func(void *data) { return; }
1375 on_each_cpu(on_each_cpu_func, NULL, 0);
1378 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1379 [on_each_cpu wants 3 args])
1386 dnl # 2.6.18 API change,
1387 dnl # kallsyms_lookup_name no longer exported
1389 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1390 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1391 SPL_LINUX_TRY_COMPILE_SYMBOL([
1392 #include <linux/kallsyms.h>
1394 kallsyms_lookup_name(NULL);
1395 ], [kallsyms_lookup_name], [], [
1397 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1398 [kallsyms_lookup_name() is available])
1405 dnl # Proposed API change,
1406 dnl # This symbol is not available in stock kernels. You may build a
1407 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1408 dnl # these symbols for use. If your already rolling a custom kernel for
1409 dnl # your environment this is recommended.
1411 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1412 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1413 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1415 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1416 [get_vmalloc_info() is available])
1423 dnl # 3.10 API change,
1424 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1426 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1427 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1428 SPL_LINUX_TRY_COMPILE([
1429 #include <linux/vmalloc.h>
1430 struct vmalloc_info { void *a; };
1437 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1442 dnl # 3.10 API change,
1443 dnl # PDE is replaced by PDE_DATA
1445 AC_DEFUN([SPL_AC_PDE_DATA], [
1446 AC_MSG_CHECKING([whether PDE_DATA() is available])
1447 SPL_LINUX_TRY_COMPILE_SYMBOL([
1448 #include <linux/proc_fs.h>
1451 ], [PDE_DATA], [], [
1453 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1460 dnl # 2.6.17 API change
1461 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1462 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1463 dnl # were exported in 2.6.17 for use by modules which was consistent with
1464 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1465 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1466 dnl # were dropped entirely leaving modules no way to directly iterate over
1467 dnl # the zone list. Because we need access to the zone helpers we check
1468 dnl # if the kernel contains the old or new implementation. Then we check
1469 dnl # to see if the symbols we need for each version are available. If they
1470 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1472 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1473 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1474 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1476 if test $rc -eq 0; then
1477 AC_MSG_RESULT([yes])
1478 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1485 dnl # Proposed API change,
1486 dnl # This symbol is not available in stock kernels. You may build a
1487 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1488 dnl # these symbols for use. If your already rolling a custom kernel for
1489 dnl # your environment this is recommended.
1491 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1492 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1493 SPL_LINUX_TRY_COMPILE_SYMBOL([
1494 #include <linux/mmzone.h>
1496 first_online_pgdat();
1497 ], [first_online_pgdat], [], [
1499 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1500 [first_online_pgdat() is available])
1507 dnl # Proposed API change,
1508 dnl # This symbol is not available in stock kernels. You may build a
1509 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1510 dnl # these symbols for use. If your already rolling a custom kernel for
1511 dnl # your environment this is recommended.
1513 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1514 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1515 SPL_LINUX_TRY_COMPILE_SYMBOL([
1516 #include <linux/mmzone.h>
1518 next_online_pgdat(NULL);
1519 ], [next_online_pgdat], [], [
1521 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1522 [next_online_pgdat() is available])
1529 dnl # Proposed API change,
1530 dnl # This symbol is not available in stock kernels. You may build a
1531 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1532 dnl # these symbols for use. If your already rolling a custom kernel for
1533 dnl # your environment this is recommended.
1535 AC_DEFUN([SPL_AC_NEXT_ZONE],
1536 [AC_MSG_CHECKING([whether next_zone() is available])
1537 SPL_LINUX_TRY_COMPILE_SYMBOL([
1538 #include <linux/mmzone.h>
1541 ], [next_zone], [], [
1543 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1550 dnl # 2.6.17 API change,
1551 dnl # See SPL_AC_PGDAT_HELPERS for details.
1553 AC_DEFUN([SPL_AC_PGDAT_LIST],
1554 [AC_MSG_CHECKING([whether pgdat_list is available])
1555 SPL_LINUX_TRY_COMPILE_SYMBOL([
1556 #include <linux/topology.h>
1557 pg_data_t *tmp = pgdat_list;
1558 ], [], [pgdat_list], [], [
1560 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1567 dnl # 2.6.18 API change,
1568 dnl # First introduced global_page_state() support as an inline.
1570 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1571 AC_MSG_CHECKING([whether global_page_state() is available])
1572 SPL_LINUX_TRY_COMPILE([
1573 #include <linux/mm.h>
1575 unsigned long state __attribute__ ((unused));
1576 state = global_page_state(0);
1579 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1580 [global_page_state() is available])
1587 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1588 dnl # Public global zone stats now include a free page count. However
1589 dnl # the enumerated names of the counters have changed since this API
1590 dnl # was introduced. We need to deduce the corrent name to use. This
1591 dnl # replaces the priviate get_zone_counts() interface.
1593 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1594 dnl # is 2.6.30 as of when this was written.
1596 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1597 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1598 SPL_LINUX_TRY_COMPILE([
1599 #include <linux/mm.h>
1601 enum zone_stat_item zsi __attribute__ ((unused));
1602 zsi = NR_FREE_PAGES;
1605 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1606 [Page state NR_FREE_PAGES is available])
1613 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1614 dnl # Public global zone stats now include an inactive page count. However
1615 dnl # the enumerated names of the counters have changed since this API
1616 dnl # was introduced. We need to deduce the corrent name to use. This
1617 dnl # replaces the priviate get_zone_counts() interface.
1619 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1620 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1621 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1623 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1624 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1625 SPL_LINUX_TRY_COMPILE([
1626 #include <linux/mm.h>
1628 enum zone_stat_item zsi __attribute__ ((unused));
1632 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1633 [Page state NR_INACTIVE is available])
1638 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1639 SPL_LINUX_TRY_COMPILE([
1640 #include <linux/mm.h>
1642 enum zone_stat_item zsi __attribute__ ((unused));
1643 zsi = NR_INACTIVE_ANON;
1646 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1647 [Page state NR_INACTIVE_ANON is available])
1652 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1653 SPL_LINUX_TRY_COMPILE([
1654 #include <linux/mm.h>
1656 enum zone_stat_item zsi __attribute__ ((unused));
1657 zsi = NR_INACTIVE_FILE;
1660 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1661 [Page state NR_INACTIVE_FILE is available])
1668 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1669 dnl # Public global zone stats now include an active page count. However
1670 dnl # the enumerated names of the counters have changed since this API
1671 dnl # was introduced. We need to deduce the corrent name to use. This
1672 dnl # replaces the priviate get_zone_counts() interface.
1674 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1675 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1676 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1678 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1679 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1680 SPL_LINUX_TRY_COMPILE([
1681 #include <linux/mm.h>
1683 enum zone_stat_item zsi __attribute__ ((unused));
1687 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1688 [Page state NR_ACTIVE is available])
1693 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1694 SPL_LINUX_TRY_COMPILE([
1695 #include <linux/mm.h>
1697 enum zone_stat_item zsi __attribute__ ((unused));
1698 zsi = NR_ACTIVE_ANON;
1701 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1702 [Page state NR_ACTIVE_ANON is available])
1707 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1708 SPL_LINUX_TRY_COMPILE([
1709 #include <linux/mm.h>
1711 enum zone_stat_item zsi __attribute__ ((unused));
1712 zsi = NR_ACTIVE_FILE;
1715 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1716 [Page state NR_ACTIVE_FILE is available])
1723 dnl # Proposed API change for legacy kernels.
1724 dnl # This symbol is not available in older kernels. For kernels post
1725 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1726 dnl # page state information. This symbol is only used in legacy kernels
1727 dnl # any only as a last resort.
1729 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1730 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1731 SPL_LINUX_TRY_COMPILE([
1733 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1734 #error "global_page_state needs NR_FREE_PAGES"
1737 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1738 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1739 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1740 #error "global_page_state needs NR_ACTIVE*"
1743 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1744 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1745 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1746 #error "global_page_state needs NR_INACTIVE*"
1752 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1753 [get_zone_counts() is needed])
1755 AC_MSG_CHECKING([whether get_zone_counts() is available])
1756 SPL_LINUX_TRY_COMPILE_SYMBOL([
1757 #include <linux/mmzone.h>
1759 get_zone_counts(NULL, NULL, NULL);
1760 ], [get_zone_counts], [], [
1762 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1763 [get_zone_counts() is available])
1771 dnl # 2.6.27 API change,
1772 dnl # The user_path_dir() replaces __user_walk()
1774 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1775 [AC_MSG_CHECKING([whether user_path_dir() is available])
1776 SPL_LINUX_TRY_COMPILE_SYMBOL([
1777 #include <linux/fcntl.h>
1778 #include <linux/namei.h>
1780 user_path_dir(NULL, NULL);
1781 ], [user_path_at], [], [
1783 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1790 dnl # Symbol available in RHEL kernels not in stock kernels.
1792 AC_DEFUN([SPL_AC_SET_FS_PWD],
1793 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1794 SPL_LINUX_TRY_COMPILE_SYMBOL([
1795 #include <linux/spinlock.h>
1796 #include <linux/fs_struct.h>
1799 ], [set_fs_pwd], [], [
1801 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1808 dnl # 3.9 API change
1809 dnl # set_fs_pwd takes const struct path *
1811 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1812 tmp_flags="$EXTRA_KCFLAGS"
1813 EXTRA_KCFLAGS="-Werror"
1814 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1815 SPL_LINUX_TRY_COMPILE([
1816 #include <linux/spinlock.h>
1817 #include <linux/fs_struct.h>
1818 #include <linux/path.h>
1819 void (*const set_fs_pwd_func)
1820 (struct fs_struct *, const struct path *)
1826 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1827 [set_fs_pwd() needs const path *])
1829 SPL_LINUX_TRY_COMPILE([
1830 #include <linux/spinlock.h>
1831 #include <linux/fs_struct.h>
1832 #include <linux/path.h>
1833 void (*const set_fs_pwd_func)
1834 (struct fs_struct *, struct path *)
1841 AC_MSG_ERROR(unknown)
1844 EXTRA_KCFLAGS="$tmp_flags"
1847 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1848 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1849 SPL_LINUX_TRY_COMPILE([
1850 #include <linux/fs.h>
1852 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1855 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1856 [vfs_unlink() wants 2 args])
1860 dnl # Linux 3.13 API change
1861 dnl # Added delegated inode
1863 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1864 SPL_LINUX_TRY_COMPILE([
1865 #include <linux/fs.h>
1867 vfs_unlink((struct inode *) NULL,
1868 (struct dentry *) NULL,
1869 (struct inode **) NULL);
1872 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1873 [vfs_unlink() wants 3 args])
1881 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1882 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1883 SPL_LINUX_TRY_COMPILE([
1884 #include <linux/fs.h>
1886 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1887 (struct inode *) NULL, (struct dentry *) NULL);
1890 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1891 [vfs_rename() wants 4 args])
1895 dnl # Linux 3.13 API change
1896 dnl # Added delegated inode
1898 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1899 SPL_LINUX_TRY_COMPILE([
1900 #include <linux/fs.h>
1902 vfs_rename((struct inode *) NULL,
1903 (struct dentry *) NULL,
1904 (struct inode *) NULL,
1905 (struct dentry *) NULL,
1906 (struct inode **) NULL);
1909 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1910 [vfs_rename() wants 5 args])
1914 dnl # Linux 3.15 API change
1917 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1918 SPL_LINUX_TRY_COMPILE([
1919 #include <linux/fs.h>
1921 vfs_rename((struct inode *) NULL,
1922 (struct dentry *) NULL,
1923 (struct inode *) NULL,
1924 (struct dentry *) NULL,
1925 (struct inode **) NULL,
1929 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1930 [vfs_rename() wants 6 args])
1939 dnl # 2.6.36 API change,
1940 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1941 dnl # a spinlock_t to improve the fastpath performance.
1943 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1944 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1945 tmp_flags="$EXTRA_KCFLAGS"
1946 EXTRA_KCFLAGS="-Werror"
1947 SPL_LINUX_TRY_COMPILE([
1948 #include <linux/sched.h>
1949 #include <linux/fs_struct.h>
1951 struct fs_struct fs;
1952 spin_lock_init(&fs.lock);
1955 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1956 [struct fs_struct uses spinlock_t])
1960 EXTRA_KCFLAGS="$tmp_flags"
1964 dnl # 2.6.29 API change,
1965 dnl # check whether 'struct cred' exists
1967 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1968 AC_MSG_CHECKING([whether struct cred exists])
1969 SPL_LINUX_TRY_COMPILE([
1970 #include <linux/cred.h>
1972 struct cred *cr __attribute__ ((unused));
1976 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1984 dnl # User namespaces, use kuid_t in place of uid_t
1985 dnl # where available. Not strictly a user namespaces thing
1986 dnl # but it should prevent surprises
1988 AC_DEFUN([SPL_AC_KUIDGID_T], [
1989 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1990 SPL_LINUX_TRY_COMPILE([
1991 #include <linux/uidgid.h>
1993 kuid_t userid = KUIDT_INIT(0);
1994 kgid_t groupid = KGIDT_INIT(0);
1996 SPL_LINUX_TRY_COMPILE([
1997 #include <linux/uidgid.h>
2002 AC_MSG_RESULT(yes; optional)
2004 AC_MSG_RESULT(yes; mandatory)
2005 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
2013 dnl # Custom SPL patch may export this symbol.
2015 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
2016 [AC_MSG_CHECKING([whether groups_search() is available])
2017 SPL_LINUX_TRY_COMPILE_SYMBOL([
2018 #include <linux/cred.h>
2019 #ifdef HAVE_KUIDGID_T
2020 #include <linux/uidgid.h>
2023 #ifdef HAVE_KUIDGID_T
2024 groups_search(NULL, KGIDT_INIT(0));
2026 groups_search(NULL, 0);
2028 ], [groups_search], [], [
2030 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
2037 dnl # 2.6.x API change,
2038 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
2040 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
2041 [AC_MSG_CHECKING([whether __put_task_struct() is available])
2042 SPL_LINUX_TRY_COMPILE_SYMBOL([
2043 #include <linux/sched.h>
2045 __put_task_struct(NULL);
2046 ], [__put_task_struct], [], [
2048 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
2049 [__put_task_struct() is available])
2056 dnl # 2.6.32 API change,
2057 dnl # Unused 'struct file *' removed from prototype.
2059 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
2060 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
2061 SPL_LINUX_TRY_COMPILE([
2062 #include <linux/sysctl.h>
2064 proc_dostring(NULL, 0, NULL, NULL, NULL);
2067 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
2068 [proc_handler() wants 5 args])
2075 dnl # 2.6.x API change,
2076 dnl # kvasprintf() function added.
2078 AC_DEFUN([SPL_AC_KVASPRINTF],
2079 [AC_MSG_CHECKING([whether kvasprintf() is available])
2080 SPL_LINUX_TRY_COMPILE_SYMBOL([
2081 #include <linux/kernel.h>
2083 kvasprintf(0, NULL, *((va_list*)NULL));
2084 ], [kvasprintf], [], [
2086 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
2093 dnl # 2.6.29 API change,
2094 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
2096 AC_DEFUN([SPL_AC_VFS_FSYNC],
2097 [AC_MSG_CHECKING([whether vfs_fsync() is available])
2098 SPL_LINUX_TRY_COMPILE_SYMBOL([
2099 #include <linux/fs.h>
2102 ], [vfs_fsync], [fs/sync.c], [
2104 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2111 dnl # 2.6.35 API change,
2112 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2114 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2115 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2116 SPL_LINUX_TRY_COMPILE([
2117 #include <linux/fs.h>
2122 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2129 dnl # 3.5 API change,
2130 dnl # inode_operations.truncate_range removed
2132 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2133 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2134 SPL_LINUX_TRY_COMPILE([
2135 #include <linux/fs.h>
2137 struct inode_operations ops;
2138 ops.truncate_range = NULL;
2141 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2142 [truncate_range() inode operation is available])
2149 dnl # Linux 2.6.38 - 3.x API
2151 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2152 AC_MSG_CHECKING([whether fops->fallocate() exists])
2153 SPL_LINUX_TRY_COMPILE([
2154 #include <linux/fs.h>
2156 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2157 struct file_operations fops __attribute__ ((unused)) = {
2158 .fallocate = fallocate,
2162 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2169 dnl # Linux 2.6.x - 2.6.37 API
2171 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2172 AC_MSG_CHECKING([whether iops->fallocate() exists])
2173 SPL_LINUX_TRY_COMPILE([
2174 #include <linux/fs.h>
2176 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2177 struct inode_operations fops __attribute__ ((unused)) = {
2178 .fallocate = fallocate,
2182 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2189 dnl # PaX Linux 2.6.38 - 3.x API
2191 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2192 AC_MSG_CHECKING([whether fops->fallocate() exists])
2193 SPL_LINUX_TRY_COMPILE([
2194 #include <linux/fs.h>
2196 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2197 struct file_operations_no_const fops __attribute__ ((unused)) = {
2198 .fallocate = fallocate,
2202 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2209 dnl # The fallocate callback was moved from the inode_operations
2210 dnl # structure to the file_operations structure.
2212 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2213 SPL_AC_KERNEL_FILE_FALLOCATE
2214 SPL_AC_KERNEL_INODE_FALLOCATE
2215 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2219 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2220 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2221 dnl # condition. The fixed version is exported as a symbol. The race
2222 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2223 dnl # call that version while holding sem->wait_lock.
2225 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2226 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2227 SPL_LINUX_TRY_COMPILE_SYMBOL([
2228 #include <linux/rwsem.h>
2229 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2230 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2232 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2233 [rwsem_is_locked() acquires sem->wait_lock])
2240 dnl # 2.6.xx API compat,
2241 dnl # There currently exists no exposed API to partially shrink the dcache.
2242 dnl # The expected mechanism to shrink the cache is a registered shrinker
2243 dnl # which is called during memory pressure.
2245 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2246 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2247 SPL_LINUX_TRY_COMPILE_SYMBOL([
2248 #include <linux/dcache.h>
2250 shrink_dcache_memory(0, 0);
2251 ], [shrink_dcache_memory], [fs/dcache.c], [
2253 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2254 [shrink_dcache_memory() is available])
2261 dnl # 2.6.xx API compat,
2262 dnl # There currently exists no exposed API to partially shrink the icache.
2263 dnl # The expected mechanism to shrink the cache is a registered shrinker
2264 dnl # which is called during memory pressure.
2266 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2267 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2268 SPL_LINUX_TRY_COMPILE_SYMBOL([
2269 #include <linux/dcache.h>
2271 shrink_icache_memory(0, 0);
2272 ], [shrink_icache_memory], [fs/inode.c], [
2274 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2275 [shrink_icache_memory() is available])
2282 dnl # 2.6.39 API compat,
2283 dnl # The path_lookup() function has been renamed to kern_path_parent()
2284 dnl # and the flags argument has been removed. The only behavior now
2285 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2286 dnl # this flag so dropping the flag does not impact us.
2288 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2289 SPL_CHECK_SYMBOL_HEADER(
2291 [int kern_path_parent(const char \*, struct nameidata \*)],
2292 [include/linux/namei.h],
2293 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2294 [kern_path_parent() is available])],
2299 dnl # 3.1 API compat,
2300 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2301 dnl # However, it remains the prefered interface and since we still have
2302 dnl # access to the prototype we dynamically lookup the required address.
2304 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2305 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2306 SPL_LINUX_TRY_COMPILE_SYMBOL([
2307 #include <linux/namei.h>
2309 kern_path_parent(NULL, NULL);
2310 ], [kern_path_parent], [fs/namei.c], [
2312 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2313 [kern_path_parent() is available])
2320 dnl # 3.6 API compat,
2321 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2322 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2324 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2325 SPL_CHECK_SYMBOL_HEADER(
2327 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2328 [include/linux/namei.h],
2329 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2330 [kern_path_locked() is available])],
2335 dnl # /proc/kallsyms support,
2336 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2338 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2339 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2340 SPL_LINUX_TRY_COMPILE([
2341 #if !defined(CONFIG_KALLSYMS)
2342 #error CONFIG_KALLSYMS not defined
2345 AC_MSG_RESULT([yes])
2349 *** This kernel does not include the required kallsyms support.
2350 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2355 dnl # zlib inflate compat,
2356 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2358 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2359 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2360 SPL_LINUX_TRY_COMPILE([
2361 #if !defined(CONFIG_ZLIB_INFLATE) && \
2362 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2363 #error CONFIG_ZLIB_INFLATE not defined
2366 AC_MSG_RESULT([yes])
2370 *** This kernel does not include the required zlib inflate support.
2371 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2376 dnl # zlib deflate compat,
2377 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2379 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2380 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2381 SPL_LINUX_TRY_COMPILE([
2382 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2383 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2384 #error CONFIG_ZLIB_DEFLATE not defined
2387 AC_MSG_RESULT([yes])
2391 *** This kernel does not include the required zlib deflate support.
2392 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2397 dnl # 2.6.39 API compat,
2398 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2399 dnl # This was done to avoid always having to allocate the maximum size
2400 dnl # workspace (268K). The caller can now specific the windowBits and
2401 dnl # memLevel compression parameters to get a smaller workspace.
2403 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2404 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2405 SPL_LINUX_TRY_COMPILE([
2406 #include <linux/zlib.h>
2408 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2411 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2412 [zlib_deflate_workspacesize() wants 2 args])
2419 dnl # 2.6.39 API change,
2420 dnl # Shrinker adjust to use common shrink_control structure.
2422 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2423 AC_MSG_CHECKING([whether struct shrink_control exists])
2424 SPL_LINUX_TRY_COMPILE([
2425 #include <linux/mm.h>
2427 struct shrink_control sc __attribute__ ((unused));
2430 sc.gfp_mask = GFP_KERNEL;
2433 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2434 [struct shrink_control exists])
2441 dnl # 3.1 API Change
2443 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2444 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2446 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2447 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2448 tmp_flags="$EXTRA_KCFLAGS"
2449 EXTRA_KCFLAGS="-Werror"
2450 SPL_LINUX_TRY_COMPILE([
2451 #include <linux/rwsem.h>
2453 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2454 raw_spinlock_t dummy_lock __attribute__ ((unused));
2455 dummy_semaphore.wait_lock = dummy_lock;
2458 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2459 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2463 EXTRA_KCFLAGS="$tmp_flags"
2467 dnl # 3.9 API change,
2468 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2470 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2471 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2472 SPL_LINUX_TRY_COMPILE([
2473 #include <linux/sched.h>
2474 #include <linux/sched/rt.h>
2478 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2486 dnl # 3.9 API change,
2487 dnl # vfs_getattr() uses 2 args
2488 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2490 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2491 AC_MSG_CHECKING([whether vfs_getattr() wants])
2492 SPL_LINUX_TRY_COMPILE([
2493 #include <linux/fs.h>
2495 vfs_getattr((struct path *) NULL,
2496 (struct kstat *)NULL);
2498 AC_MSG_RESULT(2 args)
2499 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2500 [vfs_getattr wants 2 args])
2502 SPL_LINUX_TRY_COMPILE([
2503 #include <linux/fs.h>
2505 vfs_getattr((struct vfsmount *)NULL,
2506 (struct dentry *)NULL,
2507 (struct kstat *)NULL);
2509 AC_MSG_RESULT(3 args)
2511 AC_MSG_ERROR(unknown)
2517 dnl # 2.6.36 API compatibility.
2518 dnl # Added usleep_range timer.
2519 dnl # usleep_range is a finer precision implementation of msleep
2520 dnl # designed to be a drop-in replacement for udelay where a precise
2521 dnl # sleep / busy-wait is unnecessary.
2523 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2524 AC_MSG_CHECKING([whether usleep_range() is available])
2525 SPL_LINUX_TRY_COMPILE([
2526 #include <linux/delay.h>
2531 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2532 [usleep_range is available])
2539 dnl # 2.6.35 API change,
2540 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2541 dnl # private allocation flags which are applied when allocating a new slab
2542 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2543 dnl # non-default flags.
2545 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2546 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2547 SPL_LINUX_TRY_COMPILE([
2548 #include <linux/slab.h>
2550 struct kmem_cache cachep __attribute__ ((unused));
2551 cachep.allocflags = GFP_KERNEL;
2554 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2555 [struct kmem_cache has allocflags])
2559 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2560 SPL_LINUX_TRY_COMPILE([
2561 #include <linux/slab.h>
2563 struct kmem_cache cachep __attribute__ ((unused));
2564 cachep.gfpflags = GFP_KERNEL;
2567 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2568 [struct kmem_cache has gfpflags])
2576 dnl # 3.17 API change,
2577 dnl # wait_on_bit() no longer requires an action argument. The former
2578 dnl # "wait_on_bit" interface required an 'action' function to be provided
2579 dnl # which does the actual waiting. There were over 20 such functions in the
2580 dnl # kernel, many of them identical, though most cases can be satisfied by one
2581 dnl # of just two functions: one which uses io_schedule() and one which just
2582 dnl # uses schedule(). This API change was made to consolidate all of those
2583 dnl # redundant wait functions.
2585 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2586 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2587 SPL_LINUX_TRY_COMPILE([
2588 #include <linux/wait.h>
2590 int (*action)(void *) = NULL;
2591 wait_on_bit(NULL, 0, action, 0);
2594 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])