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)
22 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_SHRINKER_CALLBACK
27 SPL_AC_CONFIG_TRIM_UNUSED_KSYMS
29 SPL_AC_SET_FS_PWD_WITH_CONST
30 SPL_AC_2ARGS_VFS_UNLINK
31 SPL_AC_4ARGS_VFS_RENAME
32 SPL_AC_2ARGS_VFS_FSYNC
33 SPL_AC_INODE_TRUNCATE_RANGE
34 SPL_AC_FS_STRUCT_SPINLOCK
36 SPL_AC_PUT_TASK_STRUCT
37 SPL_AC_KERNEL_FALLOCATE
38 SPL_AC_CONFIG_ZLIB_INFLATE
39 SPL_AC_CONFIG_ZLIB_DEFLATE
40 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
41 SPL_AC_SHRINK_CONTROL_STRUCT
42 SPL_AC_RWSEM_SPINLOCK_IS_RAW
44 SPL_AC_RWSEM_ATOMIC_LONG_COUNT
45 SPL_AC_SCHED_RT_HEADER
46 SPL_AC_4ARGS_VFS_GETATTR
47 SPL_AC_3ARGS_VFS_GETATTR
48 SPL_AC_2ARGS_VFS_GETATTR
50 SPL_AC_KMEM_CACHE_ALLOCFLAGS
55 SPL_AC_KMEM_CACHE_CREATE_USERCOPY
58 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
59 modpost=$LINUX/scripts/Makefile.modpost
60 AC_MSG_CHECKING([kernel file name for module symbols])
61 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
62 if grep -q Modules.symvers $modpost; then
63 LINUX_SYMBOLS=Modules.symvers
65 LINUX_SYMBOLS=Module.symvers
68 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
70 *** Please make sure the kernel devel package for your distribution
71 *** is installed. If you are building with a custom kernel, make sure the
72 *** kernel is configured, built, and the '--with-linux=PATH' configure
73 *** option refers to the location of the kernel source.])
78 AC_MSG_RESULT($LINUX_SYMBOLS)
79 AC_SUBST(LINUX_SYMBOLS)
82 AC_DEFUN([SPL_AC_KERNEL], [
84 AS_HELP_STRING([--with-linux=PATH],
85 [Path to kernel source]),
86 [kernelsrc="$withval"])
88 AC_ARG_WITH([linux-obj],
89 AS_HELP_STRING([--with-linux-obj=PATH],
90 [Path to kernel build objects]),
91 [kernelbuild="$withval"])
93 AC_MSG_CHECKING([kernel source directory])
94 if test -z "$kernelsrc"; then
95 if test -e "/lib/modules/$(uname -r)/source"; then
96 headersdir="/lib/modules/$(uname -r)/source"
97 sourcelink=$(readlink -f "$headersdir")
98 elif test -e "/lib/modules/$(uname -r)/build"; then
99 headersdir="/lib/modules/$(uname -r)/build"
100 sourcelink=$(readlink -f "$headersdir")
102 sourcelink=$(ls -1d /usr/src/kernels/* \
104 2>/dev/null | grep -v obj | tail -1)
107 if test -n "$sourcelink" && test -e ${sourcelink}; then
108 kernelsrc=`readlink -f ${sourcelink}`
110 kernelsrc="[Not found]"
113 if test "$kernelsrc" = "NONE"; then
118 AC_MSG_RESULT([$kernelsrc])
119 if test ! -d "$kernelsrc"; then
121 *** Please make sure the kernel devel package for your distribution
122 *** is installed and then try again. If that fails, you can specify the
123 *** location of the kernel source with the '--with-linux=PATH' option.])
126 AC_MSG_CHECKING([kernel build directory])
127 if test -z "$kernelbuild"; then
128 if test -e "/lib/modules/$(uname -r)/build"; then
129 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
130 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
131 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
132 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
133 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
134 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
135 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
137 kernelbuild=${kernelsrc}
140 AC_MSG_RESULT([$kernelbuild])
142 AC_MSG_CHECKING([kernel source version])
143 utsrelease1=$kernelbuild/include/linux/version.h
144 utsrelease2=$kernelbuild/include/linux/utsrelease.h
145 utsrelease3=$kernelbuild/include/generated/utsrelease.h
146 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
147 utsrelease=linux/version.h
148 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
149 utsrelease=linux/utsrelease.h
150 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
151 utsrelease=generated/utsrelease.h
154 if test "$utsrelease"; then
155 kernsrcver=`(echo "#include <$utsrelease>";
156 echo "kernsrcver=UTS_RELEASE") |
157 cpp -I $kernelbuild/include |
158 grep "^kernsrcver=" | cut -d \" -f 2`
160 if test -z "$kernsrcver"; then
161 AC_MSG_RESULT([Not found])
162 AC_MSG_ERROR([*** Cannot determine kernel version.])
165 AC_MSG_RESULT([Not found])
166 if test "x$enable_linux_builtin" != xyes; then
167 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
170 *** Cannot find UTS_RELEASE definition.
171 *** Please run 'make prepare' inside the kernel source tree.])
175 AC_MSG_RESULT([$kernsrcver])
178 LINUX_OBJ=${kernelbuild}
179 LINUX_VERSION=${kernsrcver}
183 AC_SUBST(LINUX_VERSION)
185 SPL_AC_MODULE_SYMVERS
189 dnl # Default SPL user configuration
191 AC_DEFUN([SPL_AC_CONFIG_USER], [])
194 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
195 dnl # are missing, it is non-fatal, but you will not be able to build
196 dnl # RPM packages and will be warned if you try too.
198 dnl # By default, the generic spec file will be used because it requires
199 dnl # minimal dependencies. Distribution specific spec files can be
200 dnl # placed under the 'rpm/<distribution>' directory and enabled using
201 dnl # the --with-spec=<distribution> configure option.
203 AC_DEFUN([SPL_AC_RPM], [
207 AC_MSG_CHECKING([whether $RPM is available])
208 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
209 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
211 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
214 AC_MSG_RESULT([$HAVE_RPM])
217 AC_MSG_CHECKING([whether $RPMBUILD is available])
218 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
219 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
221 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
224 AC_MSG_RESULT([$HAVE_RPMBUILD])
227 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
229 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
232 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
237 RPM_SPEC_DIR="rpm/generic"
239 AS_HELP_STRING([--with-spec=SPEC],
240 [Spec files 'generic|redhat']),
241 [RPM_SPEC_DIR="rpm/$withval"])
243 AC_MSG_CHECKING([whether spec files are available])
244 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
248 AC_SUBST(RPM_VERSION)
250 AC_SUBST(HAVE_RPMBUILD)
252 AC_SUBST(RPMBUILD_VERSION)
254 AC_SUBST(RPM_SPEC_DIR)
255 AC_SUBST(RPM_DEFINE_UTIL)
256 AC_SUBST(RPM_DEFINE_KMOD)
257 AC_SUBST(RPM_DEFINE_DKMS)
258 AC_SUBST(RPM_DEFINE_COMMON)
259 AC_SUBST(SRPM_DEFINE_UTIL)
260 AC_SUBST(SRPM_DEFINE_KMOD)
261 AC_SUBST(SRPM_DEFINE_DKMS)
262 AC_SUBST(SRPM_DEFINE_COMMON)
266 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
267 dnl # tools are missing it is non-fatal but you will not be able to build
268 dnl # DEB packages and will be warned if you try too.
270 AC_DEFUN([SPL_AC_DPKG], [
272 DPKGBUILD=dpkg-buildpackage
274 AC_MSG_CHECKING([whether $DPKG is available])
275 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
276 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
278 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
281 AC_MSG_RESULT([$HAVE_DPKG])
284 AC_MSG_CHECKING([whether $DPKGBUILD is available])
285 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
286 DPKGBUILD_VERSION=$(echo $tmp | \
287 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
289 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
292 AC_MSG_RESULT([$HAVE_DPKGBUILD])
297 AC_SUBST(DPKG_VERSION)
299 AC_SUBST(HAVE_DPKGBUILD)
301 AC_SUBST(DPKGBUILD_VERSION)
305 dnl # Until native packaging for various different packing systems
306 dnl # can be added the least we can do is attempt to use alien to
307 dnl # convert the RPM packages to the needed package type. This is
308 dnl # a hack but so far it has worked reasonable well.
310 AC_DEFUN([SPL_AC_ALIEN], [
313 AC_MSG_CHECKING([whether $ALIEN is available])
314 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
315 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
317 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
320 AC_MSG_RESULT([$HAVE_ALIEN])
325 AC_SUBST(ALIEN_VERSION)
329 dnl # Using the VENDOR tag from config.guess set the default
330 dnl # package type for 'make pkg': (rpm | deb | tgz)
332 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
333 AC_MSG_CHECKING([linux distribution])
334 if test -f /etc/toss-release ; then
336 elif test -f /etc/fedora-release ; then
338 elif test -f /etc/redhat-release ; then
340 elif test -f /etc/gentoo-release ; then
342 elif test -f /etc/arch-release ; then
344 elif test -f /etc/SuSE-release ; then
346 elif test -f /etc/slackware-version ; then
348 elif test -f /etc/lunar.release ; then
350 elif test -f /etc/lsb-release ; then
352 elif test -f /etc/debian_version ; then
357 AC_MSG_RESULT([$VENDOR])
360 AC_MSG_CHECKING([default package type])
362 toss) DEFAULT_PACKAGE=rpm ;;
363 redhat) DEFAULT_PACKAGE=rpm ;;
364 fedora) DEFAULT_PACKAGE=rpm ;;
365 gentoo) DEFAULT_PACKAGE=tgz ;;
366 arch) DEFAULT_PACKAGE=tgz ;;
367 sles) DEFAULT_PACKAGE=rpm ;;
368 slackware) DEFAULT_PACKAGE=tgz ;;
369 lunar) DEFAULT_PACKAGE=tgz ;;
370 ubuntu) DEFAULT_PACKAGE=deb ;;
371 debian) DEFAULT_PACKAGE=deb ;;
372 *) DEFAULT_PACKAGE=rpm ;;
375 AC_MSG_RESULT([$DEFAULT_PACKAGE])
376 AC_SUBST(DEFAULT_PACKAGE)
380 dnl # Default SPL user configuration
382 AC_DEFUN([SPL_AC_PACKAGE], [
383 SPL_AC_DEFAULT_PACKAGE
389 AC_DEFUN([SPL_AC_LICENSE], [
390 AC_MSG_CHECKING([spl author])
391 AC_MSG_RESULT([$SPL_META_AUTHOR])
393 AC_MSG_CHECKING([spl license])
394 AC_MSG_RESULT([$SPL_META_LICENSE])
397 AC_DEFUN([SPL_AC_CONFIG], [
399 AC_ARG_WITH([config],
400 AS_HELP_STRING([--with-config=CONFIG],
401 [Config file 'kernel|user|all|srpm']),
402 [SPL_CONFIG="$withval"])
403 AC_ARG_ENABLE([linux-builtin],
404 [AC_HELP_STRING([--enable-linux-builtin],
405 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
407 [enable_linux_builtin=no])
409 AC_MSG_CHECKING([spl config])
410 AC_MSG_RESULT([$SPL_CONFIG]);
413 case "$SPL_CONFIG" in
414 kernel) SPL_AC_CONFIG_KERNEL ;;
415 user) SPL_AC_CONFIG_USER ;;
416 all) SPL_AC_CONFIG_KERNEL
417 SPL_AC_CONFIG_USER ;;
420 AC_MSG_RESULT([Error!])
421 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
422 user kernel|user|all|srpm]) ;;
425 AM_CONDITIONAL([CONFIG_USER],
426 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
427 AM_CONDITIONAL([CONFIG_KERNEL],
428 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
429 [test "x$enable_linux_builtin" != xyes ])
433 dnl # Enable if the SPL should be compiled with internal debugging enabled.
434 dnl # By default this support is disabled.
436 AC_DEFUN([SPL_AC_DEBUG], [
437 AC_MSG_CHECKING([whether debugging is enabled])
438 AC_ARG_ENABLE([debug],
439 [AS_HELP_STRING([--enable-debug],
440 [Enable generic debug support @<:@default=no@:>@])],
444 AS_IF([test "x$enable_debug" = xyes],
446 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
447 DEBUG_CFLAGS="-DDEBUG -Werror"
448 DEBUG_SPL="_with_debug"
450 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
451 DEBUG_CFLAGS="-DNDEBUG"
452 DEBUG_SPL="_without_debug"
455 AC_SUBST(DEBUG_CFLAGS)
457 AC_MSG_RESULT([$enable_debug])
461 dnl # Enabled by default it provides a minimal level of memory tracking.
462 dnl # A total count of bytes allocated is kept for each alloc and free.
463 dnl # Then at module unload time a report to the console will be printed
464 dnl # if memory was leaked.
466 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
467 AC_ARG_ENABLE([debug-kmem],
468 [AS_HELP_STRING([--enable-debug-kmem],
469 [Enable basic kmem accounting @<:@default=no@:>@])],
471 [enable_debug_kmem=no])
473 AS_IF([test "x$enable_debug_kmem" = xyes],
475 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
476 DEBUG_KMEM="_with_debug_kmem"
477 AC_DEFINE([DEBUG_KMEM], [1],
478 [Define to 1 to enable basic kmem accounting])
480 DEBUG_KMEM="_without_debug_kmem"
484 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
485 AC_MSG_RESULT([$enable_debug_kmem])
489 dnl # Disabled by default it provides detailed memory tracking. This
490 dnl # feature also requires --enable-debug-kmem to be set. When enabled
491 dnl # not only will total bytes be tracked but also the location of every
492 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
493 dnl # addresses and where they were allocated will be dumped to the console.
494 dnl # Enabling this feature has a significant impact on performance but it
495 dnl # makes finding memory leaks pretty straight forward.
497 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
498 AC_ARG_ENABLE([debug-kmem-tracking],
499 [AS_HELP_STRING([--enable-debug-kmem-tracking],
500 [Enable detailed kmem tracking @<:@default=no@:>@])],
502 [enable_debug_kmem_tracking=no])
504 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
506 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
507 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
508 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
509 [Define to 1 to enable detailed kmem tracking])
511 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
514 AC_SUBST(DEBUG_KMEM_TRACKING)
515 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
516 AC_MSG_RESULT([$enable_debug_kmem_tracking])
520 dnl # SPL_LINUX_CONFTEST
522 AC_DEFUN([SPL_LINUX_CONFTEST], [
523 cat confdefs.h - <<_ACEOF >conftest.c
529 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
531 m4_define([SPL_LANG_PROGRAM], [
536 dnl Do *not* indent the following line: there may be CPP directives.
537 dnl Don't move the `;' right after for the same reason.
545 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
547 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
548 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
549 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
550 echo "obj-m := conftest.o" >build/Makefile
552 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
554 [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])],
556 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
562 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
564 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
565 [SPL_LINUX_COMPILE_IFELSE(
566 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
568 [test -s build/conftest.o],
573 dnl # SPL_CHECK_SYMBOL_EXPORT
574 dnl # check symbol exported or not
576 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
577 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
578 $LINUX_OBJ/Module*.symvers 2>/dev/null
580 if test $rc -ne 0; then
583 grep -q -E "EXPORT_SYMBOL.*($1)" \
584 "$LINUX_OBJ/$file" 2>/dev/null
586 if test $rc -eq 0; then
591 if test $export -eq 0; then :
602 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
603 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
604 dnl # is called if not compiling for builtin
606 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
607 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
608 if test $rc -ne 0; then :
611 if test "x$enable_linux_builtin" != xyes; then
612 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
614 if test $rc -ne 0; then :
623 dnl # SPL_CHECK_SYMBOL_HEADER
624 dnl # check if a symbol prototype is defined in listed headers.
626 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
627 AC_MSG_CHECKING([whether symbol $1 exists in header])
630 grep -q "$2" "$LINUX/$file" 2>/dev/null
632 if test $rc -eq 0; then
637 if test $header -eq 0; then
647 dnl # SPL_CHECK_HEADER
648 dnl # check whether header exists and define HAVE_$2_HEADER
650 AC_DEFUN([SPL_CHECK_HEADER],
651 [AC_MSG_CHECKING([whether header $1 exists])
652 SPL_LINUX_TRY_COMPILE([
657 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
667 dnl # Basic toolchain sanity check. Verify that kernel modules can
668 dnl # be built and which symbols can be used.
670 AC_DEFUN([SPL_AC_TEST_MODULE],
671 [AC_MSG_CHECKING([whether modules can be built])
672 SPL_LINUX_TRY_COMPILE([],[],[
676 if test "x$enable_linux_builtin" != xyes; then
677 AC_MSG_ERROR([*** Unable to build an empty module.])
680 *** Unable to build an empty module.
681 *** Please run 'make scripts' inside the kernel source tree.])
685 AS_IF([test "x$cross_compiling" != xyes], [
688 #include "$LINUX/include/linux/license.h"
690 return !license_is_gpl_compatible(
691 "$SPL_META_LICENSE");
694 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
695 [Define to 1 if GPL-only symbols can be used])
702 dnl # Use the atomic implemenation based on global spinlocks. This
703 dnl # should only be needed by 32-bit kernels which do not provide
704 dnl # the atomic64_* API. It may be optionally enabled as a fallback
705 dnl # if problems are observed with the direct mapping to the native
706 dnl # Linux atomic operations. You may not disable atomic spinlocks
707 dnl # if you kernel does not an atomic64_* API.
709 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
710 AC_ARG_ENABLE([atomic-spinlocks],
711 [AS_HELP_STRING([--enable-atomic-spinlocks],
712 [Atomic types use spinlocks @<:@default=check@:>@])],
714 [enable_atomic_spinlocks=check])
716 SPL_LINUX_TRY_COMPILE([
717 #include <linux/fs.h>
719 atomic64_t *ptr __attribute__ ((unused));
722 AC_DEFINE(HAVE_ATOMIC64_T, 1,
723 [kernel defines atomic64_t])
728 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
729 AS_IF([test "x$have_atomic64_t" = xyes], [
730 enable_atomic_spinlocks=no
732 enable_atomic_spinlocks=yes
736 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
737 AC_DEFINE([ATOMIC_SPINLOCK], [1],
738 [Atomic types use spinlocks])
740 AS_IF([test "x$have_atomic64_t" = xno], [
742 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
746 AC_MSG_CHECKING([whether atomic types use spinlocks])
747 AC_MSG_RESULT([$enable_atomic_spinlocks])
749 AC_MSG_CHECKING([whether kernel defines atomic64_t])
750 AC_MSG_RESULT([$have_atomic64_t])
753 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
754 tmp_flags="$EXTRA_KCFLAGS"
755 EXTRA_KCFLAGS="-Werror"
757 dnl # 2.6.23 to 2.6.34 API change
758 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
760 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
761 SPL_LINUX_TRY_COMPILE([
762 #include <linux/mm.h>
764 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
766 struct shrinker cache_shrinker = {
767 .shrink = shrinker_cb,
768 .seeks = DEFAULT_SEEKS,
770 register_shrinker(&cache_shrinker);
773 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
774 [old shrinker callback wants 2 args])
778 dnl # 2.6.35 - 2.6.39 API change
779 dnl # ->shrink(struct shrinker *,
780 dnl # int nr_to_scan, gfp_t gfp_mask)
782 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
783 SPL_LINUX_TRY_COMPILE([
784 #include <linux/mm.h>
786 int shrinker_cb(struct shrinker *, int nr_to_scan,
789 struct shrinker cache_shrinker = {
790 .shrink = shrinker_cb,
791 .seeks = DEFAULT_SEEKS,
793 register_shrinker(&cache_shrinker);
796 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
797 [old shrinker callback wants 3 args])
801 dnl # 3.0 - 3.11 API change
802 dnl # ->shrink(struct shrinker *,
803 dnl # struct shrink_control *sc)
806 [whether new 2-argument shrinker exists])
807 SPL_LINUX_TRY_COMPILE([
808 #include <linux/mm.h>
810 int shrinker_cb(struct shrinker *,
811 struct shrink_control *sc);
813 struct shrinker cache_shrinker = {
814 .shrink = shrinker_cb,
815 .seeks = DEFAULT_SEEKS,
817 register_shrinker(&cache_shrinker);
820 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
821 [new shrinker callback wants 2 args])
825 dnl # 3.12 API change,
826 dnl # ->shrink() is logically split in to
827 dnl # ->count_objects() and ->scan_objects()
830 [whether ->count_objects callback exists])
831 SPL_LINUX_TRY_COMPILE([
832 #include <linux/mm.h>
834 unsigned long shrinker_cb(
836 struct shrink_control *sc);
838 struct shrinker cache_shrinker = {
839 .count_objects = shrinker_cb,
840 .scan_objects = shrinker_cb,
841 .seeks = DEFAULT_SEEKS,
843 register_shrinker(&cache_shrinker);
846 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
847 1, [->count_objects exists])
854 EXTRA_KCFLAGS="$tmp_flags"
858 dnl # 2.6.33 API change,
859 dnl # Removed .ctl_name from struct ctl_table.
861 AC_DEFUN([SPL_AC_CTL_NAME], [
862 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
863 SPL_LINUX_TRY_COMPILE([
864 #include <linux/sysctl.h>
866 struct ctl_table ctl __attribute__ ((unused));
870 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
877 dnl # 3.10 API change,
878 dnl # PDE is replaced by PDE_DATA
880 AC_DEFUN([SPL_AC_PDE_DATA], [
881 AC_MSG_CHECKING([whether PDE_DATA() is available])
882 SPL_LINUX_TRY_COMPILE_SYMBOL([
883 #include <linux/proc_fs.h>
888 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
896 dnl # set_fs_pwd takes const struct path *
898 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
899 tmp_flags="$EXTRA_KCFLAGS"
900 EXTRA_KCFLAGS="-Werror"
901 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
902 SPL_LINUX_TRY_COMPILE([
903 #include <linux/spinlock.h>
904 #include <linux/fs_struct.h>
905 #include <linux/path.h>
906 void (*const set_fs_pwd_func)
907 (struct fs_struct *, const struct path *)
913 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
914 [set_fs_pwd() needs const path *])
916 SPL_LINUX_TRY_COMPILE([
917 #include <linux/spinlock.h>
918 #include <linux/fs_struct.h>
919 #include <linux/path.h>
920 void (*const set_fs_pwd_func)
921 (struct fs_struct *, struct path *)
928 AC_MSG_ERROR(unknown)
931 EXTRA_KCFLAGS="$tmp_flags"
935 dnl # 3.13 API change
936 dnl # vfs_unlink() updated to take a third delegated_inode argument.
938 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
939 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
940 SPL_LINUX_TRY_COMPILE([
941 #include <linux/fs.h>
943 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
946 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
947 [vfs_unlink() wants 2 args])
951 dnl # Linux 3.13 API change
952 dnl # Added delegated inode
954 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
955 SPL_LINUX_TRY_COMPILE([
956 #include <linux/fs.h>
958 vfs_unlink((struct inode *) NULL,
959 (struct dentry *) NULL,
960 (struct inode **) NULL);
963 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
964 [vfs_unlink() wants 3 args])
973 dnl # 3.13 and 3.15 API changes
974 dnl # Added delegated inode and flags argument.
976 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
977 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
978 SPL_LINUX_TRY_COMPILE([
979 #include <linux/fs.h>
981 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
982 (struct inode *) NULL, (struct dentry *) NULL);
985 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
986 [vfs_rename() wants 4 args])
990 dnl # Linux 3.13 API change
991 dnl # Added delegated inode
993 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
994 SPL_LINUX_TRY_COMPILE([
995 #include <linux/fs.h>
997 vfs_rename((struct inode *) NULL,
998 (struct dentry *) NULL,
999 (struct inode *) NULL,
1000 (struct dentry *) NULL,
1001 (struct inode **) NULL);
1004 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1005 [vfs_rename() wants 5 args])
1009 dnl # Linux 3.15 API change
1012 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1013 SPL_LINUX_TRY_COMPILE([
1014 #include <linux/fs.h>
1016 vfs_rename((struct inode *) NULL,
1017 (struct dentry *) NULL,
1018 (struct inode *) NULL,
1019 (struct dentry *) NULL,
1020 (struct inode **) NULL,
1024 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1025 [vfs_rename() wants 6 args])
1034 dnl # 2.6.36 API change,
1035 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1036 dnl # a spinlock_t to improve the fastpath performance.
1038 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1039 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1040 tmp_flags="$EXTRA_KCFLAGS"
1041 EXTRA_KCFLAGS="-Werror"
1042 SPL_LINUX_TRY_COMPILE([
1043 #include <linux/sched.h>
1044 #include <linux/fs_struct.h>
1046 static struct fs_struct fs;
1047 spin_lock_init(&fs.lock);
1050 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1051 [struct fs_struct uses spinlock_t])
1055 EXTRA_KCFLAGS="$tmp_flags"
1059 dnl # User namespaces, use kuid_t in place of uid_t
1060 dnl # where available. Not strictly a user namespaces thing
1061 dnl # but it should prevent surprises
1063 AC_DEFUN([SPL_AC_KUIDGID_T], [
1064 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1065 SPL_LINUX_TRY_COMPILE([
1066 #include <linux/uidgid.h>
1068 kuid_t userid = KUIDT_INIT(0);
1069 kgid_t groupid = KGIDT_INIT(0);
1071 SPL_LINUX_TRY_COMPILE([
1072 #include <linux/uidgid.h>
1077 AC_MSG_RESULT(yes; optional)
1079 AC_MSG_RESULT(yes; mandatory)
1080 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1088 dnl # 2.6.39 API change,
1089 dnl # __put_task_struct() was exported by the mainline kernel.
1091 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1092 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1093 SPL_LINUX_TRY_COMPILE_SYMBOL([
1094 #include <linux/sched.h>
1096 __put_task_struct(NULL);
1097 ], [__put_task_struct], [], [
1099 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1100 [__put_task_struct() is available])
1107 dnl # 2.6.35 API change,
1108 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1110 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1111 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1112 SPL_LINUX_TRY_COMPILE([
1113 #include <linux/fs.h>
1118 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1125 dnl # 3.5 API change,
1126 dnl # inode_operations.truncate_range removed
1128 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1129 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1130 SPL_LINUX_TRY_COMPILE([
1131 #include <linux/fs.h>
1133 struct inode_operations ops;
1134 ops.truncate_range = NULL;
1137 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1138 [truncate_range() inode operation is available])
1145 dnl # Linux 2.6.38 - 3.x API
1147 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1148 AC_MSG_CHECKING([whether fops->fallocate() exists])
1149 SPL_LINUX_TRY_COMPILE([
1150 #include <linux/fs.h>
1152 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1153 struct file_operations fops __attribute__ ((unused)) = {
1154 .fallocate = fallocate,
1158 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1165 dnl # Linux 2.6.x - 2.6.37 API
1167 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1168 AC_MSG_CHECKING([whether iops->fallocate() exists])
1169 SPL_LINUX_TRY_COMPILE([
1170 #include <linux/fs.h>
1172 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1173 struct inode_operations fops __attribute__ ((unused)) = {
1174 .fallocate = fallocate,
1178 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1185 dnl # PaX Linux 2.6.38 - 3.x API
1187 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1188 AC_MSG_CHECKING([whether fops->fallocate() exists])
1189 SPL_LINUX_TRY_COMPILE([
1190 #include <linux/fs.h>
1192 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1193 struct file_operations_no_const fops __attribute__ ((unused)) = {
1194 .fallocate = fallocate,
1198 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1205 dnl # The fallocate callback was moved from the inode_operations
1206 dnl # structure to the file_operations structure.
1208 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1209 SPL_AC_KERNEL_FILE_FALLOCATE
1210 SPL_AC_KERNEL_INODE_FALLOCATE
1211 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1215 dnl # zlib inflate compat,
1216 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1218 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1219 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1220 SPL_LINUX_TRY_COMPILE([
1221 #if !defined(CONFIG_ZLIB_INFLATE) && \
1222 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1223 #error CONFIG_ZLIB_INFLATE not defined
1226 AC_MSG_RESULT([yes])
1230 *** This kernel does not include the required zlib inflate support.
1231 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1236 dnl # zlib deflate compat,
1237 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1239 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1240 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1241 SPL_LINUX_TRY_COMPILE([
1242 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1243 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1244 #error CONFIG_ZLIB_DEFLATE not defined
1247 AC_MSG_RESULT([yes])
1251 *** This kernel does not include the required zlib deflate support.
1252 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1257 dnl # config trim unused symbols,
1258 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1260 AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1261 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1262 SPL_LINUX_TRY_COMPILE([
1263 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1264 #error CONFIG_TRIM_UNUSED_KSYMS not defined
1267 AC_MSG_RESULT([yes])
1271 *** This kernel has unused symbols trimming enabled, please disable.
1272 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1277 dnl # 2.6.39 API compat,
1278 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1279 dnl # This was done to avoid always having to allocate the maximum size
1280 dnl # workspace (268K). The caller can now specific the windowBits and
1281 dnl # memLevel compression parameters to get a smaller workspace.
1283 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1284 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1285 SPL_LINUX_TRY_COMPILE([
1286 #include <linux/zlib.h>
1288 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1291 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1292 [zlib_deflate_workspacesize() wants 2 args])
1299 dnl # 2.6.39 API change,
1300 dnl # Shrinker adjust to use common shrink_control structure.
1302 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1303 AC_MSG_CHECKING([whether struct shrink_control exists])
1304 SPL_LINUX_TRY_COMPILE([
1305 #include <linux/mm.h>
1307 struct shrink_control sc __attribute__ ((unused));
1310 sc.gfp_mask = GFP_KERNEL;
1313 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1314 [struct shrink_control exists])
1321 dnl # 3.1 API Change
1323 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1324 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1326 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1327 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1328 tmp_flags="$EXTRA_KCFLAGS"
1329 EXTRA_KCFLAGS="-Werror"
1330 SPL_LINUX_TRY_COMPILE([
1331 #include <linux/rwsem.h>
1333 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1334 raw_spinlock_t dummy_lock __attribute__ ((unused));
1335 dummy_semaphore.wait_lock = dummy_lock;
1338 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1339 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1343 EXTRA_KCFLAGS="$tmp_flags"
1347 dnl # 3.16 API Change
1349 dnl # rwsem-spinlock "->activity" changed to "->count"
1351 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1352 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1353 tmp_flags="$EXTRA_KCFLAGS"
1354 EXTRA_KCFLAGS="-Werror"
1355 SPL_LINUX_TRY_COMPILE([
1356 #include <linux/rwsem.h>
1358 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1359 dummy_semaphore.activity = 0;
1362 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1363 [struct rw_semaphore has member activity])
1367 EXTRA_KCFLAGS="$tmp_flags"
1371 dnl # 4.8 API Change
1373 dnl # rwsem "->count" changed to atomic_long_t type
1375 AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1377 [whether struct rw_semaphore has atomic_long_t member count])
1378 tmp_flags="$EXTRA_KCFLAGS"
1379 EXTRA_KCFLAGS="-Werror"
1380 SPL_LINUX_TRY_COMPILE([
1381 #include <linux/rwsem.h>
1383 DECLARE_RWSEM(dummy_semaphore);
1384 (void) atomic_long_read(&dummy_semaphore.count);
1387 AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1388 [struct rw_semaphore has atomic_long_t member count])
1392 EXTRA_KCFLAGS="$tmp_flags"
1396 dnl # 3.9 API change,
1397 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1399 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1400 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1401 SPL_LINUX_TRY_COMPILE([
1402 #include <linux/sched.h>
1403 #include <linux/sched/rt.h>
1407 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1416 dnl # 4.11 API, a528d35e@torvalds/linux
1417 dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1419 AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1420 AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1421 SPL_LINUX_TRY_COMPILE([
1422 #include <linux/fs.h>
1424 vfs_getattr((const struct path *)NULL,
1425 (struct kstat *)NULL,
1430 AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1431 [vfs_getattr wants 4 args])
1439 dnl # vfs_getattr(struct path *p, struct kstat *s)
1441 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1442 AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1443 SPL_LINUX_TRY_COMPILE([
1444 #include <linux/fs.h>
1446 vfs_getattr((struct path *) NULL,
1447 (struct kstat *)NULL);
1450 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1451 [vfs_getattr wants 2 args])
1459 dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1461 AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1462 AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1463 SPL_LINUX_TRY_COMPILE([
1464 #include <linux/fs.h>
1466 vfs_getattr((struct vfsmount *)NULL,
1467 (struct dentry *)NULL,
1468 (struct kstat *)NULL);
1471 AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1472 [vfs_getattr wants 3 args])
1479 dnl # 2.6.36 API compatibility.
1480 dnl # Added usleep_range timer.
1481 dnl # usleep_range is a finer precision implementation of msleep
1482 dnl # designed to be a drop-in replacement for udelay where a precise
1483 dnl # sleep / busy-wait is unnecessary.
1485 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1486 AC_MSG_CHECKING([whether usleep_range() is available])
1487 SPL_LINUX_TRY_COMPILE([
1488 #include <linux/delay.h>
1493 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1494 [usleep_range is available])
1501 dnl # 2.6.35 API change,
1502 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1503 dnl # private allocation flags which are applied when allocating a new slab
1504 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1505 dnl # non-default flags.
1507 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1508 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1509 SPL_LINUX_TRY_COMPILE([
1510 #include <linux/slab.h>
1512 struct kmem_cache cachep __attribute__ ((unused));
1513 cachep.allocflags = GFP_KERNEL;
1516 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1517 [struct kmem_cache has allocflags])
1521 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1522 SPL_LINUX_TRY_COMPILE([
1523 #include <linux/slab.h>
1525 struct kmem_cache cachep __attribute__ ((unused));
1526 cachep.gfpflags = GFP_KERNEL;
1529 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1530 [struct kmem_cache has gfpflags])
1538 dnl # 3.17 API change,
1539 dnl # wait_on_bit() no longer requires an action argument. The former
1540 dnl # "wait_on_bit" interface required an 'action' function to be provided
1541 dnl # which does the actual waiting. There were over 20 such functions in the
1542 dnl # kernel, many of them identical, though most cases can be satisfied by one
1543 dnl # of just two functions: one which uses io_schedule() and one which just
1544 dnl # uses schedule(). This API change was made to consolidate all of those
1545 dnl # redundant wait functions.
1547 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1548 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1549 SPL_LINUX_TRY_COMPILE([
1550 #include <linux/wait.h>
1552 int (*action)(void *) = NULL;
1553 wait_on_bit(NULL, 0, action, 0);
1556 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1563 dnl # Check whether mutex has owner with task_struct type.
1565 dnl # Note that before Linux 3.0, mutex owner is of type thread_info.
1567 dnl # Note that in Linux 3.18, the condition for owner is changed from
1568 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to
1569 dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
1571 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1572 AC_MSG_CHECKING([whether mutex has owner])
1573 tmp_flags="$EXTRA_KCFLAGS"
1574 EXTRA_KCFLAGS="-Werror"
1575 SPL_LINUX_TRY_COMPILE([
1576 #include <linux/mutex.h>
1577 #include <linux/spinlock.h>
1580 struct task_struct *t __attribute__ ((unused));
1584 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes])
1588 EXTRA_KCFLAGS="$tmp_flags"
1592 dnl # 4.7 API change
1593 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1594 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1595 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1597 AC_DEFUN([SPL_AC_INODE_LOCK], [
1598 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1599 tmp_flags="$EXTRA_KCFLAGS"
1600 EXTRA_KCFLAGS="-Werror"
1601 SPL_LINUX_TRY_COMPILE([
1602 #include <linux/fs.h>
1604 struct inode *inode = NULL;
1605 inode_lock_shared(inode);
1608 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1612 EXTRA_KCFLAGS="$tmp_flags"
1616 dnl # 4.9 API change
1617 dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1619 AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1620 AC_MSG_CHECKING([whether group_info->gid exists])
1621 tmp_flags="$EXTRA_KCFLAGS"
1622 EXTRA_KCFLAGS="-Werror"
1623 SPL_LINUX_TRY_COMPILE([
1624 #include <linux/cred.h>
1626 struct group_info *gi = groups_alloc(1);
1627 gi->gid[0] = KGIDT_INIT(0);
1630 AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1634 EXTRA_KCFLAGS="$tmp_flags"
1638 dnl # grsecurity API change,
1639 dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
1640 dnl # kmem_cache_create_usercopy().
1642 AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
1643 AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
1644 tmp_flags="$EXTRA_KCFLAGS"
1645 EXTRA_KCFLAGS="-Werror"
1646 SPL_LINUX_TRY_COMPILE([
1647 #include <linux/slab.h>
1648 static void ctor(void *foo)
1653 struct kmem_cache *skc_linux_cache;
1654 const char *name = "test";
1657 unsigned long flags = 0;
1658 size_t useroffset = 0;
1659 size_t usersize = size - useroffset;
1661 skc_linux_cache = kmem_cache_create_usercopy(
1662 name, size, align, flags, useroffset, usersize, ctor);
1665 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
1666 [kmem_cache_create_usercopy() exists])
1670 EXTRA_KCFLAGS="$tmp_flags"