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
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_MONOTONIC_CLOCK
51 SPL_AC_MUTEX_OWNER_TASK_STRUCT
52 SPL_AC_MUTEX_LOCK_NESTED
53 SPL_AC_3ARGS_ON_EACH_CPU
54 SPL_AC_KALLSYMS_LOOKUP_NAME
55 SPL_AC_GET_VMALLOC_INFO
57 SPL_AC_FIRST_ONLINE_PGDAT
58 SPL_AC_NEXT_ONLINE_PGDAT
61 SPL_AC_GLOBAL_PAGE_STATE
62 SPL_AC_ZONE_STAT_ITEM_FREE
63 SPL_AC_ZONE_STAT_ITEM_INACTIVE
64 SPL_AC_ZONE_STAT_ITEM_ACTIVE
65 SPL_AC_GET_ZONE_COUNTS
68 SPL_AC_SET_FS_PWD_WITH_CONST
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
72 SPL_AC_2ARGS_VFS_FSYNC
73 SPL_AC_INODE_TRUNCATE_RANGE
74 SPL_AC_FS_STRUCT_SPINLOCK
78 SPL_AC_PUT_TASK_STRUCT
79 SPL_AC_5ARGS_PROC_HANDLER
81 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
82 SPL_AC_KERNEL_FALLOCATE
83 SPL_AC_SHRINK_DCACHE_MEMORY
84 SPL_AC_SHRINK_ICACHE_MEMORY
85 SPL_AC_KERN_PATH_PARENT_HEADER
86 SPL_AC_KERN_PATH_PARENT_SYMBOL
87 SPL_AC_KERN_PATH_LOCKED
88 SPL_AC_CONFIG_KALLSYMS
89 SPL_AC_CONFIG_ZLIB_INFLATE
90 SPL_AC_CONFIG_ZLIB_DEFLATE
91 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
92 SPL_AC_SHRINK_CONTROL_STRUCT
93 SPL_AC_RWSEM_SPINLOCK_IS_RAW
94 SPL_AC_SCHED_RT_HEADER
95 SPL_AC_2ARGS_VFS_GETATTR
98 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
99 modpost=$LINUX/scripts/Makefile.modpost
100 AC_MSG_CHECKING([kernel file name for module symbols])
101 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
102 if grep -q Modules.symvers $modpost; then
103 LINUX_SYMBOLS=Modules.symvers
105 LINUX_SYMBOLS=Module.symvers
108 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
110 *** Please make sure the kernel devel package for your distribution
111 *** is installed. If you are building with a custom kernel, make sure the
112 *** kernel is configured, built, and the '--with-linux=PATH' configure
113 *** option refers to the location of the kernel source.])
118 AC_MSG_RESULT($LINUX_SYMBOLS)
119 AC_SUBST(LINUX_SYMBOLS)
122 AC_DEFUN([SPL_AC_KERNEL], [
124 AS_HELP_STRING([--with-linux=PATH],
125 [Path to kernel source]),
126 [kernelsrc="$withval"])
128 AC_ARG_WITH([linux-obj],
129 AS_HELP_STRING([--with-linux-obj=PATH],
130 [Path to kernel build objects]),
131 [kernelbuild="$withval"])
133 AC_MSG_CHECKING([kernel source directory])
134 if test -z "$kernelsrc"; then
135 if test -e "/lib/modules/$(uname -r)/source"; then
136 headersdir="/lib/modules/$(uname -r)/source"
137 sourcelink=$(readlink -f "$headersdir")
138 elif test -e "/lib/modules/$(uname -r)/build"; then
139 headersdir="/lib/modules/$(uname -r)/build"
140 sourcelink=$(readlink -f "$headersdir")
142 sourcelink=$(ls -1d /usr/src/kernels/* \
144 2>/dev/null | grep -v obj | tail -1)
147 if test -n "$sourcelink" && test -e ${sourcelink}; then
148 kernelsrc=`readlink -f ${sourcelink}`
150 kernelsrc="[Not found]"
153 if test "$kernelsrc" = "NONE"; then
158 AC_MSG_RESULT([$kernelsrc])
159 if test ! -d "$kernelsrc"; then
161 *** Please make sure the kernel devel package for your distribution
162 *** is installed and then try again. If that fails, you can specify the
163 *** location of the kernel source with the '--with-linux=PATH' option.])
166 AC_MSG_CHECKING([kernel build directory])
167 if test -z "$kernelbuild"; then
168 if test -e "/lib/modules/$(uname -r)/build"; then
169 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
170 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
171 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
172 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
173 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
174 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
175 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
177 kernelbuild=${kernelsrc}
180 AC_MSG_RESULT([$kernelbuild])
182 AC_MSG_CHECKING([kernel source version])
183 utsrelease1=$kernelbuild/include/linux/version.h
184 utsrelease2=$kernelbuild/include/linux/utsrelease.h
185 utsrelease3=$kernelbuild/include/generated/utsrelease.h
186 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
187 utsrelease=linux/version.h
188 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
189 utsrelease=linux/utsrelease.h
190 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
191 utsrelease=generated/utsrelease.h
194 if test "$utsrelease"; then
195 kernsrcver=`(echo "#include <$utsrelease>";
196 echo "kernsrcver=UTS_RELEASE") |
197 cpp -I $kernelbuild/include |
198 grep "^kernsrcver=" | cut -d \" -f 2`
200 if test -z "$kernsrcver"; then
201 AC_MSG_RESULT([Not found])
202 AC_MSG_ERROR([*** Cannot determine kernel version.])
205 AC_MSG_RESULT([Not found])
206 if test "x$enable_linux_builtin" != xyes; then
207 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
210 *** Cannot find UTS_RELEASE definition.
211 *** Please run 'make prepare' inside the kernel source tree.])
215 AC_MSG_RESULT([$kernsrcver])
218 LINUX_OBJ=${kernelbuild}
219 LINUX_VERSION=${kernsrcver}
223 AC_SUBST(LINUX_VERSION)
225 SPL_AC_MODULE_SYMVERS
229 dnl # Default SPL user configuration
231 AC_DEFUN([SPL_AC_CONFIG_USER], [])
234 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
235 dnl # are missing, it is non-fatal, but you will not be able to build
236 dnl # RPM packages and will be warned if you try too.
238 dnl # By default, the generic spec file will be used because it requires
239 dnl # minimal dependencies. Distribution specific spec files can be
240 dnl # placed under the 'rpm/<distribution>' directory and enabled using
241 dnl # the --with-spec=<distribution> configure option.
243 AC_DEFUN([SPL_AC_RPM], [
247 AC_MSG_CHECKING([whether $RPM is available])
248 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
249 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
251 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
254 AC_MSG_RESULT([$HAVE_RPM])
257 AC_MSG_CHECKING([whether $RPMBUILD is available])
258 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
259 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
261 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
264 AC_MSG_RESULT([$HAVE_RPMBUILD])
267 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
269 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
272 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
277 RPM_SPEC_DIR="rpm/generic"
279 AS_HELP_STRING([--with-spec=SPEC],
280 [Spec files 'generic|fedora']),
281 [RPM_SPEC_DIR="rpm/$withval"])
283 AC_MSG_CHECKING([whether spec files are available])
284 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
288 AC_SUBST(RPM_VERSION)
290 AC_SUBST(HAVE_RPMBUILD)
292 AC_SUBST(RPMBUILD_VERSION)
294 AC_SUBST(RPM_SPEC_DIR)
295 AC_SUBST(RPM_DEFINE_UTIL)
296 AC_SUBST(RPM_DEFINE_KMOD)
297 AC_SUBST(RPM_DEFINE_DKMS)
298 AC_SUBST(RPM_DEFINE_COMMON)
299 AC_SUBST(SRPM_DEFINE_UTIL)
300 AC_SUBST(SRPM_DEFINE_KMOD)
301 AC_SUBST(SRPM_DEFINE_DKMS)
302 AC_SUBST(SRPM_DEFINE_COMMON)
306 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
307 dnl # tools are missing it is non-fatal but you will not be able to build
308 dnl # DEB packages and will be warned if you try too.
310 AC_DEFUN([SPL_AC_DPKG], [
312 DPKGBUILD=dpkg-buildpackage
314 AC_MSG_CHECKING([whether $DPKG is available])
315 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
316 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
318 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
321 AC_MSG_RESULT([$HAVE_DPKG])
324 AC_MSG_CHECKING([whether $DPKGBUILD is available])
325 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
326 DPKGBUILD_VERSION=$(echo $tmp | \
327 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
329 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
332 AC_MSG_RESULT([$HAVE_DPKGBUILD])
337 AC_SUBST(DPKG_VERSION)
339 AC_SUBST(HAVE_DPKGBUILD)
341 AC_SUBST(DPKGBUILD_VERSION)
345 dnl # Until native packaging for various different packing systems
346 dnl # can be added the least we can do is attempt to use alien to
347 dnl # convert the RPM packages to the needed package type. This is
348 dnl # a hack but so far it has worked reasonable well.
350 AC_DEFUN([SPL_AC_ALIEN], [
353 AC_MSG_CHECKING([whether $ALIEN is available])
354 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
355 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
357 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
360 AC_MSG_RESULT([$HAVE_ALIEN])
365 AC_SUBST(ALIEN_VERSION)
369 dnl # Using the VENDOR tag from config.guess set the default
370 dnl # package type for 'make pkg': (rpm | deb | tgz)
372 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
373 AC_MSG_CHECKING([linux distribution])
374 if test -f /etc/toss-release ; then
376 elif test -f /etc/fedora-release ; then
378 elif test -f /etc/redhat-release ; then
380 elif test -f /etc/gentoo-release ; then
382 elif test -f /etc/arch-release ; then
384 elif test -f /etc/SuSE-release ; then
386 elif test -f /etc/slackware-version ; then
388 elif test -f /etc/lunar.release ; then
390 elif test -f /etc/lsb-release ; then
392 elif test -f /etc/debian_version ; then
397 AC_MSG_RESULT([$VENDOR])
400 AC_MSG_CHECKING([default package type])
402 toss) DEFAULT_PACKAGE=rpm ;;
403 redhat) DEFAULT_PACKAGE=rpm ;;
404 fedora) DEFAULT_PACKAGE=rpm ;;
405 gentoo) DEFAULT_PACKAGE=tgz ;;
406 arch) DEFAULT_PACKAGE=tgz ;;
407 sles) DEFAULT_PACKAGE=rpm ;;
408 slackware) DEFAULT_PACKAGE=tgz ;;
409 lunar) DEFAULT_PACKAGE=tgz ;;
410 ubuntu) DEFAULT_PACKAGE=deb ;;
411 debian) DEFAULT_PACKAGE=deb ;;
412 *) DEFAULT_PACKAGE=rpm ;;
415 AC_MSG_RESULT([$DEFAULT_PACKAGE])
416 AC_SUBST(DEFAULT_PACKAGE)
420 dnl # Default SPL user configuration
422 AC_DEFUN([SPL_AC_PACKAGE], [
423 SPL_AC_DEFAULT_PACKAGE
429 AC_DEFUN([SPL_AC_LICENSE], [
430 AC_MSG_CHECKING([spl license])
432 AC_MSG_RESULT([$LICENSE])
433 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
437 AC_DEFUN([SPL_AC_CONFIG], [
439 AC_ARG_WITH([config],
440 AS_HELP_STRING([--with-config=CONFIG],
441 [Config file 'kernel|user|all|srpm']),
442 [SPL_CONFIG="$withval"])
443 AC_ARG_ENABLE([linux-builtin],
444 [AC_HELP_STRING([--enable-linux-builtin],
445 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
447 [enable_linux_builtin=no])
449 AC_MSG_CHECKING([spl config])
450 AC_MSG_RESULT([$SPL_CONFIG]);
453 case "$SPL_CONFIG" in
454 kernel) SPL_AC_CONFIG_KERNEL ;;
455 user) SPL_AC_CONFIG_USER ;;
456 all) SPL_AC_CONFIG_KERNEL
457 SPL_AC_CONFIG_USER ;;
460 AC_MSG_RESULT([Error!])
461 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
462 user kernel|user|all|srpm]) ;;
465 AM_CONDITIONAL([CONFIG_USER],
466 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
467 AM_CONDITIONAL([CONFIG_KERNEL],
468 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
469 [test "x$enable_linux_builtin" != xyes ])
473 dnl # Enable if the SPL should be compiled with internal debugging enabled.
474 dnl # By default this support is disabled.
476 AC_DEFUN([SPL_AC_DEBUG], [
477 AC_MSG_CHECKING([whether debugging is enabled])
478 AC_ARG_ENABLE([debug],
479 [AS_HELP_STRING([--enable-debug],
480 [Enable generic debug support @<:@default=no@:>@])],
484 AS_IF([test "x$enable_debug" = xyes],
486 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
487 DEBUG_CFLAGS="-DDEBUG -Werror"
488 DEBUG_SPL="_with_debug"
490 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
491 DEBUG_CFLAGS="-DNDEBUG"
492 DEBUG_SPL="_without_debug"
495 AC_SUBST(DEBUG_CFLAGS)
497 AC_MSG_RESULT([$enable_debug])
501 dnl # Enabled by default it provides a basic debug log infrastructure.
502 dnl # Each subsystem registers itself with a name and logs messages
503 dnl # using predefined types. If the debug mask it set to allow the
504 dnl # message type it will be written to the internal log. The log
505 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
506 dnl # after dumping the log it must be decoded using the spl utility.
508 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
509 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
511 AC_DEFUN([SPL_AC_DEBUG_LOG], [
512 AC_ARG_ENABLE([debug-log],
513 [AS_HELP_STRING([--enable-debug-log],
514 [Enable basic debug logging @<:@default=yes@:>@])],
516 [enable_debug_log=yes])
518 AS_IF([test "x$enable_debug_log" = xyes],
520 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
521 DEBUG_LOG="_with_debug_log"
522 AC_DEFINE([DEBUG_LOG], [1],
523 [Define to 1 to enable basic debug logging])
525 DEBUG_LOG="_without_debug_log"
529 AC_MSG_CHECKING([whether basic debug logging is enabled])
530 AC_MSG_RESULT([$enable_debug_log])
534 dnl # Enabled by default it provides a minimal level of memory tracking.
535 dnl # A total count of bytes allocated is kept for each alloc and free.
536 dnl # Then at module unload time a report to the console will be printed
537 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
538 dnl # and provide an easy way to inspect the kmem based slab.
540 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
541 AC_ARG_ENABLE([debug-kmem],
542 [AS_HELP_STRING([--enable-debug-kmem],
543 [Enable basic kmem accounting @<:@default=yes@:>@])],
545 [enable_debug_kmem=yes])
547 AS_IF([test "x$enable_debug_kmem" = xyes],
549 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
550 DEBUG_KMEM="_with_debug_kmem"
551 AC_DEFINE([DEBUG_KMEM], [1],
552 [Define to 1 to enable basic kmem accounting])
554 DEBUG_KMEM="_without_debug_kmem"
558 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
559 AC_MSG_RESULT([$enable_debug_kmem])
563 dnl # Disabled by default it provides detailed memory tracking. This
564 dnl # feature also requires --enable-debug-kmem to be set. When enabled
565 dnl # not only will total bytes be tracked but also the location of every
566 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
567 dnl # addresses and where they were allocated will be dumped to the console.
568 dnl # Enabling this feature has a significant impact on performance but it
569 dnl # makes finding memory leaks pretty straight forward.
571 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
572 AC_ARG_ENABLE([debug-kmem-tracking],
573 [AS_HELP_STRING([--enable-debug-kmem-tracking],
574 [Enable detailed kmem tracking @<:@default=no@:>@])],
576 [enable_debug_kmem_tracking=no])
578 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
580 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
581 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
582 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
583 [Define to 1 to enable detailed kmem tracking])
585 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
588 AC_SUBST(DEBUG_KMEM_TRACKING)
589 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
590 AC_MSG_RESULT([$enable_debug_kmem_tracking])
594 dnl # SPL_LINUX_CONFTEST
596 AC_DEFUN([SPL_LINUX_CONFTEST], [
597 cat confdefs.h - <<_ACEOF >conftest.c
603 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
605 m4_define([SPL_LANG_PROGRAM], [
610 dnl Do *not* indent the following line: there may be CPP directives.
611 dnl Don't move the `;' right after for the same reason.
619 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
621 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
622 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
623 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
624 echo "obj-m := conftest.o" >build/Makefile
626 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
628 [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])],
630 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
636 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
638 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
639 [SPL_LINUX_COMPILE_IFELSE(
640 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
642 [test -s build/conftest.o],
647 dnl # SPL_CHECK_SYMBOL_EXPORT
648 dnl # check symbol exported or not
650 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
651 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
652 $LINUX_OBJ/Module*.symvers 2>/dev/null
654 if test $rc -ne 0; then
657 grep -q -E "EXPORT_SYMBOL.*($1)" \
658 "$LINUX_OBJ/$file" 2>/dev/null
660 if test $rc -eq 0; then
665 if test $export -eq 0; then :
676 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
677 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
678 dnl # is called if not compiling for builtin
680 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
681 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
682 if test $rc -ne 0; then :
685 if test "x$enable_linux_builtin" != xyes; then
686 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
688 if test $rc -ne 0; then :
697 dnl # SPL_CHECK_SYMBOL_HEADER
698 dnl # check if a symbol prototype is defined in listed headers.
700 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
701 AC_MSG_CHECKING([whether symbol $1 exists in header])
704 grep -q "$2" "$LINUX/$file" 2>/dev/null
706 if test $rc -eq 0; then
711 if test $header -eq 0; then
721 dnl # SPL_CHECK_HEADER
722 dnl # check whether header exists and define HAVE_$2_HEADER
724 AC_DEFUN([SPL_CHECK_HEADER],
725 [AC_MSG_CHECKING([whether header $1 exists])
726 SPL_LINUX_TRY_COMPILE([
731 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
741 dnl # Basic toolchain sanity check.
743 AC_DEFUN([SPL_AC_TEST_MODULE],
744 [AC_MSG_CHECKING([whether modules can be built])
745 SPL_LINUX_TRY_COMPILE([],[],[
749 if test "x$enable_linux_builtin" != xyes; then
750 AC_MSG_ERROR([*** Unable to build an empty module.])
753 *** Unable to build an empty module.
754 *** Please run 'make scripts' inside the kernel source tree.])
760 dnl # Use the atomic implemenation based on global spinlocks. This
761 dnl # should only be needed by 32-bit kernels which do not provide
762 dnl # the atomic64_* API. It may be optionally enabled as a fallback
763 dnl # if problems are observed with the direct mapping to the native
764 dnl # Linux atomic operations. You may not disable atomic spinlocks
765 dnl # if you kernel does not an atomic64_* API.
767 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
768 AC_ARG_ENABLE([atomic-spinlocks],
769 [AS_HELP_STRING([--enable-atomic-spinlocks],
770 [Atomic types use spinlocks @<:@default=check@:>@])],
772 [enable_atomic_spinlocks=check])
774 SPL_LINUX_TRY_COMPILE([
775 #include <linux/fs.h>
777 atomic64_t *ptr __attribute__ ((unused));
780 AC_DEFINE(HAVE_ATOMIC64_T, 1,
781 [kernel defines atomic64_t])
786 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
787 AS_IF([test "x$have_atomic64_t" = xyes], [
788 enable_atomic_spinlocks=no
790 enable_atomic_spinlocks=yes
794 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
795 AC_DEFINE([ATOMIC_SPINLOCK], [1],
796 [Atomic types use spinlocks])
798 AS_IF([test "x$have_atomic64_t" = xno], [
800 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
804 AC_MSG_CHECKING([whether atomic types use spinlocks])
805 AC_MSG_RESULT([$enable_atomic_spinlocks])
807 AC_MSG_CHECKING([whether kernel defines atomic64_t])
808 AC_MSG_RESULT([$have_atomic64_t])
812 dnl # 2.6.24 API change,
813 dnl # check if atomic64_cmpxchg is defined
815 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
816 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
817 SPL_LINUX_TRY_COMPILE([
818 #include <linux/fs.h>
820 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
823 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
824 [kernel defines atomic64_cmpxchg])
831 dnl # 2.6.24 API change,
832 dnl # check if atomic64_xchg is defined
834 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
835 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
836 SPL_LINUX_TRY_COMPILE([
837 #include <linux/fs.h>
839 atomic64_xchg((atomic64_t *)NULL, 0);
842 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
843 [kernel defines atomic64_xchg])
850 dnl # 2.6.24 API change,
851 dnl # check if uintptr_t typedef is defined
853 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
854 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
855 SPL_LINUX_TRY_COMPILE([
856 #include <linux/types.h>
858 uintptr_t *ptr __attribute__ ((unused));
861 AC_DEFINE(HAVE_UINTPTR_T, 1,
862 [kernel defines uintptr_t])
869 dnl # 2.6.21 API change,
870 dnl # 'register_sysctl_table' use only one argument instead of two
872 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
873 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
874 SPL_LINUX_TRY_COMPILE([
875 #include <linux/sysctl.h>
877 (void) register_sysctl_table(NULL, 0);
880 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
881 [register_sysctl_table() wants 2 args])
888 dnl # 2.6.23 API change
889 dnl # Old set_shrinker API replaced with register_shrinker
891 AC_DEFUN([SPL_AC_SET_SHRINKER], [
892 AC_MSG_CHECKING([whether set_shrinker() available])
893 SPL_LINUX_TRY_COMPILE([
894 #include <linux/mm.h>
896 return set_shrinker(DEFAULT_SEEKS, NULL);
899 AC_DEFINE(HAVE_SET_SHRINKER, 1,
900 [set_shrinker() available])
907 dnl # 2.6.35 API change,
908 dnl # Add context to shrinker callback
910 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
911 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
912 tmp_flags="$EXTRA_KCFLAGS"
913 EXTRA_KCFLAGS="-Werror"
914 SPL_LINUX_TRY_COMPILE([
915 #include <linux/mm.h>
917 int shrinker_cb(struct shrinker *, int, unsigned int);
919 struct shrinker cache_shrinker = {
920 .shrink = shrinker_cb,
921 .seeks = DEFAULT_SEEKS,
923 register_shrinker(&cache_shrinker);
926 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
927 [shrinker callback wants 3 args])
931 EXTRA_KCFLAGS="$tmp_flags"
935 dnl # 2.6.25 API change,
936 dnl # struct path entry added to struct nameidata
938 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
939 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
940 SPL_LINUX_TRY_COMPILE([
941 #include <linux/namei.h>
943 struct nameidata nd __attribute__ ((unused));
946 nd.path.dentry = NULL;
949 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
950 [struct path used in struct nameidata])
957 dnl # Custom SPL patch may export this system it is not required
959 AC_DEFUN([SPL_AC_TASK_CURR],
960 [AC_MSG_CHECKING([whether task_curr() is available])
961 SPL_LINUX_TRY_COMPILE_SYMBOL([
962 #include <linux/sched.h>
965 ], [task_curr], [kernel/sched.c], [
967 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
974 dnl # 2.6.19 API change,
975 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
977 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
978 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
979 SPL_LINUX_TRY_COMPILE([
980 #include <linux/sysctl.h>
982 #ifndef CTL_UNNUMBERED
983 #error CTL_UNNUMBERED undefined
987 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
988 [unnumbered sysctl support exists])
995 dnl # 2.6.33 API change,
996 dnl # Removed .ctl_name from struct ctl_table.
998 AC_DEFUN([SPL_AC_CTL_NAME], [
999 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1000 SPL_LINUX_TRY_COMPILE([
1001 #include <linux/sysctl.h>
1003 struct ctl_table ctl __attribute__ ((unused));
1007 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1014 dnl # 2.6.16 API change.
1015 dnl # Check if 'fls64()' is available
1017 AC_DEFUN([SPL_AC_FLS64],
1018 [AC_MSG_CHECKING([whether fls64() is available])
1019 SPL_LINUX_TRY_COMPILE([
1020 #include <linux/bitops.h>
1025 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1032 dnl # 2.6.18 API change, check whether device_create() is available.
1033 dnl # Device_create() was introduced in 2.6.18 and depricated
1034 dnl # class_device_create() which was fully removed in 2.6.26.
1036 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1037 [AC_MSG_CHECKING([whether device_create() is available])
1038 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1040 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1041 [device_create() is available])
1048 dnl # 2.6.27 API change,
1049 dnl # device_create() uses 5 args, new 'drvdata' argument.
1051 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1052 AC_MSG_CHECKING([whether device_create() wants 5 args])
1053 tmp_flags="$EXTRA_KCFLAGS"
1054 EXTRA_KCFLAGS="-Werror"
1055 SPL_LINUX_TRY_COMPILE([
1056 #include <linux/device.h>
1058 device_create(NULL, NULL, 0, NULL, "%d", 1);
1061 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1062 [device_create wants 5 args])
1066 EXTRA_KCFLAGS="$tmp_flags"
1070 dnl # 2.6.13 API change, check whether class_device_create() is available.
1071 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1072 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1074 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1075 [AC_MSG_CHECKING([whether class_device_create() is available])
1076 SPL_LINUX_TRY_COMPILE_SYMBOL([
1077 #include <linux/device.h>
1079 class_device_create(NULL, NULL, 0, NULL, NULL);
1080 ], [class_device_create], [drivers/base/class.c], [
1082 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1083 [class_device_create() is available])
1090 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1092 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1093 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1094 SPL_LINUX_TRY_COMPILE_SYMBOL([
1095 #include <linux/time.h>
1097 set_normalized_timespec(NULL, 0, 0);
1098 ], [set_normalized_timespec], [kernel/time.c], [
1100 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1101 [set_normalized_timespec() is available as export])
1108 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1109 dnl # previously it was available in time.h as an inline.
1111 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1112 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1113 SPL_LINUX_TRY_COMPILE([
1114 #include <linux/time.h>
1115 void set_normalized_timespec(struct timespec *ts,
1116 time_t sec, long nsec) { }
1123 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1124 [set_normalized_timespec() is available as inline])
1129 dnl # 2.6.18 API change,
1130 dnl # timespec_sub() inline function available in linux/time.h
1132 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1133 AC_MSG_CHECKING([whether timespec_sub() is available])
1134 SPL_LINUX_TRY_COMPILE([
1135 #include <linux/time.h>
1137 struct timespec a = { 0 };
1138 struct timespec b = { 0 };
1139 struct timespec c __attribute__ ((unused));
1140 c = timespec_sub(a, b);
1143 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1150 dnl # 2.6.19 API change,
1151 dnl # check if init_utsname() is available in linux/utsname.h
1153 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1154 AC_MSG_CHECKING([whether init_utsname() is available])
1155 SPL_LINUX_TRY_COMPILE([
1156 #include <linux/utsname.h>
1158 struct new_utsname *a __attribute__ ((unused));
1162 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1169 dnl # 2.6.18 API change,
1170 dnl # added linux/uaccess.h
1172 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1173 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1177 dnl # 2.6.12 API change,
1178 dnl # check whether 'kmalloc_node()' is available.
1180 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1181 AC_MSG_CHECKING([whether kmalloc_node() is available])
1182 SPL_LINUX_TRY_COMPILE([
1183 #include <linux/slab.h>
1185 void *a __attribute__ ((unused));
1186 a = kmalloc_node(1, GFP_KERNEL, 0);
1189 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1196 dnl # 2.6.9 API change,
1197 dnl # check whether 'monotonic_clock()' is available it may
1198 dnl # be available for some archs but not others.
1200 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1201 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1202 SPL_LINUX_TRY_COMPILE_SYMBOL([
1203 #include <linux/timex.h>
1206 ], [monotonic_clock], [], [
1208 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1209 [monotonic_clock() is available])
1216 dnl # 2.6.16 API change,
1217 dnl # check whether 'struct inode' has i_mutex
1219 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1220 AC_MSG_CHECKING([whether struct inode has i_mutex])
1221 SPL_LINUX_TRY_COMPILE([
1222 #include <linux/fs.h>
1223 #include <linux/mutex.h>
1226 mutex_init(&i.i_mutex);
1229 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1236 dnl # 2.6.29 API change,
1237 dnl # Adaptive mutexs introduced.
1239 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1240 AC_MSG_CHECKING([whether struct mutex has owner])
1241 SPL_LINUX_TRY_COMPILE([
1242 #include <linux/mutex.h>
1244 struct mutex mtx __attribute__ ((unused));
1248 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1255 dnl # 2.6.39 API change,
1256 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1257 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1258 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1259 dnl # pointer which frankly makes a lot more sense.
1261 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1262 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1263 tmp_flags="$EXTRA_KCFLAGS"
1264 EXTRA_KCFLAGS="-Werror"
1265 SPL_LINUX_TRY_COMPILE([
1266 #include <linux/mutex.h>
1267 #include <linux/sched.h>
1269 struct mutex mtx __attribute__ ((unused));
1270 mtx.owner = current;
1273 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1274 [struct mutex owner is a task_struct])
1278 EXTRA_KCFLAGS="$tmp_flags"
1282 dnl # 2.6.18 API change,
1283 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1284 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1285 dnl # if the mutex validator is disabled or otherwise unavailable.
1287 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1288 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1289 SPL_LINUX_TRY_COMPILE([
1290 #include <linux/mutex.h>
1294 mutex_lock_nested(&mutex, 0);
1297 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1298 [mutex_lock_nested() is available])
1305 dnl # 2.6.27 API change,
1306 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1308 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1309 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1310 SPL_LINUX_TRY_COMPILE([
1311 #include <linux/interrupt.h>
1312 #include <linux/smp.h>
1314 void on_each_cpu_func(void *data) { return; }
1316 on_each_cpu(on_each_cpu_func, 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 # 3.10 API change,
1365 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1367 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1368 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1369 SPL_LINUX_TRY_COMPILE([
1370 #include <linux/vmalloc.h>
1371 struct vmalloc_info { void *a; };
1378 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1383 dnl # 3.10 API change,
1384 dnl # PDE is replaced by PDE_DATA
1386 AC_DEFUN([SPL_AC_PDE_DATA], [
1387 AC_MSG_CHECKING([whether PDE_DATA() is available])
1388 SPL_LINUX_TRY_COMPILE_SYMBOL([
1389 #include <linux/proc_fs.h>
1392 ], [PDE_DATA], [], [
1394 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1401 dnl # 2.6.17 API change
1402 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1403 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1404 dnl # were exported in 2.6.17 for use by modules which was consistent with
1405 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1406 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1407 dnl # were dropped entirely leaving modules no way to directly iterate over
1408 dnl # the zone list. Because we need access to the zone helpers we check
1409 dnl # if the kernel contains the old or new implementation. Then we check
1410 dnl # to see if the symbols we need for each version are available. If they
1411 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1413 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1414 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1415 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1417 if test $rc -eq 0; then
1418 AC_MSG_RESULT([yes])
1419 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1426 dnl # Proposed API change,
1427 dnl # This symbol is not available in stock kernels. You may build a
1428 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1429 dnl # these symbols for use. If your already rolling a custom kernel for
1430 dnl # your environment this is recommended.
1432 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1433 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1434 SPL_LINUX_TRY_COMPILE_SYMBOL([
1435 #include <linux/mmzone.h>
1437 first_online_pgdat();
1438 ], [first_online_pgdat], [], [
1440 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1441 [first_online_pgdat() 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_NEXT_ONLINE_PGDAT],
1455 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1456 SPL_LINUX_TRY_COMPILE_SYMBOL([
1457 #include <linux/mmzone.h>
1459 next_online_pgdat(NULL);
1460 ], [next_online_pgdat], [], [
1462 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1463 [next_online_pgdat() is available])
1470 dnl # Proposed API change,
1471 dnl # This symbol is not available in stock kernels. You may build a
1472 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1473 dnl # these symbols for use. If your already rolling a custom kernel for
1474 dnl # your environment this is recommended.
1476 AC_DEFUN([SPL_AC_NEXT_ZONE],
1477 [AC_MSG_CHECKING([whether next_zone() is available])
1478 SPL_LINUX_TRY_COMPILE_SYMBOL([
1479 #include <linux/mmzone.h>
1482 ], [next_zone], [], [
1484 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1491 dnl # 2.6.17 API change,
1492 dnl # See SPL_AC_PGDAT_HELPERS for details.
1494 AC_DEFUN([SPL_AC_PGDAT_LIST],
1495 [AC_MSG_CHECKING([whether pgdat_list is available])
1496 SPL_LINUX_TRY_COMPILE_SYMBOL([
1497 #include <linux/topology.h>
1498 pg_data_t *tmp = pgdat_list;
1499 ], [], [pgdat_list], [], [
1501 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1508 dnl # 2.6.18 API change,
1509 dnl # First introduced global_page_state() support as an inline.
1511 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1512 AC_MSG_CHECKING([whether global_page_state() is available])
1513 SPL_LINUX_TRY_COMPILE([
1514 #include <linux/mm.h>
1516 unsigned long state __attribute__ ((unused));
1517 state = global_page_state(0);
1520 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1521 [global_page_state() is available])
1528 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1529 dnl # Public global zone stats now include a free page count. However
1530 dnl # the enumerated names of the counters have changed since this API
1531 dnl # was introduced. We need to deduce the corrent name to use. This
1532 dnl # replaces the priviate get_zone_counts() interface.
1534 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1535 dnl # is 2.6.30 as of when this was written.
1537 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1538 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1539 SPL_LINUX_TRY_COMPILE([
1540 #include <linux/mm.h>
1542 enum zone_stat_item zsi __attribute__ ((unused));
1543 zsi = NR_FREE_PAGES;
1546 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1547 [Page state NR_FREE_PAGES is available])
1554 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1555 dnl # Public global zone stats now include an inactive page count. However
1556 dnl # the enumerated names of the counters have changed since this API
1557 dnl # was introduced. We need to deduce the corrent name to use. This
1558 dnl # replaces the priviate get_zone_counts() interface.
1560 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1561 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1562 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1564 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1565 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1566 SPL_LINUX_TRY_COMPILE([
1567 #include <linux/mm.h>
1569 enum zone_stat_item zsi __attribute__ ((unused));
1573 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1574 [Page state NR_INACTIVE is available])
1579 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1580 SPL_LINUX_TRY_COMPILE([
1581 #include <linux/mm.h>
1583 enum zone_stat_item zsi __attribute__ ((unused));
1584 zsi = NR_INACTIVE_ANON;
1587 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1588 [Page state NR_INACTIVE_ANON is available])
1593 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1594 SPL_LINUX_TRY_COMPILE([
1595 #include <linux/mm.h>
1597 enum zone_stat_item zsi __attribute__ ((unused));
1598 zsi = NR_INACTIVE_FILE;
1601 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1602 [Page state NR_INACTIVE_FILE is available])
1609 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1610 dnl # Public global zone stats now include an active page count. However
1611 dnl # the enumerated names of the counters have changed since this API
1612 dnl # was introduced. We need to deduce the corrent name to use. This
1613 dnl # replaces the priviate get_zone_counts() interface.
1615 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1616 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1617 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1619 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1620 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1621 SPL_LINUX_TRY_COMPILE([
1622 #include <linux/mm.h>
1624 enum zone_stat_item zsi __attribute__ ((unused));
1628 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1629 [Page state NR_ACTIVE is available])
1634 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1635 SPL_LINUX_TRY_COMPILE([
1636 #include <linux/mm.h>
1638 enum zone_stat_item zsi __attribute__ ((unused));
1639 zsi = NR_ACTIVE_ANON;
1642 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1643 [Page state NR_ACTIVE_ANON is available])
1648 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1649 SPL_LINUX_TRY_COMPILE([
1650 #include <linux/mm.h>
1652 enum zone_stat_item zsi __attribute__ ((unused));
1653 zsi = NR_ACTIVE_FILE;
1656 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1657 [Page state NR_ACTIVE_FILE is available])
1664 dnl # Proposed API change for legacy kernels.
1665 dnl # This symbol is not available in older kernels. For kernels post
1666 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1667 dnl # page state information. This symbol is only used in legacy kernels
1668 dnl # any only as a last resort.
1670 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1671 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1672 SPL_LINUX_TRY_COMPILE([
1674 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1675 #error "global_page_state needs NR_FREE_PAGES"
1678 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1679 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1680 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1681 #error "global_page_state needs NR_ACTIVE*"
1684 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1685 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1686 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1687 #error "global_page_state needs NR_INACTIVE*"
1693 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1694 [get_zone_counts() is needed])
1696 AC_MSG_CHECKING([whether get_zone_counts() is available])
1697 SPL_LINUX_TRY_COMPILE_SYMBOL([
1698 #include <linux/mmzone.h>
1700 get_zone_counts(NULL, NULL, NULL);
1701 ], [get_zone_counts], [], [
1703 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1704 [get_zone_counts() is available])
1712 dnl # 2.6.27 API change,
1713 dnl # The user_path_dir() replaces __user_walk()
1715 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1716 [AC_MSG_CHECKING([whether user_path_dir() is available])
1717 SPL_LINUX_TRY_COMPILE_SYMBOL([
1718 #include <linux/fcntl.h>
1719 #include <linux/namei.h>
1721 user_path_dir(NULL, NULL);
1722 ], [user_path_at], [], [
1724 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1731 dnl # Symbol available in RHEL kernels not in stock kernels.
1733 AC_DEFUN([SPL_AC_SET_FS_PWD],
1734 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1735 SPL_LINUX_TRY_COMPILE_SYMBOL([
1736 #include <linux/spinlock.h>
1737 #include <linux/fs_struct.h>
1740 ], [set_fs_pwd], [], [
1742 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1749 dnl # 3.9 API change
1750 dnl # set_fs_pwd takes const struct path *
1752 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1753 tmp_flags="$EXTRA_KCFLAGS"
1754 EXTRA_KCFLAGS="-Werror"
1755 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1756 SPL_LINUX_TRY_COMPILE([
1757 #include <linux/spinlock.h>
1758 #include <linux/fs_struct.h>
1759 #include <linux/path.h>
1760 void (*const set_fs_pwd_func)
1761 (struct fs_struct *, const struct path *)
1767 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1768 [set_fs_pwd() needs const path *])
1770 SPL_LINUX_TRY_COMPILE([
1771 #include <linux/spinlock.h>
1772 #include <linux/fs_struct.h>
1773 #include <linux/path.h>
1774 void (*const set_fs_pwd_func)
1775 (struct fs_struct *, struct path *)
1782 AC_MSG_ERROR(unknown)
1785 EXTRA_KCFLAGS="$tmp_flags"
1789 dnl # SLES API change, never adopted in mainline,
1790 dnl # Third 'struct vfsmount *' argument removed.
1792 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1793 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1794 SPL_LINUX_TRY_COMPILE([
1795 #include <linux/fs.h>
1797 vfs_unlink(NULL, NULL);
1800 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1801 [vfs_unlink() wants 2 args])
1808 dnl # SLES API change, never adopted in mainline,
1809 dnl # Third and sixth 'struct vfsmount *' argument removed.
1811 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1812 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1813 SPL_LINUX_TRY_COMPILE([
1814 #include <linux/fs.h>
1816 vfs_rename(NULL, NULL, NULL, NULL);
1819 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1820 [vfs_rename() wants 4 args])
1827 dnl # 2.6.36 API change,
1828 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1829 dnl # a spinlock_t to improve the fastpath performance.
1831 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1832 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1833 tmp_flags="$EXTRA_KCFLAGS"
1834 EXTRA_KCFLAGS="-Werror"
1835 SPL_LINUX_TRY_COMPILE([
1836 #include <linux/sched.h>
1837 #include <linux/fs_struct.h>
1839 struct fs_struct fs;
1840 spin_lock_init(&fs.lock);
1843 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1844 [struct fs_struct uses spinlock_t])
1848 EXTRA_KCFLAGS="$tmp_flags"
1852 dnl # 2.6.29 API change,
1853 dnl # check whether 'struct cred' exists
1855 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1856 AC_MSG_CHECKING([whether struct cred exists])
1857 SPL_LINUX_TRY_COMPILE([
1858 #include <linux/cred.h>
1860 struct cred *cr __attribute__ ((unused));
1864 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1872 dnl # User namespaces, use kuid_t in place of uid_t
1873 dnl # where available. Not strictly a user namespaces thing
1874 dnl # but it should prevent surprises
1876 AC_DEFUN([SPL_AC_KUIDGID_T], [
1877 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1878 SPL_LINUX_TRY_COMPILE([
1879 #include <linux/uidgid.h>
1881 kuid_t userid = KUIDT_INIT(0);
1882 kgid_t groupid = KGIDT_INIT(0);
1884 SPL_LINUX_TRY_COMPILE([
1885 #include <linux/uidgid.h>
1890 AC_MSG_RESULT(yes; optional)
1892 AC_MSG_RESULT(yes; mandatory)
1893 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1901 dnl # Custom SPL patch may export this symbol.
1903 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1904 [AC_MSG_CHECKING([whether groups_search() is available])
1905 SPL_LINUX_TRY_COMPILE_SYMBOL([
1906 #include <linux/cred.h>
1907 #ifdef HAVE_KUIDGID_T
1908 #include <linux/uidgid.h>
1911 #ifdef HAVE_KUIDGID_T
1912 groups_search(NULL, KGIDT_INIT(0));
1914 groups_search(NULL, 0);
1916 ], [groups_search], [], [
1918 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1925 dnl # 2.6.x API change,
1926 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1928 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1929 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1930 SPL_LINUX_TRY_COMPILE_SYMBOL([
1931 #include <linux/sched.h>
1933 __put_task_struct(NULL);
1934 ], [__put_task_struct], [], [
1936 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1937 [__put_task_struct() is available])
1944 dnl # 2.6.32 API change,
1945 dnl # Unused 'struct file *' removed from prototype.
1947 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1948 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1949 SPL_LINUX_TRY_COMPILE([
1950 #include <linux/sysctl.h>
1952 proc_dostring(NULL, 0, NULL, NULL, NULL);
1955 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1956 [proc_handler() wants 5 args])
1963 dnl # 2.6.x API change,
1964 dnl # kvasprintf() function added.
1966 AC_DEFUN([SPL_AC_KVASPRINTF],
1967 [AC_MSG_CHECKING([whether kvasprintf() is available])
1968 SPL_LINUX_TRY_COMPILE_SYMBOL([
1969 #include <linux/kernel.h>
1971 kvasprintf(0, NULL, *((va_list*)NULL));
1972 ], [kvasprintf], [], [
1974 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1981 dnl # 2.6.29 API change,
1982 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1984 AC_DEFUN([SPL_AC_VFS_FSYNC],
1985 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1986 SPL_LINUX_TRY_COMPILE_SYMBOL([
1987 #include <linux/fs.h>
1990 ], [vfs_fsync], [fs/sync.c], [
1992 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1999 dnl # 2.6.35 API change,
2000 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2002 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2003 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2004 SPL_LINUX_TRY_COMPILE([
2005 #include <linux/fs.h>
2010 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2017 dnl # 3.5 API change,
2018 dnl # inode_operations.truncate_range removed
2020 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2021 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2022 SPL_LINUX_TRY_COMPILE([
2023 #include <linux/fs.h>
2025 struct inode_operations ops;
2026 ops.truncate_range = NULL;
2029 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2030 [truncate_range() inode operation is available])
2037 dnl # Linux 2.6.38 - 3.x API
2039 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2040 AC_MSG_CHECKING([whether fops->fallocate() exists])
2041 SPL_LINUX_TRY_COMPILE([
2042 #include <linux/fs.h>
2044 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2045 struct file_operations fops __attribute__ ((unused)) = {
2046 .fallocate = fallocate,
2050 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2057 dnl # Linux 2.6.x - 2.6.37 API
2059 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2060 AC_MSG_CHECKING([whether iops->fallocate() exists])
2061 SPL_LINUX_TRY_COMPILE([
2062 #include <linux/fs.h>
2064 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2065 struct inode_operations fops __attribute__ ((unused)) = {
2066 .fallocate = fallocate,
2070 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2077 dnl # PaX Linux 2.6.38 - 3.x API
2079 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2080 AC_MSG_CHECKING([whether fops->fallocate() exists])
2081 SPL_LINUX_TRY_COMPILE([
2082 #include <linux/fs.h>
2084 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2085 struct file_operations_no_const fops __attribute__ ((unused)) = {
2086 .fallocate = fallocate,
2090 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2097 dnl # The fallocate callback was moved from the inode_operations
2098 dnl # structure to the file_operations structure.
2100 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2101 SPL_AC_KERNEL_FILE_FALLOCATE
2102 SPL_AC_KERNEL_INODE_FALLOCATE
2103 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2107 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2108 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2109 dnl # condition. The fixed version is exported as a symbol. The race
2110 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2111 dnl # call that version while holding sem->wait_lock.
2113 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2114 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2115 SPL_LINUX_TRY_COMPILE_SYMBOL([
2116 #include <linux/rwsem.h>
2117 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2118 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2120 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2121 [rwsem_is_locked() acquires sem->wait_lock])
2128 dnl # 2.6.xx API compat,
2129 dnl # There currently exists no exposed API to partially shrink the dcache.
2130 dnl # The expected mechanism to shrink the cache is a registered shrinker
2131 dnl # which is called during memory pressure.
2133 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2134 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2135 SPL_LINUX_TRY_COMPILE_SYMBOL([
2136 #include <linux/dcache.h>
2138 shrink_dcache_memory(0, 0);
2139 ], [shrink_dcache_memory], [fs/dcache.c], [
2141 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2142 [shrink_dcache_memory() is available])
2149 dnl # 2.6.xx API compat,
2150 dnl # There currently exists no exposed API to partially shrink the icache.
2151 dnl # The expected mechanism to shrink the cache is a registered shrinker
2152 dnl # which is called during memory pressure.
2154 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2155 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2156 SPL_LINUX_TRY_COMPILE_SYMBOL([
2157 #include <linux/dcache.h>
2159 shrink_icache_memory(0, 0);
2160 ], [shrink_icache_memory], [fs/inode.c], [
2162 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2163 [shrink_icache_memory() is available])
2170 dnl # 2.6.39 API compat,
2171 dnl # The path_lookup() function has been renamed to kern_path_parent()
2172 dnl # and the flags argument has been removed. The only behavior now
2173 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2174 dnl # this flag so dropping the flag does not impact us.
2176 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2177 SPL_CHECK_SYMBOL_HEADER(
2179 [int kern_path_parent(const char \*, struct nameidata \*)],
2180 [include/linux/namei.h],
2181 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2182 [kern_path_parent() is available])],
2187 dnl # 3.1 API compat,
2188 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2189 dnl # However, it remains the prefered interface and since we still have
2190 dnl # access to the prototype we dynamically lookup the required address.
2192 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2193 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2194 SPL_LINUX_TRY_COMPILE_SYMBOL([
2195 #include <linux/namei.h>
2197 kern_path_parent(NULL, NULL);
2198 ], [kern_path_parent], [fs/namei.c], [
2200 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2201 [kern_path_parent() is available])
2208 dnl # 3.6 API compat,
2209 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2210 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2212 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2213 SPL_CHECK_SYMBOL_HEADER(
2215 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2216 [include/linux/namei.h],
2217 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2218 [kern_path_locked() is available])],
2223 dnl # /proc/kallsyms support,
2224 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2226 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2227 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2228 SPL_LINUX_TRY_COMPILE([
2229 #if !defined(CONFIG_KALLSYMS)
2230 #error CONFIG_KALLSYMS not defined
2233 AC_MSG_RESULT([yes])
2237 *** This kernel does not include the required kallsyms support.
2238 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2243 dnl # zlib inflate compat,
2244 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2246 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2247 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2248 SPL_LINUX_TRY_COMPILE([
2249 #if !defined(CONFIG_ZLIB_INFLATE) && \
2250 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2251 #error CONFIG_ZLIB_INFLATE not defined
2254 AC_MSG_RESULT([yes])
2258 *** This kernel does not include the required zlib inflate support.
2259 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2264 dnl # zlib deflate compat,
2265 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2267 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2268 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2269 SPL_LINUX_TRY_COMPILE([
2270 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2271 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2272 #error CONFIG_ZLIB_DEFLATE not defined
2275 AC_MSG_RESULT([yes])
2279 *** This kernel does not include the required zlib deflate support.
2280 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2285 dnl # 2.6.39 API compat,
2286 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2287 dnl # This was done to avoid always having to allocate the maximum size
2288 dnl # workspace (268K). The caller can now specific the windowBits and
2289 dnl # memLevel compression parameters to get a smaller workspace.
2291 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2292 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2293 SPL_LINUX_TRY_COMPILE([
2294 #include <linux/zlib.h>
2296 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2299 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2300 [zlib_deflate_workspacesize() wants 2 args])
2307 dnl # 2.6.39 API change,
2308 dnl # Shrinker adjust to use common shrink_control structure.
2310 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2311 AC_MSG_CHECKING([whether struct shrink_control exists])
2312 SPL_LINUX_TRY_COMPILE([
2313 #include <linux/mm.h>
2315 struct shrink_control sc __attribute__ ((unused));
2318 sc.gfp_mask = GFP_KERNEL;
2321 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2322 [struct shrink_control exists])
2329 dnl # 3.1 API Change
2331 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2332 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2334 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2335 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2336 tmp_flags="$EXTRA_KCFLAGS"
2337 EXTRA_KCFLAGS="-Werror"
2338 SPL_LINUX_TRY_COMPILE([
2339 #include <linux/rwsem.h>
2341 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2342 raw_spinlock_t dummy_lock __attribute__ ((unused));
2343 dummy_semaphore.wait_lock = dummy_lock;
2346 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2347 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2351 EXTRA_KCFLAGS="$tmp_flags"
2355 dnl # 3.9 API change,
2356 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2358 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2359 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2360 SPL_LINUX_TRY_COMPILE([
2361 #include <linux/sched.h>
2362 #include <linux/sched/rt.h>
2366 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2374 dnl # 3.9 API change,
2375 dnl # vfs_getattr() uses 2 args
2376 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2378 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2379 AC_MSG_CHECKING([whether vfs_getattr() wants])
2380 SPL_LINUX_TRY_COMPILE([
2381 #include <linux/fs.h>
2383 vfs_getattr((struct path *) NULL,
2384 (struct kstat *)NULL);
2386 AC_MSG_RESULT(2 args)
2387 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2388 [vfs_getattr wants 2 args])
2390 SPL_LINUX_TRY_COMPILE([
2391 #include <linux/fs.h>
2393 vfs_getattr((struct vfsmount *)NULL,
2394 (struct dentry *)NULL,
2395 (struct kstat *)NULL);
2397 AC_MSG_RESULT(3 args)
2399 AC_MSG_ERROR(unknown)