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], [
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
16 AC_SUBST(KERNELMAKE_PARAMS)
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_TYPE_ATOMIC64_CMPXCHG
26 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_3ARGS_INIT_WORK
29 SPL_AC_2ARGS_REGISTER_SYSCTL
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
48 SPL_AC_MONOTONIC_CLOCK
51 SPL_AC_MUTEX_OWNER_TASK_STRUCT
52 SPL_AC_MUTEX_LOCK_NESTED
53 SPL_AC_3ARGS_ON_EACH_CPU
54 SPL_AC_KALLSYMS_LOOKUP_NAME
55 SPL_AC_GET_VMALLOC_INFO
57 SPL_AC_FIRST_ONLINE_PGDAT
58 SPL_AC_NEXT_ONLINE_PGDAT
61 SPL_AC_GLOBAL_PAGE_STATE
62 SPL_AC_ZONE_STAT_ITEM_FREE
63 SPL_AC_ZONE_STAT_ITEM_INACTIVE
64 SPL_AC_ZONE_STAT_ITEM_ACTIVE
65 SPL_AC_GET_ZONE_COUNTS
68 SPL_AC_2ARGS_SET_FS_PWD
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
72 SPL_AC_2ARGS_VFS_FSYNC
73 SPL_AC_FS_STRUCT_SPINLOCK
76 SPL_AC_PUT_TASK_STRUCT
77 SPL_AC_5ARGS_PROC_HANDLER
79 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
80 SPL_AC_KERNEL_INVALIDATE_INODES
81 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
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_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
87 SPL_AC_SHRINK_CONTROL_STRUCT
88 SPL_AC_RWSEM_SPINLOCK_IS_RAW
91 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
92 modpost=$LINUX/scripts/Makefile.modpost
93 AC_MSG_CHECKING([kernel file name for module symbols])
94 if test -f "$modpost"; then
95 if grep -q Modules.symvers $modpost; then
96 LINUX_SYMBOLS=Modules.symvers
98 LINUX_SYMBOLS=Module.symvers
101 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
103 *** Please make sure the kernel devel package for your distribution
104 *** is installed. If your building with a custom kernel make sure the
105 *** kernel is configured, built, and the '--with-linux=PATH' configure
106 *** option refers to the location of the kernel source.])
111 AC_MSG_RESULT($LINUX_SYMBOLS)
112 AC_SUBST(LINUX_SYMBOLS)
115 AC_DEFUN([SPL_AC_KERNEL], [
117 AS_HELP_STRING([--with-linux=PATH],
118 [Path to kernel source]),
119 [kernelsrc="$withval"])
121 AC_ARG_WITH([linux-obj],
122 AS_HELP_STRING([--with-linux-obj=PATH],
123 [Path to kernel build objects]),
124 [kernelbuild="$withval"])
126 AC_MSG_CHECKING([kernel source directory])
127 if test -z "$kernelsrc"; then
128 if test -e "/lib/modules/$(uname -r)/source"; then
129 headersdir="/lib/modules/$(uname -r)/source"
130 sourcelink=$(readlink -f "$headersdir")
131 elif test -e "/lib/modules/$(uname -r)/build"; then
132 headersdir="/lib/modules/$(uname -r)/build"
133 sourcelink=$(readlink -f "$headersdir")
135 sourcelink=$(ls -1d /usr/src/kernels/* \
137 2>/dev/null | grep -v obj | tail -1)
140 if test -n "$sourcelink" && test -e ${sourcelink}; then
141 kernelsrc=`readlink -f ${sourcelink}`
143 AC_MSG_RESULT([Not found])
145 *** Please make sure the kernel devel package for your distribution
146 *** is installed then try again. If that fails you can specify the
147 *** location of the kernel source with the '--with-linux=PATH' option.])
150 if test "$kernelsrc" = "NONE"; then
155 AC_MSG_RESULT([$kernelsrc])
156 AC_MSG_CHECKING([kernel build directory])
157 if test -z "$kernelbuild"; then
158 if test -e "/lib/modules/$(uname -r)/build"; then
159 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
160 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
161 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
162 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
163 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
164 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
165 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
167 kernelbuild=${kernelsrc}
170 AC_MSG_RESULT([$kernelbuild])
172 AC_MSG_CHECKING([kernel source version])
173 utsrelease1=$kernelbuild/include/linux/version.h
174 utsrelease2=$kernelbuild/include/linux/utsrelease.h
175 utsrelease3=$kernelbuild/include/generated/utsrelease.h
176 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
177 utsrelease=linux/version.h
178 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
179 utsrelease=linux/utsrelease.h
180 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
181 utsrelease=generated/utsrelease.h
184 if test "$utsrelease"; then
185 kernsrcver=`(echo "#include <$utsrelease>";
186 echo "kernsrcver=UTS_RELEASE") |
187 cpp -I $kernelbuild/include |
188 grep "^kernsrcver=" | cut -d \" -f 2`
190 if test -z "$kernsrcver"; then
191 AC_MSG_RESULT([Not found])
192 AC_MSG_ERROR([*** Cannot determine kernel version.])
195 AC_MSG_RESULT([Not found])
196 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
199 AC_MSG_RESULT([$kernsrcver])
202 LINUX_OBJ=${kernelbuild}
203 LINUX_VERSION=${kernsrcver}
207 AC_SUBST(LINUX_VERSION)
209 SPL_AC_MODULE_SYMVERS
212 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
213 SPL_LINUX_CONFIG([PREEMPT],
215 *** Kernel built with CONFIG_PREEMPT which is not supported.
216 ** You must rebuild your kernel without this option.]), [])
220 dnl # Default SPL user configuration
222 AC_DEFUN([SPL_AC_CONFIG_USER], [])
225 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
226 dnl # are missing it is non-fatal but you will not be able to build
227 dnl # RPM packages and will be warned if you try too.
229 AC_DEFUN([SPL_AC_RPM], [
233 AC_MSG_CHECKING([whether $RPM is available])
234 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
235 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
237 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
240 AC_MSG_RESULT([$HAVE_RPM])
243 AC_MSG_CHECKING([whether $RPMBUILD is available])
244 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
245 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
247 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
250 AC_MSG_RESULT([$HAVE_RPMBUILD])
255 AC_SUBST(RPM_VERSION)
257 AC_SUBST(HAVE_RPMBUILD)
259 AC_SUBST(RPMBUILD_VERSION)
263 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
264 dnl # tools are missing it is non-fatal but you will not be able to build
265 dnl # DEB packages and will be warned if you try too.
267 AC_DEFUN([SPL_AC_DPKG], [
269 DPKGBUILD=dpkg-buildpackage
271 AC_MSG_CHECKING([whether $DPKG is available])
272 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
273 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
275 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
278 AC_MSG_RESULT([$HAVE_DPKG])
281 AC_MSG_CHECKING([whether $DPKGBUILD is available])
282 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
283 DPKGBUILD_VERSION=$(echo $tmp | \
284 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
286 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
289 AC_MSG_RESULT([$HAVE_DPKGBUILD])
294 AC_SUBST(DPKG_VERSION)
296 AC_SUBST(HAVE_DPKGBUILD)
298 AC_SUBST(DPKGBUILD_VERSION)
302 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
303 dnl # tools are missing it is non-fatal but you will not be able to
304 dnl # build Arch Linux packages and will be warned if you try too.
306 AC_DEFUN([SPL_AC_PACMAN], [
310 AC_MSG_CHECKING([whether $PACMAN is available])
311 tmp=$($PACMAN --version 2>/dev/null)
312 AS_IF([test -n "$tmp"], [
313 PACMAN_VERSION=$(echo $tmp |
314 $AWK '/Pacman/ { print $[3] }' |
317 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
320 AC_MSG_RESULT([$HAVE_PACMAN])
323 AC_MSG_CHECKING([whether $MAKEPKG is available])
324 tmp=$($MAKEPKG --version 2>/dev/null)
325 AS_IF([test -n "$tmp"], [
326 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
328 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
331 AC_MSG_RESULT([$HAVE_MAKEPKG])
334 AC_SUBST(HAVE_PACMAN)
336 AC_SUBST(PACMAN_VERSION)
338 AC_SUBST(HAVE_MAKEPKG)
340 AC_SUBST(MAKEPKG_VERSION)
344 dnl # Until native packaging for various different packing systems
345 dnl # can be added the least we can do is attempt to use alien to
346 dnl # convert the RPM packages to the needed package type. This is
347 dnl # a hack but so far it has worked reasonable well.
349 AC_DEFUN([SPL_AC_ALIEN], [
352 AC_MSG_CHECKING([whether $ALIEN is available])
353 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
354 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
356 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
359 AC_MSG_RESULT([$HAVE_ALIEN])
364 AC_SUBST(ALIEN_VERSION)
368 dnl # Using the VENDOR tag from config.guess set the default
369 dnl # package type for 'make pkg': (rpm | deb | tgz)
371 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
372 AC_MSG_CHECKING([linux distribution])
373 if test -f /etc/redhat-release ; then
375 elif test -f /etc/fedora-release ; then
377 elif test -f /etc/arch-release ; then
379 elif test -f /etc/lsb-release ; then
381 elif test -f /etc/debian_version ; then
383 elif test -f /etc/SuSE-release ; then
385 elif test -f /etc/slackware-version ; then
387 elif test -f /etc/gentoo-release ; then
392 AC_MSG_RESULT([$VENDOR])
395 AC_MSG_CHECKING([default package type])
397 fedora) DEFAULT_PACKAGE=rpm ;;
398 redhat) DEFAULT_PACKAGE=rpm ;;
399 sles) DEFAULT_PACKAGE=rpm ;;
400 ubuntu) DEFAULT_PACKAGE=deb ;;
401 debian) DEFAULT_PACKAGE=deb ;;
402 slackware) DEFAULT_PACKAGE=tgz ;;
403 arch) DEFAULT_PACKAGE=arch;;
404 *) DEFAULT_PACKAGE=rpm ;;
407 AC_MSG_RESULT([$DEFAULT_PACKAGE])
408 AC_SUBST(DEFAULT_PACKAGE)
412 dnl # Default SPL user configuration
414 AC_DEFUN([SPL_AC_PACKAGE], [
415 SPL_AC_DEFAULT_PACKAGE
420 AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
423 AC_DEFUN([SPL_AC_LICENSE], [
424 AC_MSG_CHECKING([spl license])
426 AC_MSG_RESULT([$LICENSE])
427 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
431 AC_DEFUN([SPL_AC_CONFIG], [
433 AC_ARG_WITH([config],
434 AS_HELP_STRING([--with-config=CONFIG],
435 [Config file 'kernel|user|all|srpm']),
436 [SPL_CONFIG="$withval"])
438 AC_MSG_CHECKING([spl config])
439 AC_MSG_RESULT([$SPL_CONFIG]);
442 case "$SPL_CONFIG" in
443 kernel) SPL_AC_CONFIG_KERNEL ;;
444 user) SPL_AC_CONFIG_USER ;;
445 all) SPL_AC_CONFIG_KERNEL
446 SPL_AC_CONFIG_USER ;;
449 AC_MSG_RESULT([Error!])
450 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
451 user kernel|user|all|srpm]) ;;
454 AM_CONDITIONAL([CONFIG_USER],
455 [test "$SPL_CONFIG" = user] ||
456 [test "$SPL_CONFIG" = all])
457 AM_CONDITIONAL([CONFIG_KERNEL],
458 [test "$SPL_CONFIG" = kernel] ||
459 [test "$SPL_CONFIG" = all])
463 dnl # Enable if the SPL should be compiled with internal debugging enabled.
464 dnl # By default this support is disabled.
466 AC_DEFUN([SPL_AC_DEBUG], [
467 AC_MSG_CHECKING([whether debugging is enabled])
468 AC_ARG_ENABLE([debug],
469 [AS_HELP_STRING([--enable-debug],
470 [Enable generic debug support @<:@default=no@:>@])],
474 AS_IF([test "x$enable_debug" = xyes],
476 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
477 DEBUG_CFLAGS="-DDEBUG -Werror"
480 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
481 DEBUG_CFLAGS="-DNDEBUG"
484 AC_SUBST(DEBUG_CFLAGS)
485 AC_MSG_RESULT([$enable_debug])
489 dnl # Enabled by default it provides a minimal level of memory tracking.
490 dnl # A total count of bytes allocated is kept for each alloc and free.
491 dnl # Then at module unload time a report to the console will be printed
492 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
493 dnl # and provide an easy way to inspect the kmem based slab.
495 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
496 AC_ARG_ENABLE([debug-kmem],
497 [AS_HELP_STRING([--enable-debug-kmem],
498 [Enable basic kmem accounting @<:@default=yes@:>@])],
500 [enable_debug_kmem=yes])
502 AS_IF([test "x$enable_debug_kmem" = xyes],
503 [AC_DEFINE([DEBUG_KMEM], [1],
504 [Define to 1 to enable basic kmem accounting])
505 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
507 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
508 AC_MSG_RESULT([$enable_debug_kmem])
512 dnl # Disabled by default it provides detailed memory tracking. This
513 dnl # feature also requires --enable-debug-kmem to be set. When enabled
514 dnl # not only will total bytes be tracked but also the location of every
515 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
516 dnl # addresses and where they were allocated will be dumped to the console.
517 dnl # Enabling this feature has a significant impact on performance but it
518 dnl # makes finding memory leaks pretty straight forward.
520 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
521 AC_ARG_ENABLE([debug-kmem-tracking],
522 [AS_HELP_STRING([--enable-debug-kmem-tracking],
523 [Enable detailed kmem tracking @<:@default=no@:>@])],
525 [enable_debug_kmem_tracking=no])
527 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
528 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
529 [Define to 1 to enable detailed kmem tracking])
530 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
532 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
533 AC_MSG_RESULT([$enable_debug_kmem_tracking])
537 dnl # SPL_LINUX_CONFTEST
539 AC_DEFUN([SPL_LINUX_CONFTEST], [
540 cat confdefs.h - <<_ACEOF >conftest.c
546 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
548 m4_define([SPL_LANG_PROGRAM], [
553 dnl Do *not* indent the following line: there may be CPP directives.
554 dnl Don't move the `;' right after for the same reason.
562 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
564 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
565 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
566 rm -Rf build && mkdir -p build
567 echo "obj-m := conftest.o" >build/Makefile
569 [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) >/dev/null && AC_TRY_COMMAND([$3])],
571 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
577 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
579 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
580 [SPL_LINUX_COMPILE_IFELSE(
581 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
583 [test -s build/conftest.o],
588 dnl # SPL_LINUX_CONFIG
590 AC_DEFUN([SPL_LINUX_CONFIG],
591 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
592 SPL_LINUX_TRY_COMPILE([
593 #include <linux/module.h>
596 #error CONFIG_$1 not #defined
608 dnl # SPL_CHECK_SYMBOL_EXPORT
609 dnl # check symbol exported or not
611 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
612 [AC_MSG_CHECKING([whether symbol $1 is exported])
613 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
614 $LINUX_OBJ/Module*.symvers 2>/dev/null
616 if test $rc -ne 0; then
619 grep -q -E "EXPORT_SYMBOL.*($1)" \
620 "$LINUX_OBJ/$file" 2>/dev/null
622 if test $rc -eq 0; then
627 if test $export -eq 0; then
641 dnl # SPL_CHECK_SYMBOL_HEADER
642 dnl # check if a symbol prototype is defined in listed headers.
644 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
645 AC_MSG_CHECKING([whether symbol $1 exists in header])
648 grep -q "$2" "$LINUX/$file" 2>/dev/null
650 if test $rc -eq 0; then
655 if test $header -eq 0; then
665 dnl # SPL_CHECK_HEADER
666 dnl # check whether header exists and define HAVE_$2_HEADER
668 AC_DEFUN([SPL_CHECK_HEADER],
669 [AC_MSG_CHECKING([whether header $1 exists])
670 SPL_LINUX_TRY_COMPILE([
675 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
685 dnl # Use the atomic implemenation based on global spinlocks. This
686 dnl # should only be needed by 32-bit kernels which do not provide
687 dnl # the atomic64_* API. It may be optionally enabled as a fallback
688 dnl # if problems are observed with the direct mapping to the native
689 dnl # Linux atomic operations. You may not disable atomic spinlocks
690 dnl # if you kernel does not an atomic64_* API.
692 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
693 AC_ARG_ENABLE([atomic-spinlocks],
694 [AS_HELP_STRING([--enable-atomic-spinlocks],
695 [Atomic types use spinlocks @<:@default=check@:>@])],
697 [enable_atomic_spinlocks=check])
699 SPL_LINUX_TRY_COMPILE([
700 #include <asm/atomic.h>
702 atomic64_t *ptr __attribute__ ((unused));
705 AC_DEFINE(HAVE_ATOMIC64_T, 1,
706 [kernel defines atomic64_t])
711 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
712 AS_IF([test "x$have_atomic64_t" = xyes], [
713 enable_atomic_spinlocks=no
715 enable_atomic_spinlocks=yes
719 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
720 AC_DEFINE([ATOMIC_SPINLOCK], [1],
721 [Atomic types use spinlocks])
723 AS_IF([test "x$have_atomic64_t" = xno], [
725 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
729 AC_MSG_CHECKING([whether atomic types use spinlocks])
730 AC_MSG_RESULT([$enable_atomic_spinlocks])
732 AC_MSG_CHECKING([whether kernel defines atomic64_t])
733 AC_MSG_RESULT([$have_atomic64_t])
737 dnl # 2.6.24 API change,
738 dnl # check if atomic64_cmpxchg is defined
740 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
741 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
742 SPL_LINUX_TRY_COMPILE([
743 #include <asm/atomic.h>
744 #include <asm/system.h>
746 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
749 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
750 [kernel defines atomic64_cmpxchg])
757 dnl # 2.6.24 API change,
758 dnl # check if atomic64_xchg is defined
760 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
761 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
762 SPL_LINUX_TRY_COMPILE([
763 #include <asm/atomic.h>
765 atomic64_xchg((atomic64_t *)NULL, 0);
768 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
769 [kernel defines atomic64_xchg])
776 dnl # 2.6.24 API change,
777 dnl # check if uintptr_t typedef is defined
779 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
780 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
781 SPL_LINUX_TRY_COMPILE([
782 #include <linux/types.h>
784 uintptr_t *ptr __attribute__ ((unused));
787 AC_DEFINE(HAVE_UINTPTR_T, 1,
788 [kernel defines uintptr_t])
795 dnl # 2.6.20 API change,
796 dnl # INIT_WORK use 2 args and not store data inside
798 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
799 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
800 SPL_LINUX_TRY_COMPILE([
801 #include <linux/workqueue.h>
803 struct work_struct work __attribute__ ((unused));
804 INIT_WORK(&work, NULL, NULL);
807 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
808 [INIT_WORK wants 3 args])
815 dnl # 2.6.21 API change,
816 dnl # 'register_sysctl_table' use only one argument instead of two
818 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
819 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
820 SPL_LINUX_TRY_COMPILE([
821 #include <linux/sysctl.h>
823 (void) register_sysctl_table(NULL, 0);
826 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
827 [register_sysctl_table() wants 2 args])
834 dnl # 2.6.23 API change
835 dnl # Old set_shrinker API replaced with register_shrinker
837 AC_DEFUN([SPL_AC_SET_SHRINKER], [
838 AC_MSG_CHECKING([whether set_shrinker() available])
839 SPL_LINUX_TRY_COMPILE([
840 #include <linux/mm.h>
842 return set_shrinker(DEFAULT_SEEKS, NULL);
845 AC_DEFINE(HAVE_SET_SHRINKER, 1,
846 [set_shrinker() available])
853 dnl # 2.6.35 API change,
854 dnl # Add context to shrinker callback
856 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
857 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
858 tmp_flags="$EXTRA_KCFLAGS"
859 EXTRA_KCFLAGS="-Werror"
860 SPL_LINUX_TRY_COMPILE([
861 #include <linux/mm.h>
863 int shrinker_cb(struct shrinker *, int, unsigned int);
865 struct shrinker cache_shrinker = {
866 .shrink = shrinker_cb,
867 .seeks = DEFAULT_SEEKS,
869 register_shrinker(&cache_shrinker);
872 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
873 [shrinker callback wants 3 args])
877 EXTRA_KCFLAGS="$tmp_flags"
881 dnl # 2.6.25 API change,
882 dnl # struct path entry added to struct nameidata
884 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
885 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
886 SPL_LINUX_TRY_COMPILE([
887 #include <linux/namei.h>
889 struct nameidata nd __attribute__ ((unused));
892 nd.path.dentry = NULL;
895 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
896 [struct path used in struct nameidata])
903 dnl # Custom SPL patch may export this system it is not required
905 AC_DEFUN([SPL_AC_TASK_CURR], [
906 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
907 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
912 dnl # 2.6.19 API change,
913 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
915 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
916 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
917 SPL_LINUX_TRY_COMPILE([
918 #include <linux/sysctl.h>
920 #ifndef CTL_UNNUMBERED
921 #error CTL_UNNUMBERED undefined
925 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
926 [unnumbered sysctl support exists])
933 dnl # 2.6.33 API change,
934 dnl # Removed .ctl_name from struct ctl_table.
936 AC_DEFUN([SPL_AC_CTL_NAME], [
937 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
938 SPL_LINUX_TRY_COMPILE([
939 #include <linux/sysctl.h>
941 struct ctl_table ctl __attribute__ ((unused));
945 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
952 dnl # 2.6.16 API change.
953 dnl # Check if 'fls64()' is available
955 AC_DEFUN([SPL_AC_FLS64],
956 [AC_MSG_CHECKING([whether fls64() is available])
957 SPL_LINUX_TRY_COMPILE([
958 #include <linux/bitops.h>
963 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
970 dnl # 2.6.18 API change, check whether device_create() is available.
971 dnl # Device_create() was introduced in 2.6.18 and depricated
972 dnl # class_device_create() which was fully removed in 2.6.26.
974 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
975 SPL_CHECK_SYMBOL_EXPORT(
977 [drivers/base/core.c],
978 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
979 [device_create() is available])],
984 dnl # 2.6.27 API change,
985 dnl # device_create() uses 5 args, new 'drvdata' argument.
987 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
988 AC_MSG_CHECKING([whether device_create() wants 5 args])
989 tmp_flags="$EXTRA_KCFLAGS"
990 EXTRA_KCFLAGS="-Werror"
991 SPL_LINUX_TRY_COMPILE([
992 #include <linux/device.h>
994 device_create(NULL, NULL, 0, NULL, "%d", 1);
997 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
998 [device_create wants 5 args])
1002 EXTRA_KCFLAGS="$tmp_flags"
1006 dnl # 2.6.13 API change, check whether class_device_create() is available.
1007 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1008 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1010 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
1011 SPL_CHECK_SYMBOL_EXPORT(
1012 [class_device_create],
1013 [drivers/base/class.c],
1014 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1015 [class_device_create() is available])],
1020 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1022 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
1023 SPL_CHECK_SYMBOL_EXPORT(
1024 [set_normalized_timespec],
1026 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1027 [set_normalized_timespec() is available as export])],
1032 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1033 dnl # previously it was available in time.h as an inline.
1035 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1036 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1037 SPL_LINUX_TRY_COMPILE([
1038 #include <linux/time.h>
1039 void set_normalized_timespec(struct timespec *ts,
1040 time_t sec, long nsec) { }
1047 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1048 [set_normalized_timespec() is available as inline])
1053 dnl # 2.6.18 API change,
1054 dnl # timespec_sub() inline function available in linux/time.h
1056 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1057 AC_MSG_CHECKING([whether timespec_sub() is available])
1058 SPL_LINUX_TRY_COMPILE([
1059 #include <linux/time.h>
1061 struct timespec a = { 0 };
1062 struct timespec b = { 0 };
1063 struct timespec c __attribute__ ((unused));
1064 c = timespec_sub(a, b);
1067 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1074 dnl # 2.6.19 API change,
1075 dnl # check if init_utsname() is available in linux/utsname.h
1077 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1078 AC_MSG_CHECKING([whether init_utsname() is available])
1079 SPL_LINUX_TRY_COMPILE([
1080 #include <linux/utsname.h>
1082 struct new_utsname *a __attribute__ ((unused));
1086 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1093 dnl # 2.6.26 API change,
1094 dnl # definition of struct fdtable relocated to linux/fdtable.h
1096 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1097 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1101 dnl # 2.6.14 API change,
1102 dnl # check whether 'files_fdtable()' exists
1104 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1105 AC_MSG_CHECKING([whether files_fdtable() is available])
1106 SPL_LINUX_TRY_COMPILE([
1107 #include <linux/sched.h>
1108 #include <linux/file.h>
1109 #ifdef HAVE_FDTABLE_HEADER
1110 #include <linux/fdtable.h>
1113 struct files_struct *files = current->files;
1114 struct fdtable *fdt __attribute__ ((unused));
1115 fdt = files_fdtable(files);
1118 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1125 dnl # 2.6.18 API change,
1126 dnl # added linux/uaccess.h
1128 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1129 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1133 dnl # 2.6.12 API change,
1134 dnl # check whether 'kmalloc_node()' is available.
1136 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1137 AC_MSG_CHECKING([whether kmalloc_node() is available])
1138 SPL_LINUX_TRY_COMPILE([
1139 #include <linux/slab.h>
1141 void *a __attribute__ ((unused));
1142 a = kmalloc_node(1, GFP_KERNEL, 0);
1145 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1152 dnl # 2.6.9 API change,
1153 dnl # check whether 'monotonic_clock()' is available it may
1154 dnl # be available for some archs but not others.
1156 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1157 SPL_CHECK_SYMBOL_EXPORT(
1160 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1161 [monotonic_clock() is available])],
1166 dnl # 2.6.16 API change,
1167 dnl # check whether 'struct inode' has i_mutex
1169 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1170 AC_MSG_CHECKING([whether struct inode has i_mutex])
1171 SPL_LINUX_TRY_COMPILE([
1172 #include <linux/fs.h>
1173 #include <linux/mutex.h>
1176 mutex_init(&i.i_mutex);
1179 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1186 dnl # 2.6.29 API change,
1187 dnl # Adaptive mutexs introduced.
1189 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1190 AC_MSG_CHECKING([whether struct mutex has owner])
1191 SPL_LINUX_TRY_COMPILE([
1192 #include <linux/mutex.h>
1194 struct mutex mtx __attribute__ ((unused));
1198 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1205 dnl # 2.6.39 API change,
1206 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1207 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1208 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1209 dnl # pointer which frankly makes a lot more sense.
1211 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1212 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1213 tmp_flags="$EXTRA_KCFLAGS"
1214 EXTRA_KCFLAGS="-Werror"
1215 SPL_LINUX_TRY_COMPILE([
1216 #include <linux/mutex.h>
1218 struct mutex mtx __attribute__ ((unused));
1219 mtx.owner = current;
1222 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1223 [struct mutex owner is a task_struct])
1227 EXTRA_KCFLAGS="$tmp_flags"
1231 dnl # 2.6.18 API change,
1232 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1233 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1234 dnl # if the mutex validator is disabled or otherwise unavailable.
1236 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1237 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1238 SPL_LINUX_TRY_COMPILE([
1239 #include <linux/mutex.h>
1243 mutex_lock_nested(&mutex, 0);
1246 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1247 [mutex_lock_nested() is available])
1254 dnl # 2.6.27 API change,
1255 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1257 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1258 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1259 SPL_LINUX_TRY_COMPILE([
1260 #include <linux/smp.h>
1262 on_each_cpu(NULL, NULL, 0);
1265 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1266 [on_each_cpu wants 3 args])
1273 dnl # 2.6.18 API change,
1274 dnl # kallsyms_lookup_name no longer exported
1276 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1277 SPL_CHECK_SYMBOL_EXPORT(
1278 [kallsyms_lookup_name],
1280 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1281 [kallsyms_lookup_name() is available])],
1286 dnl # Proposed API change,
1287 dnl # This symbol is not available in stock kernels. You may build a
1288 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1289 dnl # these symbols for use. If your already rolling a custom kernel for
1290 dnl # your environment this is recommended.
1292 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1293 SPL_CHECK_SYMBOL_EXPORT(
1296 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1297 [get_vmalloc_info() is available])],
1302 dnl # 2.6.17 API change
1303 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1304 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1305 dnl # were exported in 2.6.17 for use by modules which was consistent with
1306 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1307 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1308 dnl # were dropped entirely leaving modules no way to directly iterate over
1309 dnl # the zone list. Because we need access to the zone helpers we check
1310 dnl # if the kernel contains the old or new implementation. Then we check
1311 dnl # to see if the symbols we need for each version are available. If they
1312 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1314 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1315 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1316 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1318 if test $rc -eq 0; then
1319 AC_MSG_RESULT([yes])
1320 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1327 dnl # Proposed API change,
1328 dnl # This symbol is not available in stock kernels. You may build a
1329 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1330 dnl # these symbols for use. If your already rolling a custom kernel for
1331 dnl # your environment this is recommended.
1333 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1334 SPL_CHECK_SYMBOL_EXPORT(
1335 [first_online_pgdat],
1337 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1338 [first_online_pgdat() is available])],
1343 dnl # Proposed API change,
1344 dnl # This symbol is not available in stock kernels. You may build a
1345 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1346 dnl # these symbols for use. If your already rolling a custom kernel for
1347 dnl # your environment this is recommended.
1349 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1350 SPL_CHECK_SYMBOL_EXPORT(
1351 [next_online_pgdat],
1353 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1354 [next_online_pgdat() is available])],
1359 dnl # Proposed API change,
1360 dnl # This symbol is not available in stock kernels. You may build a
1361 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1362 dnl # these symbols for use. If your already rolling a custom kernel for
1363 dnl # your environment this is recommended.
1365 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1366 SPL_CHECK_SYMBOL_EXPORT(
1369 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1370 [next_zone() is available])],
1375 dnl # 2.6.17 API change,
1376 dnl # See SPL_AC_PGDAT_HELPERS for details.
1378 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1379 SPL_CHECK_SYMBOL_EXPORT(
1382 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1383 [pgdat_list is available])],
1388 dnl # 2.6.18 API change,
1389 dnl # First introduced global_page_state() support as an inline.
1391 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1392 AC_MSG_CHECKING([whether global_page_state() is available])
1393 SPL_LINUX_TRY_COMPILE([
1394 #include <linux/mm.h>
1396 unsigned long state __attribute__ ((unused));
1397 state = global_page_state(0);
1400 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1401 [global_page_state() is available])
1408 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1409 dnl # Public global zone stats now include a free page count. However
1410 dnl # the enumerated names of the counters have changed since this API
1411 dnl # was introduced. We need to deduce the corrent name to use. This
1412 dnl # replaces the priviate get_zone_counts() interface.
1414 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1415 dnl # is 2.6.30 as of when this was written.
1417 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1418 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1419 SPL_LINUX_TRY_COMPILE([
1420 #include <linux/mm.h>
1422 enum zone_stat_item zsi __attribute__ ((unused));
1423 zsi = NR_FREE_PAGES;
1426 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1427 [Page state NR_FREE_PAGES is available])
1434 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1435 dnl # Public global zone stats now include an inactive page count. However
1436 dnl # the enumerated names of the counters have changed since this API
1437 dnl # was introduced. We need to deduce the corrent name to use. This
1438 dnl # replaces the priviate get_zone_counts() interface.
1440 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1441 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1442 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1444 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1445 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1446 SPL_LINUX_TRY_COMPILE([
1447 #include <linux/mm.h>
1449 enum zone_stat_item zsi __attribute__ ((unused));
1453 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1454 [Page state NR_INACTIVE is available])
1459 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1460 SPL_LINUX_TRY_COMPILE([
1461 #include <linux/mm.h>
1463 enum zone_stat_item zsi __attribute__ ((unused));
1464 zsi = NR_INACTIVE_ANON;
1467 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1468 [Page state NR_INACTIVE_ANON is available])
1473 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1474 SPL_LINUX_TRY_COMPILE([
1475 #include <linux/mm.h>
1477 enum zone_stat_item zsi __attribute__ ((unused));
1478 zsi = NR_INACTIVE_FILE;
1481 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1482 [Page state NR_INACTIVE_FILE is available])
1489 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1490 dnl # Public global zone stats now include an active page count. However
1491 dnl # the enumerated names of the counters have changed since this API
1492 dnl # was introduced. We need to deduce the corrent name to use. This
1493 dnl # replaces the priviate get_zone_counts() interface.
1495 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1496 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1497 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1499 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1500 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1501 SPL_LINUX_TRY_COMPILE([
1502 #include <linux/mm.h>
1504 enum zone_stat_item zsi __attribute__ ((unused));
1508 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1509 [Page state NR_ACTIVE is available])
1514 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1515 SPL_LINUX_TRY_COMPILE([
1516 #include <linux/mm.h>
1518 enum zone_stat_item zsi __attribute__ ((unused));
1519 zsi = NR_ACTIVE_ANON;
1522 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1523 [Page state NR_ACTIVE_ANON is available])
1528 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1529 SPL_LINUX_TRY_COMPILE([
1530 #include <linux/mm.h>
1532 enum zone_stat_item zsi __attribute__ ((unused));
1533 zsi = NR_ACTIVE_FILE;
1536 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1537 [Page state NR_ACTIVE_FILE is available])
1544 dnl # Proposed API change for legacy kernels.
1545 dnl # This symbol is not available in older kernels. For kernels post
1546 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1547 dnl # page state information. This symbol is only used in legacy kernels
1548 dnl # any only as a last resort.
1550 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1551 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1552 SPL_LINUX_TRY_COMPILE([
1554 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1555 #error "global_page_state needs NR_FREE_PAGES"
1558 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1559 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1560 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1561 #error "global_page_state needs NR_ACTIVE*"
1564 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1565 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1566 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1567 #error "global_page_state needs NR_INACTIVE*"
1573 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1574 [get_zone_counts() is needed])
1576 SPL_CHECK_SYMBOL_EXPORT(
1579 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1580 [get_zone_counts() is available])],
1586 dnl # 2.6.27 API change,
1587 dnl # The user_path_dir() replaces __user_walk()
1589 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1590 SPL_CHECK_SYMBOL_EXPORT(
1593 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1594 [user_path_dir() is available])],
1599 dnl # Symbol available in RHEL kernels not in stock kernels.
1601 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1602 SPL_CHECK_SYMBOL_EXPORT(
1605 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1606 [set_fs_pwd() is available])],
1611 dnl # 2.6.25 API change,
1612 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1614 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1615 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1616 SPL_LINUX_TRY_COMPILE([
1617 #include <linux/sched.h>
1618 #include <linux/fs_struct.h>
1620 set_fs_pwd(NULL, NULL);
1623 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1624 [set_fs_pwd() wants 2 args])
1631 dnl # SLES API change, never adopted in mainline,
1632 dnl # Third 'struct vfsmount *' argument removed.
1634 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1635 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1636 SPL_LINUX_TRY_COMPILE([
1637 #include <linux/fs.h>
1639 vfs_unlink(NULL, NULL);
1642 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1643 [vfs_unlink() wants 2 args])
1650 dnl # SLES API change, never adopted in mainline,
1651 dnl # Third and sixth 'struct vfsmount *' argument removed.
1653 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1654 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1655 SPL_LINUX_TRY_COMPILE([
1656 #include <linux/fs.h>
1658 vfs_rename(NULL, NULL, NULL, NULL);
1661 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1662 [vfs_rename() wants 4 args])
1669 dnl # 2.6.36 API change,
1670 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1671 dnl # a spinlock_t to improve the fastpath performance.
1673 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1674 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1675 tmp_flags="$EXTRA_KCFLAGS"
1676 EXTRA_KCFLAGS="-Werror"
1677 SPL_LINUX_TRY_COMPILE([
1678 #include <linux/sched.h>
1679 #include <linux/fs_struct.h>
1681 struct fs_struct fs;
1682 spin_lock_init(&fs.lock);
1685 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1686 [struct fs_struct uses spinlock_t])
1690 EXTRA_KCFLAGS="$tmp_flags"
1694 dnl # 2.6.29 API change,
1695 dnl # check whether 'struct cred' exists
1697 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1698 AC_MSG_CHECKING([whether struct cred exists])
1699 SPL_LINUX_TRY_COMPILE([
1700 #include <linux/cred.h>
1702 struct cred *cr __attribute__ ((unused));
1706 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1713 dnl # Custom SPL patch may export this symbol.
1715 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1716 SPL_CHECK_SYMBOL_EXPORT(
1719 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1720 [groups_search() is available])],
1725 dnl # 2.6.x API change,
1726 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1728 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1729 SPL_CHECK_SYMBOL_EXPORT(
1730 [__put_task_struct],
1732 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1733 [__put_task_struct() is available])],
1738 dnl # 2.6.32 API change,
1739 dnl # Unused 'struct file *' removed from prototype.
1741 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1742 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1743 SPL_LINUX_TRY_COMPILE([
1744 #include <linux/sysctl.h>
1746 proc_dostring(NULL, 0, NULL, NULL, NULL);
1749 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1750 [proc_handler() wants 5 args])
1757 dnl # 2.6.x API change,
1758 dnl # kvasprintf() function added.
1760 AC_DEFUN([SPL_AC_KVASPRINTF], [
1761 SPL_CHECK_SYMBOL_EXPORT(
1764 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1765 [kvasprintf() is available])],
1770 dnl # 2.6.29 API change,
1771 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1773 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1774 SPL_CHECK_SYMBOL_EXPORT(
1777 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1782 dnl # 2.6.35 API change,
1783 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1785 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1786 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1787 SPL_LINUX_TRY_COMPILE([
1788 #include <linux/fs.h>
1793 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1800 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1801 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1802 dnl # condition. The fixed version is exported as a symbol. The race
1803 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1804 dnl # call that version while holding sem->wait_lock.
1806 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1807 SPL_CHECK_SYMBOL_EXPORT(
1809 [lib/rwsem-spinlock.c],
1810 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1811 [rwsem_is_locked() acquires sem->wait_lock])],
1816 dnl # 2.6.37 API compat,
1817 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1818 dnl # The prototype however is still available which means it is safe
1819 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1821 dnl # The Proxmox VE kernel contains a patch which renames the function
1822 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1823 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1824 dnl # compatibility wrapper for legacy callers. Therefore, if either
1825 dnl # of these functions are exported invalidate_inodes() can be
1828 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1829 SPL_CHECK_SYMBOL_EXPORT(
1830 [invalidate_inodes],
1832 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1833 [invalidate_inodes() is available])],
1835 SPL_CHECK_SYMBOL_EXPORT(
1836 [invalidate_inodes_check],
1838 [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
1839 [invalidate_inodes_check() is available])],
1844 dnl # 2.6.39 API compat,
1845 dnl # The function invalidate_inodes() now take 2 arguments. The second
1846 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1847 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1848 dnl # otherwise they will be handled as busy.
1850 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1851 dnl # prototype so it's not easy to check how many arguments it takes.
1852 dnl # However, this change was done for the benefit of invalidate_device()
1853 dnl # which also added an argument. The invalidate_device() symbol does
1854 dnl # exist in the development headers so if it takes two arguments we
1855 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1856 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1858 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1859 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1860 SPL_LINUX_TRY_COMPILE([
1861 #include <linux/fs.h>
1863 return __invalidate_device(NULL, 0);
1866 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1867 [invalidate_inodes() wants 2 args])
1874 dnl # 2.6.xx API compat,
1875 dnl # There currently exists no exposed API to partially shrink the dcache.
1876 dnl # The expected mechanism to shrink the cache is a registered shrinker
1877 dnl # which is called during memory pressure.
1879 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1880 SPL_CHECK_SYMBOL_EXPORT(
1881 [shrink_dcache_memory],
1883 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1884 [shrink_dcache_memory() is available])],
1889 dnl # 2.6.xx API compat,
1890 dnl # There currently exists no exposed API to partially shrink the icache.
1891 dnl # The expected mechanism to shrink the cache is a registered shrinker
1892 dnl # which is called during memory pressure.
1894 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1895 SPL_CHECK_SYMBOL_EXPORT(
1896 [shrink_icache_memory],
1898 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1899 [shrink_icache_memory() is available])],
1904 dnl # 2.6.39 API compat,
1905 dnl # The path_lookup() function has been renamed to kern_path_parent()
1906 dnl # and the flags argument has been removed. The only behavior now
1907 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1908 dnl # this flag so dropping the flag does not impact us.
1910 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1911 SPL_CHECK_SYMBOL_HEADER(
1913 [int kern_path_parent(const char \*, struct nameidata \*)],
1914 [include/linux/namei.h],
1915 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1916 [kern_path_parent() is available])],
1921 dnl # 3.1 API compat,
1922 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1923 dnl # However, it remains the prefered interface and since we still have
1924 dnl # access to the prototype we dynamically lookup the required address.
1926 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1927 SPL_CHECK_SYMBOL_EXPORT(
1930 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1931 [kern_path_parent() is available])],
1936 dnl # 2.6.39 API compat,
1937 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1938 dnl # This was done to avoid always having to allocate the maximum size
1939 dnl # workspace (268K). The caller can now specific the windowBits and
1940 dnl # memLevel compression parameters to get a smaller workspace.
1942 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1943 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1944 SPL_LINUX_TRY_COMPILE([
1945 #include <linux/zlib.h>
1947 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1950 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1951 [zlib_deflate_workspacesize() wants 2 args])
1958 dnl # 2.6.39 API change,
1959 dnl # Shrinker adjust to use common shrink_control structure.
1961 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1962 AC_MSG_CHECKING([whether struct shrink_control exists])
1963 SPL_LINUX_TRY_COMPILE([
1964 #include <linux/mm.h>
1966 struct shrink_control sc __attribute__ ((unused));
1969 sc.gfp_mask = GFP_KERNEL;
1972 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1973 [struct shrink_control exists])
1980 dnl # 3.1 API Change
1982 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1983 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1985 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1986 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1987 tmp_flags="$EXTRA_KCFLAGS"
1988 EXTRA_KCFLAGS="-Werror"
1989 SPL_LINUX_TRY_COMPILE([
1990 #include <linux/rwsem.h>
1992 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1993 raw_spinlock_t dummy_lock __attribute__ ((unused));
1994 dummy_semaphore.wait_lock = dummy_lock;
1997 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1998 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2002 EXTRA_KCFLAGS="$tmp_flags"