1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_SHRINKER_CALLBACK
31 SPL_AC_PATH_IN_NAMEIDATA
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
47 SPL_AC_MONOTONIC_CLOCK
50 SPL_AC_MUTEX_OWNER_TASK_STRUCT
51 SPL_AC_MUTEX_LOCK_NESTED
52 SPL_AC_3ARGS_ON_EACH_CPU
53 SPL_AC_KALLSYMS_LOOKUP_NAME
54 SPL_AC_GET_VMALLOC_INFO
56 SPL_AC_FIRST_ONLINE_PGDAT
57 SPL_AC_NEXT_ONLINE_PGDAT
60 SPL_AC_GLOBAL_PAGE_STATE
61 SPL_AC_ZONE_STAT_ITEM_FREE
62 SPL_AC_ZONE_STAT_ITEM_INACTIVE
63 SPL_AC_ZONE_STAT_ITEM_ACTIVE
64 SPL_AC_GET_ZONE_COUNTS
67 SPL_AC_SET_FS_PWD_WITH_CONST
68 SPL_AC_2ARGS_VFS_UNLINK
69 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_2ARGS_VFS_FSYNC
72 SPL_AC_INODE_TRUNCATE_RANGE
73 SPL_AC_FS_STRUCT_SPINLOCK
77 SPL_AC_PUT_TASK_STRUCT
78 SPL_AC_5ARGS_PROC_HANDLER
80 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
81 SPL_AC_KERNEL_FALLOCATE
82 SPL_AC_SHRINK_DCACHE_MEMORY
83 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_KERN_PATH_PARENT_HEADER
85 SPL_AC_KERN_PATH_PARENT_SYMBOL
86 SPL_AC_KERN_PATH_LOCKED
87 SPL_AC_CONFIG_KALLSYMS
88 SPL_AC_CONFIG_ZLIB_INFLATE
89 SPL_AC_CONFIG_ZLIB_DEFLATE
90 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
91 SPL_AC_SHRINK_CONTROL_STRUCT
92 SPL_AC_RWSEM_SPINLOCK_IS_RAW
93 SPL_AC_SCHED_RT_HEADER
94 SPL_AC_2ARGS_VFS_GETATTR
96 SPL_AC_KMEM_CACHE_ALLOCFLAGS
99 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
100 modpost=$LINUX/scripts/Makefile.modpost
101 AC_MSG_CHECKING([kernel file name for module symbols])
102 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
103 if grep -q Modules.symvers $modpost; then
104 LINUX_SYMBOLS=Modules.symvers
106 LINUX_SYMBOLS=Module.symvers
109 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
111 *** Please make sure the kernel devel package for your distribution
112 *** is installed. If you are building with a custom kernel, make sure the
113 *** kernel is configured, built, and the '--with-linux=PATH' configure
114 *** option refers to the location of the kernel source.])
119 AC_MSG_RESULT($LINUX_SYMBOLS)
120 AC_SUBST(LINUX_SYMBOLS)
123 AC_DEFUN([SPL_AC_KERNEL], [
125 AS_HELP_STRING([--with-linux=PATH],
126 [Path to kernel source]),
127 [kernelsrc="$withval"])
129 AC_ARG_WITH([linux-obj],
130 AS_HELP_STRING([--with-linux-obj=PATH],
131 [Path to kernel build objects]),
132 [kernelbuild="$withval"])
134 AC_MSG_CHECKING([kernel source directory])
135 if test -z "$kernelsrc"; then
136 if test -e "/lib/modules/$(uname -r)/source"; then
137 headersdir="/lib/modules/$(uname -r)/source"
138 sourcelink=$(readlink -f "$headersdir")
139 elif test -e "/lib/modules/$(uname -r)/build"; then
140 headersdir="/lib/modules/$(uname -r)/build"
141 sourcelink=$(readlink -f "$headersdir")
143 sourcelink=$(ls -1d /usr/src/kernels/* \
145 2>/dev/null | grep -v obj | tail -1)
148 if test -n "$sourcelink" && test -e ${sourcelink}; then
149 kernelsrc=`readlink -f ${sourcelink}`
151 kernelsrc="[Not found]"
154 if test "$kernelsrc" = "NONE"; then
159 AC_MSG_RESULT([$kernelsrc])
160 if test ! -d "$kernelsrc"; then
162 *** Please make sure the kernel devel package for your distribution
163 *** is installed and then try again. If that fails, you can specify the
164 *** location of the kernel source with the '--with-linux=PATH' option.])
167 AC_MSG_CHECKING([kernel build directory])
168 if test -z "$kernelbuild"; then
169 if test -e "/lib/modules/$(uname -r)/build"; then
170 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
171 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
172 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
173 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
174 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
175 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
176 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
178 kernelbuild=${kernelsrc}
181 AC_MSG_RESULT([$kernelbuild])
183 AC_MSG_CHECKING([kernel source version])
184 utsrelease1=$kernelbuild/include/linux/version.h
185 utsrelease2=$kernelbuild/include/linux/utsrelease.h
186 utsrelease3=$kernelbuild/include/generated/utsrelease.h
187 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
188 utsrelease=linux/version.h
189 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
190 utsrelease=linux/utsrelease.h
191 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
192 utsrelease=generated/utsrelease.h
195 if test "$utsrelease"; then
196 kernsrcver=`(echo "#include <$utsrelease>";
197 echo "kernsrcver=UTS_RELEASE") |
198 cpp -I $kernelbuild/include |
199 grep "^kernsrcver=" | cut -d \" -f 2`
201 if test -z "$kernsrcver"; then
202 AC_MSG_RESULT([Not found])
203 AC_MSG_ERROR([*** Cannot determine kernel version.])
206 AC_MSG_RESULT([Not found])
207 if test "x$enable_linux_builtin" != xyes; then
208 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
211 *** Cannot find UTS_RELEASE definition.
212 *** Please run 'make prepare' inside the kernel source tree.])
216 AC_MSG_RESULT([$kernsrcver])
219 LINUX_OBJ=${kernelbuild}
220 LINUX_VERSION=${kernsrcver}
224 AC_SUBST(LINUX_VERSION)
226 SPL_AC_MODULE_SYMVERS
230 dnl # Default SPL user configuration
232 AC_DEFUN([SPL_AC_CONFIG_USER], [])
235 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
236 dnl # are missing, it is non-fatal, but you will not be able to build
237 dnl # RPM packages and will be warned if you try too.
239 dnl # By default, the generic spec file will be used because it requires
240 dnl # minimal dependencies. Distribution specific spec files can be
241 dnl # placed under the 'rpm/<distribution>' directory and enabled using
242 dnl # the --with-spec=<distribution> configure option.
244 AC_DEFUN([SPL_AC_RPM], [
248 AC_MSG_CHECKING([whether $RPM is available])
249 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
250 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
252 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
255 AC_MSG_RESULT([$HAVE_RPM])
258 AC_MSG_CHECKING([whether $RPMBUILD is available])
259 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
260 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
262 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
265 AC_MSG_RESULT([$HAVE_RPMBUILD])
268 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
270 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
273 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
278 RPM_SPEC_DIR="rpm/generic"
280 AS_HELP_STRING([--with-spec=SPEC],
281 [Spec files 'generic|fedora']),
282 [RPM_SPEC_DIR="rpm/$withval"])
284 AC_MSG_CHECKING([whether spec files are available])
285 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
289 AC_SUBST(RPM_VERSION)
291 AC_SUBST(HAVE_RPMBUILD)
293 AC_SUBST(RPMBUILD_VERSION)
295 AC_SUBST(RPM_SPEC_DIR)
296 AC_SUBST(RPM_DEFINE_UTIL)
297 AC_SUBST(RPM_DEFINE_KMOD)
298 AC_SUBST(RPM_DEFINE_DKMS)
299 AC_SUBST(RPM_DEFINE_COMMON)
300 AC_SUBST(SRPM_DEFINE_UTIL)
301 AC_SUBST(SRPM_DEFINE_KMOD)
302 AC_SUBST(SRPM_DEFINE_DKMS)
303 AC_SUBST(SRPM_DEFINE_COMMON)
307 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
308 dnl # tools are missing it is non-fatal but you will not be able to build
309 dnl # DEB packages and will be warned if you try too.
311 AC_DEFUN([SPL_AC_DPKG], [
313 DPKGBUILD=dpkg-buildpackage
315 AC_MSG_CHECKING([whether $DPKG is available])
316 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
317 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
319 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
322 AC_MSG_RESULT([$HAVE_DPKG])
325 AC_MSG_CHECKING([whether $DPKGBUILD is available])
326 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
327 DPKGBUILD_VERSION=$(echo $tmp | \
328 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
330 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
333 AC_MSG_RESULT([$HAVE_DPKGBUILD])
338 AC_SUBST(DPKG_VERSION)
340 AC_SUBST(HAVE_DPKGBUILD)
342 AC_SUBST(DPKGBUILD_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=tgz ;;
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
430 AC_DEFUN([SPL_AC_LICENSE], [
431 AC_MSG_CHECKING([spl license])
433 AC_MSG_RESULT([$LICENSE])
434 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
438 AC_DEFUN([SPL_AC_CONFIG], [
440 AC_ARG_WITH([config],
441 AS_HELP_STRING([--with-config=CONFIG],
442 [Config file 'kernel|user|all|srpm']),
443 [SPL_CONFIG="$withval"])
444 AC_ARG_ENABLE([linux-builtin],
445 [AC_HELP_STRING([--enable-linux-builtin],
446 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
448 [enable_linux_builtin=no])
450 AC_MSG_CHECKING([spl config])
451 AC_MSG_RESULT([$SPL_CONFIG]);
454 case "$SPL_CONFIG" in
455 kernel) SPL_AC_CONFIG_KERNEL ;;
456 user) SPL_AC_CONFIG_USER ;;
457 all) SPL_AC_CONFIG_KERNEL
458 SPL_AC_CONFIG_USER ;;
461 AC_MSG_RESULT([Error!])
462 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
463 user kernel|user|all|srpm]) ;;
466 AM_CONDITIONAL([CONFIG_USER],
467 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
468 AM_CONDITIONAL([CONFIG_KERNEL],
469 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
470 [test "x$enable_linux_builtin" != xyes ])
474 dnl # Enable if the SPL should be compiled with internal debugging enabled.
475 dnl # By default this support is disabled.
477 AC_DEFUN([SPL_AC_DEBUG], [
478 AC_MSG_CHECKING([whether debugging is enabled])
479 AC_ARG_ENABLE([debug],
480 [AS_HELP_STRING([--enable-debug],
481 [Enable generic debug support @<:@default=no@:>@])],
485 AS_IF([test "x$enable_debug" = xyes],
487 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
488 DEBUG_CFLAGS="-DDEBUG -Werror"
489 DEBUG_SPL="_with_debug"
491 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
492 DEBUG_CFLAGS="-DNDEBUG"
493 DEBUG_SPL="_without_debug"
496 AC_SUBST(DEBUG_CFLAGS)
498 AC_MSG_RESULT([$enable_debug])
502 dnl # Enabled by default it provides a basic debug log infrastructure.
503 dnl # Each subsystem registers itself with a name and logs messages
504 dnl # using predefined types. If the debug mask it set to allow the
505 dnl # message type it will be written to the internal log. The log
506 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
507 dnl # after dumping the log it must be decoded using the spl utility.
509 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
510 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
512 AC_DEFUN([SPL_AC_DEBUG_LOG], [
513 AC_ARG_ENABLE([debug-log],
514 [AS_HELP_STRING([--enable-debug-log],
515 [Enable basic debug logging @<:@default=yes@:>@])],
517 [enable_debug_log=yes])
519 AS_IF([test "x$enable_debug_log" = xyes],
521 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
522 DEBUG_LOG="_with_debug_log"
523 AC_DEFINE([DEBUG_LOG], [1],
524 [Define to 1 to enable basic debug logging])
526 DEBUG_LOG="_without_debug_log"
530 AC_MSG_CHECKING([whether basic debug logging is enabled])
531 AC_MSG_RESULT([$enable_debug_log])
535 dnl # Enabled by default it provides a minimal level of memory tracking.
536 dnl # A total count of bytes allocated is kept for each alloc and free.
537 dnl # Then at module unload time a report to the console will be printed
538 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
539 dnl # and provide an easy way to inspect the kmem based slab.
541 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
542 AC_ARG_ENABLE([debug-kmem],
543 [AS_HELP_STRING([--enable-debug-kmem],
544 [Enable basic kmem accounting @<:@default=yes@:>@])],
546 [enable_debug_kmem=yes])
548 AS_IF([test "x$enable_debug_kmem" = xyes],
550 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
551 DEBUG_KMEM="_with_debug_kmem"
552 AC_DEFINE([DEBUG_KMEM], [1],
553 [Define to 1 to enable basic kmem accounting])
555 DEBUG_KMEM="_without_debug_kmem"
559 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
560 AC_MSG_RESULT([$enable_debug_kmem])
564 dnl # Disabled by default it provides detailed memory tracking. This
565 dnl # feature also requires --enable-debug-kmem to be set. When enabled
566 dnl # not only will total bytes be tracked but also the location of every
567 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
568 dnl # addresses and where they were allocated will be dumped to the console.
569 dnl # Enabling this feature has a significant impact on performance but it
570 dnl # makes finding memory leaks pretty straight forward.
572 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
573 AC_ARG_ENABLE([debug-kmem-tracking],
574 [AS_HELP_STRING([--enable-debug-kmem-tracking],
575 [Enable detailed kmem tracking @<:@default=no@:>@])],
577 [enable_debug_kmem_tracking=no])
579 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
581 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
582 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
583 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
584 [Define to 1 to enable detailed kmem tracking])
586 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
589 AC_SUBST(DEBUG_KMEM_TRACKING)
590 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
591 AC_MSG_RESULT([$enable_debug_kmem_tracking])
595 dnl # SPL_LINUX_CONFTEST
597 AC_DEFUN([SPL_LINUX_CONFTEST], [
598 cat confdefs.h - <<_ACEOF >conftest.c
604 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
606 m4_define([SPL_LANG_PROGRAM], [
611 dnl Do *not* indent the following line: there may be CPP directives.
612 dnl Don't move the `;' right after for the same reason.
620 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
622 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
623 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
624 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
625 echo "obj-m := conftest.o" >build/Makefile
627 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
629 [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])],
631 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
637 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
639 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
640 [SPL_LINUX_COMPILE_IFELSE(
641 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
643 [test -s build/conftest.o],
648 dnl # SPL_CHECK_SYMBOL_EXPORT
649 dnl # check symbol exported or not
651 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
652 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
653 $LINUX_OBJ/Module*.symvers 2>/dev/null
655 if test $rc -ne 0; then
658 grep -q -E "EXPORT_SYMBOL.*($1)" \
659 "$LINUX_OBJ/$file" 2>/dev/null
661 if test $rc -eq 0; then
666 if test $export -eq 0; then :
677 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
678 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
679 dnl # is called if not compiling for builtin
681 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
682 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
683 if test $rc -ne 0; then :
686 if test "x$enable_linux_builtin" != xyes; then
687 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
689 if test $rc -ne 0; then :
698 dnl # SPL_CHECK_SYMBOL_HEADER
699 dnl # check if a symbol prototype is defined in listed headers.
701 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
702 AC_MSG_CHECKING([whether symbol $1 exists in header])
705 grep -q "$2" "$LINUX/$file" 2>/dev/null
707 if test $rc -eq 0; then
712 if test $header -eq 0; then
722 dnl # SPL_CHECK_HEADER
723 dnl # check whether header exists and define HAVE_$2_HEADER
725 AC_DEFUN([SPL_CHECK_HEADER],
726 [AC_MSG_CHECKING([whether header $1 exists])
727 SPL_LINUX_TRY_COMPILE([
732 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
742 dnl # Basic toolchain sanity check.
744 AC_DEFUN([SPL_AC_TEST_MODULE],
745 [AC_MSG_CHECKING([whether modules can be built])
746 SPL_LINUX_TRY_COMPILE([],[],[
750 if test "x$enable_linux_builtin" != xyes; then
751 AC_MSG_ERROR([*** Unable to build an empty module.])
754 *** Unable to build an empty module.
755 *** Please run 'make scripts' inside the kernel source tree.])
761 dnl # Use the atomic implemenation based on global spinlocks. This
762 dnl # should only be needed by 32-bit kernels which do not provide
763 dnl # the atomic64_* API. It may be optionally enabled as a fallback
764 dnl # if problems are observed with the direct mapping to the native
765 dnl # Linux atomic operations. You may not disable atomic spinlocks
766 dnl # if you kernel does not an atomic64_* API.
768 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
769 AC_ARG_ENABLE([atomic-spinlocks],
770 [AS_HELP_STRING([--enable-atomic-spinlocks],
771 [Atomic types use spinlocks @<:@default=check@:>@])],
773 [enable_atomic_spinlocks=check])
775 SPL_LINUX_TRY_COMPILE([
776 #include <linux/fs.h>
778 atomic64_t *ptr __attribute__ ((unused));
781 AC_DEFINE(HAVE_ATOMIC64_T, 1,
782 [kernel defines atomic64_t])
787 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
788 AS_IF([test "x$have_atomic64_t" = xyes], [
789 enable_atomic_spinlocks=no
791 enable_atomic_spinlocks=yes
795 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
796 AC_DEFINE([ATOMIC_SPINLOCK], [1],
797 [Atomic types use spinlocks])
799 AS_IF([test "x$have_atomic64_t" = xno], [
801 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
805 AC_MSG_CHECKING([whether atomic types use spinlocks])
806 AC_MSG_RESULT([$enable_atomic_spinlocks])
808 AC_MSG_CHECKING([whether kernel defines atomic64_t])
809 AC_MSG_RESULT([$have_atomic64_t])
813 dnl # 2.6.24 API change,
814 dnl # check if atomic64_cmpxchg is defined
816 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
817 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
818 SPL_LINUX_TRY_COMPILE([
819 #include <linux/fs.h>
821 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
824 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
825 [kernel defines atomic64_cmpxchg])
832 dnl # 2.6.24 API change,
833 dnl # check if atomic64_xchg is defined
835 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
836 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
837 SPL_LINUX_TRY_COMPILE([
838 #include <linux/fs.h>
840 atomic64_xchg((atomic64_t *)NULL, 0);
843 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
844 [kernel defines atomic64_xchg])
851 dnl # 2.6.24 API change,
852 dnl # check if uintptr_t typedef is defined
854 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
855 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
856 SPL_LINUX_TRY_COMPILE([
857 #include <linux/types.h>
859 uintptr_t *ptr __attribute__ ((unused));
862 AC_DEFINE(HAVE_UINTPTR_T, 1,
863 [kernel defines uintptr_t])
870 dnl # 2.6.21 API change,
871 dnl # 'register_sysctl_table' use only one argument instead of two
873 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
874 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
875 SPL_LINUX_TRY_COMPILE([
876 #include <linux/sysctl.h>
878 (void) register_sysctl_table(NULL, 0);
881 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
882 [register_sysctl_table() wants 2 args])
888 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
889 tmp_flags="$EXTRA_KCFLAGS"
890 EXTRA_KCFLAGS="-Werror"
892 dnl # 2.6.23 to 2.6.34 API change
893 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
895 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
896 SPL_LINUX_TRY_COMPILE([
897 #include <linux/mm.h>
899 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
901 struct shrinker cache_shrinker = {
902 .shrink = shrinker_cb,
903 .seeks = DEFAULT_SEEKS,
905 register_shrinker(&cache_shrinker);
908 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
909 [old shrinker callback wants 2 args])
913 dnl # 2.6.35 - 2.6.39 API change
914 dnl # ->shrink(struct shrinker *,
915 dnl # int nr_to_scan, gfp_t gfp_mask)
917 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
918 SPL_LINUX_TRY_COMPILE([
919 #include <linux/mm.h>
921 int shrinker_cb(struct shrinker *, int nr_to_scan,
924 struct shrinker cache_shrinker = {
925 .shrink = shrinker_cb,
926 .seeks = DEFAULT_SEEKS,
928 register_shrinker(&cache_shrinker);
931 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
932 [old shrinker callback wants 3 args])
936 dnl # 3.0 - 3.11 API change
937 dnl # ->shrink(struct shrinker *,
938 dnl # struct shrink_control *sc)
941 [whether new 2-argument shrinker exists])
942 SPL_LINUX_TRY_COMPILE([
943 #include <linux/mm.h>
945 int shrinker_cb(struct shrinker *,
946 struct shrink_control *sc);
948 struct shrinker cache_shrinker = {
949 .shrink = shrinker_cb,
950 .seeks = DEFAULT_SEEKS,
952 register_shrinker(&cache_shrinker);
955 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
956 [new shrinker callback wants 2 args])
960 dnl # 3.12 API change,
961 dnl # ->shrink() is logically split in to
962 dnl # ->count_objects() and ->scan_objects()
965 [whether ->count_objects callback exists])
966 SPL_LINUX_TRY_COMPILE([
967 #include <linux/mm.h>
969 unsigned long shrinker_cb(
971 struct shrink_control *sc);
973 struct shrinker cache_shrinker = {
974 .count_objects = shrinker_cb,
975 .scan_objects = shrinker_cb,
976 .seeks = DEFAULT_SEEKS,
978 register_shrinker(&cache_shrinker);
981 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
982 1, [->count_objects exists])
989 EXTRA_KCFLAGS="$tmp_flags"
993 dnl # 2.6.25 API change,
994 dnl # struct path entry added to struct nameidata
996 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
997 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
998 SPL_LINUX_TRY_COMPILE([
999 #include <linux/namei.h>
1001 struct nameidata nd __attribute__ ((unused));
1004 nd.path.dentry = NULL;
1007 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
1008 [struct path used in struct nameidata])
1015 dnl # Custom SPL patch may export this system it is not required
1017 AC_DEFUN([SPL_AC_TASK_CURR],
1018 [AC_MSG_CHECKING([whether task_curr() is available])
1019 SPL_LINUX_TRY_COMPILE_SYMBOL([
1020 #include <linux/sched.h>
1023 ], [task_curr], [kernel/sched.c], [
1025 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1032 dnl # 2.6.19 API change,
1033 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1035 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1036 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1037 SPL_LINUX_TRY_COMPILE([
1038 #include <linux/sysctl.h>
1040 #ifndef CTL_UNNUMBERED
1041 #error CTL_UNNUMBERED undefined
1045 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1046 [unnumbered sysctl support exists])
1053 dnl # 2.6.33 API change,
1054 dnl # Removed .ctl_name from struct ctl_table.
1056 AC_DEFUN([SPL_AC_CTL_NAME], [
1057 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1058 SPL_LINUX_TRY_COMPILE([
1059 #include <linux/sysctl.h>
1061 struct ctl_table ctl __attribute__ ((unused));
1065 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1072 dnl # 2.6.16 API change.
1073 dnl # Check if 'fls64()' is available
1075 AC_DEFUN([SPL_AC_FLS64],
1076 [AC_MSG_CHECKING([whether fls64() is available])
1077 SPL_LINUX_TRY_COMPILE([
1078 #include <linux/bitops.h>
1083 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1090 dnl # 2.6.18 API change, check whether device_create() is available.
1091 dnl # Device_create() was introduced in 2.6.18 and depricated
1092 dnl # class_device_create() which was fully removed in 2.6.26.
1094 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1095 [AC_MSG_CHECKING([whether device_create() is available])
1096 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1098 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1099 [device_create() is available])
1106 dnl # 2.6.27 API change,
1107 dnl # device_create() uses 5 args, new 'drvdata' argument.
1109 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1110 AC_MSG_CHECKING([whether device_create() wants 5 args])
1111 tmp_flags="$EXTRA_KCFLAGS"
1112 EXTRA_KCFLAGS="-Werror"
1113 SPL_LINUX_TRY_COMPILE([
1114 #include <linux/device.h>
1116 device_create(NULL, NULL, 0, NULL, "%d", 1);
1119 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1120 [device_create wants 5 args])
1124 EXTRA_KCFLAGS="$tmp_flags"
1128 dnl # 2.6.13 API change, check whether class_device_create() is available.
1129 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1130 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1132 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1133 [AC_MSG_CHECKING([whether class_device_create() is available])
1134 SPL_LINUX_TRY_COMPILE_SYMBOL([
1135 #include <linux/device.h>
1137 class_device_create(NULL, NULL, 0, NULL, NULL);
1138 ], [class_device_create], [drivers/base/class.c], [
1140 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1141 [class_device_create() is available])
1148 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1150 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1151 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1152 SPL_LINUX_TRY_COMPILE_SYMBOL([
1153 #include <linux/time.h>
1155 set_normalized_timespec(NULL, 0, 0);
1156 ], [set_normalized_timespec], [kernel/time.c], [
1158 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1159 [set_normalized_timespec() is available as export])
1166 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1167 dnl # previously it was available in time.h as an inline.
1169 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1170 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1171 SPL_LINUX_TRY_COMPILE([
1172 #include <linux/time.h>
1173 void set_normalized_timespec(struct timespec *ts,
1174 time_t sec, long nsec) { }
1181 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1182 [set_normalized_timespec() is available as inline])
1187 dnl # 2.6.18 API change,
1188 dnl # timespec_sub() inline function available in linux/time.h
1190 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1191 AC_MSG_CHECKING([whether timespec_sub() is available])
1192 SPL_LINUX_TRY_COMPILE([
1193 #include <linux/time.h>
1195 struct timespec a = { 0 };
1196 struct timespec b = { 0 };
1197 struct timespec c __attribute__ ((unused));
1198 c = timespec_sub(a, b);
1201 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1208 dnl # 2.6.19 API change,
1209 dnl # check if init_utsname() is available in linux/utsname.h
1211 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1212 AC_MSG_CHECKING([whether init_utsname() is available])
1213 SPL_LINUX_TRY_COMPILE([
1214 #include <linux/utsname.h>
1216 struct new_utsname *a __attribute__ ((unused));
1220 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1227 dnl # 2.6.18 API change,
1228 dnl # added linux/uaccess.h
1230 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1231 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1235 dnl # 2.6.12 API change,
1236 dnl # check whether 'kmalloc_node()' is available.
1238 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1239 AC_MSG_CHECKING([whether kmalloc_node() is available])
1240 SPL_LINUX_TRY_COMPILE([
1241 #include <linux/slab.h>
1243 void *a __attribute__ ((unused));
1244 a = kmalloc_node(1, GFP_KERNEL, 0);
1247 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1254 dnl # 2.6.9 API change,
1255 dnl # check whether 'monotonic_clock()' is available it may
1256 dnl # be available for some archs but not others.
1258 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1259 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1260 SPL_LINUX_TRY_COMPILE_SYMBOL([
1261 #include <linux/timex.h>
1264 ], [monotonic_clock], [], [
1266 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1267 [monotonic_clock() is available])
1274 dnl # 2.6.16 API change,
1275 dnl # check whether 'struct inode' has i_mutex
1277 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1278 AC_MSG_CHECKING([whether struct inode has i_mutex])
1279 SPL_LINUX_TRY_COMPILE([
1280 #include <linux/fs.h>
1281 #include <linux/mutex.h>
1284 mutex_init(&i.i_mutex);
1287 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1294 dnl # 2.6.29 API change,
1295 dnl # Adaptive mutexs introduced.
1297 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1298 AC_MSG_CHECKING([whether struct mutex has owner])
1299 SPL_LINUX_TRY_COMPILE([
1300 #include <linux/mutex.h>
1302 struct mutex mtx __attribute__ ((unused));
1306 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1313 dnl # 2.6.39 API change,
1314 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1315 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1316 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1317 dnl # pointer which frankly makes a lot more sense.
1319 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1320 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1321 tmp_flags="$EXTRA_KCFLAGS"
1322 EXTRA_KCFLAGS="-Werror"
1323 SPL_LINUX_TRY_COMPILE([
1324 #include <linux/mutex.h>
1325 #include <linux/sched.h>
1327 struct mutex mtx __attribute__ ((unused));
1328 mtx.owner = current;
1331 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1332 [struct mutex owner is a task_struct])
1336 EXTRA_KCFLAGS="$tmp_flags"
1340 dnl # 2.6.18 API change,
1341 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1342 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1343 dnl # if the mutex validator is disabled or otherwise unavailable.
1345 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1346 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1347 SPL_LINUX_TRY_COMPILE([
1348 #include <linux/mutex.h>
1352 mutex_lock_nested(&mutex, 0);
1355 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1356 [mutex_lock_nested() is available])
1363 dnl # 2.6.27 API change,
1364 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1366 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1367 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1368 SPL_LINUX_TRY_COMPILE([
1369 #include <linux/interrupt.h>
1370 #include <linux/smp.h>
1372 void on_each_cpu_func(void *data) { return; }
1374 on_each_cpu(on_each_cpu_func, NULL, 0);
1377 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1378 [on_each_cpu wants 3 args])
1385 dnl # 2.6.18 API change,
1386 dnl # kallsyms_lookup_name no longer exported
1388 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1389 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1390 SPL_LINUX_TRY_COMPILE_SYMBOL([
1391 #include <linux/kallsyms.h>
1393 kallsyms_lookup_name(NULL);
1394 ], [kallsyms_lookup_name], [], [
1396 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1397 [kallsyms_lookup_name() is available])
1404 dnl # Proposed API change,
1405 dnl # This symbol is not available in stock kernels. You may build a
1406 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1407 dnl # these symbols for use. If your already rolling a custom kernel for
1408 dnl # your environment this is recommended.
1410 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1411 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1412 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1414 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1415 [get_vmalloc_info() is available])
1422 dnl # 3.10 API change,
1423 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1425 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1426 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1427 SPL_LINUX_TRY_COMPILE([
1428 #include <linux/vmalloc.h>
1429 struct vmalloc_info { void *a; };
1436 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1441 dnl # 3.10 API change,
1442 dnl # PDE is replaced by PDE_DATA
1444 AC_DEFUN([SPL_AC_PDE_DATA], [
1445 AC_MSG_CHECKING([whether PDE_DATA() is available])
1446 SPL_LINUX_TRY_COMPILE_SYMBOL([
1447 #include <linux/proc_fs.h>
1450 ], [PDE_DATA], [], [
1452 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1459 dnl # 2.6.17 API change
1460 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1461 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1462 dnl # were exported in 2.6.17 for use by modules which was consistent with
1463 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1464 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1465 dnl # were dropped entirely leaving modules no way to directly iterate over
1466 dnl # the zone list. Because we need access to the zone helpers we check
1467 dnl # if the kernel contains the old or new implementation. Then we check
1468 dnl # to see if the symbols we need for each version are available. If they
1469 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1471 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1472 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1473 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1475 if test $rc -eq 0; then
1476 AC_MSG_RESULT([yes])
1477 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1484 dnl # Proposed API change,
1485 dnl # This symbol is not available in stock kernels. You may build a
1486 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1487 dnl # these symbols for use. If your already rolling a custom kernel for
1488 dnl # your environment this is recommended.
1490 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1491 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1492 SPL_LINUX_TRY_COMPILE_SYMBOL([
1493 #include <linux/mmzone.h>
1495 first_online_pgdat();
1496 ], [first_online_pgdat], [], [
1498 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1499 [first_online_pgdat() is available])
1506 dnl # Proposed API change,
1507 dnl # This symbol is not available in stock kernels. You may build a
1508 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1509 dnl # these symbols for use. If your already rolling a custom kernel for
1510 dnl # your environment this is recommended.
1512 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1513 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1514 SPL_LINUX_TRY_COMPILE_SYMBOL([
1515 #include <linux/mmzone.h>
1517 next_online_pgdat(NULL);
1518 ], [next_online_pgdat], [], [
1520 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1521 [next_online_pgdat() is available])
1528 dnl # Proposed API change,
1529 dnl # This symbol is not available in stock kernels. You may build a
1530 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1531 dnl # these symbols for use. If your already rolling a custom kernel for
1532 dnl # your environment this is recommended.
1534 AC_DEFUN([SPL_AC_NEXT_ZONE],
1535 [AC_MSG_CHECKING([whether next_zone() is available])
1536 SPL_LINUX_TRY_COMPILE_SYMBOL([
1537 #include <linux/mmzone.h>
1540 ], [next_zone], [], [
1542 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1549 dnl # 2.6.17 API change,
1550 dnl # See SPL_AC_PGDAT_HELPERS for details.
1552 AC_DEFUN([SPL_AC_PGDAT_LIST],
1553 [AC_MSG_CHECKING([whether pgdat_list is available])
1554 SPL_LINUX_TRY_COMPILE_SYMBOL([
1555 #include <linux/topology.h>
1556 pg_data_t *tmp = pgdat_list;
1557 ], [], [pgdat_list], [], [
1559 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1566 dnl # 2.6.18 API change,
1567 dnl # First introduced global_page_state() support as an inline.
1569 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1570 AC_MSG_CHECKING([whether global_page_state() is available])
1571 SPL_LINUX_TRY_COMPILE([
1572 #include <linux/mm.h>
1574 unsigned long state __attribute__ ((unused));
1575 state = global_page_state(0);
1578 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1579 [global_page_state() is available])
1586 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1587 dnl # Public global zone stats now include a free page count. However
1588 dnl # the enumerated names of the counters have changed since this API
1589 dnl # was introduced. We need to deduce the corrent name to use. This
1590 dnl # replaces the priviate get_zone_counts() interface.
1592 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1593 dnl # is 2.6.30 as of when this was written.
1595 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1596 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1597 SPL_LINUX_TRY_COMPILE([
1598 #include <linux/mm.h>
1600 enum zone_stat_item zsi __attribute__ ((unused));
1601 zsi = NR_FREE_PAGES;
1604 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1605 [Page state NR_FREE_PAGES is available])
1612 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1613 dnl # Public global zone stats now include an inactive page count. However
1614 dnl # the enumerated names of the counters have changed since this API
1615 dnl # was introduced. We need to deduce the corrent name to use. This
1616 dnl # replaces the priviate get_zone_counts() interface.
1618 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1619 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1620 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1622 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1623 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1624 SPL_LINUX_TRY_COMPILE([
1625 #include <linux/mm.h>
1627 enum zone_stat_item zsi __attribute__ ((unused));
1631 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1632 [Page state NR_INACTIVE is available])
1637 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1638 SPL_LINUX_TRY_COMPILE([
1639 #include <linux/mm.h>
1641 enum zone_stat_item zsi __attribute__ ((unused));
1642 zsi = NR_INACTIVE_ANON;
1645 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1646 [Page state NR_INACTIVE_ANON is available])
1651 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1652 SPL_LINUX_TRY_COMPILE([
1653 #include <linux/mm.h>
1655 enum zone_stat_item zsi __attribute__ ((unused));
1656 zsi = NR_INACTIVE_FILE;
1659 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1660 [Page state NR_INACTIVE_FILE is available])
1667 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1668 dnl # Public global zone stats now include an active page count. However
1669 dnl # the enumerated names of the counters have changed since this API
1670 dnl # was introduced. We need to deduce the corrent name to use. This
1671 dnl # replaces the priviate get_zone_counts() interface.
1673 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1674 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1675 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1677 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1678 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1679 SPL_LINUX_TRY_COMPILE([
1680 #include <linux/mm.h>
1682 enum zone_stat_item zsi __attribute__ ((unused));
1686 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1687 [Page state NR_ACTIVE is available])
1692 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1693 SPL_LINUX_TRY_COMPILE([
1694 #include <linux/mm.h>
1696 enum zone_stat_item zsi __attribute__ ((unused));
1697 zsi = NR_ACTIVE_ANON;
1700 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1701 [Page state NR_ACTIVE_ANON is available])
1706 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1707 SPL_LINUX_TRY_COMPILE([
1708 #include <linux/mm.h>
1710 enum zone_stat_item zsi __attribute__ ((unused));
1711 zsi = NR_ACTIVE_FILE;
1714 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1715 [Page state NR_ACTIVE_FILE is available])
1722 dnl # Proposed API change for legacy kernels.
1723 dnl # This symbol is not available in older kernels. For kernels post
1724 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1725 dnl # page state information. This symbol is only used in legacy kernels
1726 dnl # any only as a last resort.
1728 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1729 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1730 SPL_LINUX_TRY_COMPILE([
1732 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1733 #error "global_page_state needs NR_FREE_PAGES"
1736 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1737 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1738 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1739 #error "global_page_state needs NR_ACTIVE*"
1742 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1743 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1744 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1745 #error "global_page_state needs NR_INACTIVE*"
1751 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1752 [get_zone_counts() is needed])
1754 AC_MSG_CHECKING([whether get_zone_counts() is available])
1755 SPL_LINUX_TRY_COMPILE_SYMBOL([
1756 #include <linux/mmzone.h>
1758 get_zone_counts(NULL, NULL, NULL);
1759 ], [get_zone_counts], [], [
1761 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1762 [get_zone_counts() is available])
1770 dnl # 2.6.27 API change,
1771 dnl # The user_path_dir() replaces __user_walk()
1773 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1774 [AC_MSG_CHECKING([whether user_path_dir() is available])
1775 SPL_LINUX_TRY_COMPILE_SYMBOL([
1776 #include <linux/fcntl.h>
1777 #include <linux/namei.h>
1779 user_path_dir(NULL, NULL);
1780 ], [user_path_at], [], [
1782 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1789 dnl # Symbol available in RHEL kernels not in stock kernels.
1791 AC_DEFUN([SPL_AC_SET_FS_PWD],
1792 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1793 SPL_LINUX_TRY_COMPILE_SYMBOL([
1794 #include <linux/spinlock.h>
1795 #include <linux/fs_struct.h>
1798 ], [set_fs_pwd], [], [
1800 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1807 dnl # 3.9 API change
1808 dnl # set_fs_pwd takes const struct path *
1810 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1811 tmp_flags="$EXTRA_KCFLAGS"
1812 EXTRA_KCFLAGS="-Werror"
1813 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1814 SPL_LINUX_TRY_COMPILE([
1815 #include <linux/spinlock.h>
1816 #include <linux/fs_struct.h>
1817 #include <linux/path.h>
1818 void (*const set_fs_pwd_func)
1819 (struct fs_struct *, const struct path *)
1825 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1826 [set_fs_pwd() needs const path *])
1828 SPL_LINUX_TRY_COMPILE([
1829 #include <linux/spinlock.h>
1830 #include <linux/fs_struct.h>
1831 #include <linux/path.h>
1832 void (*const set_fs_pwd_func)
1833 (struct fs_struct *, struct path *)
1840 AC_MSG_ERROR(unknown)
1843 EXTRA_KCFLAGS="$tmp_flags"
1846 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1847 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1848 SPL_LINUX_TRY_COMPILE([
1849 #include <linux/fs.h>
1851 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1854 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1855 [vfs_unlink() wants 2 args])
1859 dnl # Linux 3.13 API change
1860 dnl # Added delegated inode
1862 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1863 SPL_LINUX_TRY_COMPILE([
1864 #include <linux/fs.h>
1866 vfs_unlink((struct inode *) NULL,
1867 (struct dentry *) NULL,
1868 (struct inode **) NULL);
1871 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1872 [vfs_unlink() wants 3 args])
1880 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1881 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1882 SPL_LINUX_TRY_COMPILE([
1883 #include <linux/fs.h>
1885 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1886 (struct inode *) NULL, (struct dentry *) NULL);
1889 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1890 [vfs_rename() wants 4 args])
1894 dnl # Linux 3.13 API change
1895 dnl # Added delegated inode
1897 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1898 SPL_LINUX_TRY_COMPILE([
1899 #include <linux/fs.h>
1901 vfs_rename((struct inode *) NULL,
1902 (struct dentry *) NULL,
1903 (struct inode *) NULL,
1904 (struct dentry *) NULL,
1905 (struct inode **) NULL);
1908 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1909 [vfs_rename() wants 5 args])
1913 dnl # Linux 3.15 API change
1916 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1917 SPL_LINUX_TRY_COMPILE([
1918 #include <linux/fs.h>
1920 vfs_rename((struct inode *) NULL,
1921 (struct dentry *) NULL,
1922 (struct inode *) NULL,
1923 (struct dentry *) NULL,
1924 (struct inode **) NULL,
1928 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1929 [vfs_rename() wants 6 args])
1938 dnl # 2.6.36 API change,
1939 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1940 dnl # a spinlock_t to improve the fastpath performance.
1942 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1943 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1944 tmp_flags="$EXTRA_KCFLAGS"
1945 EXTRA_KCFLAGS="-Werror"
1946 SPL_LINUX_TRY_COMPILE([
1947 #include <linux/sched.h>
1948 #include <linux/fs_struct.h>
1950 struct fs_struct fs;
1951 spin_lock_init(&fs.lock);
1954 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1955 [struct fs_struct uses spinlock_t])
1959 EXTRA_KCFLAGS="$tmp_flags"
1963 dnl # 2.6.29 API change,
1964 dnl # check whether 'struct cred' exists
1966 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1967 AC_MSG_CHECKING([whether struct cred exists])
1968 SPL_LINUX_TRY_COMPILE([
1969 #include <linux/cred.h>
1971 struct cred *cr __attribute__ ((unused));
1975 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1983 dnl # User namespaces, use kuid_t in place of uid_t
1984 dnl # where available. Not strictly a user namespaces thing
1985 dnl # but it should prevent surprises
1987 AC_DEFUN([SPL_AC_KUIDGID_T], [
1988 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1989 SPL_LINUX_TRY_COMPILE([
1990 #include <linux/uidgid.h>
1992 kuid_t userid = KUIDT_INIT(0);
1993 kgid_t groupid = KGIDT_INIT(0);
1995 SPL_LINUX_TRY_COMPILE([
1996 #include <linux/uidgid.h>
2001 AC_MSG_RESULT(yes; optional)
2003 AC_MSG_RESULT(yes; mandatory)
2004 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
2012 dnl # Custom SPL patch may export this symbol.
2014 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
2015 [AC_MSG_CHECKING([whether groups_search() is available])
2016 SPL_LINUX_TRY_COMPILE_SYMBOL([
2017 #include <linux/cred.h>
2018 #ifdef HAVE_KUIDGID_T
2019 #include <linux/uidgid.h>
2022 #ifdef HAVE_KUIDGID_T
2023 groups_search(NULL, KGIDT_INIT(0));
2025 groups_search(NULL, 0);
2027 ], [groups_search], [], [
2029 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
2036 dnl # 2.6.x API change,
2037 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
2039 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
2040 [AC_MSG_CHECKING([whether __put_task_struct() is available])
2041 SPL_LINUX_TRY_COMPILE_SYMBOL([
2042 #include <linux/sched.h>
2044 __put_task_struct(NULL);
2045 ], [__put_task_struct], [], [
2047 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
2048 [__put_task_struct() is available])
2055 dnl # 2.6.32 API change,
2056 dnl # Unused 'struct file *' removed from prototype.
2058 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
2059 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
2060 SPL_LINUX_TRY_COMPILE([
2061 #include <linux/sysctl.h>
2063 proc_dostring(NULL, 0, NULL, NULL, NULL);
2066 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
2067 [proc_handler() wants 5 args])
2074 dnl # 2.6.x API change,
2075 dnl # kvasprintf() function added.
2077 AC_DEFUN([SPL_AC_KVASPRINTF],
2078 [AC_MSG_CHECKING([whether kvasprintf() is available])
2079 SPL_LINUX_TRY_COMPILE_SYMBOL([
2080 #include <linux/kernel.h>
2082 kvasprintf(0, NULL, *((va_list*)NULL));
2083 ], [kvasprintf], [], [
2085 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
2092 dnl # 2.6.29 API change,
2093 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
2095 AC_DEFUN([SPL_AC_VFS_FSYNC],
2096 [AC_MSG_CHECKING([whether vfs_fsync() is available])
2097 SPL_LINUX_TRY_COMPILE_SYMBOL([
2098 #include <linux/fs.h>
2101 ], [vfs_fsync], [fs/sync.c], [
2103 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2110 dnl # 2.6.35 API change,
2111 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2113 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2114 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2115 SPL_LINUX_TRY_COMPILE([
2116 #include <linux/fs.h>
2121 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2128 dnl # 3.5 API change,
2129 dnl # inode_operations.truncate_range removed
2131 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2132 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2133 SPL_LINUX_TRY_COMPILE([
2134 #include <linux/fs.h>
2136 struct inode_operations ops;
2137 ops.truncate_range = NULL;
2140 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2141 [truncate_range() inode operation is available])
2148 dnl # Linux 2.6.38 - 3.x API
2150 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2151 AC_MSG_CHECKING([whether fops->fallocate() exists])
2152 SPL_LINUX_TRY_COMPILE([
2153 #include <linux/fs.h>
2155 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2156 struct file_operations fops __attribute__ ((unused)) = {
2157 .fallocate = fallocate,
2161 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2168 dnl # Linux 2.6.x - 2.6.37 API
2170 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2171 AC_MSG_CHECKING([whether iops->fallocate() exists])
2172 SPL_LINUX_TRY_COMPILE([
2173 #include <linux/fs.h>
2175 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2176 struct inode_operations fops __attribute__ ((unused)) = {
2177 .fallocate = fallocate,
2181 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2188 dnl # PaX Linux 2.6.38 - 3.x API
2190 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2191 AC_MSG_CHECKING([whether fops->fallocate() exists])
2192 SPL_LINUX_TRY_COMPILE([
2193 #include <linux/fs.h>
2195 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2196 struct file_operations_no_const fops __attribute__ ((unused)) = {
2197 .fallocate = fallocate,
2201 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2208 dnl # The fallocate callback was moved from the inode_operations
2209 dnl # structure to the file_operations structure.
2211 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2212 SPL_AC_KERNEL_FILE_FALLOCATE
2213 SPL_AC_KERNEL_INODE_FALLOCATE
2214 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2218 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2219 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2220 dnl # condition. The fixed version is exported as a symbol. The race
2221 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2222 dnl # call that version while holding sem->wait_lock.
2224 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2225 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2226 SPL_LINUX_TRY_COMPILE_SYMBOL([
2227 #include <linux/rwsem.h>
2228 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2229 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2231 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2232 [rwsem_is_locked() acquires sem->wait_lock])
2239 dnl # 2.6.xx API compat,
2240 dnl # There currently exists no exposed API to partially shrink the dcache.
2241 dnl # The expected mechanism to shrink the cache is a registered shrinker
2242 dnl # which is called during memory pressure.
2244 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2245 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2246 SPL_LINUX_TRY_COMPILE_SYMBOL([
2247 #include <linux/dcache.h>
2249 shrink_dcache_memory(0, 0);
2250 ], [shrink_dcache_memory], [fs/dcache.c], [
2252 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2253 [shrink_dcache_memory() is available])
2260 dnl # 2.6.xx API compat,
2261 dnl # There currently exists no exposed API to partially shrink the icache.
2262 dnl # The expected mechanism to shrink the cache is a registered shrinker
2263 dnl # which is called during memory pressure.
2265 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2266 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2267 SPL_LINUX_TRY_COMPILE_SYMBOL([
2268 #include <linux/dcache.h>
2270 shrink_icache_memory(0, 0);
2271 ], [shrink_icache_memory], [fs/inode.c], [
2273 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2274 [shrink_icache_memory() is available])
2281 dnl # 2.6.39 API compat,
2282 dnl # The path_lookup() function has been renamed to kern_path_parent()
2283 dnl # and the flags argument has been removed. The only behavior now
2284 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2285 dnl # this flag so dropping the flag does not impact us.
2287 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2288 SPL_CHECK_SYMBOL_HEADER(
2290 [int kern_path_parent(const char \*, struct nameidata \*)],
2291 [include/linux/namei.h],
2292 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2293 [kern_path_parent() is available])],
2298 dnl # 3.1 API compat,
2299 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2300 dnl # However, it remains the prefered interface and since we still have
2301 dnl # access to the prototype we dynamically lookup the required address.
2303 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2304 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2305 SPL_LINUX_TRY_COMPILE_SYMBOL([
2306 #include <linux/namei.h>
2308 kern_path_parent(NULL, NULL);
2309 ], [kern_path_parent], [fs/namei.c], [
2311 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2312 [kern_path_parent() is available])
2319 dnl # 3.6 API compat,
2320 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2321 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2323 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2324 SPL_CHECK_SYMBOL_HEADER(
2326 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2327 [include/linux/namei.h],
2328 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2329 [kern_path_locked() is available])],
2334 dnl # /proc/kallsyms support,
2335 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2337 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2338 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2339 SPL_LINUX_TRY_COMPILE([
2340 #if !defined(CONFIG_KALLSYMS)
2341 #error CONFIG_KALLSYMS not defined
2344 AC_MSG_RESULT([yes])
2348 *** This kernel does not include the required kallsyms support.
2349 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2354 dnl # zlib inflate compat,
2355 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2357 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2358 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2359 SPL_LINUX_TRY_COMPILE([
2360 #if !defined(CONFIG_ZLIB_INFLATE) && \
2361 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2362 #error CONFIG_ZLIB_INFLATE not defined
2365 AC_MSG_RESULT([yes])
2369 *** This kernel does not include the required zlib inflate support.
2370 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2375 dnl # zlib deflate compat,
2376 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2378 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2379 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2380 SPL_LINUX_TRY_COMPILE([
2381 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2382 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2383 #error CONFIG_ZLIB_DEFLATE not defined
2386 AC_MSG_RESULT([yes])
2390 *** This kernel does not include the required zlib deflate support.
2391 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2396 dnl # 2.6.39 API compat,
2397 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2398 dnl # This was done to avoid always having to allocate the maximum size
2399 dnl # workspace (268K). The caller can now specific the windowBits and
2400 dnl # memLevel compression parameters to get a smaller workspace.
2402 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2403 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2404 SPL_LINUX_TRY_COMPILE([
2405 #include <linux/zlib.h>
2407 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2410 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2411 [zlib_deflate_workspacesize() wants 2 args])
2418 dnl # 2.6.39 API change,
2419 dnl # Shrinker adjust to use common shrink_control structure.
2421 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2422 AC_MSG_CHECKING([whether struct shrink_control exists])
2423 SPL_LINUX_TRY_COMPILE([
2424 #include <linux/mm.h>
2426 struct shrink_control sc __attribute__ ((unused));
2429 sc.gfp_mask = GFP_KERNEL;
2432 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2433 [struct shrink_control exists])
2440 dnl # 3.1 API Change
2442 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2443 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2445 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2446 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2447 tmp_flags="$EXTRA_KCFLAGS"
2448 EXTRA_KCFLAGS="-Werror"
2449 SPL_LINUX_TRY_COMPILE([
2450 #include <linux/rwsem.h>
2452 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2453 raw_spinlock_t dummy_lock __attribute__ ((unused));
2454 dummy_semaphore.wait_lock = dummy_lock;
2457 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2458 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2462 EXTRA_KCFLAGS="$tmp_flags"
2466 dnl # 3.9 API change,
2467 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2469 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2470 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2471 SPL_LINUX_TRY_COMPILE([
2472 #include <linux/sched.h>
2473 #include <linux/sched/rt.h>
2477 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2485 dnl # 3.9 API change,
2486 dnl # vfs_getattr() uses 2 args
2487 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2489 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2490 AC_MSG_CHECKING([whether vfs_getattr() wants])
2491 SPL_LINUX_TRY_COMPILE([
2492 #include <linux/fs.h>
2494 vfs_getattr((struct path *) NULL,
2495 (struct kstat *)NULL);
2497 AC_MSG_RESULT(2 args)
2498 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2499 [vfs_getattr wants 2 args])
2501 SPL_LINUX_TRY_COMPILE([
2502 #include <linux/fs.h>
2504 vfs_getattr((struct vfsmount *)NULL,
2505 (struct dentry *)NULL,
2506 (struct kstat *)NULL);
2508 AC_MSG_RESULT(3 args)
2510 AC_MSG_ERROR(unknown)
2516 dnl # 2.6.36 API compatibility.
2517 dnl # Added usleep_range timer.
2518 dnl # usleep_range is a finer precision implementation of msleep
2519 dnl # designed to be a drop-in replacement for udelay where a precise
2520 dnl # sleep / busy-wait is unnecessary.
2522 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2523 AC_MSG_CHECKING([whether usleep_range() is available])
2524 SPL_LINUX_TRY_COMPILE([
2525 #include <linux/delay.h>
2530 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2531 [usleep_range is available])
2538 dnl # 2.6.35 API change,
2539 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2540 dnl # private allocation flags which are applied when allocating a new slab
2541 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2542 dnl # non-default flags.
2544 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2545 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2546 SPL_LINUX_TRY_COMPILE([
2547 #include <linux/slab.h>
2549 struct kmem_cache cachep __attribute__ ((unused));
2550 cachep.allocflags = GFP_KERNEL;
2553 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2554 [struct kmem_cache has allocflags])
2558 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2559 SPL_LINUX_TRY_COMPILE([
2560 #include <linux/slab.h>
2562 struct kmem_cache cachep __attribute__ ((unused));
2563 cachep.gfpflags = GFP_KERNEL;
2566 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2567 [struct kmem_cache has gfpflags])