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_SHRINKER_CALLBACK
30 SPL_AC_MUTEX_OWNER_TASK_STRUCT
31 SPL_AC_SET_FS_PWD_WITH_CONST
32 SPL_AC_2ARGS_VFS_UNLINK
33 SPL_AC_4ARGS_VFS_RENAME
35 SPL_AC_2ARGS_VFS_FSYNC
36 SPL_AC_INODE_TRUNCATE_RANGE
37 SPL_AC_FS_STRUCT_SPINLOCK
39 SPL_AC_PUT_TASK_STRUCT
40 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
41 SPL_AC_KERNEL_FALLOCATE
43 SPL_AC_CONFIG_ZLIB_INFLATE
44 SPL_AC_CONFIG_ZLIB_DEFLATE
45 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
46 SPL_AC_SHRINK_CONTROL_STRUCT
47 SPL_AC_RWSEM_SPINLOCK_IS_RAW
48 SPL_AC_SCHED_RT_HEADER
49 SPL_AC_2ARGS_VFS_GETATTR
51 SPL_AC_KMEM_CACHE_ALLOCFLAGS
55 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
56 modpost=$LINUX/scripts/Makefile.modpost
57 AC_MSG_CHECKING([kernel file name for module symbols])
58 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
59 if grep -q Modules.symvers $modpost; then
60 LINUX_SYMBOLS=Modules.symvers
62 LINUX_SYMBOLS=Module.symvers
65 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
67 *** Please make sure the kernel devel package for your distribution
68 *** is installed. If you are building with a custom kernel, make sure the
69 *** kernel is configured, built, and the '--with-linux=PATH' configure
70 *** option refers to the location of the kernel source.])
75 AC_MSG_RESULT($LINUX_SYMBOLS)
76 AC_SUBST(LINUX_SYMBOLS)
79 AC_DEFUN([SPL_AC_KERNEL], [
81 AS_HELP_STRING([--with-linux=PATH],
82 [Path to kernel source]),
83 [kernelsrc="$withval"])
85 AC_ARG_WITH([linux-obj],
86 AS_HELP_STRING([--with-linux-obj=PATH],
87 [Path to kernel build objects]),
88 [kernelbuild="$withval"])
90 AC_MSG_CHECKING([kernel source directory])
91 if test -z "$kernelsrc"; then
92 if test -e "/lib/modules/$(uname -r)/source"; then
93 headersdir="/lib/modules/$(uname -r)/source"
94 sourcelink=$(readlink -f "$headersdir")
95 elif test -e "/lib/modules/$(uname -r)/build"; then
96 headersdir="/lib/modules/$(uname -r)/build"
97 sourcelink=$(readlink -f "$headersdir")
99 sourcelink=$(ls -1d /usr/src/kernels/* \
101 2>/dev/null | grep -v obj | tail -1)
104 if test -n "$sourcelink" && test -e ${sourcelink}; then
105 kernelsrc=`readlink -f ${sourcelink}`
107 kernelsrc="[Not found]"
110 if test "$kernelsrc" = "NONE"; then
115 AC_MSG_RESULT([$kernelsrc])
116 if test ! -d "$kernelsrc"; then
118 *** Please make sure the kernel devel package for your distribution
119 *** is installed and then try again. If that fails, you can specify the
120 *** location of the kernel source with the '--with-linux=PATH' option.])
123 AC_MSG_CHECKING([kernel build directory])
124 if test -z "$kernelbuild"; then
125 if test -e "/lib/modules/$(uname -r)/build"; then
126 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
127 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
128 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
129 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
130 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
131 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
132 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
134 kernelbuild=${kernelsrc}
137 AC_MSG_RESULT([$kernelbuild])
139 AC_MSG_CHECKING([kernel source version])
140 utsrelease1=$kernelbuild/include/linux/version.h
141 utsrelease2=$kernelbuild/include/linux/utsrelease.h
142 utsrelease3=$kernelbuild/include/generated/utsrelease.h
143 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
144 utsrelease=linux/version.h
145 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
146 utsrelease=linux/utsrelease.h
147 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
148 utsrelease=generated/utsrelease.h
151 if test "$utsrelease"; then
152 kernsrcver=`(echo "#include <$utsrelease>";
153 echo "kernsrcver=UTS_RELEASE") |
154 cpp -I $kernelbuild/include |
155 grep "^kernsrcver=" | cut -d \" -f 2`
157 if test -z "$kernsrcver"; then
158 AC_MSG_RESULT([Not found])
159 AC_MSG_ERROR([*** Cannot determine kernel version.])
162 AC_MSG_RESULT([Not found])
163 if test "x$enable_linux_builtin" != xyes; then
164 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
167 *** Cannot find UTS_RELEASE definition.
168 *** Please run 'make prepare' inside the kernel source tree.])
172 AC_MSG_RESULT([$kernsrcver])
175 LINUX_OBJ=${kernelbuild}
176 LINUX_VERSION=${kernsrcver}
180 AC_SUBST(LINUX_VERSION)
182 SPL_AC_MODULE_SYMVERS
186 dnl # Default SPL user configuration
188 AC_DEFUN([SPL_AC_CONFIG_USER], [])
191 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
192 dnl # are missing, it is non-fatal, but you will not be able to build
193 dnl # RPM packages and will be warned if you try too.
195 dnl # By default, the generic spec file will be used because it requires
196 dnl # minimal dependencies. Distribution specific spec files can be
197 dnl # placed under the 'rpm/<distribution>' directory and enabled using
198 dnl # the --with-spec=<distribution> configure option.
200 AC_DEFUN([SPL_AC_RPM], [
204 AC_MSG_CHECKING([whether $RPM is available])
205 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
206 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
208 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
211 AC_MSG_RESULT([$HAVE_RPM])
214 AC_MSG_CHECKING([whether $RPMBUILD is available])
215 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
216 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
218 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
221 AC_MSG_RESULT([$HAVE_RPMBUILD])
224 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
226 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
229 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
234 RPM_SPEC_DIR="rpm/generic"
236 AS_HELP_STRING([--with-spec=SPEC],
237 [Spec files 'generic|fedora']),
238 [RPM_SPEC_DIR="rpm/$withval"])
240 AC_MSG_CHECKING([whether spec files are available])
241 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
245 AC_SUBST(RPM_VERSION)
247 AC_SUBST(HAVE_RPMBUILD)
249 AC_SUBST(RPMBUILD_VERSION)
251 AC_SUBST(RPM_SPEC_DIR)
252 AC_SUBST(RPM_DEFINE_UTIL)
253 AC_SUBST(RPM_DEFINE_KMOD)
254 AC_SUBST(RPM_DEFINE_DKMS)
255 AC_SUBST(RPM_DEFINE_COMMON)
256 AC_SUBST(SRPM_DEFINE_UTIL)
257 AC_SUBST(SRPM_DEFINE_KMOD)
258 AC_SUBST(SRPM_DEFINE_DKMS)
259 AC_SUBST(SRPM_DEFINE_COMMON)
263 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
264 dnl # tools are missing it is non-fatal but you will not be able to build
265 dnl # DEB packages and will be warned if you try too.
267 AC_DEFUN([SPL_AC_DPKG], [
269 DPKGBUILD=dpkg-buildpackage
271 AC_MSG_CHECKING([whether $DPKG is available])
272 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
273 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
275 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
278 AC_MSG_RESULT([$HAVE_DPKG])
281 AC_MSG_CHECKING([whether $DPKGBUILD is available])
282 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
283 DPKGBUILD_VERSION=$(echo $tmp | \
284 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
286 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
289 AC_MSG_RESULT([$HAVE_DPKGBUILD])
294 AC_SUBST(DPKG_VERSION)
296 AC_SUBST(HAVE_DPKGBUILD)
298 AC_SUBST(DPKGBUILD_VERSION)
302 dnl # Until native packaging for various different packing systems
303 dnl # can be added the least we can do is attempt to use alien to
304 dnl # convert the RPM packages to the needed package type. This is
305 dnl # a hack but so far it has worked reasonable well.
307 AC_DEFUN([SPL_AC_ALIEN], [
310 AC_MSG_CHECKING([whether $ALIEN is available])
311 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
312 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
314 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
317 AC_MSG_RESULT([$HAVE_ALIEN])
322 AC_SUBST(ALIEN_VERSION)
326 dnl # Using the VENDOR tag from config.guess set the default
327 dnl # package type for 'make pkg': (rpm | deb | tgz)
329 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
330 AC_MSG_CHECKING([linux distribution])
331 if test -f /etc/toss-release ; then
333 elif test -f /etc/fedora-release ; then
335 elif test -f /etc/redhat-release ; then
337 elif test -f /etc/gentoo-release ; then
339 elif test -f /etc/arch-release ; then
341 elif test -f /etc/SuSE-release ; then
343 elif test -f /etc/slackware-version ; then
345 elif test -f /etc/lunar.release ; then
347 elif test -f /etc/lsb-release ; then
349 elif test -f /etc/debian_version ; then
354 AC_MSG_RESULT([$VENDOR])
357 AC_MSG_CHECKING([default package type])
359 toss) DEFAULT_PACKAGE=rpm ;;
360 redhat) DEFAULT_PACKAGE=rpm ;;
361 fedora) DEFAULT_PACKAGE=rpm ;;
362 gentoo) DEFAULT_PACKAGE=tgz ;;
363 arch) DEFAULT_PACKAGE=tgz ;;
364 sles) DEFAULT_PACKAGE=rpm ;;
365 slackware) DEFAULT_PACKAGE=tgz ;;
366 lunar) DEFAULT_PACKAGE=tgz ;;
367 ubuntu) DEFAULT_PACKAGE=deb ;;
368 debian) DEFAULT_PACKAGE=deb ;;
369 *) DEFAULT_PACKAGE=rpm ;;
372 AC_MSG_RESULT([$DEFAULT_PACKAGE])
373 AC_SUBST(DEFAULT_PACKAGE)
377 dnl # Default SPL user configuration
379 AC_DEFUN([SPL_AC_PACKAGE], [
380 SPL_AC_DEFAULT_PACKAGE
386 AC_DEFUN([SPL_AC_LICENSE], [
387 AC_MSG_CHECKING([spl author])
388 AC_MSG_RESULT([$SPL_META_AUTHOR])
390 AC_MSG_CHECKING([spl license])
391 AC_MSG_RESULT([$SPL_META_LICENSE])
394 AC_DEFUN([SPL_AC_CONFIG], [
396 AC_ARG_WITH([config],
397 AS_HELP_STRING([--with-config=CONFIG],
398 [Config file 'kernel|user|all|srpm']),
399 [SPL_CONFIG="$withval"])
400 AC_ARG_ENABLE([linux-builtin],
401 [AC_HELP_STRING([--enable-linux-builtin],
402 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
404 [enable_linux_builtin=no])
406 AC_MSG_CHECKING([spl config])
407 AC_MSG_RESULT([$SPL_CONFIG]);
410 case "$SPL_CONFIG" in
411 kernel) SPL_AC_CONFIG_KERNEL ;;
412 user) SPL_AC_CONFIG_USER ;;
413 all) SPL_AC_CONFIG_KERNEL
414 SPL_AC_CONFIG_USER ;;
417 AC_MSG_RESULT([Error!])
418 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
419 user kernel|user|all|srpm]) ;;
422 AM_CONDITIONAL([CONFIG_USER],
423 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
424 AM_CONDITIONAL([CONFIG_KERNEL],
425 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
426 [test "x$enable_linux_builtin" != xyes ])
430 dnl # Enable if the SPL should be compiled with internal debugging enabled.
431 dnl # By default this support is disabled.
433 AC_DEFUN([SPL_AC_DEBUG], [
434 AC_MSG_CHECKING([whether debugging is enabled])
435 AC_ARG_ENABLE([debug],
436 [AS_HELP_STRING([--enable-debug],
437 [Enable generic debug support @<:@default=no@:>@])],
441 AS_IF([test "x$enable_debug" = xyes],
443 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
444 DEBUG_CFLAGS="-DDEBUG -Werror"
445 DEBUG_SPL="_with_debug"
447 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
448 DEBUG_CFLAGS="-DNDEBUG"
449 DEBUG_SPL="_without_debug"
452 AC_SUBST(DEBUG_CFLAGS)
454 AC_MSG_RESULT([$enable_debug])
458 dnl # Enabled by default it provides a basic debug log infrastructure.
459 dnl # Each subsystem registers itself with a name and logs messages
460 dnl # using predefined types. If the debug mask it set to allow the
461 dnl # message type it will be written to the internal log. The log
462 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
463 dnl # after dumping the log it must be decoded using the spl utility.
465 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
466 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
468 AC_DEFUN([SPL_AC_DEBUG_LOG], [
469 AC_ARG_ENABLE([debug-log],
470 [AS_HELP_STRING([--enable-debug-log],
471 [Enable basic debug logging @<:@default=yes@:>@])],
473 [enable_debug_log=yes])
475 AS_IF([test "x$enable_debug_log" = xyes],
477 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
478 DEBUG_LOG="_with_debug_log"
479 AC_DEFINE([DEBUG_LOG], [1],
480 [Define to 1 to enable basic debug logging])
482 DEBUG_LOG="_without_debug_log"
486 AC_MSG_CHECKING([whether basic debug logging is enabled])
487 AC_MSG_RESULT([$enable_debug_log])
491 dnl # Enabled by default it provides a minimal level of memory tracking.
492 dnl # A total count of bytes allocated is kept for each alloc and free.
493 dnl # Then at module unload time a report to the console will be printed
494 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
495 dnl # and provide an easy way to inspect the kmem based slab.
497 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
498 AC_ARG_ENABLE([debug-kmem],
499 [AS_HELP_STRING([--enable-debug-kmem],
500 [Enable basic kmem accounting @<:@default=yes@:>@])],
502 [enable_debug_kmem=yes])
504 AS_IF([test "x$enable_debug_kmem" = xyes],
506 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
507 DEBUG_KMEM="_with_debug_kmem"
508 AC_DEFINE([DEBUG_KMEM], [1],
509 [Define to 1 to enable basic kmem accounting])
511 DEBUG_KMEM="_without_debug_kmem"
515 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
516 AC_MSG_RESULT([$enable_debug_kmem])
520 dnl # Disabled by default it provides detailed memory tracking. This
521 dnl # feature also requires --enable-debug-kmem to be set. When enabled
522 dnl # not only will total bytes be tracked but also the location of every
523 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
524 dnl # addresses and where they were allocated will be dumped to the console.
525 dnl # Enabling this feature has a significant impact on performance but it
526 dnl # makes finding memory leaks pretty straight forward.
528 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
529 AC_ARG_ENABLE([debug-kmem-tracking],
530 [AS_HELP_STRING([--enable-debug-kmem-tracking],
531 [Enable detailed kmem tracking @<:@default=no@:>@])],
533 [enable_debug_kmem_tracking=no])
535 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
537 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
538 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
539 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
540 [Define to 1 to enable detailed kmem tracking])
542 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
545 AC_SUBST(DEBUG_KMEM_TRACKING)
546 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
547 AC_MSG_RESULT([$enable_debug_kmem_tracking])
551 dnl # SPL_LINUX_CONFTEST
553 AC_DEFUN([SPL_LINUX_CONFTEST], [
554 cat confdefs.h - <<_ACEOF >conftest.c
560 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
562 m4_define([SPL_LANG_PROGRAM], [
567 dnl Do *not* indent the following line: there may be CPP directives.
568 dnl Don't move the `;' right after for the same reason.
576 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
578 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
579 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
580 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
581 echo "obj-m := conftest.o" >build/Makefile
583 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
585 [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])],
587 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
593 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
595 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
596 [SPL_LINUX_COMPILE_IFELSE(
597 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
599 [test -s build/conftest.o],
604 dnl # SPL_CHECK_SYMBOL_EXPORT
605 dnl # check symbol exported or not
607 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
608 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
609 $LINUX_OBJ/Module*.symvers 2>/dev/null
611 if test $rc -ne 0; then
614 grep -q -E "EXPORT_SYMBOL.*($1)" \
615 "$LINUX_OBJ/$file" 2>/dev/null
617 if test $rc -eq 0; then
622 if test $export -eq 0; then :
633 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
634 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
635 dnl # is called if not compiling for builtin
637 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
638 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
639 if test $rc -ne 0; then :
642 if test "x$enable_linux_builtin" != xyes; then
643 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
645 if test $rc -ne 0; then :
654 dnl # SPL_CHECK_SYMBOL_HEADER
655 dnl # check if a symbol prototype is defined in listed headers.
657 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
658 AC_MSG_CHECKING([whether symbol $1 exists in header])
661 grep -q "$2" "$LINUX/$file" 2>/dev/null
663 if test $rc -eq 0; then
668 if test $header -eq 0; then
678 dnl # SPL_CHECK_HEADER
679 dnl # check whether header exists and define HAVE_$2_HEADER
681 AC_DEFUN([SPL_CHECK_HEADER],
682 [AC_MSG_CHECKING([whether header $1 exists])
683 SPL_LINUX_TRY_COMPILE([
688 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
698 dnl # Basic toolchain sanity check. Verify that kernel modules can
699 dnl # be built and which symbols can be used.
701 AC_DEFUN([SPL_AC_TEST_MODULE],
702 [AC_MSG_CHECKING([whether modules can be built])
703 SPL_LINUX_TRY_COMPILE([],[],[
707 if test "x$enable_linux_builtin" != xyes; then
708 AC_MSG_ERROR([*** Unable to build an empty module.])
711 *** Unable to build an empty module.
712 *** Please run 'make scripts' inside the kernel source tree.])
718 #include "$LINUX/include/linux/license.h"
720 return !license_is_gpl_compatible("$SPL_META_LICENSE");
723 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
724 [Define to 1 if GPL-only symbols can be used])
730 dnl # Use the atomic implemenation based on global spinlocks. This
731 dnl # should only be needed by 32-bit kernels which do not provide
732 dnl # the atomic64_* API. It may be optionally enabled as a fallback
733 dnl # if problems are observed with the direct mapping to the native
734 dnl # Linux atomic operations. You may not disable atomic spinlocks
735 dnl # if you kernel does not an atomic64_* API.
737 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
738 AC_ARG_ENABLE([atomic-spinlocks],
739 [AS_HELP_STRING([--enable-atomic-spinlocks],
740 [Atomic types use spinlocks @<:@default=check@:>@])],
742 [enable_atomic_spinlocks=check])
744 SPL_LINUX_TRY_COMPILE([
745 #include <linux/fs.h>
747 atomic64_t *ptr __attribute__ ((unused));
750 AC_DEFINE(HAVE_ATOMIC64_T, 1,
751 [kernel defines atomic64_t])
756 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
757 AS_IF([test "x$have_atomic64_t" = xyes], [
758 enable_atomic_spinlocks=no
760 enable_atomic_spinlocks=yes
764 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
765 AC_DEFINE([ATOMIC_SPINLOCK], [1],
766 [Atomic types use spinlocks])
768 AS_IF([test "x$have_atomic64_t" = xno], [
770 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
774 AC_MSG_CHECKING([whether atomic types use spinlocks])
775 AC_MSG_RESULT([$enable_atomic_spinlocks])
777 AC_MSG_CHECKING([whether kernel defines atomic64_t])
778 AC_MSG_RESULT([$have_atomic64_t])
781 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
782 tmp_flags="$EXTRA_KCFLAGS"
783 EXTRA_KCFLAGS="-Werror"
785 dnl # 2.6.23 to 2.6.34 API change
786 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
788 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
789 SPL_LINUX_TRY_COMPILE([
790 #include <linux/mm.h>
792 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
794 struct shrinker cache_shrinker = {
795 .shrink = shrinker_cb,
796 .seeks = DEFAULT_SEEKS,
798 register_shrinker(&cache_shrinker);
801 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
802 [old shrinker callback wants 2 args])
806 dnl # 2.6.35 - 2.6.39 API change
807 dnl # ->shrink(struct shrinker *,
808 dnl # int nr_to_scan, gfp_t gfp_mask)
810 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
811 SPL_LINUX_TRY_COMPILE([
812 #include <linux/mm.h>
814 int shrinker_cb(struct shrinker *, int nr_to_scan,
817 struct shrinker cache_shrinker = {
818 .shrink = shrinker_cb,
819 .seeks = DEFAULT_SEEKS,
821 register_shrinker(&cache_shrinker);
824 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
825 [old shrinker callback wants 3 args])
829 dnl # 3.0 - 3.11 API change
830 dnl # ->shrink(struct shrinker *,
831 dnl # struct shrink_control *sc)
834 [whether new 2-argument shrinker exists])
835 SPL_LINUX_TRY_COMPILE([
836 #include <linux/mm.h>
838 int shrinker_cb(struct shrinker *,
839 struct shrink_control *sc);
841 struct shrinker cache_shrinker = {
842 .shrink = shrinker_cb,
843 .seeks = DEFAULT_SEEKS,
845 register_shrinker(&cache_shrinker);
848 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
849 [new shrinker callback wants 2 args])
853 dnl # 3.12 API change,
854 dnl # ->shrink() is logically split in to
855 dnl # ->count_objects() and ->scan_objects()
858 [whether ->count_objects callback exists])
859 SPL_LINUX_TRY_COMPILE([
860 #include <linux/mm.h>
862 unsigned long shrinker_cb(
864 struct shrink_control *sc);
866 struct shrinker cache_shrinker = {
867 .count_objects = shrinker_cb,
868 .scan_objects = shrinker_cb,
869 .seeks = DEFAULT_SEEKS,
871 register_shrinker(&cache_shrinker);
874 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
875 1, [->count_objects exists])
882 EXTRA_KCFLAGS="$tmp_flags"
886 dnl # 2.6.33 API change,
887 dnl # Removed .ctl_name from struct ctl_table.
889 AC_DEFUN([SPL_AC_CTL_NAME], [
890 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
891 SPL_LINUX_TRY_COMPILE([
892 #include <linux/sysctl.h>
894 struct ctl_table ctl __attribute__ ((unused));
898 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
905 dnl # 2.6.29 API change,
906 dnl # Adaptive mutexs were introduced which track the mutex owner. The
907 dnl # mutex wrappers leverage this functionality to avoid tracking the
908 dnl # owner multipe times.
910 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
911 AC_MSG_CHECKING([whether struct mutex has owner])
912 SPL_LINUX_TRY_COMPILE([
913 #include <linux/mutex.h>
915 struct mutex mtx __attribute__ ((unused));
919 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
926 dnl # 2.6.39 API change,
927 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
928 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
929 dnl # was defined. As of 2.6.39 this was changed to a task_struct
930 dnl # pointer which frankly makes a lot more sense.
932 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
933 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
934 tmp_flags="$EXTRA_KCFLAGS"
935 EXTRA_KCFLAGS="-Werror"
936 SPL_LINUX_TRY_COMPILE([
937 #include <linux/mutex.h>
938 #include <linux/sched.h>
940 struct mutex mtx __attribute__ ((unused));
944 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
945 [struct mutex owner is a task_struct])
949 EXTRA_KCFLAGS="$tmp_flags"
953 dnl # 3.10 API change,
954 dnl # PDE is replaced by PDE_DATA
956 AC_DEFUN([SPL_AC_PDE_DATA], [
957 AC_MSG_CHECKING([whether PDE_DATA() is available])
958 SPL_LINUX_TRY_COMPILE_SYMBOL([
959 #include <linux/proc_fs.h>
964 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
972 dnl # set_fs_pwd takes const struct path *
974 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
975 tmp_flags="$EXTRA_KCFLAGS"
976 EXTRA_KCFLAGS="-Werror"
977 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
978 SPL_LINUX_TRY_COMPILE([
979 #include <linux/spinlock.h>
980 #include <linux/fs_struct.h>
981 #include <linux/path.h>
982 void (*const set_fs_pwd_func)
983 (struct fs_struct *, const struct path *)
989 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
990 [set_fs_pwd() needs const path *])
992 SPL_LINUX_TRY_COMPILE([
993 #include <linux/spinlock.h>
994 #include <linux/fs_struct.h>
995 #include <linux/path.h>
996 void (*const set_fs_pwd_func)
997 (struct fs_struct *, struct path *)
1004 AC_MSG_ERROR(unknown)
1007 EXTRA_KCFLAGS="$tmp_flags"
1011 dnl # 3.13 API change
1012 dnl # vfs_unlink() updated to take a third delegated_inode argument.
1014 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1015 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/fs.h>
1019 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1022 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1023 [vfs_unlink() wants 2 args])
1027 dnl # Linux 3.13 API change
1028 dnl # Added delegated inode
1030 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1031 SPL_LINUX_TRY_COMPILE([
1032 #include <linux/fs.h>
1034 vfs_unlink((struct inode *) NULL,
1035 (struct dentry *) NULL,
1036 (struct inode **) NULL);
1039 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1040 [vfs_unlink() wants 3 args])
1049 dnl # 3.13 and 3.15 API changes
1050 dnl # Added delegated inode and flags argument.
1052 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1053 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1054 SPL_LINUX_TRY_COMPILE([
1055 #include <linux/fs.h>
1057 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1058 (struct inode *) NULL, (struct dentry *) NULL);
1061 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1062 [vfs_rename() wants 4 args])
1066 dnl # Linux 3.13 API change
1067 dnl # Added delegated inode
1069 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1070 SPL_LINUX_TRY_COMPILE([
1071 #include <linux/fs.h>
1073 vfs_rename((struct inode *) NULL,
1074 (struct dentry *) NULL,
1075 (struct inode *) NULL,
1076 (struct dentry *) NULL,
1077 (struct inode **) NULL);
1080 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1081 [vfs_rename() wants 5 args])
1085 dnl # Linux 3.15 API change
1088 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1089 SPL_LINUX_TRY_COMPILE([
1090 #include <linux/fs.h>
1092 vfs_rename((struct inode *) NULL,
1093 (struct dentry *) NULL,
1094 (struct inode *) NULL,
1095 (struct dentry *) NULL,
1096 (struct inode **) NULL,
1100 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1101 [vfs_rename() wants 6 args])
1110 dnl # 2.6.36 API change,
1111 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1112 dnl # a spinlock_t to improve the fastpath performance.
1114 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1115 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1116 tmp_flags="$EXTRA_KCFLAGS"
1117 EXTRA_KCFLAGS="-Werror"
1118 SPL_LINUX_TRY_COMPILE([
1119 #include <linux/sched.h>
1120 #include <linux/fs_struct.h>
1122 struct fs_struct fs;
1123 spin_lock_init(&fs.lock);
1126 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1127 [struct fs_struct uses spinlock_t])
1131 EXTRA_KCFLAGS="$tmp_flags"
1135 dnl # User namespaces, use kuid_t in place of uid_t
1136 dnl # where available. Not strictly a user namespaces thing
1137 dnl # but it should prevent surprises
1139 AC_DEFUN([SPL_AC_KUIDGID_T], [
1140 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1141 SPL_LINUX_TRY_COMPILE([
1142 #include <linux/uidgid.h>
1144 kuid_t userid = KUIDT_INIT(0);
1145 kgid_t groupid = KGIDT_INIT(0);
1147 SPL_LINUX_TRY_COMPILE([
1148 #include <linux/uidgid.h>
1153 AC_MSG_RESULT(yes; optional)
1155 AC_MSG_RESULT(yes; mandatory)
1156 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1164 dnl # 2.6.39 API change,
1165 dnl # __put_task_struct() was exported by the mainline kernel.
1167 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1168 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1169 SPL_LINUX_TRY_COMPILE_SYMBOL([
1170 #include <linux/sched.h>
1172 __put_task_struct(NULL);
1173 ], [__put_task_struct], [], [
1175 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1176 [__put_task_struct() is available])
1183 dnl # 2.6.29 API change,
1184 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1186 AC_DEFUN([SPL_AC_VFS_FSYNC],
1187 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1188 SPL_LINUX_TRY_COMPILE_SYMBOL([
1189 #include <linux/fs.h>
1192 ], [vfs_fsync], [fs/sync.c], [
1194 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1201 dnl # 2.6.35 API change,
1202 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1204 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1205 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1206 SPL_LINUX_TRY_COMPILE([
1207 #include <linux/fs.h>
1212 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1219 dnl # 3.5 API change,
1220 dnl # inode_operations.truncate_range removed
1222 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1223 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1224 SPL_LINUX_TRY_COMPILE([
1225 #include <linux/fs.h>
1227 struct inode_operations ops;
1228 ops.truncate_range = NULL;
1231 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1232 [truncate_range() inode operation is available])
1239 dnl # Linux 2.6.38 - 3.x API
1241 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1242 AC_MSG_CHECKING([whether fops->fallocate() exists])
1243 SPL_LINUX_TRY_COMPILE([
1244 #include <linux/fs.h>
1246 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1247 struct file_operations fops __attribute__ ((unused)) = {
1248 .fallocate = fallocate,
1252 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1259 dnl # Linux 2.6.x - 2.6.37 API
1261 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1262 AC_MSG_CHECKING([whether iops->fallocate() exists])
1263 SPL_LINUX_TRY_COMPILE([
1264 #include <linux/fs.h>
1266 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1267 struct inode_operations fops __attribute__ ((unused)) = {
1268 .fallocate = fallocate,
1272 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1279 dnl # PaX Linux 2.6.38 - 3.x API
1281 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1282 AC_MSG_CHECKING([whether fops->fallocate() exists])
1283 SPL_LINUX_TRY_COMPILE([
1284 #include <linux/fs.h>
1286 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1287 struct file_operations_no_const fops __attribute__ ((unused)) = {
1288 .fallocate = fallocate,
1292 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1299 dnl # The fallocate callback was moved from the inode_operations
1300 dnl # structure to the file_operations structure.
1302 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1303 SPL_AC_KERNEL_FILE_FALLOCATE
1304 SPL_AC_KERNEL_INODE_FALLOCATE
1305 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1309 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1310 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1311 dnl # condition. The fixed version is exported as a symbol. The race
1312 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1313 dnl # call that version while holding sem->wait_lock.
1315 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1316 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1317 SPL_LINUX_TRY_COMPILE_SYMBOL([
1318 #include <linux/rwsem.h>
1319 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1320 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1322 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1323 [rwsem_is_locked() acquires sem->wait_lock])
1330 dnl # 2.6.28 API change
1331 dnl # The kern_path() function has been introduced. We adopt it as the new way
1332 dnl # of looking up paths. When it is not available, we emulate it using the
1333 dnl # older interfaces.
1335 AC_DEFUN([SPL_AC_KERN_PATH],
1336 [AC_MSG_CHECKING([whether kern_path() is available])
1337 SPL_LINUX_TRY_COMPILE_SYMBOL([
1338 #include <linux/namei.h>
1340 int r = kern_path(NULL, 0, NULL);
1341 ], [kern_path], [fs/namei.c], [
1343 AC_DEFINE(HAVE_KERN_PATH, 1,
1344 [kern_path() is available])
1347 AC_MSG_CHECKING([whether path_lookup() is available])
1348 SPL_LINUX_TRY_COMPILE_SYMBOL([
1349 #include <linux/namei.h>
1351 int r = path_lookup(NULL, 0, NULL);
1352 ], [path_lookup], [fs/namei.c], [
1354 AC_DEFINE(HAVE_KERN_PATH, 1,
1355 [kern_path() is available])
1359 *** Neither kern_path() nor path_lookup() is available.
1360 *** Please file an issue:
1361 *** https://github.com/zfsonlinux/spl/issues/new])
1368 dnl # zlib inflate compat,
1369 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1371 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1372 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1373 SPL_LINUX_TRY_COMPILE([
1374 #if !defined(CONFIG_ZLIB_INFLATE) && \
1375 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1376 #error CONFIG_ZLIB_INFLATE not defined
1379 AC_MSG_RESULT([yes])
1383 *** This kernel does not include the required zlib inflate support.
1384 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1389 dnl # zlib deflate compat,
1390 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1392 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1393 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1394 SPL_LINUX_TRY_COMPILE([
1395 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1396 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1397 #error CONFIG_ZLIB_DEFLATE not defined
1400 AC_MSG_RESULT([yes])
1404 *** This kernel does not include the required zlib deflate support.
1405 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1410 dnl # 2.6.39 API compat,
1411 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1412 dnl # This was done to avoid always having to allocate the maximum size
1413 dnl # workspace (268K). The caller can now specific the windowBits and
1414 dnl # memLevel compression parameters to get a smaller workspace.
1416 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1417 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1418 SPL_LINUX_TRY_COMPILE([
1419 #include <linux/zlib.h>
1421 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1424 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1425 [zlib_deflate_workspacesize() wants 2 args])
1432 dnl # 2.6.39 API change,
1433 dnl # Shrinker adjust to use common shrink_control structure.
1435 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1436 AC_MSG_CHECKING([whether struct shrink_control exists])
1437 SPL_LINUX_TRY_COMPILE([
1438 #include <linux/mm.h>
1440 struct shrink_control sc __attribute__ ((unused));
1443 sc.gfp_mask = GFP_KERNEL;
1446 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1447 [struct shrink_control exists])
1454 dnl # 3.1 API Change
1456 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1457 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1459 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1460 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1461 tmp_flags="$EXTRA_KCFLAGS"
1462 EXTRA_KCFLAGS="-Werror"
1463 SPL_LINUX_TRY_COMPILE([
1464 #include <linux/rwsem.h>
1466 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1467 raw_spinlock_t dummy_lock __attribute__ ((unused));
1468 dummy_semaphore.wait_lock = dummy_lock;
1471 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1472 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1476 EXTRA_KCFLAGS="$tmp_flags"
1480 dnl # 3.9 API change,
1481 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1483 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1484 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1485 SPL_LINUX_TRY_COMPILE([
1486 #include <linux/sched.h>
1487 #include <linux/sched/rt.h>
1491 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1499 dnl # 3.9 API change,
1500 dnl # vfs_getattr() uses 2 args
1501 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1503 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1504 AC_MSG_CHECKING([whether vfs_getattr() wants])
1505 SPL_LINUX_TRY_COMPILE([
1506 #include <linux/fs.h>
1508 vfs_getattr((struct path *) NULL,
1509 (struct kstat *)NULL);
1511 AC_MSG_RESULT(2 args)
1512 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1513 [vfs_getattr wants 2 args])
1515 SPL_LINUX_TRY_COMPILE([
1516 #include <linux/fs.h>
1518 vfs_getattr((struct vfsmount *)NULL,
1519 (struct dentry *)NULL,
1520 (struct kstat *)NULL);
1522 AC_MSG_RESULT(3 args)
1524 AC_MSG_ERROR(unknown)
1530 dnl # 2.6.36 API compatibility.
1531 dnl # Added usleep_range timer.
1532 dnl # usleep_range is a finer precision implementation of msleep
1533 dnl # designed to be a drop-in replacement for udelay where a precise
1534 dnl # sleep / busy-wait is unnecessary.
1536 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1537 AC_MSG_CHECKING([whether usleep_range() is available])
1538 SPL_LINUX_TRY_COMPILE([
1539 #include <linux/delay.h>
1544 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1545 [usleep_range is available])
1552 dnl # 2.6.35 API change,
1553 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1554 dnl # private allocation flags which are applied when allocating a new slab
1555 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1556 dnl # non-default flags.
1558 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1559 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1560 SPL_LINUX_TRY_COMPILE([
1561 #include <linux/slab.h>
1563 struct kmem_cache cachep __attribute__ ((unused));
1564 cachep.allocflags = GFP_KERNEL;
1567 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1568 [struct kmem_cache has allocflags])
1572 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1573 SPL_LINUX_TRY_COMPILE([
1574 #include <linux/slab.h>
1576 struct kmem_cache cachep __attribute__ ((unused));
1577 cachep.gfpflags = GFP_KERNEL;
1580 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1581 [struct kmem_cache has gfpflags])
1589 dnl # 3.17 API change,
1590 dnl # wait_on_bit() no longer requires an action argument. The former
1591 dnl # "wait_on_bit" interface required an 'action' function to be provided
1592 dnl # which does the actual waiting. There were over 20 such functions in the
1593 dnl # kernel, many of them identical, though most cases can be satisfied by one
1594 dnl # of just two functions: one which uses io_schedule() and one which just
1595 dnl # uses schedule(). This API change was made to consolidate all of those
1596 dnl # redundant wait functions.
1598 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1599 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1600 SPL_LINUX_TRY_COMPILE([
1601 #include <linux/wait.h>
1603 int (*action)(void *) = NULL;
1604 wait_on_bit(NULL, 0, action, 0);
1607 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])