1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_2ARGS_REGISTER_SYSCTL
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
46 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_MUTEX_OWNER_TASK_STRUCT
50 SPL_AC_MUTEX_LOCK_NESTED
51 SPL_AC_3ARGS_ON_EACH_CPU
52 SPL_AC_KALLSYMS_LOOKUP_NAME
53 SPL_AC_GET_VMALLOC_INFO
55 SPL_AC_FIRST_ONLINE_PGDAT
56 SPL_AC_NEXT_ONLINE_PGDAT
59 SPL_AC_GLOBAL_PAGE_STATE
60 SPL_AC_ZONE_STAT_ITEM_FREE
61 SPL_AC_ZONE_STAT_ITEM_INACTIVE
62 SPL_AC_ZONE_STAT_ITEM_ACTIVE
63 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_2ARGS_SET_FS_PWD
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
70 SPL_AC_2ARGS_VFS_FSYNC
71 SPL_AC_INODE_TRUNCATE_RANGE
72 SPL_AC_FS_STRUCT_SPINLOCK
75 SPL_AC_PUT_TASK_STRUCT
76 SPL_AC_5ARGS_PROC_HANDLER
78 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
79 SPL_AC_KERNEL_INVALIDATE_INODES
80 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
81 SPL_AC_SHRINK_DCACHE_MEMORY
82 SPL_AC_SHRINK_ICACHE_MEMORY
83 SPL_AC_KERN_PATH_PARENT_HEADER
84 SPL_AC_KERN_PATH_PARENT_SYMBOL
85 SPL_AC_KERN_PATH_LOCKED
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 "x$enable_linux_builtin" != xyes -a -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 kernelsrc="[Not found]"
146 if test "$kernelsrc" = "NONE"; then
151 AC_MSG_RESULT([$kernelsrc])
152 if test ! -d "$kernelsrc"; then
154 *** Please make sure the kernel devel package for your distribution
155 *** is installed then try again. If that fails you can specify the
156 *** location of the kernel source with the '--with-linux=PATH' option.])
159 AC_MSG_CHECKING([kernel build directory])
160 if test -z "$kernelbuild"; then
161 if test -e "/lib/modules/$(uname -r)/build"; then
162 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
163 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
164 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
165 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
166 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
167 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
168 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
170 kernelbuild=${kernelsrc}
173 AC_MSG_RESULT([$kernelbuild])
175 AC_MSG_CHECKING([kernel source version])
176 utsrelease1=$kernelbuild/include/linux/version.h
177 utsrelease2=$kernelbuild/include/linux/utsrelease.h
178 utsrelease3=$kernelbuild/include/generated/utsrelease.h
179 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
180 utsrelease=linux/version.h
181 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
182 utsrelease=linux/utsrelease.h
183 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
184 utsrelease=generated/utsrelease.h
187 if test "$utsrelease"; then
188 kernsrcver=`(echo "#include <$utsrelease>";
189 echo "kernsrcver=UTS_RELEASE") |
190 cpp -I $kernelbuild/include |
191 grep "^kernsrcver=" | cut -d \" -f 2`
193 if test -z "$kernsrcver"; then
194 AC_MSG_RESULT([Not found])
195 AC_MSG_ERROR([*** Cannot determine kernel version.])
198 AC_MSG_RESULT([Not found])
199 if test "x$enable_linux_builtin" != xyes; then
200 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
203 *** Cannot find UTS_RELEASE definition.
204 *** Please run 'make prepare' inside the kernel source tree.])
208 AC_MSG_RESULT([$kernsrcver])
211 LINUX_OBJ=${kernelbuild}
212 LINUX_VERSION=${kernsrcver}
216 AC_SUBST(LINUX_VERSION)
218 SPL_AC_MODULE_SYMVERS
222 dnl # Default SPL user configuration
224 AC_DEFUN([SPL_AC_CONFIG_USER], [])
227 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
228 dnl # are missing it is non-fatal but you will not be able to build
229 dnl # RPM packages and will be warned if you try too.
231 AC_DEFUN([SPL_AC_RPM], [
235 AC_MSG_CHECKING([whether $RPM is available])
236 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
237 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
239 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
242 AC_MSG_RESULT([$HAVE_RPM])
245 AC_MSG_CHECKING([whether $RPMBUILD is available])
246 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
247 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
249 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
252 AC_MSG_RESULT([$HAVE_RPMBUILD])
257 AC_SUBST(RPM_VERSION)
259 AC_SUBST(HAVE_RPMBUILD)
261 AC_SUBST(RPMBUILD_VERSION)
265 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
266 dnl # tools are missing it is non-fatal but you will not be able to build
267 dnl # DEB packages and will be warned if you try too.
269 AC_DEFUN([SPL_AC_DPKG], [
271 DPKGBUILD=dpkg-buildpackage
273 AC_MSG_CHECKING([whether $DPKG is available])
274 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
275 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
277 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
280 AC_MSG_RESULT([$HAVE_DPKG])
283 AC_MSG_CHECKING([whether $DPKGBUILD is available])
284 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
285 DPKGBUILD_VERSION=$(echo $tmp | \
286 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
288 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
291 AC_MSG_RESULT([$HAVE_DPKGBUILD])
296 AC_SUBST(DPKG_VERSION)
298 AC_SUBST(HAVE_DPKGBUILD)
300 AC_SUBST(DPKGBUILD_VERSION)
304 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
305 dnl # tools are missing it is non-fatal but you will not be able to
306 dnl # build Arch Linux packages and will be warned if you try too.
308 AC_DEFUN([SPL_AC_PACMAN], [
312 AC_MSG_CHECKING([whether $PACMAN is available])
313 tmp=$($PACMAN --version 2>/dev/null)
314 AS_IF([test -n "$tmp"], [
315 PACMAN_VERSION=$(echo $tmp |
316 $AWK '/Pacman/ { print $[3] }' |
319 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
322 AC_MSG_RESULT([$HAVE_PACMAN])
325 AC_MSG_CHECKING([whether $MAKEPKG is available])
326 tmp=$($MAKEPKG --version 2>/dev/null)
327 AS_IF([test -n "$tmp"], [
328 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
330 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
333 AC_MSG_RESULT([$HAVE_MAKEPKG])
336 AC_SUBST(HAVE_PACMAN)
338 AC_SUBST(PACMAN_VERSION)
340 AC_SUBST(HAVE_MAKEPKG)
342 AC_SUBST(MAKEPKG_VERSION)
346 dnl # Until native packaging for various different packing systems
347 dnl # can be added the least we can do is attempt to use alien to
348 dnl # convert the RPM packages to the needed package type. This is
349 dnl # a hack but so far it has worked reasonable well.
351 AC_DEFUN([SPL_AC_ALIEN], [
354 AC_MSG_CHECKING([whether $ALIEN is available])
355 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
356 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
358 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
361 AC_MSG_RESULT([$HAVE_ALIEN])
366 AC_SUBST(ALIEN_VERSION)
370 dnl # Using the VENDOR tag from config.guess set the default
371 dnl # package type for 'make pkg': (rpm | deb | tgz)
373 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
374 AC_MSG_CHECKING([linux distribution])
375 if test -f /etc/toss-release ; then
377 elif test -f /etc/fedora-release ; then
379 elif test -f /etc/redhat-release ; then
381 elif test -f /etc/gentoo-release ; then
383 elif test -f /etc/arch-release ; then
385 elif test -f /etc/SuSE-release ; then
387 elif test -f /etc/slackware-version ; then
389 elif test -f /etc/lunar.release ; then
391 elif test -f /etc/lsb-release ; then
393 elif test -f /etc/debian_version ; then
398 AC_MSG_RESULT([$VENDOR])
401 AC_MSG_CHECKING([default package type])
403 toss) DEFAULT_PACKAGE=rpm ;;
404 redhat) DEFAULT_PACKAGE=rpm ;;
405 fedora) DEFAULT_PACKAGE=rpm ;;
406 gentoo) DEFAULT_PACKAGE=tgz ;;
407 arch) DEFAULT_PACKAGE=arch ;;
408 sles) DEFAULT_PACKAGE=rpm ;;
409 slackware) DEFAULT_PACKAGE=tgz ;;
410 lunar) DEFAULT_PACKAGE=tgz ;;
411 ubuntu) DEFAULT_PACKAGE=deb ;;
412 debian) DEFAULT_PACKAGE=deb ;;
413 *) DEFAULT_PACKAGE=rpm ;;
416 AC_MSG_RESULT([$DEFAULT_PACKAGE])
417 AC_SUBST(DEFAULT_PACKAGE)
421 dnl # Default SPL user configuration
423 AC_DEFUN([SPL_AC_PACKAGE], [
424 SPL_AC_DEFAULT_PACKAGE
429 AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
432 AC_DEFUN([SPL_AC_LICENSE], [
433 AC_MSG_CHECKING([spl license])
435 AC_MSG_RESULT([$LICENSE])
436 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
440 AC_DEFUN([SPL_AC_CONFIG], [
442 AC_ARG_WITH([config],
443 AS_HELP_STRING([--with-config=CONFIG],
444 [Config file 'kernel|user|all|srpm']),
445 [SPL_CONFIG="$withval"])
446 AC_ARG_ENABLE([linux-builtin],
447 [AC_HELP_STRING([--enable-linux-builtin],
448 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
450 [enable_linux_builtin=no])
452 AC_MSG_CHECKING([spl config])
453 AC_MSG_RESULT([$SPL_CONFIG]);
456 case "$SPL_CONFIG" in
457 kernel) SPL_AC_CONFIG_KERNEL ;;
458 user) SPL_AC_CONFIG_USER ;;
459 all) SPL_AC_CONFIG_KERNEL
460 SPL_AC_CONFIG_USER ;;
463 AC_MSG_RESULT([Error!])
464 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
465 user kernel|user|all|srpm]) ;;
468 AM_CONDITIONAL([CONFIG_USER],
469 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
470 AM_CONDITIONAL([CONFIG_KERNEL],
471 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
472 [test "x$enable_linux_builtin" != xyes ])
476 dnl # Enable if the SPL should be compiled with internal debugging enabled.
477 dnl # By default this support is disabled.
479 AC_DEFUN([SPL_AC_DEBUG], [
480 AC_MSG_CHECKING([whether debugging is enabled])
481 AC_ARG_ENABLE([debug],
482 [AS_HELP_STRING([--enable-debug],
483 [Enable generic debug support @<:@default=no@:>@])],
487 AS_IF([test "x$enable_debug" = xyes],
489 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
490 DEBUG_CFLAGS="-DDEBUG -Werror"
491 DEBUG_SPL="_with_debug"
493 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
494 DEBUG_CFLAGS="-DNDEBUG"
495 DEBUG_SPL="_without_debug"
498 AC_SUBST(DEBUG_CFLAGS)
500 AC_MSG_RESULT([$enable_debug])
504 dnl # Enabled by default it provides a basic debug log infrastructure.
505 dnl # Each subsystem registers itself with a name and logs messages
506 dnl # using predefined types. If the debug mask it set to allow the
507 dnl # message type it will be written to the internal log. The log
508 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
509 dnl # after dumping the log it must be decoded using the spl utility.
511 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
512 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
514 AC_DEFUN([SPL_AC_DEBUG_LOG], [
515 AC_ARG_ENABLE([debug-log],
516 [AS_HELP_STRING([--enable-debug-log],
517 [Enable basic debug logging @<:@default=yes@:>@])],
519 [enable_debug_log=yes])
521 AS_IF([test "x$enable_debug_log" = xyes],
523 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
524 DEBUG_LOG="_with_debug_log"
525 AC_DEFINE([DEBUG_LOG], [1],
526 [Define to 1 to enable basic debug logging])
528 DEBUG_LOG="_without_debug_log"
532 AC_MSG_CHECKING([whether basic debug logging is enabled])
533 AC_MSG_RESULT([$enable_debug_log])
537 dnl # Enabled by default it provides a minimal level of memory tracking.
538 dnl # A total count of bytes allocated is kept for each alloc and free.
539 dnl # Then at module unload time a report to the console will be printed
540 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
541 dnl # and provide an easy way to inspect the kmem based slab.
543 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
544 AC_ARG_ENABLE([debug-kmem],
545 [AS_HELP_STRING([--enable-debug-kmem],
546 [Enable basic kmem accounting @<:@default=yes@:>@])],
548 [enable_debug_kmem=yes])
550 AS_IF([test "x$enable_debug_kmem" = xyes],
552 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
553 DEBUG_KMEM="_with_debug_kmem"
554 AC_DEFINE([DEBUG_KMEM], [1],
555 [Define to 1 to enable basic kmem accounting])
557 DEBUG_KMEM="_without_debug_kmem"
561 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
562 AC_MSG_RESULT([$enable_debug_kmem])
566 dnl # Disabled by default it provides detailed memory tracking. This
567 dnl # feature also requires --enable-debug-kmem to be set. When enabled
568 dnl # not only will total bytes be tracked but also the location of every
569 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
570 dnl # addresses and where they were allocated will be dumped to the console.
571 dnl # Enabling this feature has a significant impact on performance but it
572 dnl # makes finding memory leaks pretty straight forward.
574 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
575 AC_ARG_ENABLE([debug-kmem-tracking],
576 [AS_HELP_STRING([--enable-debug-kmem-tracking],
577 [Enable detailed kmem tracking @<:@default=no@:>@])],
579 [enable_debug_kmem_tracking=no])
581 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
583 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
584 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
585 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
586 [Define to 1 to enable detailed kmem tracking])
588 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
591 AC_SUBST(DEBUG_KMEM_TRACKING)
592 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
593 AC_MSG_RESULT([$enable_debug_kmem_tracking])
597 dnl # SPL_LINUX_CONFTEST
599 AC_DEFUN([SPL_LINUX_CONFTEST], [
600 cat confdefs.h - <<_ACEOF >conftest.c
606 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
608 m4_define([SPL_LANG_PROGRAM], [
613 dnl Do *not* indent the following line: there may be CPP directives.
614 dnl Don't move the `;' right after for the same reason.
622 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
624 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
625 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
626 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
627 echo "obj-m := conftest.o" >build/Makefile
629 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
631 [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])],
633 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
639 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
641 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
642 [SPL_LINUX_COMPILE_IFELSE(
643 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
645 [test -s build/conftest.o],
650 dnl # SPL_CHECK_SYMBOL_EXPORT
651 dnl # check symbol exported or not
653 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
654 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
655 $LINUX_OBJ/Module*.symvers 2>/dev/null
657 if test $rc -ne 0; then
660 grep -q -E "EXPORT_SYMBOL.*($1)" \
661 "$LINUX_OBJ/$file" 2>/dev/null
663 if test $rc -eq 0; then
668 if test $export -eq 0; then :
679 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
680 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
681 dnl # is called if not compiling for builtin
683 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
684 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
685 if test $rc -ne 0; then :
688 if test "x$enable_linux_builtin" != xyes; then
689 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
691 if test $rc -ne 0; then :
700 dnl # SPL_CHECK_SYMBOL_HEADER
701 dnl # check if a symbol prototype is defined in listed headers.
703 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
704 AC_MSG_CHECKING([whether symbol $1 exists in header])
707 grep -q "$2" "$LINUX/$file" 2>/dev/null
709 if test $rc -eq 0; then
714 if test $header -eq 0; then
724 dnl # SPL_CHECK_HEADER
725 dnl # check whether header exists and define HAVE_$2_HEADER
727 AC_DEFUN([SPL_CHECK_HEADER],
728 [AC_MSG_CHECKING([whether header $1 exists])
729 SPL_LINUX_TRY_COMPILE([
734 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
744 dnl # Basic toolchain sanity check.
746 AC_DEFUN([SPL_AC_TEST_MODULE],
747 [AC_MSG_CHECKING([whether modules can be built])
748 SPL_LINUX_TRY_COMPILE([],[],[
752 if test "x$enable_linux_builtin" != xyes; then
753 AC_MSG_ERROR([*** Unable to build an empty module.])
756 *** Unable to build an empty module.
757 *** Please run 'make scripts' inside the kernel source tree.])
763 dnl # Use the atomic implemenation based on global spinlocks. This
764 dnl # should only be needed by 32-bit kernels which do not provide
765 dnl # the atomic64_* API. It may be optionally enabled as a fallback
766 dnl # if problems are observed with the direct mapping to the native
767 dnl # Linux atomic operations. You may not disable atomic spinlocks
768 dnl # if you kernel does not an atomic64_* API.
770 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
771 AC_ARG_ENABLE([atomic-spinlocks],
772 [AS_HELP_STRING([--enable-atomic-spinlocks],
773 [Atomic types use spinlocks @<:@default=check@:>@])],
775 [enable_atomic_spinlocks=check])
777 SPL_LINUX_TRY_COMPILE([
778 #include <asm/atomic.h>
780 atomic64_t *ptr __attribute__ ((unused));
783 AC_DEFINE(HAVE_ATOMIC64_T, 1,
784 [kernel defines atomic64_t])
789 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
790 AS_IF([test "x$have_atomic64_t" = xyes], [
791 enable_atomic_spinlocks=no
793 enable_atomic_spinlocks=yes
797 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
798 AC_DEFINE([ATOMIC_SPINLOCK], [1],
799 [Atomic types use spinlocks])
801 AS_IF([test "x$have_atomic64_t" = xno], [
803 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
807 AC_MSG_CHECKING([whether atomic types use spinlocks])
808 AC_MSG_RESULT([$enable_atomic_spinlocks])
810 AC_MSG_CHECKING([whether kernel defines atomic64_t])
811 AC_MSG_RESULT([$have_atomic64_t])
815 dnl # 2.6.24 API change,
816 dnl # check if atomic64_cmpxchg is defined
818 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
819 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
820 SPL_LINUX_TRY_COMPILE([
821 #include <asm/atomic.h>
822 #include <asm/system.h>
824 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
827 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
828 [kernel defines atomic64_cmpxchg])
835 dnl # 2.6.24 API change,
836 dnl # check if atomic64_xchg is defined
838 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
839 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
840 SPL_LINUX_TRY_COMPILE([
841 #include <asm/atomic.h>
843 atomic64_xchg((atomic64_t *)NULL, 0);
846 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
847 [kernel defines atomic64_xchg])
854 dnl # 2.6.24 API change,
855 dnl # check if uintptr_t typedef is defined
857 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
858 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
859 SPL_LINUX_TRY_COMPILE([
860 #include <linux/types.h>
862 uintptr_t *ptr __attribute__ ((unused));
865 AC_DEFINE(HAVE_UINTPTR_T, 1,
866 [kernel defines uintptr_t])
873 dnl # 2.6.21 API change,
874 dnl # 'register_sysctl_table' use only one argument instead of two
876 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
877 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
878 SPL_LINUX_TRY_COMPILE([
879 #include <linux/sysctl.h>
881 (void) register_sysctl_table(NULL, 0);
884 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
885 [register_sysctl_table() wants 2 args])
892 dnl # 2.6.23 API change
893 dnl # Old set_shrinker API replaced with register_shrinker
895 AC_DEFUN([SPL_AC_SET_SHRINKER], [
896 AC_MSG_CHECKING([whether set_shrinker() available])
897 SPL_LINUX_TRY_COMPILE([
898 #include <linux/mm.h>
900 return set_shrinker(DEFAULT_SEEKS, NULL);
903 AC_DEFINE(HAVE_SET_SHRINKER, 1,
904 [set_shrinker() available])
911 dnl # 2.6.35 API change,
912 dnl # Add context to shrinker callback
914 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
915 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
916 tmp_flags="$EXTRA_KCFLAGS"
917 EXTRA_KCFLAGS="-Werror"
918 SPL_LINUX_TRY_COMPILE([
919 #include <linux/mm.h>
921 int shrinker_cb(struct shrinker *, int, unsigned int);
923 struct shrinker cache_shrinker = {
924 .shrink = shrinker_cb,
925 .seeks = DEFAULT_SEEKS,
927 register_shrinker(&cache_shrinker);
930 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
931 [shrinker callback wants 3 args])
935 EXTRA_KCFLAGS="$tmp_flags"
939 dnl # 2.6.25 API change,
940 dnl # struct path entry added to struct nameidata
942 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
943 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
944 SPL_LINUX_TRY_COMPILE([
945 #include <linux/namei.h>
947 struct nameidata nd __attribute__ ((unused));
950 nd.path.dentry = NULL;
953 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
954 [struct path used in struct nameidata])
961 dnl # Custom SPL patch may export this system it is not required
963 AC_DEFUN([SPL_AC_TASK_CURR],
964 [AC_MSG_CHECKING([whether task_curr() is available])
965 SPL_LINUX_TRY_COMPILE_SYMBOL([
966 #include <linux/sched.h>
969 ], [task_curr], [kernel/sched.c], [
971 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
978 dnl # 2.6.19 API change,
979 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
981 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
982 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
983 SPL_LINUX_TRY_COMPILE([
984 #include <linux/sysctl.h>
986 #ifndef CTL_UNNUMBERED
987 #error CTL_UNNUMBERED undefined
991 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
992 [unnumbered sysctl support exists])
999 dnl # 2.6.33 API change,
1000 dnl # Removed .ctl_name from struct ctl_table.
1002 AC_DEFUN([SPL_AC_CTL_NAME], [
1003 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1004 SPL_LINUX_TRY_COMPILE([
1005 #include <linux/sysctl.h>
1007 struct ctl_table ctl __attribute__ ((unused));
1011 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1018 dnl # 2.6.16 API change.
1019 dnl # Check if 'fls64()' is available
1021 AC_DEFUN([SPL_AC_FLS64],
1022 [AC_MSG_CHECKING([whether fls64() is available])
1023 SPL_LINUX_TRY_COMPILE([
1024 #include <linux/bitops.h>
1029 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1036 dnl # 2.6.18 API change, check whether device_create() is available.
1037 dnl # Device_create() was introduced in 2.6.18 and depricated
1038 dnl # class_device_create() which was fully removed in 2.6.26.
1040 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1041 [AC_MSG_CHECKING([whether device_create() is available])
1042 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1044 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1045 [device_create() is available])
1052 dnl # 2.6.27 API change,
1053 dnl # device_create() uses 5 args, new 'drvdata' argument.
1055 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1056 AC_MSG_CHECKING([whether device_create() wants 5 args])
1057 tmp_flags="$EXTRA_KCFLAGS"
1058 EXTRA_KCFLAGS="-Werror"
1059 SPL_LINUX_TRY_COMPILE([
1060 #include <linux/device.h>
1062 device_create(NULL, NULL, 0, NULL, "%d", 1);
1065 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1066 [device_create wants 5 args])
1070 EXTRA_KCFLAGS="$tmp_flags"
1074 dnl # 2.6.13 API change, check whether class_device_create() is available.
1075 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1076 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1078 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1079 [AC_MSG_CHECKING([whether class_device_create() is available])
1080 SPL_LINUX_TRY_COMPILE_SYMBOL([
1081 #include <linux/device.h>
1083 class_device_create(NULL, NULL, 0, NULL, NULL);
1084 ], [class_device_create], [drivers/base/class.c], [
1086 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1087 [class_device_create() is available])
1094 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1096 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1097 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1098 SPL_LINUX_TRY_COMPILE_SYMBOL([
1099 #include <linux/time.h>
1101 set_normalized_timespec(NULL, 0, 0);
1102 ], [set_normalized_timespec], [kernel/time.c], [
1104 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1105 [set_normalized_timespec() is available as export])
1112 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1113 dnl # previously it was available in time.h as an inline.
1115 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1116 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1117 SPL_LINUX_TRY_COMPILE([
1118 #include <linux/time.h>
1119 void set_normalized_timespec(struct timespec *ts,
1120 time_t sec, long nsec) { }
1127 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1128 [set_normalized_timespec() is available as inline])
1133 dnl # 2.6.18 API change,
1134 dnl # timespec_sub() inline function available in linux/time.h
1136 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1137 AC_MSG_CHECKING([whether timespec_sub() is available])
1138 SPL_LINUX_TRY_COMPILE([
1139 #include <linux/time.h>
1141 struct timespec a = { 0 };
1142 struct timespec b = { 0 };
1143 struct timespec c __attribute__ ((unused));
1144 c = timespec_sub(a, b);
1147 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1154 dnl # 2.6.19 API change,
1155 dnl # check if init_utsname() is available in linux/utsname.h
1157 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1158 AC_MSG_CHECKING([whether init_utsname() is available])
1159 SPL_LINUX_TRY_COMPILE([
1160 #include <linux/utsname.h>
1162 struct new_utsname *a __attribute__ ((unused));
1166 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1173 dnl # 2.6.18 API change,
1174 dnl # added linux/uaccess.h
1176 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1177 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1181 dnl # 2.6.12 API change,
1182 dnl # check whether 'kmalloc_node()' is available.
1184 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1185 AC_MSG_CHECKING([whether kmalloc_node() is available])
1186 SPL_LINUX_TRY_COMPILE([
1187 #include <linux/slab.h>
1189 void *a __attribute__ ((unused));
1190 a = kmalloc_node(1, GFP_KERNEL, 0);
1193 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1200 dnl # 2.6.9 API change,
1201 dnl # check whether 'monotonic_clock()' is available it may
1202 dnl # be available for some archs but not others.
1204 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1205 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1206 SPL_LINUX_TRY_COMPILE_SYMBOL([
1207 #include <linux/timex.h>
1210 ], [monotonic_clock], [], [
1212 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1213 [monotonic_clock() is available])
1220 dnl # 2.6.16 API change,
1221 dnl # check whether 'struct inode' has i_mutex
1223 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1224 AC_MSG_CHECKING([whether struct inode has i_mutex])
1225 SPL_LINUX_TRY_COMPILE([
1226 #include <linux/fs.h>
1227 #include <linux/mutex.h>
1230 mutex_init(&i.i_mutex);
1233 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1240 dnl # 2.6.29 API change,
1241 dnl # Adaptive mutexs introduced.
1243 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1244 AC_MSG_CHECKING([whether struct mutex has owner])
1245 SPL_LINUX_TRY_COMPILE([
1246 #include <linux/mutex.h>
1248 struct mutex mtx __attribute__ ((unused));
1252 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1259 dnl # 2.6.39 API change,
1260 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1261 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1262 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1263 dnl # pointer which frankly makes a lot more sense.
1265 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1266 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1267 tmp_flags="$EXTRA_KCFLAGS"
1268 EXTRA_KCFLAGS="-Werror"
1269 SPL_LINUX_TRY_COMPILE([
1270 #include <linux/mutex.h>
1272 struct mutex mtx __attribute__ ((unused));
1273 mtx.owner = current;
1276 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1277 [struct mutex owner is a task_struct])
1281 EXTRA_KCFLAGS="$tmp_flags"
1285 dnl # 2.6.18 API change,
1286 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1287 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1288 dnl # if the mutex validator is disabled or otherwise unavailable.
1290 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1291 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1292 SPL_LINUX_TRY_COMPILE([
1293 #include <linux/mutex.h>
1297 mutex_lock_nested(&mutex, 0);
1300 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1301 [mutex_lock_nested() is available])
1308 dnl # 2.6.27 API change,
1309 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1311 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1312 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1313 SPL_LINUX_TRY_COMPILE([
1314 #include <linux/smp.h>
1316 on_each_cpu(NULL, NULL, 0);
1319 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1320 [on_each_cpu wants 3 args])
1327 dnl # 2.6.18 API change,
1328 dnl # kallsyms_lookup_name no longer exported
1330 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1331 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1332 SPL_LINUX_TRY_COMPILE_SYMBOL([
1333 #include <linux/kallsyms.h>
1335 kallsyms_lookup_name(NULL);
1336 ], [kallsyms_lookup_name], [], [
1338 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1339 [kallsyms_lookup_name() is available])
1346 dnl # Proposed API change,
1347 dnl # This symbol is not available in stock kernels. You may build a
1348 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1349 dnl # these symbols for use. If your already rolling a custom kernel for
1350 dnl # your environment this is recommended.
1352 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1353 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1354 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1356 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1357 [get_vmalloc_info() is available])
1364 dnl # 2.6.17 API change
1365 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1366 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1367 dnl # were exported in 2.6.17 for use by modules which was consistent with
1368 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1369 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1370 dnl # were dropped entirely leaving modules no way to directly iterate over
1371 dnl # the zone list. Because we need access to the zone helpers we check
1372 dnl # if the kernel contains the old or new implementation. Then we check
1373 dnl # to see if the symbols we need for each version are available. If they
1374 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1376 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1377 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1378 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1380 if test $rc -eq 0; then
1381 AC_MSG_RESULT([yes])
1382 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1389 dnl # Proposed API change,
1390 dnl # This symbol is not available in stock kernels. You may build a
1391 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1392 dnl # these symbols for use. If your already rolling a custom kernel for
1393 dnl # your environment this is recommended.
1395 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1396 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1397 SPL_LINUX_TRY_COMPILE_SYMBOL([
1398 #include <linux/mmzone.h>
1400 first_online_pgdat();
1401 ], [first_online_pgdat], [], [
1403 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1404 [first_online_pgdat() is available])
1411 dnl # Proposed API change,
1412 dnl # This symbol is not available in stock kernels. You may build a
1413 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1414 dnl # these symbols for use. If your already rolling a custom kernel for
1415 dnl # your environment this is recommended.
1417 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1418 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1419 SPL_LINUX_TRY_COMPILE_SYMBOL([
1420 #include <linux/mmzone.h>
1422 next_online_pgdat(NULL);
1423 ], [next_online_pgdat], [], [
1425 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1426 [next_online_pgdat() is available])
1433 dnl # Proposed API change,
1434 dnl # This symbol is not available in stock kernels. You may build a
1435 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1436 dnl # these symbols for use. If your already rolling a custom kernel for
1437 dnl # your environment this is recommended.
1439 AC_DEFUN([SPL_AC_NEXT_ZONE],
1440 [AC_MSG_CHECKING([whether next_zone() is available])
1441 SPL_LINUX_TRY_COMPILE_SYMBOL([
1442 #include <linux/mmzone.h>
1445 ], [next_zone], [], [
1447 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1454 dnl # 2.6.17 API change,
1455 dnl # See SPL_AC_PGDAT_HELPERS for details.
1457 AC_DEFUN([SPL_AC_PGDAT_LIST],
1458 [AC_MSG_CHECKING([whether pgdat_list is available])
1459 SPL_LINUX_TRY_COMPILE_SYMBOL([
1460 #include <linux/topology.h>
1461 pg_data_t *tmp = pgdat_list;
1462 ], [], [pgdat_list], [], [
1464 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1471 dnl # 2.6.18 API change,
1472 dnl # First introduced global_page_state() support as an inline.
1474 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1475 AC_MSG_CHECKING([whether global_page_state() is available])
1476 SPL_LINUX_TRY_COMPILE([
1477 #include <linux/mm.h>
1479 unsigned long state __attribute__ ((unused));
1480 state = global_page_state(0);
1483 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1484 [global_page_state() is available])
1491 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1492 dnl # Public global zone stats now include a free page count. However
1493 dnl # the enumerated names of the counters have changed since this API
1494 dnl # was introduced. We need to deduce the corrent name to use. This
1495 dnl # replaces the priviate get_zone_counts() interface.
1497 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1498 dnl # is 2.6.30 as of when this was written.
1500 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1501 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1502 SPL_LINUX_TRY_COMPILE([
1503 #include <linux/mm.h>
1505 enum zone_stat_item zsi __attribute__ ((unused));
1506 zsi = NR_FREE_PAGES;
1509 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1510 [Page state NR_FREE_PAGES is available])
1517 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1518 dnl # Public global zone stats now include an inactive page count. However
1519 dnl # the enumerated names of the counters have changed since this API
1520 dnl # was introduced. We need to deduce the corrent name to use. This
1521 dnl # replaces the priviate get_zone_counts() interface.
1523 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1524 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1525 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1527 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1528 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1529 SPL_LINUX_TRY_COMPILE([
1530 #include <linux/mm.h>
1532 enum zone_stat_item zsi __attribute__ ((unused));
1536 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1537 [Page state NR_INACTIVE is available])
1542 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1543 SPL_LINUX_TRY_COMPILE([
1544 #include <linux/mm.h>
1546 enum zone_stat_item zsi __attribute__ ((unused));
1547 zsi = NR_INACTIVE_ANON;
1550 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1551 [Page state NR_INACTIVE_ANON is available])
1556 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1557 SPL_LINUX_TRY_COMPILE([
1558 #include <linux/mm.h>
1560 enum zone_stat_item zsi __attribute__ ((unused));
1561 zsi = NR_INACTIVE_FILE;
1564 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1565 [Page state NR_INACTIVE_FILE is available])
1572 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1573 dnl # Public global zone stats now include an active page count. However
1574 dnl # the enumerated names of the counters have changed since this API
1575 dnl # was introduced. We need to deduce the corrent name to use. This
1576 dnl # replaces the priviate get_zone_counts() interface.
1578 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1579 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1580 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1582 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1583 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1584 SPL_LINUX_TRY_COMPILE([
1585 #include <linux/mm.h>
1587 enum zone_stat_item zsi __attribute__ ((unused));
1591 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1592 [Page state NR_ACTIVE is available])
1597 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1598 SPL_LINUX_TRY_COMPILE([
1599 #include <linux/mm.h>
1601 enum zone_stat_item zsi __attribute__ ((unused));
1602 zsi = NR_ACTIVE_ANON;
1605 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1606 [Page state NR_ACTIVE_ANON is available])
1611 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1612 SPL_LINUX_TRY_COMPILE([
1613 #include <linux/mm.h>
1615 enum zone_stat_item zsi __attribute__ ((unused));
1616 zsi = NR_ACTIVE_FILE;
1619 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1620 [Page state NR_ACTIVE_FILE is available])
1627 dnl # Proposed API change for legacy kernels.
1628 dnl # This symbol is not available in older kernels. For kernels post
1629 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1630 dnl # page state information. This symbol is only used in legacy kernels
1631 dnl # any only as a last resort.
1633 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1634 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1635 SPL_LINUX_TRY_COMPILE([
1637 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1638 #error "global_page_state needs NR_FREE_PAGES"
1641 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1642 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1643 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1644 #error "global_page_state needs NR_ACTIVE*"
1647 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1648 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1649 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1650 #error "global_page_state needs NR_INACTIVE*"
1656 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1657 [get_zone_counts() is needed])
1659 AC_MSG_CHECKING([whether get_zone_counts() is available])
1660 SPL_LINUX_TRY_COMPILE_SYMBOL([
1661 #include <linux/mmzone.h>
1663 get_zone_counts(NULL, NULL, NULL);
1664 ], [get_zone_counts], [], [
1666 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1667 [get_zone_counts() is available])
1675 dnl # 2.6.27 API change,
1676 dnl # The user_path_dir() replaces __user_walk()
1678 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1679 [AC_MSG_CHECKING([whether user_path_dir() is available])
1680 SPL_LINUX_TRY_COMPILE_SYMBOL([
1681 #include <linux/fcntl.h>
1682 #include <linux/namei.h>
1684 user_path_dir(NULL, NULL);
1685 ], [user_path_at], [], [
1687 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1694 dnl # Symbol available in RHEL kernels not in stock kernels.
1696 AC_DEFUN([SPL_AC_SET_FS_PWD],
1697 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1698 SPL_LINUX_TRY_COMPILE_SYMBOL([
1699 #include <linux/spinlock.h>
1700 #include <linux/fs_struct.h>
1703 ], [set_fs_pwd], [], [
1705 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1712 dnl # 2.6.25 API change,
1713 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1715 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1716 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1717 SPL_LINUX_TRY_COMPILE([
1718 #include <linux/sched.h>
1719 #include <linux/fs_struct.h>
1721 set_fs_pwd(NULL, NULL);
1724 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1725 [set_fs_pwd() wants 2 args])
1732 dnl # SLES API change, never adopted in mainline,
1733 dnl # Third 'struct vfsmount *' argument removed.
1735 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1736 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1737 SPL_LINUX_TRY_COMPILE([
1738 #include <linux/fs.h>
1740 vfs_unlink(NULL, NULL);
1743 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1744 [vfs_unlink() wants 2 args])
1751 dnl # SLES API change, never adopted in mainline,
1752 dnl # Third and sixth 'struct vfsmount *' argument removed.
1754 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1755 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1756 SPL_LINUX_TRY_COMPILE([
1757 #include <linux/fs.h>
1759 vfs_rename(NULL, NULL, NULL, NULL);
1762 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1763 [vfs_rename() wants 4 args])
1770 dnl # 2.6.36 API change,
1771 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1772 dnl # a spinlock_t to improve the fastpath performance.
1774 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1775 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1776 tmp_flags="$EXTRA_KCFLAGS"
1777 EXTRA_KCFLAGS="-Werror"
1778 SPL_LINUX_TRY_COMPILE([
1779 #include <linux/sched.h>
1780 #include <linux/fs_struct.h>
1782 struct fs_struct fs;
1783 spin_lock_init(&fs.lock);
1786 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1787 [struct fs_struct uses spinlock_t])
1791 EXTRA_KCFLAGS="$tmp_flags"
1795 dnl # 2.6.29 API change,
1796 dnl # check whether 'struct cred' exists
1798 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1799 AC_MSG_CHECKING([whether struct cred exists])
1800 SPL_LINUX_TRY_COMPILE([
1801 #include <linux/cred.h>
1803 struct cred *cr __attribute__ ((unused));
1807 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1814 dnl # Custom SPL patch may export this symbol.
1816 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1817 [AC_MSG_CHECKING([whether groups_search() is available])
1818 SPL_LINUX_TRY_COMPILE_SYMBOL([
1819 #include <linux/cred.h>
1821 groups_search(NULL, 0);
1822 ], [groups_search], [], [
1824 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1831 dnl # 2.6.x API change,
1832 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1834 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1835 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1836 SPL_LINUX_TRY_COMPILE_SYMBOL([
1837 #include <linux/sched.h>
1839 __put_task_struct(NULL);
1840 ], [__put_task_struct], [], [
1842 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1843 [__put_task_struct() is available])
1850 dnl # 2.6.32 API change,
1851 dnl # Unused 'struct file *' removed from prototype.
1853 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1854 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1855 SPL_LINUX_TRY_COMPILE([
1856 #include <linux/sysctl.h>
1858 proc_dostring(NULL, 0, NULL, NULL, NULL);
1861 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1862 [proc_handler() wants 5 args])
1869 dnl # 2.6.x API change,
1870 dnl # kvasprintf() function added.
1872 AC_DEFUN([SPL_AC_KVASPRINTF],
1873 [AC_MSG_CHECKING([whether kvasprintf() is available])
1874 SPL_LINUX_TRY_COMPILE_SYMBOL([
1875 #include <linux/kernel.h>
1877 kvasprintf(0, NULL, *((va_list*)NULL));
1878 ], [kvasprintf], [], [
1880 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1887 dnl # 2.6.29 API change,
1888 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1890 AC_DEFUN([SPL_AC_VFS_FSYNC],
1891 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1892 SPL_LINUX_TRY_COMPILE_SYMBOL([
1893 #include <linux/fs.h>
1896 ], [vfs_fsync], [fs/sync.c], [
1898 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1905 dnl # 2.6.35 API change,
1906 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1908 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1909 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1910 SPL_LINUX_TRY_COMPILE([
1911 #include <linux/fs.h>
1916 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1923 dnl # 3.5 API change,
1924 dnl # inode_operations.truncate_range removed
1925 dnl # (deprecated in favor of FALLOC_FL_PUNCH_HOLE)
1927 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1928 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1929 SPL_LINUX_TRY_COMPILE([
1930 #include <linux/fs.h>
1932 struct inode_operations ops;
1933 ops.truncate_range = NULL;
1936 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1937 [truncate_range() inode operation is available])
1944 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1945 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1946 dnl # condition. The fixed version is exported as a symbol. The race
1947 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1948 dnl # call that version while holding sem->wait_lock.
1950 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1951 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1952 SPL_LINUX_TRY_COMPILE_SYMBOL([
1953 #include <linux/rwsem.h>
1954 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1955 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1957 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1958 [rwsem_is_locked() acquires sem->wait_lock])
1965 dnl # 2.6.37 API compat,
1966 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1967 dnl # The prototype however is still available which means it is safe
1968 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1970 dnl # The Proxmox VE kernel contains a patch which renames the function
1971 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1972 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1973 dnl # compatibility wrapper for legacy callers. Therefore, if either
1974 dnl # of these functions are exported invalidate_inodes() can be
1977 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1978 AC_MSG_CHECKING([whether invalidate_inodes() is available])
1979 SPL_LINUX_TRY_COMPILE_SYMBOL([
1980 #include <linux/fs.h>
1983 ], [invalidate_inodes], [], [
1985 AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1986 [invalidate_inodes() is available])
1991 AC_MSG_CHECKING([whether invalidate_inodes_check() is available])
1992 SPL_LINUX_TRY_COMPILE_SYMBOL([
1993 #include <linux/fs.h>
1994 #ifndef invalidate_inodes
1995 #error invalidate_inodes is not a macro
1997 ], [ ], [invalidate_inodes_check], [], [
1999 AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
2000 [invalidate_inodes_check() is available])
2007 dnl # 2.6.39 API compat,
2008 dnl # The function invalidate_inodes() now take 2 arguments. The second
2009 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
2010 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
2011 dnl # otherwise they will be handled as busy.
2013 dnl # Unfortunately, we don't have access to the invalidate_inodes()
2014 dnl # prototype so it's not easy to check how many arguments it takes.
2015 dnl # However, this change was done for the benefit of invalidate_device()
2016 dnl # which also added an argument. The invalidate_device() symbol does
2017 dnl # exist in the development headers so if it takes two arguments we
2018 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
2019 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
2021 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
2022 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
2023 SPL_LINUX_TRY_COMPILE([
2024 #include <linux/fs.h>
2026 return __invalidate_device(NULL, 0);
2029 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
2030 [invalidate_inodes() wants 2 args])
2037 dnl # 2.6.xx API compat,
2038 dnl # There currently exists no exposed API to partially shrink the dcache.
2039 dnl # The expected mechanism to shrink the cache is a registered shrinker
2040 dnl # which is called during memory pressure.
2042 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2043 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2044 SPL_LINUX_TRY_COMPILE_SYMBOL([
2045 #include <linux/dcache.h>
2047 shrink_dcache_memory(0, 0);
2048 ], [shrink_dcache_memory], [fs/dcache.c], [
2050 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2051 [shrink_dcache_memory() is available])
2058 dnl # 2.6.xx API compat,
2059 dnl # There currently exists no exposed API to partially shrink the icache.
2060 dnl # The expected mechanism to shrink the cache is a registered shrinker
2061 dnl # which is called during memory pressure.
2063 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2064 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2065 SPL_LINUX_TRY_COMPILE_SYMBOL([
2066 #include <linux/dcache.h>
2068 shrink_icache_memory(0, 0);
2069 ], [shrink_icache_memory], [fs/inode.c], [
2071 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2072 [shrink_icache_memory() is available])
2079 dnl # 2.6.39 API compat,
2080 dnl # The path_lookup() function has been renamed to kern_path_parent()
2081 dnl # and the flags argument has been removed. The only behavior now
2082 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2083 dnl # this flag so dropping the flag does not impact us.
2085 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2086 SPL_CHECK_SYMBOL_HEADER(
2088 [int kern_path_parent(const char \*, struct nameidata \*)],
2089 [include/linux/namei.h],
2090 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2091 [kern_path_parent() is available])],
2096 dnl # 3.1 API compat,
2097 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2098 dnl # However, it remains the prefered interface and since we still have
2099 dnl # access to the prototype we dynamically lookup the required address.
2101 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2102 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2103 SPL_LINUX_TRY_COMPILE_SYMBOL([
2104 #include <linux/namei.h>
2106 kern_path_parent(NULL, NULL);
2107 ], [kern_path_parent], [fs/namei.c], [
2109 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2110 [kern_path_parent() is available])
2117 dnl # 3.6 API compat,
2118 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2119 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2121 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2122 SPL_CHECK_SYMBOL_HEADER(
2124 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2125 [include/linux/namei.h],
2126 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2127 [kern_path_locked() is available])],
2132 dnl # 2.6.39 API compat,
2133 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2134 dnl # This was done to avoid always having to allocate the maximum size
2135 dnl # workspace (268K). The caller can now specific the windowBits and
2136 dnl # memLevel compression parameters to get a smaller workspace.
2138 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2139 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2140 SPL_LINUX_TRY_COMPILE([
2141 #include <linux/zlib.h>
2143 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2146 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2147 [zlib_deflate_workspacesize() wants 2 args])
2154 dnl # 2.6.39 API change,
2155 dnl # Shrinker adjust to use common shrink_control structure.
2157 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2158 AC_MSG_CHECKING([whether struct shrink_control exists])
2159 SPL_LINUX_TRY_COMPILE([
2160 #include <linux/mm.h>
2162 struct shrink_control sc __attribute__ ((unused));
2165 sc.gfp_mask = GFP_KERNEL;
2168 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2169 [struct shrink_control exists])
2176 dnl # 3.1 API Change
2178 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2179 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2181 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2182 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2183 tmp_flags="$EXTRA_KCFLAGS"
2184 EXTRA_KCFLAGS="-Werror"
2185 SPL_LINUX_TRY_COMPILE([
2186 #include <linux/rwsem.h>
2188 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2189 raw_spinlock_t dummy_lock __attribute__ ((unused));
2190 dummy_semaphore.wait_lock = dummy_lock;
2193 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2194 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2198 EXTRA_KCFLAGS="$tmp_flags"