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
34 SPL_AC_2ARGS_VFS_FSYNC
35 SPL_AC_INODE_TRUNCATE_RANGE
36 SPL_AC_FS_STRUCT_SPINLOCK
38 SPL_AC_PUT_TASK_STRUCT
39 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
40 SPL_AC_KERNEL_FALLOCATE
41 SPL_AC_CONFIG_ZLIB_INFLATE
42 SPL_AC_CONFIG_ZLIB_DEFLATE
43 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
44 SPL_AC_SHRINK_CONTROL_STRUCT
45 SPL_AC_RWSEM_SPINLOCK_IS_RAW
46 SPL_AC_SCHED_RT_HEADER
47 SPL_AC_2ARGS_VFS_GETATTR
49 SPL_AC_KMEM_CACHE_ALLOCFLAGS
53 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
54 modpost=$LINUX/scripts/Makefile.modpost
55 AC_MSG_CHECKING([kernel file name for module symbols])
56 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
57 if grep -q Modules.symvers $modpost; then
58 LINUX_SYMBOLS=Modules.symvers
60 LINUX_SYMBOLS=Module.symvers
63 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
65 *** Please make sure the kernel devel package for your distribution
66 *** is installed. If you are building with a custom kernel, make sure the
67 *** kernel is configured, built, and the '--with-linux=PATH' configure
68 *** option refers to the location of the kernel source.])
73 AC_MSG_RESULT($LINUX_SYMBOLS)
74 AC_SUBST(LINUX_SYMBOLS)
77 AC_DEFUN([SPL_AC_KERNEL], [
79 AS_HELP_STRING([--with-linux=PATH],
80 [Path to kernel source]),
81 [kernelsrc="$withval"])
83 AC_ARG_WITH([linux-obj],
84 AS_HELP_STRING([--with-linux-obj=PATH],
85 [Path to kernel build objects]),
86 [kernelbuild="$withval"])
88 AC_MSG_CHECKING([kernel source directory])
89 if test -z "$kernelsrc"; then
90 if test -e "/lib/modules/$(uname -r)/source"; then
91 headersdir="/lib/modules/$(uname -r)/source"
92 sourcelink=$(readlink -f "$headersdir")
93 elif test -e "/lib/modules/$(uname -r)/build"; then
94 headersdir="/lib/modules/$(uname -r)/build"
95 sourcelink=$(readlink -f "$headersdir")
97 sourcelink=$(ls -1d /usr/src/kernels/* \
99 2>/dev/null | grep -v obj | tail -1)
102 if test -n "$sourcelink" && test -e ${sourcelink}; then
103 kernelsrc=`readlink -f ${sourcelink}`
105 kernelsrc="[Not found]"
108 if test "$kernelsrc" = "NONE"; then
113 AC_MSG_RESULT([$kernelsrc])
114 if test ! -d "$kernelsrc"; then
116 *** Please make sure the kernel devel package for your distribution
117 *** is installed and then try again. If that fails, you can specify the
118 *** location of the kernel source with the '--with-linux=PATH' option.])
121 AC_MSG_CHECKING([kernel build directory])
122 if test -z "$kernelbuild"; then
123 if test -e "/lib/modules/$(uname -r)/build"; then
124 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
125 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
126 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
127 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
128 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
129 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
130 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
132 kernelbuild=${kernelsrc}
135 AC_MSG_RESULT([$kernelbuild])
137 AC_MSG_CHECKING([kernel source version])
138 utsrelease1=$kernelbuild/include/linux/version.h
139 utsrelease2=$kernelbuild/include/linux/utsrelease.h
140 utsrelease3=$kernelbuild/include/generated/utsrelease.h
141 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
142 utsrelease=linux/version.h
143 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
144 utsrelease=linux/utsrelease.h
145 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
146 utsrelease=generated/utsrelease.h
149 if test "$utsrelease"; then
150 kernsrcver=`(echo "#include <$utsrelease>";
151 echo "kernsrcver=UTS_RELEASE") |
152 cpp -I $kernelbuild/include |
153 grep "^kernsrcver=" | cut -d \" -f 2`
155 if test -z "$kernsrcver"; then
156 AC_MSG_RESULT([Not found])
157 AC_MSG_ERROR([*** Cannot determine kernel version.])
160 AC_MSG_RESULT([Not found])
161 if test "x$enable_linux_builtin" != xyes; then
162 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
165 *** Cannot find UTS_RELEASE definition.
166 *** Please run 'make prepare' inside the kernel source tree.])
170 AC_MSG_RESULT([$kernsrcver])
173 LINUX_OBJ=${kernelbuild}
174 LINUX_VERSION=${kernsrcver}
178 AC_SUBST(LINUX_VERSION)
180 SPL_AC_MODULE_SYMVERS
184 dnl # Default SPL user configuration
186 AC_DEFUN([SPL_AC_CONFIG_USER], [])
189 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
190 dnl # are missing, it is non-fatal, but you will not be able to build
191 dnl # RPM packages and will be warned if you try too.
193 dnl # By default, the generic spec file will be used because it requires
194 dnl # minimal dependencies. Distribution specific spec files can be
195 dnl # placed under the 'rpm/<distribution>' directory and enabled using
196 dnl # the --with-spec=<distribution> configure option.
198 AC_DEFUN([SPL_AC_RPM], [
202 AC_MSG_CHECKING([whether $RPM is available])
203 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
204 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
206 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
209 AC_MSG_RESULT([$HAVE_RPM])
212 AC_MSG_CHECKING([whether $RPMBUILD is available])
213 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
214 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
216 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
219 AC_MSG_RESULT([$HAVE_RPMBUILD])
222 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
224 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
227 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
232 RPM_SPEC_DIR="rpm/generic"
234 AS_HELP_STRING([--with-spec=SPEC],
235 [Spec files 'generic|fedora']),
236 [RPM_SPEC_DIR="rpm/$withval"])
238 AC_MSG_CHECKING([whether spec files are available])
239 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
243 AC_SUBST(RPM_VERSION)
245 AC_SUBST(HAVE_RPMBUILD)
247 AC_SUBST(RPMBUILD_VERSION)
249 AC_SUBST(RPM_SPEC_DIR)
250 AC_SUBST(RPM_DEFINE_UTIL)
251 AC_SUBST(RPM_DEFINE_KMOD)
252 AC_SUBST(RPM_DEFINE_DKMS)
253 AC_SUBST(RPM_DEFINE_COMMON)
254 AC_SUBST(SRPM_DEFINE_UTIL)
255 AC_SUBST(SRPM_DEFINE_KMOD)
256 AC_SUBST(SRPM_DEFINE_DKMS)
257 AC_SUBST(SRPM_DEFINE_COMMON)
261 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
262 dnl # tools are missing it is non-fatal but you will not be able to build
263 dnl # DEB packages and will be warned if you try too.
265 AC_DEFUN([SPL_AC_DPKG], [
267 DPKGBUILD=dpkg-buildpackage
269 AC_MSG_CHECKING([whether $DPKG is available])
270 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
271 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
273 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
276 AC_MSG_RESULT([$HAVE_DPKG])
279 AC_MSG_CHECKING([whether $DPKGBUILD is available])
280 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
281 DPKGBUILD_VERSION=$(echo $tmp | \
282 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
284 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
287 AC_MSG_RESULT([$HAVE_DPKGBUILD])
292 AC_SUBST(DPKG_VERSION)
294 AC_SUBST(HAVE_DPKGBUILD)
296 AC_SUBST(DPKGBUILD_VERSION)
300 dnl # Until native packaging for various different packing systems
301 dnl # can be added the least we can do is attempt to use alien to
302 dnl # convert the RPM packages to the needed package type. This is
303 dnl # a hack but so far it has worked reasonable well.
305 AC_DEFUN([SPL_AC_ALIEN], [
308 AC_MSG_CHECKING([whether $ALIEN is available])
309 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
310 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
312 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
315 AC_MSG_RESULT([$HAVE_ALIEN])
320 AC_SUBST(ALIEN_VERSION)
324 dnl # Using the VENDOR tag from config.guess set the default
325 dnl # package type for 'make pkg': (rpm | deb | tgz)
327 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
328 AC_MSG_CHECKING([linux distribution])
329 if test -f /etc/toss-release ; then
331 elif test -f /etc/fedora-release ; then
333 elif test -f /etc/redhat-release ; then
335 elif test -f /etc/gentoo-release ; then
337 elif test -f /etc/arch-release ; then
339 elif test -f /etc/SuSE-release ; then
341 elif test -f /etc/slackware-version ; then
343 elif test -f /etc/lunar.release ; then
345 elif test -f /etc/lsb-release ; then
347 elif test -f /etc/debian_version ; then
352 AC_MSG_RESULT([$VENDOR])
355 AC_MSG_CHECKING([default package type])
357 toss) DEFAULT_PACKAGE=rpm ;;
358 redhat) DEFAULT_PACKAGE=rpm ;;
359 fedora) DEFAULT_PACKAGE=rpm ;;
360 gentoo) DEFAULT_PACKAGE=tgz ;;
361 arch) DEFAULT_PACKAGE=tgz ;;
362 sles) DEFAULT_PACKAGE=rpm ;;
363 slackware) DEFAULT_PACKAGE=tgz ;;
364 lunar) DEFAULT_PACKAGE=tgz ;;
365 ubuntu) DEFAULT_PACKAGE=deb ;;
366 debian) DEFAULT_PACKAGE=deb ;;
367 *) DEFAULT_PACKAGE=rpm ;;
370 AC_MSG_RESULT([$DEFAULT_PACKAGE])
371 AC_SUBST(DEFAULT_PACKAGE)
375 dnl # Default SPL user configuration
377 AC_DEFUN([SPL_AC_PACKAGE], [
378 SPL_AC_DEFAULT_PACKAGE
384 AC_DEFUN([SPL_AC_LICENSE], [
385 AC_MSG_CHECKING([spl author])
386 AC_MSG_RESULT([$SPL_META_AUTHOR])
388 AC_MSG_CHECKING([spl license])
389 AC_MSG_RESULT([$SPL_META_LICENSE])
392 AC_DEFUN([SPL_AC_CONFIG], [
394 AC_ARG_WITH([config],
395 AS_HELP_STRING([--with-config=CONFIG],
396 [Config file 'kernel|user|all|srpm']),
397 [SPL_CONFIG="$withval"])
398 AC_ARG_ENABLE([linux-builtin],
399 [AC_HELP_STRING([--enable-linux-builtin],
400 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
402 [enable_linux_builtin=no])
404 AC_MSG_CHECKING([spl config])
405 AC_MSG_RESULT([$SPL_CONFIG]);
408 case "$SPL_CONFIG" in
409 kernel) SPL_AC_CONFIG_KERNEL ;;
410 user) SPL_AC_CONFIG_USER ;;
411 all) SPL_AC_CONFIG_KERNEL
412 SPL_AC_CONFIG_USER ;;
415 AC_MSG_RESULT([Error!])
416 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
417 user kernel|user|all|srpm]) ;;
420 AM_CONDITIONAL([CONFIG_USER],
421 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
422 AM_CONDITIONAL([CONFIG_KERNEL],
423 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
424 [test "x$enable_linux_builtin" != xyes ])
428 dnl # Enable if the SPL should be compiled with internal debugging enabled.
429 dnl # By default this support is disabled.
431 AC_DEFUN([SPL_AC_DEBUG], [
432 AC_MSG_CHECKING([whether debugging is enabled])
433 AC_ARG_ENABLE([debug],
434 [AS_HELP_STRING([--enable-debug],
435 [Enable generic debug support @<:@default=no@:>@])],
439 AS_IF([test "x$enable_debug" = xyes],
441 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
442 DEBUG_CFLAGS="-DDEBUG -Werror"
443 DEBUG_SPL="_with_debug"
445 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
446 DEBUG_CFLAGS="-DNDEBUG"
447 DEBUG_SPL="_without_debug"
450 AC_SUBST(DEBUG_CFLAGS)
452 AC_MSG_RESULT([$enable_debug])
456 dnl # Enabled by default it provides a basic debug log infrastructure.
457 dnl # Each subsystem registers itself with a name and logs messages
458 dnl # using predefined types. If the debug mask it set to allow the
459 dnl # message type it will be written to the internal log. The log
460 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
461 dnl # after dumping the log it must be decoded using the spl utility.
463 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
464 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
466 AC_DEFUN([SPL_AC_DEBUG_LOG], [
467 AC_ARG_ENABLE([debug-log],
468 [AS_HELP_STRING([--enable-debug-log],
469 [Enable basic debug logging @<:@default=yes@:>@])],
471 [enable_debug_log=yes])
473 AS_IF([test "x$enable_debug_log" = xyes],
475 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
476 DEBUG_LOG="_with_debug_log"
477 AC_DEFINE([DEBUG_LOG], [1],
478 [Define to 1 to enable basic debug logging])
480 DEBUG_LOG="_without_debug_log"
484 AC_MSG_CHECKING([whether basic debug logging is enabled])
485 AC_MSG_RESULT([$enable_debug_log])
489 dnl # Enabled by default it provides a minimal level of memory tracking.
490 dnl # A total count of bytes allocated is kept for each alloc and free.
491 dnl # Then at module unload time a report to the console will be printed
492 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
493 dnl # and provide an easy way to inspect the kmem based slab.
495 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
496 AC_ARG_ENABLE([debug-kmem],
497 [AS_HELP_STRING([--enable-debug-kmem],
498 [Enable basic kmem accounting @<:@default=yes@:>@])],
500 [enable_debug_kmem=yes])
502 AS_IF([test "x$enable_debug_kmem" = xyes],
504 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
505 DEBUG_KMEM="_with_debug_kmem"
506 AC_DEFINE([DEBUG_KMEM], [1],
507 [Define to 1 to enable basic kmem accounting])
509 DEBUG_KMEM="_without_debug_kmem"
513 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
514 AC_MSG_RESULT([$enable_debug_kmem])
518 dnl # Disabled by default it provides detailed memory tracking. This
519 dnl # feature also requires --enable-debug-kmem to be set. When enabled
520 dnl # not only will total bytes be tracked but also the location of every
521 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
522 dnl # addresses and where they were allocated will be dumped to the console.
523 dnl # Enabling this feature has a significant impact on performance but it
524 dnl # makes finding memory leaks pretty straight forward.
526 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
527 AC_ARG_ENABLE([debug-kmem-tracking],
528 [AS_HELP_STRING([--enable-debug-kmem-tracking],
529 [Enable detailed kmem tracking @<:@default=no@:>@])],
531 [enable_debug_kmem_tracking=no])
533 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
535 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
536 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
537 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
538 [Define to 1 to enable detailed kmem tracking])
540 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
543 AC_SUBST(DEBUG_KMEM_TRACKING)
544 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
545 AC_MSG_RESULT([$enable_debug_kmem_tracking])
549 dnl # SPL_LINUX_CONFTEST
551 AC_DEFUN([SPL_LINUX_CONFTEST], [
552 cat confdefs.h - <<_ACEOF >conftest.c
558 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
560 m4_define([SPL_LANG_PROGRAM], [
565 dnl Do *not* indent the following line: there may be CPP directives.
566 dnl Don't move the `;' right after for the same reason.
574 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
576 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
577 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
578 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
579 echo "obj-m := conftest.o" >build/Makefile
581 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
583 [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])],
585 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
591 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
593 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
594 [SPL_LINUX_COMPILE_IFELSE(
595 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
597 [test -s build/conftest.o],
602 dnl # SPL_CHECK_SYMBOL_EXPORT
603 dnl # check symbol exported or not
605 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
606 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
607 $LINUX_OBJ/Module*.symvers 2>/dev/null
609 if test $rc -ne 0; then
612 grep -q -E "EXPORT_SYMBOL.*($1)" \
613 "$LINUX_OBJ/$file" 2>/dev/null
615 if test $rc -eq 0; then
620 if test $export -eq 0; then :
631 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
632 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
633 dnl # is called if not compiling for builtin
635 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
636 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
637 if test $rc -ne 0; then :
640 if test "x$enable_linux_builtin" != xyes; then
641 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
643 if test $rc -ne 0; then :
652 dnl # SPL_CHECK_SYMBOL_HEADER
653 dnl # check if a symbol prototype is defined in listed headers.
655 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
656 AC_MSG_CHECKING([whether symbol $1 exists in header])
659 grep -q "$2" "$LINUX/$file" 2>/dev/null
661 if test $rc -eq 0; then
666 if test $header -eq 0; then
676 dnl # SPL_CHECK_HEADER
677 dnl # check whether header exists and define HAVE_$2_HEADER
679 AC_DEFUN([SPL_CHECK_HEADER],
680 [AC_MSG_CHECKING([whether header $1 exists])
681 SPL_LINUX_TRY_COMPILE([
686 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
696 dnl # Basic toolchain sanity check. Verify that kernel modules can
697 dnl # be built and which symbols can be used.
699 AC_DEFUN([SPL_AC_TEST_MODULE],
700 [AC_MSG_CHECKING([whether modules can be built])
701 SPL_LINUX_TRY_COMPILE([],[],[
705 if test "x$enable_linux_builtin" != xyes; then
706 AC_MSG_ERROR([*** Unable to build an empty module.])
709 *** Unable to build an empty module.
710 *** Please run 'make scripts' inside the kernel source tree.])
716 #include "$LINUX/include/linux/license.h"
718 return !license_is_gpl_compatible("$SPL_META_LICENSE");
721 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
722 [Define to 1 if GPL-only symbols can be used])
728 dnl # Use the atomic implemenation based on global spinlocks. This
729 dnl # should only be needed by 32-bit kernels which do not provide
730 dnl # the atomic64_* API. It may be optionally enabled as a fallback
731 dnl # if problems are observed with the direct mapping to the native
732 dnl # Linux atomic operations. You may not disable atomic spinlocks
733 dnl # if you kernel does not an atomic64_* API.
735 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
736 AC_ARG_ENABLE([atomic-spinlocks],
737 [AS_HELP_STRING([--enable-atomic-spinlocks],
738 [Atomic types use spinlocks @<:@default=check@:>@])],
740 [enable_atomic_spinlocks=check])
742 SPL_LINUX_TRY_COMPILE([
743 #include <linux/fs.h>
745 atomic64_t *ptr __attribute__ ((unused));
748 AC_DEFINE(HAVE_ATOMIC64_T, 1,
749 [kernel defines atomic64_t])
754 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
755 AS_IF([test "x$have_atomic64_t" = xyes], [
756 enable_atomic_spinlocks=no
758 enable_atomic_spinlocks=yes
762 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
763 AC_DEFINE([ATOMIC_SPINLOCK], [1],
764 [Atomic types use spinlocks])
766 AS_IF([test "x$have_atomic64_t" = xno], [
768 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
772 AC_MSG_CHECKING([whether atomic types use spinlocks])
773 AC_MSG_RESULT([$enable_atomic_spinlocks])
775 AC_MSG_CHECKING([whether kernel defines atomic64_t])
776 AC_MSG_RESULT([$have_atomic64_t])
779 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
780 tmp_flags="$EXTRA_KCFLAGS"
781 EXTRA_KCFLAGS="-Werror"
783 dnl # 2.6.23 to 2.6.34 API change
784 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
786 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
787 SPL_LINUX_TRY_COMPILE([
788 #include <linux/mm.h>
790 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
792 struct shrinker cache_shrinker = {
793 .shrink = shrinker_cb,
794 .seeks = DEFAULT_SEEKS,
796 register_shrinker(&cache_shrinker);
799 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
800 [old shrinker callback wants 2 args])
804 dnl # 2.6.35 - 2.6.39 API change
805 dnl # ->shrink(struct shrinker *,
806 dnl # int nr_to_scan, gfp_t gfp_mask)
808 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
809 SPL_LINUX_TRY_COMPILE([
810 #include <linux/mm.h>
812 int shrinker_cb(struct shrinker *, int nr_to_scan,
815 struct shrinker cache_shrinker = {
816 .shrink = shrinker_cb,
817 .seeks = DEFAULT_SEEKS,
819 register_shrinker(&cache_shrinker);
822 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
823 [old shrinker callback wants 3 args])
827 dnl # 3.0 - 3.11 API change
828 dnl # ->shrink(struct shrinker *,
829 dnl # struct shrink_control *sc)
832 [whether new 2-argument shrinker exists])
833 SPL_LINUX_TRY_COMPILE([
834 #include <linux/mm.h>
836 int shrinker_cb(struct shrinker *,
837 struct shrink_control *sc);
839 struct shrinker cache_shrinker = {
840 .shrink = shrinker_cb,
841 .seeks = DEFAULT_SEEKS,
843 register_shrinker(&cache_shrinker);
846 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
847 [new shrinker callback wants 2 args])
851 dnl # 3.12 API change,
852 dnl # ->shrink() is logically split in to
853 dnl # ->count_objects() and ->scan_objects()
856 [whether ->count_objects callback exists])
857 SPL_LINUX_TRY_COMPILE([
858 #include <linux/mm.h>
860 unsigned long shrinker_cb(
862 struct shrink_control *sc);
864 struct shrinker cache_shrinker = {
865 .count_objects = shrinker_cb,
866 .scan_objects = shrinker_cb,
867 .seeks = DEFAULT_SEEKS,
869 register_shrinker(&cache_shrinker);
872 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
873 1, [->count_objects exists])
880 EXTRA_KCFLAGS="$tmp_flags"
884 dnl # 2.6.33 API change,
885 dnl # Removed .ctl_name from struct ctl_table.
887 AC_DEFUN([SPL_AC_CTL_NAME], [
888 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
889 SPL_LINUX_TRY_COMPILE([
890 #include <linux/sysctl.h>
892 struct ctl_table ctl __attribute__ ((unused));
896 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
903 dnl # 2.6.29 API change,
904 dnl # Adaptive mutexs were introduced which track the mutex owner. The
905 dnl # mutex wrappers leverage this functionality to avoid tracking the
906 dnl # owner multipe times.
908 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
909 AC_MSG_CHECKING([whether struct mutex has owner])
910 SPL_LINUX_TRY_COMPILE([
911 #include <linux/mutex.h>
913 struct mutex mtx __attribute__ ((unused));
917 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
924 dnl # 2.6.39 API change,
925 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
926 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
927 dnl # was defined. As of 2.6.39 this was changed to a task_struct
928 dnl # pointer which frankly makes a lot more sense.
930 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
931 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
932 tmp_flags="$EXTRA_KCFLAGS"
933 EXTRA_KCFLAGS="-Werror"
934 SPL_LINUX_TRY_COMPILE([
935 #include <linux/mutex.h>
936 #include <linux/sched.h>
938 struct mutex mtx __attribute__ ((unused));
942 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
943 [struct mutex owner is a task_struct])
947 EXTRA_KCFLAGS="$tmp_flags"
951 dnl # 3.10 API change,
952 dnl # PDE is replaced by PDE_DATA
954 AC_DEFUN([SPL_AC_PDE_DATA], [
955 AC_MSG_CHECKING([whether PDE_DATA() is available])
956 SPL_LINUX_TRY_COMPILE_SYMBOL([
957 #include <linux/proc_fs.h>
962 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
970 dnl # set_fs_pwd takes const struct path *
972 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
973 tmp_flags="$EXTRA_KCFLAGS"
974 EXTRA_KCFLAGS="-Werror"
975 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
976 SPL_LINUX_TRY_COMPILE([
977 #include <linux/spinlock.h>
978 #include <linux/fs_struct.h>
979 #include <linux/path.h>
980 void (*const set_fs_pwd_func)
981 (struct fs_struct *, const struct path *)
987 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
988 [set_fs_pwd() needs const path *])
990 SPL_LINUX_TRY_COMPILE([
991 #include <linux/spinlock.h>
992 #include <linux/fs_struct.h>
993 #include <linux/path.h>
994 void (*const set_fs_pwd_func)
995 (struct fs_struct *, struct path *)
1002 AC_MSG_ERROR(unknown)
1005 EXTRA_KCFLAGS="$tmp_flags"
1009 dnl # 3.13 API change
1010 dnl # vfs_unlink() updated to take a third delegated_inode argument.
1012 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1013 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1014 SPL_LINUX_TRY_COMPILE([
1015 #include <linux/fs.h>
1017 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1020 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1021 [vfs_unlink() wants 2 args])
1025 dnl # Linux 3.13 API change
1026 dnl # Added delegated inode
1028 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1029 SPL_LINUX_TRY_COMPILE([
1030 #include <linux/fs.h>
1032 vfs_unlink((struct inode *) NULL,
1033 (struct dentry *) NULL,
1034 (struct inode **) NULL);
1037 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1038 [vfs_unlink() wants 3 args])
1047 dnl # 3.13 and 3.15 API changes
1048 dnl # Added delegated inode and flags argument.
1050 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1051 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1052 SPL_LINUX_TRY_COMPILE([
1053 #include <linux/fs.h>
1055 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1056 (struct inode *) NULL, (struct dentry *) NULL);
1059 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1060 [vfs_rename() wants 4 args])
1064 dnl # Linux 3.13 API change
1065 dnl # Added delegated inode
1067 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1068 SPL_LINUX_TRY_COMPILE([
1069 #include <linux/fs.h>
1071 vfs_rename((struct inode *) NULL,
1072 (struct dentry *) NULL,
1073 (struct inode *) NULL,
1074 (struct dentry *) NULL,
1075 (struct inode **) NULL);
1078 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1079 [vfs_rename() wants 5 args])
1083 dnl # Linux 3.15 API change
1086 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1087 SPL_LINUX_TRY_COMPILE([
1088 #include <linux/fs.h>
1090 vfs_rename((struct inode *) NULL,
1091 (struct dentry *) NULL,
1092 (struct inode *) NULL,
1093 (struct dentry *) NULL,
1094 (struct inode **) NULL,
1098 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1099 [vfs_rename() wants 6 args])
1108 dnl # 2.6.36 API change,
1109 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1110 dnl # a spinlock_t to improve the fastpath performance.
1112 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1113 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1114 tmp_flags="$EXTRA_KCFLAGS"
1115 EXTRA_KCFLAGS="-Werror"
1116 SPL_LINUX_TRY_COMPILE([
1117 #include <linux/sched.h>
1118 #include <linux/fs_struct.h>
1120 struct fs_struct fs;
1121 spin_lock_init(&fs.lock);
1124 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1125 [struct fs_struct uses spinlock_t])
1129 EXTRA_KCFLAGS="$tmp_flags"
1133 dnl # User namespaces, use kuid_t in place of uid_t
1134 dnl # where available. Not strictly a user namespaces thing
1135 dnl # but it should prevent surprises
1137 AC_DEFUN([SPL_AC_KUIDGID_T], [
1138 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1139 SPL_LINUX_TRY_COMPILE([
1140 #include <linux/uidgid.h>
1142 kuid_t userid = KUIDT_INIT(0);
1143 kgid_t groupid = KGIDT_INIT(0);
1145 SPL_LINUX_TRY_COMPILE([
1146 #include <linux/uidgid.h>
1151 AC_MSG_RESULT(yes; optional)
1153 AC_MSG_RESULT(yes; mandatory)
1154 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1162 dnl # 2.6.39 API change,
1163 dnl # __put_task_struct() was exported by the mainline kernel.
1165 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1166 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1167 SPL_LINUX_TRY_COMPILE_SYMBOL([
1168 #include <linux/sched.h>
1170 __put_task_struct(NULL);
1171 ], [__put_task_struct], [], [
1173 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1174 [__put_task_struct() is available])
1181 dnl # 2.6.35 API change,
1182 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1184 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1185 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1186 SPL_LINUX_TRY_COMPILE([
1187 #include <linux/fs.h>
1192 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1199 dnl # 3.5 API change,
1200 dnl # inode_operations.truncate_range removed
1202 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1203 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1204 SPL_LINUX_TRY_COMPILE([
1205 #include <linux/fs.h>
1207 struct inode_operations ops;
1208 ops.truncate_range = NULL;
1211 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1212 [truncate_range() inode operation is available])
1219 dnl # Linux 2.6.38 - 3.x API
1221 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1222 AC_MSG_CHECKING([whether fops->fallocate() exists])
1223 SPL_LINUX_TRY_COMPILE([
1224 #include <linux/fs.h>
1226 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1227 struct file_operations fops __attribute__ ((unused)) = {
1228 .fallocate = fallocate,
1232 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1239 dnl # Linux 2.6.x - 2.6.37 API
1241 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1242 AC_MSG_CHECKING([whether iops->fallocate() exists])
1243 SPL_LINUX_TRY_COMPILE([
1244 #include <linux/fs.h>
1246 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1247 struct inode_operations fops __attribute__ ((unused)) = {
1248 .fallocate = fallocate,
1252 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1259 dnl # PaX Linux 2.6.38 - 3.x API
1261 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1262 AC_MSG_CHECKING([whether fops->fallocate() exists])
1263 SPL_LINUX_TRY_COMPILE([
1264 #include <linux/fs.h>
1266 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1267 struct file_operations_no_const fops __attribute__ ((unused)) = {
1268 .fallocate = fallocate,
1272 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1279 dnl # The fallocate callback was moved from the inode_operations
1280 dnl # structure to the file_operations structure.
1282 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1283 SPL_AC_KERNEL_FILE_FALLOCATE
1284 SPL_AC_KERNEL_INODE_FALLOCATE
1285 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1289 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1290 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1291 dnl # condition. The fixed version is exported as a symbol. The race
1292 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1293 dnl # call that version while holding sem->wait_lock.
1295 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
1296 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
1297 SPL_LINUX_TRY_COMPILE_SYMBOL([
1298 #include <linux/rwsem.h>
1299 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
1300 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
1302 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1303 [rwsem_is_locked() acquires sem->wait_lock])
1310 dnl # zlib inflate compat,
1311 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1313 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1314 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1315 SPL_LINUX_TRY_COMPILE([
1316 #if !defined(CONFIG_ZLIB_INFLATE) && \
1317 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1318 #error CONFIG_ZLIB_INFLATE not defined
1321 AC_MSG_RESULT([yes])
1325 *** This kernel does not include the required zlib inflate support.
1326 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1331 dnl # zlib deflate compat,
1332 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1334 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1335 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1336 SPL_LINUX_TRY_COMPILE([
1337 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1338 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1339 #error CONFIG_ZLIB_DEFLATE not defined
1342 AC_MSG_RESULT([yes])
1346 *** This kernel does not include the required zlib deflate support.
1347 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1352 dnl # 2.6.39 API compat,
1353 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1354 dnl # This was done to avoid always having to allocate the maximum size
1355 dnl # workspace (268K). The caller can now specific the windowBits and
1356 dnl # memLevel compression parameters to get a smaller workspace.
1358 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1359 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1360 SPL_LINUX_TRY_COMPILE([
1361 #include <linux/zlib.h>
1363 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1366 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1367 [zlib_deflate_workspacesize() wants 2 args])
1374 dnl # 2.6.39 API change,
1375 dnl # Shrinker adjust to use common shrink_control structure.
1377 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1378 AC_MSG_CHECKING([whether struct shrink_control exists])
1379 SPL_LINUX_TRY_COMPILE([
1380 #include <linux/mm.h>
1382 struct shrink_control sc __attribute__ ((unused));
1385 sc.gfp_mask = GFP_KERNEL;
1388 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1389 [struct shrink_control exists])
1396 dnl # 3.1 API Change
1398 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1399 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1401 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1402 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1403 tmp_flags="$EXTRA_KCFLAGS"
1404 EXTRA_KCFLAGS="-Werror"
1405 SPL_LINUX_TRY_COMPILE([
1406 #include <linux/rwsem.h>
1408 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1409 raw_spinlock_t dummy_lock __attribute__ ((unused));
1410 dummy_semaphore.wait_lock = dummy_lock;
1413 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1414 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1418 EXTRA_KCFLAGS="$tmp_flags"
1422 dnl # 3.9 API change,
1423 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1425 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1426 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1427 SPL_LINUX_TRY_COMPILE([
1428 #include <linux/sched.h>
1429 #include <linux/sched/rt.h>
1433 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1441 dnl # 3.9 API change,
1442 dnl # vfs_getattr() uses 2 args
1443 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1445 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1446 AC_MSG_CHECKING([whether vfs_getattr() wants])
1447 SPL_LINUX_TRY_COMPILE([
1448 #include <linux/fs.h>
1450 vfs_getattr((struct path *) NULL,
1451 (struct kstat *)NULL);
1453 AC_MSG_RESULT(2 args)
1454 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1455 [vfs_getattr wants 2 args])
1457 SPL_LINUX_TRY_COMPILE([
1458 #include <linux/fs.h>
1460 vfs_getattr((struct vfsmount *)NULL,
1461 (struct dentry *)NULL,
1462 (struct kstat *)NULL);
1464 AC_MSG_RESULT(3 args)
1466 AC_MSG_ERROR(unknown)
1472 dnl # 2.6.36 API compatibility.
1473 dnl # Added usleep_range timer.
1474 dnl # usleep_range is a finer precision implementation of msleep
1475 dnl # designed to be a drop-in replacement for udelay where a precise
1476 dnl # sleep / busy-wait is unnecessary.
1478 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1479 AC_MSG_CHECKING([whether usleep_range() is available])
1480 SPL_LINUX_TRY_COMPILE([
1481 #include <linux/delay.h>
1486 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1487 [usleep_range is available])
1494 dnl # 2.6.35 API change,
1495 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1496 dnl # private allocation flags which are applied when allocating a new slab
1497 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1498 dnl # non-default flags.
1500 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1501 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1502 SPL_LINUX_TRY_COMPILE([
1503 #include <linux/slab.h>
1505 struct kmem_cache cachep __attribute__ ((unused));
1506 cachep.allocflags = GFP_KERNEL;
1509 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1510 [struct kmem_cache has allocflags])
1514 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1515 SPL_LINUX_TRY_COMPILE([
1516 #include <linux/slab.h>
1518 struct kmem_cache cachep __attribute__ ((unused));
1519 cachep.gfpflags = GFP_KERNEL;
1522 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1523 [struct kmem_cache has gfpflags])
1531 dnl # 3.17 API change,
1532 dnl # wait_on_bit() no longer requires an action argument. The former
1533 dnl # "wait_on_bit" interface required an 'action' function to be provided
1534 dnl # which does the actual waiting. There were over 20 such functions in the
1535 dnl # kernel, many of them identical, though most cases can be satisfied by one
1536 dnl # of just two functions: one which uses io_schedule() and one which just
1537 dnl # uses schedule(). This API change was made to consolidate all of those
1538 dnl # redundant wait functions.
1540 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1541 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1542 SPL_LINUX_TRY_COMPILE([
1543 #include <linux/wait.h>
1545 int (*action)(void *) = NULL;
1546 wait_on_bit(NULL, 0, action, 0);
1549 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])