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)
24 SPL_AC_DEBUG_KMEM_TRACKING
26 SPL_AC_ATOMIC_SPINLOCK
27 SPL_AC_TYPE_ATOMIC64_CMPXCHG
28 SPL_AC_TYPE_ATOMIC64_XCHG
30 SPL_AC_3ARGS_INIT_WORK
31 SPL_AC_2ARGS_REGISTER_SYSCTL
33 SPL_AC_3ARGS_SHRINKER_CALLBACK
34 SPL_AC_PATH_IN_NAMEIDATA
40 SPL_AC_5ARGS_DEVICE_CREATE
41 SPL_AC_CLASS_DEVICE_CREATE
42 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
43 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
48 SPL_AC_CLEAR_CLOSE_ON_EXEC
51 SPL_AC_MONOTONIC_CLOCK
54 SPL_AC_MUTEX_OWNER_TASK_STRUCT
55 SPL_AC_MUTEX_LOCK_NESTED
56 SPL_AC_3ARGS_ON_EACH_CPU
57 SPL_AC_KALLSYMS_LOOKUP_NAME
58 SPL_AC_GET_VMALLOC_INFO
60 SPL_AC_FIRST_ONLINE_PGDAT
61 SPL_AC_NEXT_ONLINE_PGDAT
64 SPL_AC_GLOBAL_PAGE_STATE
65 SPL_AC_ZONE_STAT_ITEM_FREE
66 SPL_AC_ZONE_STAT_ITEM_INACTIVE
67 SPL_AC_ZONE_STAT_ITEM_ACTIVE
68 SPL_AC_GET_ZONE_COUNTS
71 SPL_AC_2ARGS_SET_FS_PWD
72 SPL_AC_2ARGS_VFS_UNLINK
73 SPL_AC_4ARGS_VFS_RENAME
75 SPL_AC_2ARGS_VFS_FSYNC
76 SPL_AC_FS_STRUCT_SPINLOCK
79 SPL_AC_PUT_TASK_STRUCT
80 SPL_AC_5ARGS_PROC_HANDLER
82 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
83 SPL_AC_KERNEL_INVALIDATE_INODES
84 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
85 SPL_AC_SHRINK_DCACHE_MEMORY
86 SPL_AC_SHRINK_ICACHE_MEMORY
87 SPL_AC_KERN_PATH_PARENT_HEADER
88 SPL_AC_KERN_PATH_PARENT_SYMBOL
89 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
90 SPL_AC_SHRINK_CONTROL_STRUCT
91 SPL_AC_RWSEM_SPINLOCK_IS_RAW
92 SPL_AC_PMD_ALLOC_WITH_MASK
95 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
96 modpost=$LINUX/scripts/Makefile.modpost
97 AC_MSG_CHECKING([kernel file name for module symbols])
98 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
99 if grep -q Modules.symvers $modpost; then
100 LINUX_SYMBOLS=Modules.symvers
102 LINUX_SYMBOLS=Module.symvers
105 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
107 *** Please make sure the kernel devel package for your distribution
108 *** is installed. If your building with a custom kernel make sure the
109 *** kernel is configured, built, and the '--with-linux=PATH' configure
110 *** option refers to the location of the kernel source.])
115 AC_MSG_RESULT($LINUX_SYMBOLS)
116 AC_SUBST(LINUX_SYMBOLS)
119 AC_DEFUN([SPL_AC_KERNEL], [
121 AS_HELP_STRING([--with-linux=PATH],
122 [Path to kernel source]),
123 [kernelsrc="$withval"])
125 AC_ARG_WITH([linux-obj],
126 AS_HELP_STRING([--with-linux-obj=PATH],
127 [Path to kernel build objects]),
128 [kernelbuild="$withval"])
130 AC_MSG_CHECKING([kernel source directory])
131 if test -z "$kernelsrc"; then
132 if test -e "/lib/modules/$(uname -r)/source"; then
133 headersdir="/lib/modules/$(uname -r)/source"
134 sourcelink=$(readlink -f "$headersdir")
135 elif test -e "/lib/modules/$(uname -r)/build"; then
136 headersdir="/lib/modules/$(uname -r)/build"
137 sourcelink=$(readlink -f "$headersdir")
139 sourcelink=$(ls -1d /usr/src/kernels/* \
141 2>/dev/null | grep -v obj | tail -1)
144 if test -n "$sourcelink" && test -e ${sourcelink}; then
145 kernelsrc=`readlink -f ${sourcelink}`
147 AC_MSG_RESULT([Not found])
149 *** Please make sure the kernel devel package for your distribution
150 *** is installed then try again. If that fails you can specify the
151 *** location of the kernel source with the '--with-linux=PATH' option.])
154 if test "$kernelsrc" = "NONE"; then
159 AC_MSG_RESULT([$kernelsrc])
160 AC_MSG_CHECKING([kernel build directory])
161 if test -z "$kernelbuild"; then
162 if test -e "/lib/modules/$(uname -r)/build"; then
163 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
164 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
165 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
166 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
167 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
168 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
169 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
171 kernelbuild=${kernelsrc}
174 AC_MSG_RESULT([$kernelbuild])
176 AC_MSG_CHECKING([kernel source version])
177 utsrelease1=$kernelbuild/include/linux/version.h
178 utsrelease2=$kernelbuild/include/linux/utsrelease.h
179 utsrelease3=$kernelbuild/include/generated/utsrelease.h
180 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
181 utsrelease=linux/version.h
182 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
183 utsrelease=linux/utsrelease.h
184 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
185 utsrelease=generated/utsrelease.h
188 if test "$utsrelease"; then
189 kernsrcver=`(echo "#include <$utsrelease>";
190 echo "kernsrcver=UTS_RELEASE") |
191 cpp -I $kernelbuild/include |
192 grep "^kernsrcver=" | cut -d \" -f 2`
194 if test -z "$kernsrcver"; then
195 AC_MSG_RESULT([Not found])
196 AC_MSG_ERROR([*** Cannot determine kernel version.])
199 AC_MSG_RESULT([Not found])
200 if test "x$enable_linux_builtin" != xyes; then
201 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
204 *** Cannot find UTS_RELEASE definition.
205 *** Please run 'make prepare' inside the kernel source tree.])
209 AC_MSG_RESULT([$kernsrcver])
212 LINUX_OBJ=${kernelbuild}
213 LINUX_VERSION=${kernsrcver}
217 AC_SUBST(LINUX_VERSION)
219 SPL_AC_MODULE_SYMVERS
222 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
223 SPL_LINUX_CONFIG([PREEMPT],
225 *** Kernel built with CONFIG_PREEMPT which is not supported.
226 ** You must rebuild your kernel without this option.]), [])
230 dnl # Default SPL user configuration
232 AC_DEFUN([SPL_AC_CONFIG_USER], [])
235 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
236 dnl # are missing it is non-fatal but you will not be able to build
237 dnl # RPM packages and will be warned if you try too.
239 AC_DEFUN([SPL_AC_RPM], [
243 AC_MSG_CHECKING([whether $RPM is available])
244 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
245 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
247 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
250 AC_MSG_RESULT([$HAVE_RPM])
253 AC_MSG_CHECKING([whether $RPMBUILD is available])
254 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
255 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
257 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
260 AC_MSG_RESULT([$HAVE_RPMBUILD])
265 AC_SUBST(RPM_VERSION)
267 AC_SUBST(HAVE_RPMBUILD)
269 AC_SUBST(RPMBUILD_VERSION)
273 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
274 dnl # tools are missing it is non-fatal but you will not be able to build
275 dnl # DEB packages and will be warned if you try too.
277 AC_DEFUN([SPL_AC_DPKG], [
279 DPKGBUILD=dpkg-buildpackage
281 AC_MSG_CHECKING([whether $DPKG is available])
282 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
283 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
285 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
288 AC_MSG_RESULT([$HAVE_DPKG])
291 AC_MSG_CHECKING([whether $DPKGBUILD is available])
292 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
293 DPKGBUILD_VERSION=$(echo $tmp | \
294 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
296 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
299 AC_MSG_RESULT([$HAVE_DPKGBUILD])
304 AC_SUBST(DPKG_VERSION)
306 AC_SUBST(HAVE_DPKGBUILD)
308 AC_SUBST(DPKGBUILD_VERSION)
312 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
313 dnl # tools are missing it is non-fatal but you will not be able to
314 dnl # build Arch Linux packages and will be warned if you try too.
316 AC_DEFUN([SPL_AC_PACMAN], [
320 AC_MSG_CHECKING([whether $PACMAN is available])
321 tmp=$($PACMAN --version 2>/dev/null)
322 AS_IF([test -n "$tmp"], [
323 PACMAN_VERSION=$(echo $tmp |
324 $AWK '/Pacman/ { print $[3] }' |
327 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
330 AC_MSG_RESULT([$HAVE_PACMAN])
333 AC_MSG_CHECKING([whether $MAKEPKG is available])
334 tmp=$($MAKEPKG --version 2>/dev/null)
335 AS_IF([test -n "$tmp"], [
336 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
338 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
341 AC_MSG_RESULT([$HAVE_MAKEPKG])
344 AC_SUBST(HAVE_PACMAN)
346 AC_SUBST(PACMAN_VERSION)
348 AC_SUBST(HAVE_MAKEPKG)
350 AC_SUBST(MAKEPKG_VERSION)
354 dnl # Until native packaging for various different packing systems
355 dnl # can be added the least we can do is attempt to use alien to
356 dnl # convert the RPM packages to the needed package type. This is
357 dnl # a hack but so far it has worked reasonable well.
359 AC_DEFUN([SPL_AC_ALIEN], [
362 AC_MSG_CHECKING([whether $ALIEN is available])
363 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
364 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
366 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
369 AC_MSG_RESULT([$HAVE_ALIEN])
374 AC_SUBST(ALIEN_VERSION)
378 dnl # Using the VENDOR tag from config.guess set the default
379 dnl # package type for 'make pkg': (rpm | deb | tgz)
381 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
382 AC_MSG_CHECKING([linux distribution])
383 if test -f /etc/toss-release ; then
385 elif test -f /etc/fedora-release ; then
387 elif test -f /etc/redhat-release ; then
389 elif test -f /etc/gentoo-release ; then
391 elif test -f /etc/arch-release ; then
393 elif test -f /etc/SuSE-release ; then
395 elif test -f /etc/slackware-version ; then
397 elif test -f /etc/lunar.release ; then
399 elif test -f /etc/lsb-release ; then
401 elif test -f /etc/debian_version ; then
406 AC_MSG_RESULT([$VENDOR])
409 AC_MSG_CHECKING([default package type])
411 toss) DEFAULT_PACKAGE=rpm ;;
412 redhat) DEFAULT_PACKAGE=rpm ;;
413 fedora) DEFAULT_PACKAGE=rpm ;;
414 gentoo) DEFAULT_PACKAGE=tgz ;;
415 arch) DEFAULT_PACKAGE=arch ;;
416 sles) DEFAULT_PACKAGE=rpm ;;
417 slackware) DEFAULT_PACKAGE=tgz ;;
418 lunar) DEFAULT_PACKAGE=tgz ;;
419 ubuntu) DEFAULT_PACKAGE=deb ;;
420 debian) DEFAULT_PACKAGE=deb ;;
421 *) DEFAULT_PACKAGE=rpm ;;
424 AC_MSG_RESULT([$DEFAULT_PACKAGE])
425 AC_SUBST(DEFAULT_PACKAGE)
429 dnl # Default SPL user configuration
431 AC_DEFUN([SPL_AC_PACKAGE], [
432 SPL_AC_DEFAULT_PACKAGE
437 AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
440 AC_DEFUN([SPL_AC_LICENSE], [
441 AC_MSG_CHECKING([spl license])
443 AC_MSG_RESULT([$LICENSE])
444 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
448 AC_DEFUN([SPL_AC_CONFIG], [
450 AC_ARG_WITH([config],
451 AS_HELP_STRING([--with-config=CONFIG],
452 [Config file 'kernel|user|all|srpm']),
453 [SPL_CONFIG="$withval"])
454 AC_ARG_ENABLE([linux-builtin],
455 [AC_HELP_STRING([--enable-linux-builtin],
456 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
458 [enable_linux_builtin=no])
460 AC_MSG_CHECKING([spl config])
461 AC_MSG_RESULT([$SPL_CONFIG]);
464 case "$SPL_CONFIG" in
465 kernel) SPL_AC_CONFIG_KERNEL ;;
466 user) SPL_AC_CONFIG_USER ;;
467 all) SPL_AC_CONFIG_KERNEL
468 SPL_AC_CONFIG_USER ;;
471 AC_MSG_RESULT([Error!])
472 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
473 user kernel|user|all|srpm]) ;;
476 AM_CONDITIONAL([CONFIG_USER],
477 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
478 AM_CONDITIONAL([CONFIG_KERNEL],
479 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
480 [test "x$enable_linux_builtin" != xyes ])
484 dnl # Enable if the SPL should be compiled with internal debugging enabled.
485 dnl # By default this support is disabled.
487 AC_DEFUN([SPL_AC_DEBUG], [
488 AC_MSG_CHECKING([whether debugging is enabled])
489 AC_ARG_ENABLE([debug],
490 [AS_HELP_STRING([--enable-debug],
491 [Enable generic debug support @<:@default=no@:>@])],
495 AS_IF([test "x$enable_debug" = xyes],
497 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
498 DEBUG_CFLAGS="-DDEBUG -Werror"
499 DEBUG_SPL="_with_debug"
501 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
502 DEBUG_CFLAGS="-DNDEBUG"
503 DEBUG_SPL="_without_debug"
506 AC_SUBST(DEBUG_CFLAGS)
508 AC_MSG_RESULT([$enable_debug])
512 dnl # Enabled by default it provides a basic debug log infrastructure.
513 dnl # Each subsystem registers itself with a name and logs messages
514 dnl # using predefined types. If the debug mask it set to allow the
515 dnl # message type it will be written to the internal log. The log
516 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
517 dnl # after dumping the log it must be decoded using the spl utility.
519 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
520 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
522 AC_DEFUN([SPL_AC_DEBUG_LOG], [
523 AC_ARG_ENABLE([debug-log],
524 [AS_HELP_STRING([--enable-debug-log],
525 [Enable basic debug logging @<:@default=yes@:>@])],
527 [enable_debug_log=yes])
529 AS_IF([test "x$enable_debug_log" = xyes],
531 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
532 DEBUG_LOG="_with_debug_log"
533 AC_DEFINE([DEBUG_LOG], [1],
534 [Define to 1 to enable basic debug logging])
536 DEBUG_LOG="_without_debug_log"
540 AC_MSG_CHECKING([whether basic debug logging is enabled])
541 AC_MSG_RESULT([$enable_debug_log])
545 dnl # Enabled by default it provides a minimal level of memory tracking.
546 dnl # A total count of bytes allocated is kept for each alloc and free.
547 dnl # Then at module unload time a report to the console will be printed
548 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
549 dnl # and provide an easy way to inspect the kmem based slab.
551 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
552 AC_ARG_ENABLE([debug-kmem],
553 [AS_HELP_STRING([--enable-debug-kmem],
554 [Enable basic kmem accounting @<:@default=yes@:>@])],
556 [enable_debug_kmem=yes])
558 AS_IF([test "x$enable_debug_kmem" = xyes],
560 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
561 DEBUG_KMEM="_with_debug_kmem"
562 AC_DEFINE([DEBUG_KMEM], [1],
563 [Define to 1 to enable basic kmem accounting])
565 DEBUG_KMEM="_without_debug_kmem"
569 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
570 AC_MSG_RESULT([$enable_debug_kmem])
574 dnl # Disabled by default it provides detailed memory tracking. This
575 dnl # feature also requires --enable-debug-kmem to be set. When enabled
576 dnl # not only will total bytes be tracked but also the location of every
577 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
578 dnl # addresses and where they were allocated will be dumped to the console.
579 dnl # Enabling this feature has a significant impact on performance but it
580 dnl # makes finding memory leaks pretty straight forward.
582 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
583 AC_ARG_ENABLE([debug-kmem-tracking],
584 [AS_HELP_STRING([--enable-debug-kmem-tracking],
585 [Enable detailed kmem tracking @<:@default=no@:>@])],
587 [enable_debug_kmem_tracking=no])
589 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
591 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
592 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
593 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
594 [Define to 1 to enable detailed kmem tracking])
596 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
599 AC_SUBST(DEBUG_KMEM_TRACKING)
600 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
601 AC_MSG_RESULT([$enable_debug_kmem_tracking])
605 dnl # SPL_LINUX_CONFTEST
607 AC_DEFUN([SPL_LINUX_CONFTEST], [
608 cat confdefs.h - <<_ACEOF >conftest.c
614 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
616 m4_define([SPL_LANG_PROGRAM], [
621 dnl Do *not* indent the following line: there may be CPP directives.
622 dnl Don't move the `;' right after for the same reason.
630 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
632 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
633 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
634 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
635 echo "obj-m := conftest.o" >build/Makefile
637 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
639 [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])],
641 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
647 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
649 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
650 [SPL_LINUX_COMPILE_IFELSE(
651 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
653 [test -s build/conftest.o],
658 dnl # SPL_LINUX_CONFIG
660 AC_DEFUN([SPL_LINUX_CONFIG],
661 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
662 SPL_LINUX_TRY_COMPILE([
663 #include <linux/module.h>
666 #error CONFIG_$1 not #defined
678 dnl # SPL_CHECK_SYMBOL_EXPORT
679 dnl # check symbol exported or not
681 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
682 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
683 $LINUX_OBJ/Module*.symvers 2>/dev/null
685 if test $rc -ne 0; then
688 grep -q -E "EXPORT_SYMBOL.*($1)" \
689 "$LINUX_OBJ/$file" 2>/dev/null
691 if test $rc -eq 0; then
696 if test $export -eq 0; then :
707 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
708 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
709 dnl # is called if not compiling for builtin
711 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
712 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
713 if test $rc -ne 0; then :
716 if test "x$enable_linux_builtin" != xyes; then
717 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
719 if test $rc -ne 0; then :
728 dnl # SPL_CHECK_SYMBOL_HEADER
729 dnl # check if a symbol prototype is defined in listed headers.
731 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
732 AC_MSG_CHECKING([whether symbol $1 exists in header])
735 grep -q "$2" "$LINUX/$file" 2>/dev/null
737 if test $rc -eq 0; then
742 if test $header -eq 0; then
752 dnl # SPL_CHECK_HEADER
753 dnl # check whether header exists and define HAVE_$2_HEADER
755 AC_DEFUN([SPL_CHECK_HEADER],
756 [AC_MSG_CHECKING([whether header $1 exists])
757 SPL_LINUX_TRY_COMPILE([
762 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
772 dnl # Basic toolchain sanity check.
774 AC_DEFUN([SPL_AC_TEST_MODULE],
775 [AC_MSG_CHECKING([whether modules can be built])
776 SPL_LINUX_TRY_COMPILE([],[],[
780 if test "x$enable_linux_builtin" != xyes; then
781 AC_MSG_ERROR([*** Unable to build an empty module.])
784 *** Unable to build an empty module.
785 *** Please run 'make scripts' inside the kernel source tree.])
791 dnl # Use the atomic implemenation based on global spinlocks. This
792 dnl # should only be needed by 32-bit kernels which do not provide
793 dnl # the atomic64_* API. It may be optionally enabled as a fallback
794 dnl # if problems are observed with the direct mapping to the native
795 dnl # Linux atomic operations. You may not disable atomic spinlocks
796 dnl # if you kernel does not an atomic64_* API.
798 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
799 AC_ARG_ENABLE([atomic-spinlocks],
800 [AS_HELP_STRING([--enable-atomic-spinlocks],
801 [Atomic types use spinlocks @<:@default=check@:>@])],
803 [enable_atomic_spinlocks=check])
805 SPL_LINUX_TRY_COMPILE([
806 #include <asm/atomic.h>
808 atomic64_t *ptr __attribute__ ((unused));
811 AC_DEFINE(HAVE_ATOMIC64_T, 1,
812 [kernel defines atomic64_t])
817 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
818 AS_IF([test "x$have_atomic64_t" = xyes], [
819 enable_atomic_spinlocks=no
821 enable_atomic_spinlocks=yes
825 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
826 AC_DEFINE([ATOMIC_SPINLOCK], [1],
827 [Atomic types use spinlocks])
829 AS_IF([test "x$have_atomic64_t" = xno], [
831 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
835 AC_MSG_CHECKING([whether atomic types use spinlocks])
836 AC_MSG_RESULT([$enable_atomic_spinlocks])
838 AC_MSG_CHECKING([whether kernel defines atomic64_t])
839 AC_MSG_RESULT([$have_atomic64_t])
843 dnl # 2.6.24 API change,
844 dnl # check if atomic64_cmpxchg is defined
846 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
847 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
848 SPL_LINUX_TRY_COMPILE([
849 #include <asm/atomic.h>
850 #include <asm/system.h>
852 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
855 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
856 [kernel defines atomic64_cmpxchg])
863 dnl # 2.6.24 API change,
864 dnl # check if atomic64_xchg is defined
866 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
867 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
868 SPL_LINUX_TRY_COMPILE([
869 #include <asm/atomic.h>
871 atomic64_xchg((atomic64_t *)NULL, 0);
874 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
875 [kernel defines atomic64_xchg])
882 dnl # 2.6.24 API change,
883 dnl # check if uintptr_t typedef is defined
885 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
886 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
887 SPL_LINUX_TRY_COMPILE([
888 #include <linux/types.h>
890 uintptr_t *ptr __attribute__ ((unused));
893 AC_DEFINE(HAVE_UINTPTR_T, 1,
894 [kernel defines uintptr_t])
901 dnl # 2.6.20 API change,
902 dnl # INIT_WORK use 2 args and not store data inside
904 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
905 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
906 SPL_LINUX_TRY_COMPILE([
907 #include <linux/workqueue.h>
909 struct work_struct work __attribute__ ((unused));
910 INIT_WORK(&work, NULL, NULL);
913 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
914 [INIT_WORK wants 3 args])
921 dnl # 2.6.21 API change,
922 dnl # 'register_sysctl_table' use only one argument instead of two
924 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
925 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
926 SPL_LINUX_TRY_COMPILE([
927 #include <linux/sysctl.h>
929 (void) register_sysctl_table(NULL, 0);
932 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
933 [register_sysctl_table() wants 2 args])
940 dnl # 2.6.23 API change
941 dnl # Old set_shrinker API replaced with register_shrinker
943 AC_DEFUN([SPL_AC_SET_SHRINKER], [
944 AC_MSG_CHECKING([whether set_shrinker() available])
945 SPL_LINUX_TRY_COMPILE([
946 #include <linux/mm.h>
948 return set_shrinker(DEFAULT_SEEKS, NULL);
951 AC_DEFINE(HAVE_SET_SHRINKER, 1,
952 [set_shrinker() available])
959 dnl # 2.6.35 API change,
960 dnl # Add context to shrinker callback
962 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
963 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
964 tmp_flags="$EXTRA_KCFLAGS"
965 EXTRA_KCFLAGS="-Werror"
966 SPL_LINUX_TRY_COMPILE([
967 #include <linux/mm.h>
969 int shrinker_cb(struct shrinker *, int, unsigned int);
971 struct shrinker cache_shrinker = {
972 .shrink = shrinker_cb,
973 .seeks = DEFAULT_SEEKS,
975 register_shrinker(&cache_shrinker);
978 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
979 [shrinker callback wants 3 args])
983 EXTRA_KCFLAGS="$tmp_flags"
987 dnl # 2.6.25 API change,
988 dnl # struct path entry added to struct nameidata
990 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
991 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
992 SPL_LINUX_TRY_COMPILE([
993 #include <linux/namei.h>
995 struct nameidata nd __attribute__ ((unused));
998 nd.path.dentry = NULL;
1001 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
1002 [struct path used in struct nameidata])
1009 dnl # Custom SPL patch may export this system it is not required
1011 AC_DEFUN([SPL_AC_TASK_CURR],
1012 [AC_MSG_CHECKING([whether task_curr() is available])
1013 SPL_LINUX_TRY_COMPILE_SYMBOL([
1014 #include <linux/sched.h>
1017 ], [task_curr], [kernel/sched.c], [
1019 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1026 dnl # 2.6.19 API change,
1027 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1029 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1030 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1031 SPL_LINUX_TRY_COMPILE([
1032 #include <linux/sysctl.h>
1034 #ifndef CTL_UNNUMBERED
1035 #error CTL_UNNUMBERED undefined
1039 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1040 [unnumbered sysctl support exists])
1047 dnl # 2.6.33 API change,
1048 dnl # Removed .ctl_name from struct ctl_table.
1050 AC_DEFUN([SPL_AC_CTL_NAME], [
1051 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1052 SPL_LINUX_TRY_COMPILE([
1053 #include <linux/sysctl.h>
1055 struct ctl_table ctl __attribute__ ((unused));
1059 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1066 dnl # 2.6.16 API change.
1067 dnl # Check if 'fls64()' is available
1069 AC_DEFUN([SPL_AC_FLS64],
1070 [AC_MSG_CHECKING([whether fls64() is available])
1071 SPL_LINUX_TRY_COMPILE([
1072 #include <linux/bitops.h>
1077 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1084 dnl # 2.6.18 API change, check whether device_create() is available.
1085 dnl # Device_create() was introduced in 2.6.18 and depricated
1086 dnl # class_device_create() which was fully removed in 2.6.26.
1088 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1089 [AC_MSG_CHECKING([whether device_create() is available])
1090 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1092 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1093 [device_create() is available])
1100 dnl # 2.6.27 API change,
1101 dnl # device_create() uses 5 args, new 'drvdata' argument.
1103 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1104 AC_MSG_CHECKING([whether device_create() wants 5 args])
1105 tmp_flags="$EXTRA_KCFLAGS"
1106 EXTRA_KCFLAGS="-Werror"
1107 SPL_LINUX_TRY_COMPILE([
1108 #include <linux/device.h>
1110 device_create(NULL, NULL, 0, NULL, "%d", 1);
1113 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1114 [device_create wants 5 args])
1118 EXTRA_KCFLAGS="$tmp_flags"
1122 dnl # 2.6.13 API change, check whether class_device_create() is available.
1123 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1124 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1126 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1127 [AC_MSG_CHECKING([whether class_device_create() is available])
1128 SPL_LINUX_TRY_COMPILE_SYMBOL([
1129 #include <linux/device.h>
1131 class_device_create(NULL, NULL, 0, NULL, NULL);
1132 ], [class_device_create], [drivers/base/class.c], [
1134 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1135 [class_device_create() is available])
1142 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1144 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1145 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1146 SPL_LINUX_TRY_COMPILE_SYMBOL([
1147 #include <linux/time.h>
1149 set_normalized_timespec(NULL, 0, 0);
1150 ], [set_normalized_timespec], [kernel/time.c], [
1152 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1153 [set_normalized_timespec() is available as export])
1160 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1161 dnl # previously it was available in time.h as an inline.
1163 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1164 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1165 SPL_LINUX_TRY_COMPILE([
1166 #include <linux/time.h>
1167 void set_normalized_timespec(struct timespec *ts,
1168 time_t sec, long nsec) { }
1175 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1176 [set_normalized_timespec() is available as inline])
1181 dnl # 2.6.18 API change,
1182 dnl # timespec_sub() inline function available in linux/time.h
1184 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1185 AC_MSG_CHECKING([whether timespec_sub() is available])
1186 SPL_LINUX_TRY_COMPILE([
1187 #include <linux/time.h>
1189 struct timespec a = { 0 };
1190 struct timespec b = { 0 };
1191 struct timespec c __attribute__ ((unused));
1192 c = timespec_sub(a, b);
1195 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1202 dnl # 2.6.19 API change,
1203 dnl # check if init_utsname() is available in linux/utsname.h
1205 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1206 AC_MSG_CHECKING([whether init_utsname() is available])
1207 SPL_LINUX_TRY_COMPILE([
1208 #include <linux/utsname.h>
1210 struct new_utsname *a __attribute__ ((unused));
1214 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1221 dnl # 2.6.26 API change,
1222 dnl # definition of struct fdtable relocated to linux/fdtable.h
1224 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1225 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1229 dnl # 2.6.14 API change,
1230 dnl # check whether 'files_fdtable()' exists
1232 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1233 AC_MSG_CHECKING([whether files_fdtable() is available])
1234 SPL_LINUX_TRY_COMPILE([
1235 #include <linux/sched.h>
1236 #include <linux/file.h>
1237 #ifdef HAVE_FDTABLE_HEADER
1238 #include <linux/fdtable.h>
1241 struct files_struct *files = current->files;
1242 struct fdtable *fdt __attribute__ ((unused));
1243 fdt = files_fdtable(files);
1246 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1253 dnl # 3.4.0 API change,
1254 dnl # check whether '__clear_close_on_exec()' exists
1256 AC_DEFUN([SPL_AC_CLEAR_CLOSE_ON_EXEC], [
1257 AC_MSG_CHECKING([whether __clear_close_on_exec() is available])
1258 SPL_LINUX_TRY_COMPILE([
1259 #include <linux/fdtable.h>
1261 struct fdtable *fdt = NULL;
1264 __clear_close_on_exec(fd, fdt);
1267 AC_DEFINE(HAVE_CLEAR_CLOSE_ON_EXEC, 1,
1268 [__clear_close_on_exec() is available])
1275 dnl # 2.6.18 API change,
1276 dnl # added linux/uaccess.h
1278 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1279 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1283 dnl # 2.6.12 API change,
1284 dnl # check whether 'kmalloc_node()' is available.
1286 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1287 AC_MSG_CHECKING([whether kmalloc_node() is available])
1288 SPL_LINUX_TRY_COMPILE([
1289 #include <linux/slab.h>
1291 void *a __attribute__ ((unused));
1292 a = kmalloc_node(1, GFP_KERNEL, 0);
1295 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1302 dnl # 2.6.9 API change,
1303 dnl # check whether 'monotonic_clock()' is available it may
1304 dnl # be available for some archs but not others.
1306 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1307 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1308 SPL_LINUX_TRY_COMPILE_SYMBOL([
1309 #include <linux/timex.h>
1312 ], [monotonic_clock], [], [
1314 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1315 [monotonic_clock() is available])
1322 dnl # 2.6.16 API change,
1323 dnl # check whether 'struct inode' has i_mutex
1325 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1326 AC_MSG_CHECKING([whether struct inode has i_mutex])
1327 SPL_LINUX_TRY_COMPILE([
1328 #include <linux/fs.h>
1329 #include <linux/mutex.h>
1332 mutex_init(&i.i_mutex);
1335 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1342 dnl # 2.6.29 API change,
1343 dnl # Adaptive mutexs introduced.
1345 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1346 AC_MSG_CHECKING([whether struct mutex has owner])
1347 SPL_LINUX_TRY_COMPILE([
1348 #include <linux/mutex.h>
1350 struct mutex mtx __attribute__ ((unused));
1354 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1361 dnl # 2.6.39 API change,
1362 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1363 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1364 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1365 dnl # pointer which frankly makes a lot more sense.
1367 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1368 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1369 tmp_flags="$EXTRA_KCFLAGS"
1370 EXTRA_KCFLAGS="-Werror"
1371 SPL_LINUX_TRY_COMPILE([
1372 #include <linux/mutex.h>
1374 struct mutex mtx __attribute__ ((unused));
1375 mtx.owner = current;
1378 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1379 [struct mutex owner is a task_struct])
1383 EXTRA_KCFLAGS="$tmp_flags"
1387 dnl # 2.6.18 API change,
1388 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1389 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1390 dnl # if the mutex validator is disabled or otherwise unavailable.
1392 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1393 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1394 SPL_LINUX_TRY_COMPILE([
1395 #include <linux/mutex.h>
1399 mutex_lock_nested(&mutex, 0);
1402 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1403 [mutex_lock_nested() is available])
1410 dnl # 2.6.27 API change,
1411 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1413 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1414 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1415 SPL_LINUX_TRY_COMPILE([
1416 #include <linux/smp.h>
1418 on_each_cpu(NULL, NULL, 0);
1421 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1422 [on_each_cpu wants 3 args])
1429 dnl # 2.6.18 API change,
1430 dnl # kallsyms_lookup_name no longer exported
1432 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1433 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1434 SPL_LINUX_TRY_COMPILE_SYMBOL([
1435 #include <linux/kallsyms.h>
1437 kallsyms_lookup_name(NULL);
1438 ], [kallsyms_lookup_name], [], [
1440 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1441 [kallsyms_lookup_name() is available])
1448 dnl # Proposed API change,
1449 dnl # This symbol is not available in stock kernels. You may build a
1450 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1451 dnl # these symbols for use. If your already rolling a custom kernel for
1452 dnl # your environment this is recommended.
1454 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1455 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1456 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1458 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1459 [get_vmalloc_info() is available])
1466 dnl # 2.6.17 API change
1467 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1468 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1469 dnl # were exported in 2.6.17 for use by modules which was consistent with
1470 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1471 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1472 dnl # were dropped entirely leaving modules no way to directly iterate over
1473 dnl # the zone list. Because we need access to the zone helpers we check
1474 dnl # if the kernel contains the old or new implementation. Then we check
1475 dnl # to see if the symbols we need for each version are available. If they
1476 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1478 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1479 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1480 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1482 if test $rc -eq 0; then
1483 AC_MSG_RESULT([yes])
1484 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1491 dnl # Proposed API change,
1492 dnl # This symbol is not available in stock kernels. You may build a
1493 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1494 dnl # these symbols for use. If your already rolling a custom kernel for
1495 dnl # your environment this is recommended.
1497 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1498 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1499 SPL_LINUX_TRY_COMPILE_SYMBOL([
1500 #include <linux/mmzone.h>
1502 first_online_pgdat();
1503 ], [first_online_pgdat], [], [
1505 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1506 [first_online_pgdat() is available])
1513 dnl # Proposed API change,
1514 dnl # This symbol is not available in stock kernels. You may build a
1515 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1516 dnl # these symbols for use. If your already rolling a custom kernel for
1517 dnl # your environment this is recommended.
1519 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1520 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1521 SPL_LINUX_TRY_COMPILE_SYMBOL([
1522 #include <linux/mmzone.h>
1524 next_online_pgdat(NULL);
1525 ], [next_online_pgdat], [], [
1527 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1528 [next_online_pgdat() is available])
1535 dnl # Proposed API change,
1536 dnl # This symbol is not available in stock kernels. You may build a
1537 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1538 dnl # these symbols for use. If your already rolling a custom kernel for
1539 dnl # your environment this is recommended.
1541 AC_DEFUN([SPL_AC_NEXT_ZONE],
1542 [AC_MSG_CHECKING([whether next_zone() is available])
1543 SPL_LINUX_TRY_COMPILE_SYMBOL([
1544 #include <linux/mmzone.h>
1547 ], [next_zone], [], [
1549 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1556 dnl # 2.6.17 API change,
1557 dnl # See SPL_AC_PGDAT_HELPERS for details.
1559 AC_DEFUN([SPL_AC_PGDAT_LIST],
1560 [AC_MSG_CHECKING([whether pgdat_list is available])
1561 SPL_LINUX_TRY_COMPILE_SYMBOL([
1562 #include <linux/topology.h>
1563 pg_data_t *tmp = pgdat_list;
1564 ], [], [pgdat_list], [], [
1566 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1573 dnl # 2.6.18 API change,
1574 dnl # First introduced global_page_state() support as an inline.
1576 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1577 AC_MSG_CHECKING([whether global_page_state() is available])
1578 SPL_LINUX_TRY_COMPILE([
1579 #include <linux/mm.h>
1581 unsigned long state __attribute__ ((unused));
1582 state = global_page_state(0);
1585 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1586 [global_page_state() is available])
1593 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1594 dnl # Public global zone stats now include a free page count. However
1595 dnl # the enumerated names of the counters have changed since this API
1596 dnl # was introduced. We need to deduce the corrent name to use. This
1597 dnl # replaces the priviate get_zone_counts() interface.
1599 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1600 dnl # is 2.6.30 as of when this was written.
1602 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1603 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1604 SPL_LINUX_TRY_COMPILE([
1605 #include <linux/mm.h>
1607 enum zone_stat_item zsi __attribute__ ((unused));
1608 zsi = NR_FREE_PAGES;
1611 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1612 [Page state NR_FREE_PAGES is available])
1619 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1620 dnl # Public global zone stats now include an inactive page count. However
1621 dnl # the enumerated names of the counters have changed since this API
1622 dnl # was introduced. We need to deduce the corrent name to use. This
1623 dnl # replaces the priviate get_zone_counts() interface.
1625 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1626 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1627 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1629 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1630 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1631 SPL_LINUX_TRY_COMPILE([
1632 #include <linux/mm.h>
1634 enum zone_stat_item zsi __attribute__ ((unused));
1638 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1639 [Page state NR_INACTIVE is available])
1644 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1645 SPL_LINUX_TRY_COMPILE([
1646 #include <linux/mm.h>
1648 enum zone_stat_item zsi __attribute__ ((unused));
1649 zsi = NR_INACTIVE_ANON;
1652 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1653 [Page state NR_INACTIVE_ANON is available])
1658 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1659 SPL_LINUX_TRY_COMPILE([
1660 #include <linux/mm.h>
1662 enum zone_stat_item zsi __attribute__ ((unused));
1663 zsi = NR_INACTIVE_FILE;
1666 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1667 [Page state NR_INACTIVE_FILE is available])
1674 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1675 dnl # Public global zone stats now include an active page count. However
1676 dnl # the enumerated names of the counters have changed since this API
1677 dnl # was introduced. We need to deduce the corrent name to use. This
1678 dnl # replaces the priviate get_zone_counts() interface.
1680 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1681 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1682 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1684 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1685 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1686 SPL_LINUX_TRY_COMPILE([
1687 #include <linux/mm.h>
1689 enum zone_stat_item zsi __attribute__ ((unused));
1693 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1694 [Page state NR_ACTIVE is available])
1699 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1700 SPL_LINUX_TRY_COMPILE([
1701 #include <linux/mm.h>
1703 enum zone_stat_item zsi __attribute__ ((unused));
1704 zsi = NR_ACTIVE_ANON;
1707 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1708 [Page state NR_ACTIVE_ANON is available])
1713 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1714 SPL_LINUX_TRY_COMPILE([
1715 #include <linux/mm.h>
1717 enum zone_stat_item zsi __attribute__ ((unused));
1718 zsi = NR_ACTIVE_FILE;
1721 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1722 [Page state NR_ACTIVE_FILE is available])
1729 dnl # Proposed API change for legacy kernels.
1730 dnl # This symbol is not available in older kernels. For kernels post
1731 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1732 dnl # page state information. This symbol is only used in legacy kernels
1733 dnl # any only as a last resort.
1735 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1736 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1737 SPL_LINUX_TRY_COMPILE([
1739 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1740 #error "global_page_state needs NR_FREE_PAGES"
1743 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1744 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1745 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1746 #error "global_page_state needs NR_ACTIVE*"
1749 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1750 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1751 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1752 #error "global_page_state needs NR_INACTIVE*"
1758 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1759 [get_zone_counts() is needed])
1761 AC_MSG_CHECKING([whether get_zone_counts() is available])
1762 SPL_LINUX_TRY_COMPILE_SYMBOL([
1763 #include <linux/mmzone.h>
1765 get_zone_counts(NULL, NULL, NULL);
1766 ], [get_zone_counts], [], [
1768 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1769 [get_zone_counts() is available])
1777 dnl # 2.6.27 API change,
1778 dnl # The user_path_dir() replaces __user_walk()
1780 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1781 [AC_MSG_CHECKING([whether user_path_dir() is available])
1782 SPL_LINUX_TRY_COMPILE_SYMBOL([
1783 #include <linux/fcntl.h>
1784 #include <linux/namei.h>
1786 user_path_dir(NULL, NULL);
1787 ], [user_path_at], [], [
1789 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1796 dnl # Symbol available in RHEL kernels not in stock kernels.
1798 AC_DEFUN([SPL_AC_SET_FS_PWD],
1799 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1800 SPL_LINUX_TRY_COMPILE_SYMBOL([
1801 #include <linux/spinlock.h>
1802 #include <linux/fs_struct.h>
1805 ], [set_fs_pwd], [], [
1807 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1814 dnl # 2.6.25 API change,
1815 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1817 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1818 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1819 SPL_LINUX_TRY_COMPILE([
1820 #include <linux/sched.h>
1821 #include <linux/fs_struct.h>
1823 set_fs_pwd(NULL, NULL);
1826 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1827 [set_fs_pwd() wants 2 args])
1834 dnl # SLES API change, never adopted in mainline,
1835 dnl # Third 'struct vfsmount *' argument removed.
1837 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1838 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1839 SPL_LINUX_TRY_COMPILE([
1840 #include <linux/fs.h>
1842 vfs_unlink(NULL, NULL);
1845 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1846 [vfs_unlink() wants 2 args])
1853 dnl # SLES API change, never adopted in mainline,
1854 dnl # Third and sixth 'struct vfsmount *' argument removed.
1856 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1857 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1858 SPL_LINUX_TRY_COMPILE([
1859 #include <linux/fs.h>
1861 vfs_rename(NULL, NULL, NULL, NULL);
1864 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1865 [vfs_rename() wants 4 args])
1872 dnl # 2.6.36 API change,
1873 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1874 dnl # a spinlock_t to improve the fastpath performance.
1876 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1877 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1878 tmp_flags="$EXTRA_KCFLAGS"
1879 EXTRA_KCFLAGS="-Werror"
1880 SPL_LINUX_TRY_COMPILE([
1881 #include <linux/sched.h>
1882 #include <linux/fs_struct.h>
1884 struct fs_struct fs;
1885 spin_lock_init(&fs.lock);
1888 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1889 [struct fs_struct uses spinlock_t])
1893 EXTRA_KCFLAGS="$tmp_flags"
1897 dnl # 2.6.29 API change,
1898 dnl # check whether 'struct cred' exists
1900 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1901 AC_MSG_CHECKING([whether struct cred exists])
1902 SPL_LINUX_TRY_COMPILE([
1903 #include <linux/cred.h>
1905 struct cred *cr __attribute__ ((unused));
1909 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1916 dnl # Custom SPL patch may export this symbol.
1918 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1919 [AC_MSG_CHECKING([whether groups_search() is available])
1920 SPL_LINUX_TRY_COMPILE_SYMBOL([
1921 #include <linux/cred.h>
1923 groups_search(NULL, 0);
1924 ], [groups_search], [], [
1926 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1933 dnl # 2.6.x API change,
1934 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1936 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1937 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1938 SPL_LINUX_TRY_COMPILE_SYMBOL([
1939 #include <linux/sched.h>
1941 __put_task_struct(NULL);
1942 ], [__put_task_struct], [], [
1944 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1945 [__put_task_struct() is available])
1952 dnl # 2.6.32 API change,
1953 dnl # Unused 'struct file *' removed from prototype.
1955 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1956 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1957 SPL_LINUX_TRY_COMPILE([
1958 #include <linux/sysctl.h>
1960 proc_dostring(NULL, 0, NULL, NULL, NULL);
1963 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1964 [proc_handler() wants 5 args])
1971 dnl # 2.6.x API change,
1972 dnl # kvasprintf() function added.
1974 AC_DEFUN([SPL_AC_KVASPRINTF],
1975 [AC_MSG_CHECKING([whether kvasprintf() is available])
1976 SPL_LINUX_TRY_COMPILE_SYMBOL([
1977 #include <linux/kernel.h>
1979 kvasprintf(0, NULL, *((va_list*)NULL));
1980 ], [kvasprintf], [], [
1982 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1989 dnl # 2.6.29 API change,
1990 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1992 AC_DEFUN([SPL_AC_VFS_FSYNC],
1993 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1994 SPL_LINUX_TRY_COMPILE_SYMBOL([
1995 #include <linux/fs.h>
1998 ], [vfs_fsync], [fs/sync.c], [
2000 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2007 dnl # 2.6.35 API change,
2008 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2010 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2011 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2012 SPL_LINUX_TRY_COMPILE([
2013 #include <linux/fs.h>
2018 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2025 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2026 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2027 dnl # condition. The fixed version is exported as a symbol. The race
2028 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2029 dnl # call that version while holding sem->wait_lock.
2031 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2032 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2033 SPL_LINUX_TRY_COMPILE_SYMBOL([
2034 #include <linux/rwsem.h>
2035 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2036 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2038 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2039 [rwsem_is_locked() acquires sem->wait_lock])
2046 dnl # 2.6.37 API compat,
2047 dnl # The function invalidate_inodes() is no longer exported by the kernel.
2048 dnl # The prototype however is still available which means it is safe
2049 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
2051 dnl # The Proxmox VE kernel contains a patch which renames the function
2052 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
2053 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
2054 dnl # compatibility wrapper for legacy callers. Therefore, if either
2055 dnl # of these functions are exported invalidate_inodes() can be
2058 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
2059 AC_MSG_CHECKING([whether invalidate_inodes() is available])
2060 SPL_LINUX_TRY_COMPILE_SYMBOL([
2061 #include <linux/fs.h>
2064 ], [invalidate_inodes], [], [
2066 AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
2067 [invalidate_inodes() is available])
2072 AC_MSG_CHECKING([whether invalidate_inodes_check() is available])
2073 SPL_LINUX_TRY_COMPILE_SYMBOL([
2074 #include <linux/fs.h>
2076 invalidate_inodes_check(NULL, 0);
2077 ], [invalidate_inodes_check], [], [
2079 AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
2080 [invalidate_inodes_check() is available])
2087 dnl # 2.6.39 API compat,
2088 dnl # The function invalidate_inodes() now take 2 arguments. The second
2089 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
2090 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
2091 dnl # otherwise they will be handled as busy.
2093 dnl # Unfortunately, we don't have access to the invalidate_inodes()
2094 dnl # prototype so it's not easy to check how many arguments it takes.
2095 dnl # However, this change was done for the benefit of invalidate_device()
2096 dnl # which also added an argument. The invalidate_device() symbol does
2097 dnl # exist in the development headers so if it takes two arguments we
2098 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
2099 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
2101 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
2102 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
2103 SPL_LINUX_TRY_COMPILE([
2104 #include <linux/fs.h>
2106 return __invalidate_device(NULL, 0);
2109 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
2110 [invalidate_inodes() wants 2 args])
2117 dnl # 2.6.xx API compat,
2118 dnl # There currently exists no exposed API to partially shrink the dcache.
2119 dnl # The expected mechanism to shrink the cache is a registered shrinker
2120 dnl # which is called during memory pressure.
2122 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2123 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2124 SPL_LINUX_TRY_COMPILE_SYMBOL([
2125 #include <linux/dcache.h>
2127 shrink_dcache_memory(0, 0);
2128 ], [shrink_dcache_memory], [fs/dcache.c], [
2130 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2131 [shrink_dcache_memory() is available])
2138 dnl # 2.6.xx API compat,
2139 dnl # There currently exists no exposed API to partially shrink the icache.
2140 dnl # The expected mechanism to shrink the cache is a registered shrinker
2141 dnl # which is called during memory pressure.
2143 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2144 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2145 SPL_LINUX_TRY_COMPILE_SYMBOL([
2146 #include <linux/dcache.h>
2148 shrink_icache_memory(0, 0);
2149 ], [shrink_icache_memory], [fs/inode.c], [
2151 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2152 [shrink_icache_memory() is available])
2159 dnl # 2.6.39 API compat,
2160 dnl # The path_lookup() function has been renamed to kern_path_parent()
2161 dnl # and the flags argument has been removed. The only behavior now
2162 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2163 dnl # this flag so dropping the flag does not impact us.
2165 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2166 SPL_CHECK_SYMBOL_HEADER(
2168 [int kern_path_parent(const char \*, struct nameidata \*)],
2169 [include/linux/namei.h],
2170 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2171 [kern_path_parent() is available])],
2176 dnl # 3.1 API compat,
2177 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2178 dnl # However, it remains the prefered interface and since we still have
2179 dnl # access to the prototype we dynamically lookup the required address.
2181 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2182 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2183 SPL_LINUX_TRY_COMPILE_SYMBOL([
2184 #include <linux/namei.h>
2186 kern_path_parent(NULL, NULL);
2187 ], [kern_path_parent], [fs/namei.c], [
2189 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2190 [kern_path_parent() is available])
2197 dnl # 2.6.39 API compat,
2198 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2199 dnl # This was done to avoid always having to allocate the maximum size
2200 dnl # workspace (268K). The caller can now specific the windowBits and
2201 dnl # memLevel compression parameters to get a smaller workspace.
2203 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2204 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2205 SPL_LINUX_TRY_COMPILE([
2206 #include <linux/zlib.h>
2208 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2211 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2212 [zlib_deflate_workspacesize() wants 2 args])
2219 dnl # 2.6.39 API change,
2220 dnl # Shrinker adjust to use common shrink_control structure.
2222 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2223 AC_MSG_CHECKING([whether struct shrink_control exists])
2224 SPL_LINUX_TRY_COMPILE([
2225 #include <linux/mm.h>
2227 struct shrink_control sc __attribute__ ((unused));
2230 sc.gfp_mask = GFP_KERNEL;
2233 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2234 [struct shrink_control exists])
2241 dnl # 3.1 API Change
2243 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2244 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2246 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2247 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2248 tmp_flags="$EXTRA_KCFLAGS"
2249 EXTRA_KCFLAGS="-Werror"
2250 SPL_LINUX_TRY_COMPILE([
2251 #include <linux/rwsem.h>
2253 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2254 raw_spinlock_t dummy_lock __attribute__ ((unused));
2255 dummy_semaphore.wait_lock = dummy_lock;
2258 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2259 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2263 EXTRA_KCFLAGS="$tmp_flags"
2267 dnl # Proposed VM Subsystem Bug Fix
2268 dnl # https://bugs.gentoo.org/show_bug.cgi?id=416685
2270 dnl # Make __pte_alloc_kernel() honor gfp flags passed to vmalloc()
2271 dnl # This is detected by checking a macro that is changed to support this.
2273 AC_DEFUN([SPL_AC_PMD_ALLOC_WITH_MASK], [
2274 AC_MSG_CHECKING([whether pmd_alloc_with_mask exists])
2275 SPL_LINUX_TRY_COMPILE([
2276 #if !defined(CONFIG_MMU)
2280 #if defined(RCH_HAS_4LEVEL_HACK)
2281 #undef RCH_HAS_4LEVEL_HACK
2284 #include <linux/mm.h>
2286 struct mm_struct init_mm;
2288 unsigned long addr = 0;
2289 gfp_t gfp_mask = GFP_KERNEL;
2291 pmd_alloc_with_mask(&init_mm, pud, addr, gfp_mask);
2294 AC_DEFINE(HAVE_PMD_ALLOC_WITH_MASK, 1,
2295 [pmd_alloc_with_mask exists])