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_FSYNC
31 SPL_AC_INODE_TRUNCATE_RANGE
32 SPL_AC_FS_STRUCT_SPINLOCK
34 SPL_AC_KERNEL_FALLOCATE
35 SPL_AC_CONFIG_ZLIB_INFLATE
36 SPL_AC_CONFIG_ZLIB_DEFLATE
37 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
38 SPL_AC_SHRINK_CONTROL_STRUCT
39 SPL_AC_RWSEM_SPINLOCK_IS_RAW
41 SPL_AC_RWSEM_ATOMIC_LONG_COUNT
42 SPL_AC_SCHED_RT_HEADER
43 SPL_AC_SCHED_SIGNAL_HEADER
44 SPL_AC_4ARGS_VFS_GETATTR
45 SPL_AC_3ARGS_VFS_GETATTR
46 SPL_AC_2ARGS_VFS_GETATTR
48 SPL_AC_KMEM_CACHE_ALLOCFLAGS
52 SPL_AC_KMEM_CACHE_CREATE_USERCOPY
53 SPL_AC_WAIT_QUEUE_ENTRY_T
54 SPL_AC_WAIT_QUEUE_HEAD_ENTRY
57 SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
60 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
61 modpost=$LINUX/scripts/Makefile.modpost
62 AC_MSG_CHECKING([kernel file name for module symbols])
63 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
64 if grep -q Modules.symvers $modpost; then
65 LINUX_SYMBOLS=Modules.symvers
67 LINUX_SYMBOLS=Module.symvers
70 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
72 *** Please make sure the kernel devel package for your distribution
73 *** is installed. If you are building with a custom kernel, make sure the
74 *** kernel is configured, built, and the '--with-linux=PATH' configure
75 *** option refers to the location of the kernel source.])
80 AC_MSG_RESULT($LINUX_SYMBOLS)
81 AC_SUBST(LINUX_SYMBOLS)
84 AC_DEFUN([SPL_AC_KERNEL], [
86 AS_HELP_STRING([--with-linux=PATH],
87 [Path to kernel source]),
88 [kernelsrc="$withval"])
90 AC_ARG_WITH([linux-obj],
91 AS_HELP_STRING([--with-linux-obj=PATH],
92 [Path to kernel build objects]),
93 [kernelbuild="$withval"])
95 AC_MSG_CHECKING([kernel source directory])
96 if test -z "$kernelsrc"; then
97 if test -e "/lib/modules/$(uname -r)/source"; then
98 headersdir="/lib/modules/$(uname -r)/source"
99 sourcelink=$(readlink -f "$headersdir")
100 elif test -e "/lib/modules/$(uname -r)/build"; then
101 headersdir="/lib/modules/$(uname -r)/build"
102 sourcelink=$(readlink -f "$headersdir")
104 sourcelink=$(ls -1d /usr/src/kernels/* \
106 2>/dev/null | grep -v obj | tail -1)
109 if test -n "$sourcelink" && test -e ${sourcelink}; then
110 kernelsrc=`readlink -f ${sourcelink}`
112 kernelsrc="[Not found]"
115 if test "$kernelsrc" = "NONE"; then
121 AC_MSG_RESULT([$kernelsrc])
122 if test ! -d "$kernelsrc"; then
124 *** Please make sure the kernel devel package for your distribution
125 *** is installed and then try again. If that fails, you can specify the
126 *** location of the kernel source with the '--with-linux=PATH' option.])
129 AC_MSG_CHECKING([kernel build directory])
130 if test -z "$kernelbuild"; then
131 if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then
132 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
133 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
134 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
135 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
136 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
137 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
138 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
140 kernelbuild=${kernelsrc}
143 AC_MSG_RESULT([$kernelbuild])
145 AC_MSG_CHECKING([kernel source version])
146 utsrelease1=$kernelbuild/include/linux/version.h
147 utsrelease2=$kernelbuild/include/linux/utsrelease.h
148 utsrelease3=$kernelbuild/include/generated/utsrelease.h
149 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
150 utsrelease=linux/version.h
151 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
152 utsrelease=linux/utsrelease.h
153 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
154 utsrelease=generated/utsrelease.h
157 if test "$utsrelease"; then
158 kernsrcver=`(echo "#include <$utsrelease>";
159 echo "kernsrcver=UTS_RELEASE") |
160 cpp -I $kernelbuild/include |
161 grep "^kernsrcver=" | cut -d \" -f 2`
163 if test -z "$kernsrcver"; then
164 AC_MSG_RESULT([Not found])
165 AC_MSG_ERROR([*** Cannot determine kernel version.])
168 AC_MSG_RESULT([Not found])
169 if test "x$enable_linux_builtin" != xyes; then
170 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
173 *** Cannot find UTS_RELEASE definition.
174 *** Please run 'make prepare' inside the kernel source tree.])
178 AC_MSG_RESULT([$kernsrcver])
181 LINUX_OBJ=${kernelbuild}
182 LINUX_VERSION=${kernsrcver}
186 AC_SUBST(LINUX_VERSION)
188 SPL_AC_MODULE_SYMVERS
192 dnl # Default SPL user configuration
194 AC_DEFUN([SPL_AC_CONFIG_USER], [])
197 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
198 dnl # are missing, it is non-fatal, but you will not be able to build
199 dnl # RPM packages and will be warned if you try too.
201 dnl # By default, the generic spec file will be used because it requires
202 dnl # minimal dependencies. Distribution specific spec files can be
203 dnl # placed under the 'rpm/<distribution>' directory and enabled using
204 dnl # the --with-spec=<distribution> configure option.
206 AC_DEFUN([SPL_AC_RPM], [
210 AC_MSG_CHECKING([whether $RPM is available])
211 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
212 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
214 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
217 AC_MSG_RESULT([$HAVE_RPM])
220 AC_MSG_CHECKING([whether $RPMBUILD is available])
221 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
222 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
224 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
227 AC_MSG_RESULT([$HAVE_RPMBUILD])
230 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
232 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
235 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
240 RPM_SPEC_DIR="rpm/generic"
242 AS_HELP_STRING([--with-spec=SPEC],
243 [Spec files 'generic|redhat']),
244 [RPM_SPEC_DIR="rpm/$withval"])
246 AC_MSG_CHECKING([whether spec files are available])
247 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
251 AC_SUBST(RPM_VERSION)
253 AC_SUBST(HAVE_RPMBUILD)
255 AC_SUBST(RPMBUILD_VERSION)
257 AC_SUBST(RPM_SPEC_DIR)
258 AC_SUBST(RPM_DEFINE_UTIL)
259 AC_SUBST(RPM_DEFINE_KMOD)
260 AC_SUBST(RPM_DEFINE_DKMS)
261 AC_SUBST(RPM_DEFINE_COMMON)
262 AC_SUBST(SRPM_DEFINE_UTIL)
263 AC_SUBST(SRPM_DEFINE_KMOD)
264 AC_SUBST(SRPM_DEFINE_DKMS)
265 AC_SUBST(SRPM_DEFINE_COMMON)
269 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
270 dnl # tools are missing it is non-fatal but you will not be able to build
271 dnl # DEB packages and will be warned if you try too.
273 AC_DEFUN([SPL_AC_DPKG], [
275 DPKGBUILD=dpkg-buildpackage
277 AC_MSG_CHECKING([whether $DPKG is available])
278 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
279 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
281 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
284 AC_MSG_RESULT([$HAVE_DPKG])
287 AC_MSG_CHECKING([whether $DPKGBUILD is available])
288 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
289 DPKGBUILD_VERSION=$(echo $tmp | \
290 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
292 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
295 AC_MSG_RESULT([$HAVE_DPKGBUILD])
300 AC_SUBST(DPKG_VERSION)
302 AC_SUBST(HAVE_DPKGBUILD)
304 AC_SUBST(DPKGBUILD_VERSION)
308 dnl # Until native packaging for various different packing systems
309 dnl # can be added the least we can do is attempt to use alien to
310 dnl # convert the RPM packages to the needed package type. This is
311 dnl # a hack but so far it has worked reasonable well.
313 AC_DEFUN([SPL_AC_ALIEN], [
316 AC_MSG_CHECKING([whether $ALIEN is available])
317 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
318 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
320 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
323 AC_MSG_RESULT([$HAVE_ALIEN])
328 AC_SUBST(ALIEN_VERSION)
332 dnl # Using the VENDOR tag from config.guess set the default
333 dnl # package type for 'make pkg': (rpm | deb | tgz)
335 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
336 AC_MSG_CHECKING([linux distribution])
337 if test -f /etc/toss-release ; then
339 elif test -f /etc/fedora-release ; then
341 elif test -f /etc/redhat-release ; then
343 elif test -f /etc/gentoo-release ; then
345 elif test -f /etc/arch-release ; then
347 elif test -f /etc/SuSE-release ; then
349 elif test -f /etc/slackware-version ; then
351 elif test -f /etc/lunar.release ; then
353 elif test -f /etc/lsb-release ; then
355 elif test -f /etc/debian_version ; then
360 AC_MSG_RESULT([$VENDOR])
363 AC_MSG_CHECKING([default package type])
365 toss) DEFAULT_PACKAGE=rpm ;;
366 redhat) DEFAULT_PACKAGE=rpm ;;
367 fedora) DEFAULT_PACKAGE=rpm ;;
368 gentoo) DEFAULT_PACKAGE=tgz ;;
369 arch) DEFAULT_PACKAGE=tgz ;;
370 sles) DEFAULT_PACKAGE=rpm ;;
371 slackware) DEFAULT_PACKAGE=tgz ;;
372 lunar) DEFAULT_PACKAGE=tgz ;;
373 ubuntu) DEFAULT_PACKAGE=deb ;;
374 debian) DEFAULT_PACKAGE=deb ;;
375 *) DEFAULT_PACKAGE=rpm ;;
378 AC_MSG_RESULT([$DEFAULT_PACKAGE])
379 AC_SUBST(DEFAULT_PACKAGE)
383 dnl # Default SPL user configuration
385 AC_DEFUN([SPL_AC_PACKAGE], [
386 SPL_AC_DEFAULT_PACKAGE
392 AC_DEFUN([SPL_AC_LICENSE], [
393 AC_MSG_CHECKING([spl author])
394 AC_MSG_RESULT([$SPL_META_AUTHOR])
396 AC_MSG_CHECKING([spl license])
397 AC_MSG_RESULT([$SPL_META_LICENSE])
400 AC_DEFUN([SPL_AC_CONFIG], [
402 AC_ARG_WITH([config],
403 AS_HELP_STRING([--with-config=CONFIG],
404 [Config file 'kernel|user|all|srpm']),
405 [SPL_CONFIG="$withval"])
406 AC_ARG_ENABLE([linux-builtin],
407 [AC_HELP_STRING([--enable-linux-builtin],
408 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
410 [enable_linux_builtin=no])
412 AC_MSG_CHECKING([spl config])
413 AC_MSG_RESULT([$SPL_CONFIG]);
416 case "$SPL_CONFIG" in
417 kernel) SPL_AC_CONFIG_KERNEL ;;
418 user) SPL_AC_CONFIG_USER ;;
419 all) SPL_AC_CONFIG_KERNEL
420 SPL_AC_CONFIG_USER ;;
423 AC_MSG_RESULT([Error!])
424 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
425 user kernel|user|all|srpm]) ;;
428 AM_CONDITIONAL([CONFIG_USER],
429 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
430 AM_CONDITIONAL([CONFIG_KERNEL],
431 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
432 [test "x$enable_linux_builtin" != xyes ])
436 dnl # Enable if the SPL should be compiled with internal debugging enabled.
437 dnl # By default this support is disabled.
439 AC_DEFUN([SPL_AC_DEBUG], [
440 AC_MSG_CHECKING([whether debugging is enabled])
441 AC_ARG_ENABLE([debug],
442 [AS_HELP_STRING([--enable-debug],
443 [Enable generic debug support @<:@default=no@:>@])],
447 AS_IF([test "x$enable_debug" = xyes],
449 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
450 DEBUG_CFLAGS="-DDEBUG -Werror"
451 DEBUG_SPL="_with_debug"
453 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
454 DEBUG_CFLAGS="-DNDEBUG"
455 DEBUG_SPL="_without_debug"
458 AC_SUBST(DEBUG_CFLAGS)
460 AC_MSG_RESULT([$enable_debug])
464 dnl # Enabled by default it provides a minimal level of memory tracking.
465 dnl # A total count of bytes allocated is kept for each alloc and free.
466 dnl # Then at module unload time a report to the console will be printed
467 dnl # if memory was leaked.
469 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
470 AC_ARG_ENABLE([debug-kmem],
471 [AS_HELP_STRING([--enable-debug-kmem],
472 [Enable basic kmem accounting @<:@default=no@:>@])],
474 [enable_debug_kmem=no])
476 AS_IF([test "x$enable_debug_kmem" = xyes],
478 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
479 DEBUG_KMEM="_with_debug_kmem"
480 AC_DEFINE([DEBUG_KMEM], [1],
481 [Define to 1 to enable basic kmem accounting])
483 DEBUG_KMEM="_without_debug_kmem"
487 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
488 AC_MSG_RESULT([$enable_debug_kmem])
492 dnl # Disabled by default it provides detailed memory tracking. This
493 dnl # feature also requires --enable-debug-kmem to be set. When enabled
494 dnl # not only will total bytes be tracked but also the location of every
495 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
496 dnl # addresses and where they were allocated will be dumped to the console.
497 dnl # Enabling this feature has a significant impact on performance but it
498 dnl # makes finding memory leaks pretty straight forward.
500 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
501 AC_ARG_ENABLE([debug-kmem-tracking],
502 [AS_HELP_STRING([--enable-debug-kmem-tracking],
503 [Enable detailed kmem tracking @<:@default=no@:>@])],
505 [enable_debug_kmem_tracking=no])
507 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
509 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
510 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
511 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
512 [Define to 1 to enable detailed kmem tracking])
514 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
517 AC_SUBST(DEBUG_KMEM_TRACKING)
518 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
519 AC_MSG_RESULT([$enable_debug_kmem_tracking])
523 dnl # SPL_LINUX_CONFTEST
525 AC_DEFUN([SPL_LINUX_CONFTEST], [
526 cat confdefs.h - <<_ACEOF >conftest.c
532 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
534 m4_define([SPL_LANG_PROGRAM], [
539 dnl Do *not* indent the following line: there may be CPP directives.
540 dnl Don't move the `;' right after for the same reason.
548 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
550 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
551 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
552 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
553 echo "obj-m := conftest.o" >build/Makefile
555 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
557 [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])],
559 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
565 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
567 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
568 [SPL_LINUX_COMPILE_IFELSE(
569 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
571 [test -s build/conftest.o],
576 dnl # SPL_CHECK_SYMBOL_EXPORT
577 dnl # check symbol exported or not
579 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
580 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
581 $LINUX_OBJ/Module*.symvers 2>/dev/null
583 if test $rc -ne 0; then
586 grep -q -E "EXPORT_SYMBOL.*($1)" \
587 "$LINUX_OBJ/$file" 2>/dev/null
589 if test $rc -eq 0; then
594 if test $export -eq 0; then :
605 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
606 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
607 dnl # is called if not compiling for builtin
609 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
610 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
611 if test $rc -ne 0; then :
614 if test "x$enable_linux_builtin" != xyes; then
615 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
617 if test $rc -ne 0; then :
626 dnl # SPL_CHECK_SYMBOL_HEADER
627 dnl # check if a symbol prototype is defined in listed headers.
629 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
630 AC_MSG_CHECKING([whether symbol $1 exists in header])
633 grep -q "$2" "$LINUX/$file" 2>/dev/null
635 if test $rc -eq 0; then
640 if test $header -eq 0; then
650 dnl # SPL_CHECK_HEADER
651 dnl # check whether header exists and define HAVE_$2_HEADER
653 AC_DEFUN([SPL_CHECK_HEADER],
654 [AC_MSG_CHECKING([whether header $1 exists])
655 SPL_LINUX_TRY_COMPILE([
660 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
670 dnl # Basic toolchain sanity check. Verify that kernel modules can
671 dnl # be built and which symbols can be used.
673 AC_DEFUN([SPL_AC_TEST_MODULE],
674 [AC_MSG_CHECKING([whether modules can be built])
675 SPL_LINUX_TRY_COMPILE([],[],[
679 if test "x$enable_linux_builtin" != xyes; then
680 AC_MSG_ERROR([*** Unable to build an empty module.])
683 *** Unable to build an empty module.
684 *** Please run 'make scripts' inside the kernel source tree.])
688 AS_IF([test "x$cross_compiling" != xyes], [
691 #include "$LINUX/include/linux/license.h"
693 return !license_is_gpl_compatible(
694 "$SPL_META_LICENSE");
697 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
698 [Define to 1 if GPL-only symbols can be used])
705 dnl # Use the atomic implemenation based on global spinlocks. This
706 dnl # should only be needed by 32-bit kernels which do not provide
707 dnl # the atomic64_* API. It may be optionally enabled as a fallback
708 dnl # if problems are observed with the direct mapping to the native
709 dnl # Linux atomic operations. You may not disable atomic spinlocks
710 dnl # if you kernel does not an atomic64_* API.
712 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
713 AC_ARG_ENABLE([atomic-spinlocks],
714 [AS_HELP_STRING([--enable-atomic-spinlocks],
715 [Atomic types use spinlocks @<:@default=check@:>@])],
717 [enable_atomic_spinlocks=check])
719 SPL_LINUX_TRY_COMPILE([
720 #include <linux/fs.h>
722 atomic64_t *ptr __attribute__ ((unused));
725 AC_DEFINE(HAVE_ATOMIC64_T, 1,
726 [kernel defines atomic64_t])
731 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
732 AS_IF([test "x$have_atomic64_t" = xyes], [
733 enable_atomic_spinlocks=no
735 enable_atomic_spinlocks=yes
739 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
740 AC_DEFINE([ATOMIC_SPINLOCK], [1],
741 [Atomic types use spinlocks])
743 AS_IF([test "x$have_atomic64_t" = xno], [
745 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
749 AC_MSG_CHECKING([whether atomic types use spinlocks])
750 AC_MSG_RESULT([$enable_atomic_spinlocks])
752 AC_MSG_CHECKING([whether kernel defines atomic64_t])
753 AC_MSG_RESULT([$have_atomic64_t])
756 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
757 tmp_flags="$EXTRA_KCFLAGS"
758 EXTRA_KCFLAGS="-Werror"
760 dnl # 2.6.23 to 2.6.34 API change
761 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
763 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
764 SPL_LINUX_TRY_COMPILE([
765 #include <linux/mm.h>
767 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
769 struct shrinker cache_shrinker = {
770 .shrink = shrinker_cb,
771 .seeks = DEFAULT_SEEKS,
773 register_shrinker(&cache_shrinker);
776 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
777 [old shrinker callback wants 2 args])
781 dnl # 2.6.35 - 2.6.39 API change
782 dnl # ->shrink(struct shrinker *,
783 dnl # int nr_to_scan, gfp_t gfp_mask)
785 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
786 SPL_LINUX_TRY_COMPILE([
787 #include <linux/mm.h>
789 int shrinker_cb(struct shrinker *, int nr_to_scan,
792 struct shrinker cache_shrinker = {
793 .shrink = shrinker_cb,
794 .seeks = DEFAULT_SEEKS,
796 register_shrinker(&cache_shrinker);
799 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
800 [old shrinker callback wants 3 args])
804 dnl # 3.0 - 3.11 API change
805 dnl # ->shrink(struct shrinker *,
806 dnl # struct shrink_control *sc)
809 [whether new 2-argument shrinker exists])
810 SPL_LINUX_TRY_COMPILE([
811 #include <linux/mm.h>
813 int shrinker_cb(struct shrinker *,
814 struct shrink_control *sc);
816 struct shrinker cache_shrinker = {
817 .shrink = shrinker_cb,
818 .seeks = DEFAULT_SEEKS,
820 register_shrinker(&cache_shrinker);
823 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
824 [new shrinker callback wants 2 args])
828 dnl # 3.12 API change,
829 dnl # ->shrink() is logically split in to
830 dnl # ->count_objects() and ->scan_objects()
833 [whether ->count_objects callback exists])
834 SPL_LINUX_TRY_COMPILE([
835 #include <linux/mm.h>
837 unsigned long shrinker_cb(
839 struct shrink_control *sc);
841 struct shrinker cache_shrinker = {
842 .count_objects = shrinker_cb,
843 .scan_objects = shrinker_cb,
844 .seeks = DEFAULT_SEEKS,
846 register_shrinker(&cache_shrinker);
849 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
850 1, [->count_objects exists])
857 EXTRA_KCFLAGS="$tmp_flags"
861 dnl # 2.6.33 API change,
862 dnl # Removed .ctl_name from struct ctl_table.
864 AC_DEFUN([SPL_AC_CTL_NAME], [
865 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
866 SPL_LINUX_TRY_COMPILE([
867 #include <linux/sysctl.h>
869 struct ctl_table ctl __attribute__ ((unused));
873 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
880 dnl # 3.10 API change,
881 dnl # PDE is replaced by PDE_DATA
883 AC_DEFUN([SPL_AC_PDE_DATA], [
884 AC_MSG_CHECKING([whether PDE_DATA() is available])
885 SPL_LINUX_TRY_COMPILE_SYMBOL([
886 #include <linux/proc_fs.h>
891 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
899 dnl # set_fs_pwd takes const struct path *
901 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
902 tmp_flags="$EXTRA_KCFLAGS"
903 EXTRA_KCFLAGS="-Werror"
904 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
905 SPL_LINUX_TRY_COMPILE([
906 #include <linux/spinlock.h>
907 #include <linux/fs_struct.h>
908 #include <linux/path.h>
909 void (*const set_fs_pwd_func)
910 (struct fs_struct *, const struct path *)
916 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
917 [set_fs_pwd() needs const path *])
919 SPL_LINUX_TRY_COMPILE([
920 #include <linux/spinlock.h>
921 #include <linux/fs_struct.h>
922 #include <linux/path.h>
923 void (*const set_fs_pwd_func)
924 (struct fs_struct *, struct path *)
931 AC_MSG_ERROR(unknown)
934 EXTRA_KCFLAGS="$tmp_flags"
938 dnl # 2.6.36 API change,
939 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
940 dnl # a spinlock_t to improve the fastpath performance.
942 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
943 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
944 tmp_flags="$EXTRA_KCFLAGS"
945 EXTRA_KCFLAGS="-Werror"
946 SPL_LINUX_TRY_COMPILE([
947 #include <linux/sched.h>
948 #include <linux/fs_struct.h>
950 static struct fs_struct fs;
951 spin_lock_init(&fs.lock);
954 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
955 [struct fs_struct uses spinlock_t])
959 EXTRA_KCFLAGS="$tmp_flags"
963 dnl # User namespaces, use kuid_t in place of uid_t
964 dnl # where available. Not strictly a user namespaces thing
965 dnl # but it should prevent surprises
967 AC_DEFUN([SPL_AC_KUIDGID_T], [
968 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
969 SPL_LINUX_TRY_COMPILE([
970 #include <linux/uidgid.h>
972 kuid_t userid = KUIDT_INIT(0);
973 kgid_t groupid = KGIDT_INIT(0);
975 SPL_LINUX_TRY_COMPILE([
976 #include <linux/uidgid.h>
981 AC_MSG_RESULT(yes; optional)
983 AC_MSG_RESULT(yes; mandatory)
984 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
992 dnl # 2.6.35 API change,
993 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
995 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
996 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
997 SPL_LINUX_TRY_COMPILE([
998 #include <linux/fs.h>
1003 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1010 dnl # 3.5 API change,
1011 dnl # inode_operations.truncate_range removed
1013 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1014 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1015 SPL_LINUX_TRY_COMPILE([
1016 #include <linux/fs.h>
1018 struct inode_operations ops;
1019 ops.truncate_range = NULL;
1022 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1023 [truncate_range() inode operation is available])
1030 dnl # Linux 2.6.38 - 3.x API
1032 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1033 AC_MSG_CHECKING([whether fops->fallocate() exists])
1034 SPL_LINUX_TRY_COMPILE([
1035 #include <linux/fs.h>
1037 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1038 struct file_operations fops __attribute__ ((unused)) = {
1039 .fallocate = fallocate,
1043 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1050 dnl # Linux 2.6.x - 2.6.37 API
1052 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1053 AC_MSG_CHECKING([whether iops->fallocate() exists])
1054 SPL_LINUX_TRY_COMPILE([
1055 #include <linux/fs.h>
1057 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1058 struct inode_operations fops __attribute__ ((unused)) = {
1059 .fallocate = fallocate,
1063 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1070 dnl # PaX Linux 2.6.38 - 3.x API
1072 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1073 AC_MSG_CHECKING([whether fops->fallocate() exists])
1074 SPL_LINUX_TRY_COMPILE([
1075 #include <linux/fs.h>
1077 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1078 struct file_operations_no_const fops __attribute__ ((unused)) = {
1079 .fallocate = fallocate,
1083 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1090 dnl # The fallocate callback was moved from the inode_operations
1091 dnl # structure to the file_operations structure.
1093 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1094 SPL_AC_KERNEL_FILE_FALLOCATE
1095 SPL_AC_KERNEL_INODE_FALLOCATE
1096 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1100 dnl # zlib inflate compat,
1101 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1103 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1104 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1105 SPL_LINUX_TRY_COMPILE([
1106 #if !defined(CONFIG_ZLIB_INFLATE) && \
1107 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1108 #error CONFIG_ZLIB_INFLATE not defined
1111 AC_MSG_RESULT([yes])
1115 *** This kernel does not include the required zlib inflate support.
1116 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1121 dnl # zlib deflate compat,
1122 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1124 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1125 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1126 SPL_LINUX_TRY_COMPILE([
1127 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1128 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1129 #error CONFIG_ZLIB_DEFLATE not defined
1132 AC_MSG_RESULT([yes])
1136 *** This kernel does not include the required zlib deflate support.
1137 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1142 dnl # config trim unused symbols,
1143 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1145 AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1146 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1147 SPL_LINUX_TRY_COMPILE([
1148 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1149 #error CONFIG_TRIM_UNUSED_KSYMS not defined
1152 AC_MSG_RESULT([yes])
1156 *** This kernel has unused symbols trimming enabled, please disable.
1157 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1162 dnl # 2.6.39 API compat,
1163 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1164 dnl # This was done to avoid always having to allocate the maximum size
1165 dnl # workspace (268K). The caller can now specific the windowBits and
1166 dnl # memLevel compression parameters to get a smaller workspace.
1168 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1169 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1170 SPL_LINUX_TRY_COMPILE([
1171 #include <linux/zlib.h>
1173 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1176 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1177 [zlib_deflate_workspacesize() wants 2 args])
1184 dnl # 2.6.39 API change,
1185 dnl # Shrinker adjust to use common shrink_control structure.
1187 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1188 AC_MSG_CHECKING([whether struct shrink_control exists])
1189 SPL_LINUX_TRY_COMPILE([
1190 #include <linux/mm.h>
1192 struct shrink_control sc __attribute__ ((unused));
1195 sc.gfp_mask = GFP_KERNEL;
1198 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1199 [struct shrink_control exists])
1206 dnl # 3.1 API Change
1208 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1209 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1211 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1212 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1213 tmp_flags="$EXTRA_KCFLAGS"
1214 EXTRA_KCFLAGS="-Werror"
1215 SPL_LINUX_TRY_COMPILE([
1216 #include <linux/rwsem.h>
1218 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1219 raw_spinlock_t dummy_lock __attribute__ ((unused)) =
1220 __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
1221 dummy_semaphore.wait_lock = dummy_lock;
1224 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1225 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1229 EXTRA_KCFLAGS="$tmp_flags"
1233 dnl # 3.16 API Change
1235 dnl # rwsem-spinlock "->activity" changed to "->count"
1237 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1238 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1239 tmp_flags="$EXTRA_KCFLAGS"
1240 EXTRA_KCFLAGS="-Werror"
1241 SPL_LINUX_TRY_COMPILE([
1242 #include <linux/rwsem.h>
1244 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1245 dummy_semaphore.activity = 0;
1248 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1249 [struct rw_semaphore has member activity])
1253 EXTRA_KCFLAGS="$tmp_flags"
1257 dnl # 4.8 API Change
1259 dnl # rwsem "->count" changed to atomic_long_t type
1261 AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1263 [whether struct rw_semaphore has atomic_long_t member count])
1264 tmp_flags="$EXTRA_KCFLAGS"
1265 EXTRA_KCFLAGS="-Werror"
1266 SPL_LINUX_TRY_COMPILE([
1267 #include <linux/rwsem.h>
1269 DECLARE_RWSEM(dummy_semaphore);
1270 (void) atomic_long_read(&dummy_semaphore.count);
1273 AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1274 [struct rw_semaphore has atomic_long_t member count])
1278 EXTRA_KCFLAGS="$tmp_flags"
1282 dnl # 3.9 API change,
1283 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1285 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1286 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1287 SPL_LINUX_TRY_COMPILE([
1288 #include <linux/sched.h>
1289 #include <linux/sched/rt.h>
1293 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1301 dnl # 4.11 API change,
1302 dnl # Moved things from linux/sched.h to linux/sched/signal.h
1304 AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
1305 [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
1306 SPL_LINUX_TRY_COMPILE([
1307 #include <linux/sched.h>
1308 #include <linux/sched/signal.h>
1312 AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
1320 dnl # 4.11 API, a528d35e@torvalds/linux
1321 dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1323 AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1324 AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1325 SPL_LINUX_TRY_COMPILE([
1326 #include <linux/fs.h>
1328 vfs_getattr((const struct path *)NULL,
1329 (struct kstat *)NULL,
1334 AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1335 [vfs_getattr wants 4 args])
1343 dnl # vfs_getattr(struct path *p, struct kstat *s)
1345 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1346 AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1347 SPL_LINUX_TRY_COMPILE([
1348 #include <linux/fs.h>
1350 vfs_getattr((struct path *) NULL,
1351 (struct kstat *)NULL);
1354 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1355 [vfs_getattr wants 2 args])
1363 dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1365 AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1366 AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1367 SPL_LINUX_TRY_COMPILE([
1368 #include <linux/fs.h>
1370 vfs_getattr((struct vfsmount *)NULL,
1371 (struct dentry *)NULL,
1372 (struct kstat *)NULL);
1375 AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1376 [vfs_getattr wants 3 args])
1383 dnl # 2.6.36 API compatibility.
1384 dnl # Added usleep_range timer.
1385 dnl # usleep_range is a finer precision implementation of msleep
1386 dnl # designed to be a drop-in replacement for udelay where a precise
1387 dnl # sleep / busy-wait is unnecessary.
1389 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1390 AC_MSG_CHECKING([whether usleep_range() is available])
1391 SPL_LINUX_TRY_COMPILE([
1392 #include <linux/delay.h>
1397 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1398 [usleep_range is available])
1405 dnl # 2.6.35 API change,
1406 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1407 dnl # private allocation flags which are applied when allocating a new slab
1408 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1409 dnl # non-default flags.
1411 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1412 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1413 SPL_LINUX_TRY_COMPILE([
1414 #include <linux/slab.h>
1416 struct kmem_cache cachep __attribute__ ((unused));
1417 cachep.allocflags = GFP_KERNEL;
1420 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1421 [struct kmem_cache has allocflags])
1425 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1426 SPL_LINUX_TRY_COMPILE([
1427 #include <linux/slab.h>
1429 struct kmem_cache cachep __attribute__ ((unused));
1430 cachep.gfpflags = GFP_KERNEL;
1433 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1434 [struct kmem_cache has gfpflags])
1442 dnl # 3.17 API change,
1443 dnl # wait_on_bit() no longer requires an action argument. The former
1444 dnl # "wait_on_bit" interface required an 'action' function to be provided
1445 dnl # which does the actual waiting. There were over 20 such functions in the
1446 dnl # kernel, many of them identical, though most cases can be satisfied by one
1447 dnl # of just two functions: one which uses io_schedule() and one which just
1448 dnl # uses schedule(). This API change was made to consolidate all of those
1449 dnl # redundant wait functions.
1451 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1452 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1453 SPL_LINUX_TRY_COMPILE([
1454 #include <linux/wait.h>
1456 int (*action)(void *) = NULL;
1457 wait_on_bit(NULL, 0, action, 0);
1460 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1467 dnl # 4.7 API change
1468 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1469 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1470 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1472 AC_DEFUN([SPL_AC_INODE_LOCK], [
1473 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1474 tmp_flags="$EXTRA_KCFLAGS"
1475 EXTRA_KCFLAGS="-Werror"
1476 SPL_LINUX_TRY_COMPILE([
1477 #include <linux/fs.h>
1479 struct inode *inode = NULL;
1480 inode_lock_shared(inode);
1483 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1487 EXTRA_KCFLAGS="$tmp_flags"
1491 dnl # 4.9 API change
1492 dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1494 AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1495 AC_MSG_CHECKING([whether group_info->gid exists])
1496 tmp_flags="$EXTRA_KCFLAGS"
1497 EXTRA_KCFLAGS="-Werror"
1498 SPL_LINUX_TRY_COMPILE([
1499 #include <linux/cred.h>
1501 struct group_info *gi = groups_alloc(1);
1502 gi->gid[0] = KGIDT_INIT(0);
1505 AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1509 EXTRA_KCFLAGS="$tmp_flags"
1513 dnl # grsecurity API change,
1514 dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
1515 dnl # kmem_cache_create_usercopy().
1517 AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
1518 AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
1519 tmp_flags="$EXTRA_KCFLAGS"
1520 EXTRA_KCFLAGS="-Werror"
1521 SPL_LINUX_TRY_COMPILE([
1522 #include <linux/slab.h>
1523 static void ctor(void *foo)
1528 struct kmem_cache *skc_linux_cache;
1529 const char *name = "test";
1532 unsigned long flags = 0;
1533 size_t useroffset = 0;
1534 size_t usersize = size - useroffset;
1536 skc_linux_cache = kmem_cache_create_usercopy(
1537 name, size, align, flags, useroffset, usersize, ctor);
1540 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
1541 [kmem_cache_create_usercopy() exists])
1545 EXTRA_KCFLAGS="$tmp_flags"
1549 dnl # 4.13 API change
1550 dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1552 AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1553 AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1554 SPL_LINUX_TRY_COMPILE([
1555 #include <linux/wait.h>
1557 wait_queue_entry_t *entry __attribute__ ((unused));
1560 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1561 [wait_queue_entry_t exists])
1568 dnl # 4.13 API change
1569 dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1570 dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1572 AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1573 AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1574 SPL_LINUX_TRY_COMPILE([
1575 #include <linux/wait.h>
1577 #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1578 typedef wait_queue_head_t spl_wait_queue_head_t;
1579 typedef wait_queue_entry_t spl_wait_queue_entry_t;
1581 typedef wait_queue_head_t spl_wait_queue_head_t;
1582 typedef wait_queue_t spl_wait_queue_entry_t;
1585 spl_wait_queue_head_t wq_head;
1586 spl_wait_queue_entry_t wq_entry;
1587 struct list_head *head __attribute__ ((unused));
1588 struct list_head *entry __attribute__ ((unused));
1590 head = &wq_head.head;
1591 entry = &wq_entry.entry;
1594 AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1595 [wq_head->head and wq_entry->entry exist])
1602 dnl # 4.14 API change
1603 dnl # kernel_write() which was introduced in 3.9 was updated to take
1604 dnl # the offset as a pointer which is needed by vn_rdwr().
1606 AC_DEFUN([SPL_AC_KERNEL_WRITE], [
1607 AC_MSG_CHECKING([whether kernel_write() takes loff_t pointer])
1608 tmp_flags="$EXTRA_KCFLAGS"
1609 EXTRA_KCFLAGS="-Werror"
1610 SPL_LINUX_TRY_COMPILE([
1611 #include <linux/fs.h>
1613 struct file *file = NULL;
1614 const void *buf = NULL;
1619 ret = kernel_write(file, buf, count, pos);
1622 AC_DEFINE(HAVE_KERNEL_WRITE_PPOS, 1,
1623 [kernel_write() take loff_t pointer])
1627 EXTRA_KCFLAGS="$tmp_flags"
1631 dnl # 4.14 API change
1632 dnl # kernel_read() which has existed for forever was updated to take
1633 dnl # the offset as a pointer which is needed by vn_rdwr().
1635 AC_DEFUN([SPL_AC_KERNEL_READ], [
1636 AC_MSG_CHECKING([whether kernel_read() takes loff_t pointer])
1637 tmp_flags="$EXTRA_KCFLAGS"
1638 EXTRA_KCFLAGS="-Werror"
1639 SPL_LINUX_TRY_COMPILE([
1640 #include <linux/fs.h>
1642 struct file *file = NULL;
1648 ret = kernel_read(file, buf, count, pos);
1651 AC_DEFINE(HAVE_KERNEL_READ_PPOS, 1,
1652 [kernel_read() take loff_t pointer])
1656 EXTRA_KCFLAGS="$tmp_flags"
1660 dnl # 4.15 API change
1661 dnl # https://lkml.org/lkml/2017/11/25/90
1662 dnl # Check if timer_list.func get passed a timer_list or an unsigned long
1663 dnl # (older kernels). Also sanity check the from_timer() and timer_setup()
1664 dnl # macros are available as well, since they will be used in the same newer
1665 dnl # kernels that support the new timer_list.func signature.
1667 AC_DEFUN([SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST], [
1668 AC_MSG_CHECKING([whether timer_list.function gets a timer_list])
1669 tmp_flags="$EXTRA_KCFLAGS"
1670 EXTRA_KCFLAGS="-Werror"
1671 SPL_LINUX_TRY_COMPILE([
1672 #include <linux/timer.h>
1673 void task_expire(struct timer_list *tl) {}
1676 #error "No from_timer() macro"
1679 struct timer_list timer;
1680 timer.function = task_expire;
1681 timer_setup(&timer, NULL, 0);
1684 AC_DEFINE(HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST, 1,
1685 [timer_list.function gets a timer_list])
1689 EXTRA_KCFLAGS="$tmp_flags"