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
55 SPL_AC_IO_SCHEDULE_TIMEOUT
58 SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST
61 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
62 modpost=$LINUX/scripts/Makefile.modpost
63 AC_MSG_CHECKING([kernel file name for module symbols])
64 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
65 if grep -q Modules.symvers $modpost; then
66 LINUX_SYMBOLS=Modules.symvers
68 LINUX_SYMBOLS=Module.symvers
71 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
73 *** Please make sure the kernel devel package for your distribution
74 *** is installed. If you are building with a custom kernel, make sure the
75 *** kernel is configured, built, and the '--with-linux=PATH' configure
76 *** option refers to the location of the kernel source.])
81 AC_MSG_RESULT($LINUX_SYMBOLS)
82 AC_SUBST(LINUX_SYMBOLS)
85 AC_DEFUN([SPL_AC_KERNEL], [
87 AS_HELP_STRING([--with-linux=PATH],
88 [Path to kernel source]),
89 [kernelsrc="$withval"])
91 AC_ARG_WITH([linux-obj],
92 AS_HELP_STRING([--with-linux-obj=PATH],
93 [Path to kernel build objects]),
94 [kernelbuild="$withval"])
96 AC_MSG_CHECKING([kernel source directory])
97 if test -z "$kernelsrc"; then
98 if test -e "/lib/modules/$(uname -r)/source"; then
99 headersdir="/lib/modules/$(uname -r)/source"
100 sourcelink=$(readlink -f "$headersdir")
101 elif test -e "/lib/modules/$(uname -r)/build"; then
102 headersdir="/lib/modules/$(uname -r)/build"
103 sourcelink=$(readlink -f "$headersdir")
105 sourcelink=$(ls -1d /usr/src/kernels/* \
107 2>/dev/null | grep -v obj | tail -1)
110 if test -n "$sourcelink" && test -e ${sourcelink}; then
111 kernelsrc=`readlink -f ${sourcelink}`
113 kernelsrc="[Not found]"
116 if test "$kernelsrc" = "NONE"; then
122 AC_MSG_RESULT([$kernelsrc])
123 if test ! -d "$kernelsrc"; then
125 *** Please make sure the kernel devel package for your distribution
126 *** is installed and then try again. If that fails, you can specify the
127 *** location of the kernel source with the '--with-linux=PATH' option.])
130 AC_MSG_CHECKING([kernel build directory])
131 if test -z "$kernelbuild"; then
132 if test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"; then
133 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
134 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
135 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
136 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
137 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
138 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
139 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
141 kernelbuild=${kernelsrc}
144 AC_MSG_RESULT([$kernelbuild])
146 AC_MSG_CHECKING([kernel source version])
147 utsrelease1=$kernelbuild/include/linux/version.h
148 utsrelease2=$kernelbuild/include/linux/utsrelease.h
149 utsrelease3=$kernelbuild/include/generated/utsrelease.h
150 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
151 utsrelease=linux/version.h
152 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
153 utsrelease=linux/utsrelease.h
154 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
155 utsrelease=generated/utsrelease.h
158 if test "$utsrelease"; then
159 kernsrcver=`(echo "#include <$utsrelease>";
160 echo "kernsrcver=UTS_RELEASE") |
161 cpp -I $kernelbuild/include |
162 grep "^kernsrcver=" | cut -d \" -f 2`
164 if test -z "$kernsrcver"; then
165 AC_MSG_RESULT([Not found])
166 AC_MSG_ERROR([*** Cannot determine kernel version.])
169 AC_MSG_RESULT([Not found])
170 if test "x$enable_linux_builtin" != xyes; then
171 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
174 *** Cannot find UTS_RELEASE definition.
175 *** Please run 'make prepare' inside the kernel source tree.])
179 AC_MSG_RESULT([$kernsrcver])
182 LINUX_OBJ=${kernelbuild}
183 LINUX_VERSION=${kernsrcver}
187 AC_SUBST(LINUX_VERSION)
189 SPL_AC_MODULE_SYMVERS
193 dnl # Default SPL user configuration
195 AC_DEFUN([SPL_AC_CONFIG_USER], [])
198 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
199 dnl # are missing, it is non-fatal, but you will not be able to build
200 dnl # RPM packages and will be warned if you try too.
202 dnl # By default, the generic spec file will be used because it requires
203 dnl # minimal dependencies. Distribution specific spec files can be
204 dnl # placed under the 'rpm/<distribution>' directory and enabled using
205 dnl # the --with-spec=<distribution> configure option.
207 AC_DEFUN([SPL_AC_RPM], [
211 AC_MSG_CHECKING([whether $RPM is available])
212 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
213 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
215 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
218 AC_MSG_RESULT([$HAVE_RPM])
221 AC_MSG_CHECKING([whether $RPMBUILD is available])
222 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
223 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
225 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
228 AC_MSG_RESULT([$HAVE_RPMBUILD])
231 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
233 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
236 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
241 RPM_SPEC_DIR="rpm/generic"
243 AS_HELP_STRING([--with-spec=SPEC],
244 [Spec files 'generic|redhat']),
245 [RPM_SPEC_DIR="rpm/$withval"])
247 AC_MSG_CHECKING([whether spec files are available])
248 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
252 AC_SUBST(RPM_VERSION)
254 AC_SUBST(HAVE_RPMBUILD)
256 AC_SUBST(RPMBUILD_VERSION)
258 AC_SUBST(RPM_SPEC_DIR)
259 AC_SUBST(RPM_DEFINE_UTIL)
260 AC_SUBST(RPM_DEFINE_KMOD)
261 AC_SUBST(RPM_DEFINE_DKMS)
262 AC_SUBST(RPM_DEFINE_COMMON)
263 AC_SUBST(SRPM_DEFINE_UTIL)
264 AC_SUBST(SRPM_DEFINE_KMOD)
265 AC_SUBST(SRPM_DEFINE_DKMS)
266 AC_SUBST(SRPM_DEFINE_COMMON)
270 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
271 dnl # tools are missing it is non-fatal but you will not be able to build
272 dnl # DEB packages and will be warned if you try too.
274 AC_DEFUN([SPL_AC_DPKG], [
276 DPKGBUILD=dpkg-buildpackage
278 AC_MSG_CHECKING([whether $DPKG is available])
279 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
280 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
282 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
285 AC_MSG_RESULT([$HAVE_DPKG])
288 AC_MSG_CHECKING([whether $DPKGBUILD is available])
289 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
290 DPKGBUILD_VERSION=$(echo $tmp | \
291 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
293 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
296 AC_MSG_RESULT([$HAVE_DPKGBUILD])
301 AC_SUBST(DPKG_VERSION)
303 AC_SUBST(HAVE_DPKGBUILD)
305 AC_SUBST(DPKGBUILD_VERSION)
309 dnl # Until native packaging for various different packing systems
310 dnl # can be added the least we can do is attempt to use alien to
311 dnl # convert the RPM packages to the needed package type. This is
312 dnl # a hack but so far it has worked reasonable well.
314 AC_DEFUN([SPL_AC_ALIEN], [
317 AC_MSG_CHECKING([whether $ALIEN is available])
318 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
319 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
321 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
324 AC_MSG_RESULT([$HAVE_ALIEN])
329 AC_SUBST(ALIEN_VERSION)
333 dnl # Using the VENDOR tag from config.guess set the default
334 dnl # package type for 'make pkg': (rpm | deb | tgz)
336 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
337 AC_MSG_CHECKING([linux distribution])
338 if test -f /etc/toss-release ; then
340 elif test -f /etc/fedora-release ; then
342 elif test -f /etc/redhat-release ; then
344 elif test -f /etc/gentoo-release ; then
346 elif test -f /etc/arch-release ; then
348 elif test -f /etc/SuSE-release ; then
350 elif test -f /etc/slackware-version ; then
352 elif test -f /etc/lunar.release ; then
354 elif test -f /etc/lsb-release ; then
356 elif test -f /etc/debian_version ; then
361 AC_MSG_RESULT([$VENDOR])
364 AC_MSG_CHECKING([default package type])
366 toss) DEFAULT_PACKAGE=rpm ;;
367 redhat) DEFAULT_PACKAGE=rpm ;;
368 fedora) DEFAULT_PACKAGE=rpm ;;
369 gentoo) DEFAULT_PACKAGE=tgz ;;
370 arch) DEFAULT_PACKAGE=tgz ;;
371 sles) DEFAULT_PACKAGE=rpm ;;
372 slackware) DEFAULT_PACKAGE=tgz ;;
373 lunar) DEFAULT_PACKAGE=tgz ;;
374 ubuntu) DEFAULT_PACKAGE=deb ;;
375 debian) DEFAULT_PACKAGE=deb ;;
376 *) DEFAULT_PACKAGE=rpm ;;
379 AC_MSG_RESULT([$DEFAULT_PACKAGE])
380 AC_SUBST(DEFAULT_PACKAGE)
384 dnl # Default SPL user configuration
386 AC_DEFUN([SPL_AC_PACKAGE], [
387 SPL_AC_DEFAULT_PACKAGE
393 AC_DEFUN([SPL_AC_LICENSE], [
394 AC_MSG_CHECKING([spl author])
395 AC_MSG_RESULT([$SPL_META_AUTHOR])
397 AC_MSG_CHECKING([spl license])
398 AC_MSG_RESULT([$SPL_META_LICENSE])
401 AC_DEFUN([SPL_AC_CONFIG], [
403 AC_ARG_WITH([config],
404 AS_HELP_STRING([--with-config=CONFIG],
405 [Config file 'kernel|user|all|srpm']),
406 [SPL_CONFIG="$withval"])
407 AC_ARG_ENABLE([linux-builtin],
408 [AC_HELP_STRING([--enable-linux-builtin],
409 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
411 [enable_linux_builtin=no])
413 AC_MSG_CHECKING([spl config])
414 AC_MSG_RESULT([$SPL_CONFIG]);
417 case "$SPL_CONFIG" in
418 kernel) SPL_AC_CONFIG_KERNEL ;;
419 user) SPL_AC_CONFIG_USER ;;
420 all) SPL_AC_CONFIG_KERNEL
421 SPL_AC_CONFIG_USER ;;
424 AC_MSG_RESULT([Error!])
425 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
426 user kernel|user|all|srpm]) ;;
429 AM_CONDITIONAL([CONFIG_USER],
430 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
431 AM_CONDITIONAL([CONFIG_KERNEL],
432 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
433 [test "x$enable_linux_builtin" != xyes ])
437 dnl # Enable if the SPL should be compiled with internal debugging enabled.
438 dnl # By default this support is disabled.
440 AC_DEFUN([SPL_AC_DEBUG], [
441 AC_MSG_CHECKING([whether debugging is enabled])
442 AC_ARG_ENABLE([debug],
443 [AS_HELP_STRING([--enable-debug],
444 [Enable generic debug support @<:@default=no@:>@])],
448 AS_IF([test "x$enable_debug" = xyes],
450 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
451 DEBUG_CFLAGS="-DDEBUG -Werror"
452 DEBUG_SPL="_with_debug"
454 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
455 DEBUG_CFLAGS="-DNDEBUG"
456 DEBUG_SPL="_without_debug"
459 AC_SUBST(DEBUG_CFLAGS)
461 AC_MSG_RESULT([$enable_debug])
465 dnl # Enabled by default it provides a minimal level of memory tracking.
466 dnl # A total count of bytes allocated is kept for each alloc and free.
467 dnl # Then at module unload time a report to the console will be printed
468 dnl # if memory was leaked.
470 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
471 AC_ARG_ENABLE([debug-kmem],
472 [AS_HELP_STRING([--enable-debug-kmem],
473 [Enable basic kmem accounting @<:@default=no@:>@])],
475 [enable_debug_kmem=no])
477 AS_IF([test "x$enable_debug_kmem" = xyes],
479 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
480 DEBUG_KMEM="_with_debug_kmem"
481 AC_DEFINE([DEBUG_KMEM], [1],
482 [Define to 1 to enable basic kmem accounting])
484 DEBUG_KMEM="_without_debug_kmem"
488 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
489 AC_MSG_RESULT([$enable_debug_kmem])
493 dnl # Disabled by default it provides detailed memory tracking. This
494 dnl # feature also requires --enable-debug-kmem to be set. When enabled
495 dnl # not only will total bytes be tracked but also the location of every
496 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
497 dnl # addresses and where they were allocated will be dumped to the console.
498 dnl # Enabling this feature has a significant impact on performance but it
499 dnl # makes finding memory leaks pretty straight forward.
501 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
502 AC_ARG_ENABLE([debug-kmem-tracking],
503 [AS_HELP_STRING([--enable-debug-kmem-tracking],
504 [Enable detailed kmem tracking @<:@default=no@:>@])],
506 [enable_debug_kmem_tracking=no])
508 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
510 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
511 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
512 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
513 [Define to 1 to enable detailed kmem tracking])
515 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
518 AC_SUBST(DEBUG_KMEM_TRACKING)
519 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
520 AC_MSG_RESULT([$enable_debug_kmem_tracking])
524 dnl # SPL_LINUX_CONFTEST
526 AC_DEFUN([SPL_LINUX_CONFTEST], [
527 cat confdefs.h - <<_ACEOF >conftest.c
533 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
535 m4_define([SPL_LANG_PROGRAM], [
540 dnl Do *not* indent the following line: there may be CPP directives.
541 dnl Don't move the `;' right after for the same reason.
549 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
551 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
552 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
553 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
554 echo "obj-m := conftest.o" >build/Makefile
556 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
558 [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])],
560 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
566 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
568 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
569 [SPL_LINUX_COMPILE_IFELSE(
570 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
572 [test -s build/conftest.o],
577 dnl # SPL_CHECK_SYMBOL_EXPORT
578 dnl # check symbol exported or not
580 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
581 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
582 $LINUX_OBJ/Module*.symvers 2>/dev/null
584 if test $rc -ne 0; then
587 grep -q -E "EXPORT_SYMBOL.*($1)" \
588 "$LINUX_OBJ/$file" 2>/dev/null
590 if test $rc -eq 0; then
595 if test $export -eq 0; then :
606 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
607 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
608 dnl # is called if not compiling for builtin
610 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
611 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
612 if test $rc -ne 0; then :
615 if test "x$enable_linux_builtin" != xyes; then
616 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
618 if test $rc -ne 0; then :
627 dnl # SPL_CHECK_SYMBOL_HEADER
628 dnl # check if a symbol prototype is defined in listed headers.
630 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
631 AC_MSG_CHECKING([whether symbol $1 exists in header])
634 grep -q "$2" "$LINUX/$file" 2>/dev/null
636 if test $rc -eq 0; then
641 if test $header -eq 0; then
651 dnl # SPL_CHECK_HEADER
652 dnl # check whether header exists and define HAVE_$2_HEADER
654 AC_DEFUN([SPL_CHECK_HEADER],
655 [AC_MSG_CHECKING([whether header $1 exists])
656 SPL_LINUX_TRY_COMPILE([
661 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
671 dnl # Basic toolchain sanity check. Verify that kernel modules can
672 dnl # be built and which symbols can be used.
674 AC_DEFUN([SPL_AC_TEST_MODULE],
675 [AC_MSG_CHECKING([whether modules can be built])
676 SPL_LINUX_TRY_COMPILE([],[],[
680 if test "x$enable_linux_builtin" != xyes; then
681 AC_MSG_ERROR([*** Unable to build an empty module.])
684 *** Unable to build an empty module.
685 *** Please run 'make scripts' inside the kernel source tree.])
689 AS_IF([test "x$cross_compiling" != xyes], [
692 #include "$LINUX/include/linux/license.h"
694 return !license_is_gpl_compatible(
695 "$SPL_META_LICENSE");
698 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
699 [Define to 1 if GPL-only symbols can be used])
706 dnl # Use the atomic implemenation based on global spinlocks. This
707 dnl # should only be needed by 32-bit kernels which do not provide
708 dnl # the atomic64_* API. It may be optionally enabled as a fallback
709 dnl # if problems are observed with the direct mapping to the native
710 dnl # Linux atomic operations. You may not disable atomic spinlocks
711 dnl # if you kernel does not an atomic64_* API.
713 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
714 AC_ARG_ENABLE([atomic-spinlocks],
715 [AS_HELP_STRING([--enable-atomic-spinlocks],
716 [Atomic types use spinlocks @<:@default=check@:>@])],
718 [enable_atomic_spinlocks=check])
720 SPL_LINUX_TRY_COMPILE([
721 #include <linux/fs.h>
723 atomic64_t *ptr __attribute__ ((unused));
726 AC_DEFINE(HAVE_ATOMIC64_T, 1,
727 [kernel defines atomic64_t])
732 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
733 AS_IF([test "x$have_atomic64_t" = xyes], [
734 enable_atomic_spinlocks=no
736 enable_atomic_spinlocks=yes
740 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
741 AC_DEFINE([ATOMIC_SPINLOCK], [1],
742 [Atomic types use spinlocks])
744 AS_IF([test "x$have_atomic64_t" = xno], [
746 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
750 AC_MSG_CHECKING([whether atomic types use spinlocks])
751 AC_MSG_RESULT([$enable_atomic_spinlocks])
753 AC_MSG_CHECKING([whether kernel defines atomic64_t])
754 AC_MSG_RESULT([$have_atomic64_t])
757 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
758 tmp_flags="$EXTRA_KCFLAGS"
759 EXTRA_KCFLAGS="-Werror"
761 dnl # 2.6.23 to 2.6.34 API change
762 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
764 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
765 SPL_LINUX_TRY_COMPILE([
766 #include <linux/mm.h>
768 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
770 struct shrinker cache_shrinker = {
771 .shrink = shrinker_cb,
772 .seeks = DEFAULT_SEEKS,
774 register_shrinker(&cache_shrinker);
777 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
778 [old shrinker callback wants 2 args])
782 dnl # 2.6.35 - 2.6.39 API change
783 dnl # ->shrink(struct shrinker *,
784 dnl # int nr_to_scan, gfp_t gfp_mask)
786 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
787 SPL_LINUX_TRY_COMPILE([
788 #include <linux/mm.h>
790 int shrinker_cb(struct shrinker *, int nr_to_scan,
793 struct shrinker cache_shrinker = {
794 .shrink = shrinker_cb,
795 .seeks = DEFAULT_SEEKS,
797 register_shrinker(&cache_shrinker);
800 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
801 [old shrinker callback wants 3 args])
805 dnl # 3.0 - 3.11 API change
806 dnl # ->shrink(struct shrinker *,
807 dnl # struct shrink_control *sc)
810 [whether new 2-argument shrinker exists])
811 SPL_LINUX_TRY_COMPILE([
812 #include <linux/mm.h>
814 int shrinker_cb(struct shrinker *,
815 struct shrink_control *sc);
817 struct shrinker cache_shrinker = {
818 .shrink = shrinker_cb,
819 .seeks = DEFAULT_SEEKS,
821 register_shrinker(&cache_shrinker);
824 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
825 [new shrinker callback wants 2 args])
829 dnl # 3.12 API change,
830 dnl # ->shrink() is logically split in to
831 dnl # ->count_objects() and ->scan_objects()
834 [whether ->count_objects callback exists])
835 SPL_LINUX_TRY_COMPILE([
836 #include <linux/mm.h>
838 unsigned long shrinker_cb(
840 struct shrink_control *sc);
842 struct shrinker cache_shrinker = {
843 .count_objects = shrinker_cb,
844 .scan_objects = shrinker_cb,
845 .seeks = DEFAULT_SEEKS,
847 register_shrinker(&cache_shrinker);
850 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
851 1, [->count_objects exists])
858 EXTRA_KCFLAGS="$tmp_flags"
862 dnl # 2.6.33 API change,
863 dnl # Removed .ctl_name from struct ctl_table.
865 AC_DEFUN([SPL_AC_CTL_NAME], [
866 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
867 SPL_LINUX_TRY_COMPILE([
868 #include <linux/sysctl.h>
870 struct ctl_table ctl __attribute__ ((unused));
874 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
881 dnl # 3.10 API change,
882 dnl # PDE is replaced by PDE_DATA
884 AC_DEFUN([SPL_AC_PDE_DATA], [
885 AC_MSG_CHECKING([whether PDE_DATA() is available])
886 SPL_LINUX_TRY_COMPILE_SYMBOL([
887 #include <linux/proc_fs.h>
892 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
900 dnl # set_fs_pwd takes const struct path *
902 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
903 tmp_flags="$EXTRA_KCFLAGS"
904 EXTRA_KCFLAGS="-Werror"
905 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
906 SPL_LINUX_TRY_COMPILE([
907 #include <linux/spinlock.h>
908 #include <linux/fs_struct.h>
909 #include <linux/path.h>
910 void (*const set_fs_pwd_func)
911 (struct fs_struct *, const struct path *)
917 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
918 [set_fs_pwd() needs const path *])
920 SPL_LINUX_TRY_COMPILE([
921 #include <linux/spinlock.h>
922 #include <linux/fs_struct.h>
923 #include <linux/path.h>
924 void (*const set_fs_pwd_func)
925 (struct fs_struct *, struct path *)
932 AC_MSG_ERROR(unknown)
935 EXTRA_KCFLAGS="$tmp_flags"
939 dnl # 2.6.36 API change,
940 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
941 dnl # a spinlock_t to improve the fastpath performance.
943 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
944 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
945 tmp_flags="$EXTRA_KCFLAGS"
946 EXTRA_KCFLAGS="-Werror"
947 SPL_LINUX_TRY_COMPILE([
948 #include <linux/sched.h>
949 #include <linux/fs_struct.h>
951 static struct fs_struct fs;
952 spin_lock_init(&fs.lock);
955 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
956 [struct fs_struct uses spinlock_t])
960 EXTRA_KCFLAGS="$tmp_flags"
964 dnl # User namespaces, use kuid_t in place of uid_t
965 dnl # where available. Not strictly a user namespaces thing
966 dnl # but it should prevent surprises
968 AC_DEFUN([SPL_AC_KUIDGID_T], [
969 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
970 SPL_LINUX_TRY_COMPILE([
971 #include <linux/uidgid.h>
973 kuid_t userid = KUIDT_INIT(0);
974 kgid_t groupid = KGIDT_INIT(0);
976 SPL_LINUX_TRY_COMPILE([
977 #include <linux/uidgid.h>
982 AC_MSG_RESULT(yes; optional)
984 AC_MSG_RESULT(yes; mandatory)
985 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
993 dnl # 2.6.35 API change,
994 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
996 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
997 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
998 SPL_LINUX_TRY_COMPILE([
999 #include <linux/fs.h>
1004 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1011 dnl # 3.5 API change,
1012 dnl # inode_operations.truncate_range removed
1014 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1015 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/fs.h>
1019 struct inode_operations ops;
1020 ops.truncate_range = NULL;
1023 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1024 [truncate_range() inode operation is available])
1031 dnl # Linux 2.6.38 - 3.x API
1033 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1034 AC_MSG_CHECKING([whether fops->fallocate() exists])
1035 SPL_LINUX_TRY_COMPILE([
1036 #include <linux/fs.h>
1038 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1039 struct file_operations fops __attribute__ ((unused)) = {
1040 .fallocate = fallocate,
1044 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1051 dnl # Linux 2.6.x - 2.6.37 API
1053 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1054 AC_MSG_CHECKING([whether iops->fallocate() exists])
1055 SPL_LINUX_TRY_COMPILE([
1056 #include <linux/fs.h>
1058 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1059 struct inode_operations fops __attribute__ ((unused)) = {
1060 .fallocate = fallocate,
1064 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1071 dnl # PaX Linux 2.6.38 - 3.x API
1073 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1074 AC_MSG_CHECKING([whether fops->fallocate() exists])
1075 SPL_LINUX_TRY_COMPILE([
1076 #include <linux/fs.h>
1078 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1079 struct file_operations_no_const fops __attribute__ ((unused)) = {
1080 .fallocate = fallocate,
1084 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1091 dnl # The fallocate callback was moved from the inode_operations
1092 dnl # structure to the file_operations structure.
1094 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1095 SPL_AC_KERNEL_FILE_FALLOCATE
1096 SPL_AC_KERNEL_INODE_FALLOCATE
1097 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1101 dnl # zlib inflate compat,
1102 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1104 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1105 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1106 SPL_LINUX_TRY_COMPILE([
1107 #if !defined(CONFIG_ZLIB_INFLATE) && \
1108 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1109 #error CONFIG_ZLIB_INFLATE not defined
1112 AC_MSG_RESULT([yes])
1116 *** This kernel does not include the required zlib inflate support.
1117 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1122 dnl # zlib deflate compat,
1123 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1125 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1126 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1127 SPL_LINUX_TRY_COMPILE([
1128 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1129 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1130 #error CONFIG_ZLIB_DEFLATE not defined
1133 AC_MSG_RESULT([yes])
1137 *** This kernel does not include the required zlib deflate support.
1138 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1143 dnl # config trim unused symbols,
1144 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS DISABLED.
1146 AC_DEFUN([SPL_AC_CONFIG_TRIM_UNUSED_KSYMS], [
1147 AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
1148 SPL_LINUX_TRY_COMPILE([
1149 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
1150 #error CONFIG_TRIM_UNUSED_KSYMS not defined
1153 AC_MSG_RESULT([yes])
1157 *** This kernel has unused symbols trimming enabled, please disable.
1158 *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
1163 dnl # 2.6.39 API compat,
1164 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1165 dnl # This was done to avoid always having to allocate the maximum size
1166 dnl # workspace (268K). The caller can now specific the windowBits and
1167 dnl # memLevel compression parameters to get a smaller workspace.
1169 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1170 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1171 SPL_LINUX_TRY_COMPILE([
1172 #include <linux/zlib.h>
1174 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1177 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1178 [zlib_deflate_workspacesize() wants 2 args])
1185 dnl # 2.6.39 API change,
1186 dnl # Shrinker adjust to use common shrink_control structure.
1188 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1189 AC_MSG_CHECKING([whether struct shrink_control exists])
1190 SPL_LINUX_TRY_COMPILE([
1191 #include <linux/mm.h>
1193 struct shrink_control sc __attribute__ ((unused));
1196 sc.gfp_mask = GFP_KERNEL;
1199 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1200 [struct shrink_control exists])
1207 dnl # 3.1 API Change
1209 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1210 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1212 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1213 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1214 tmp_flags="$EXTRA_KCFLAGS"
1215 EXTRA_KCFLAGS="-Werror"
1216 SPL_LINUX_TRY_COMPILE([
1217 #include <linux/rwsem.h>
1219 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1220 raw_spinlock_t dummy_lock __attribute__ ((unused)) =
1221 __RAW_SPIN_LOCK_INITIALIZER(dummy_lock);
1222 dummy_semaphore.wait_lock = dummy_lock;
1225 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1226 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1230 EXTRA_KCFLAGS="$tmp_flags"
1234 dnl # 3.16 API Change
1236 dnl # rwsem-spinlock "->activity" changed to "->count"
1238 AC_DEFUN([SPL_AC_RWSEM_ACTIVITY], [
1239 AC_MSG_CHECKING([whether struct rw_semaphore has member activity])
1240 tmp_flags="$EXTRA_KCFLAGS"
1241 EXTRA_KCFLAGS="-Werror"
1242 SPL_LINUX_TRY_COMPILE([
1243 #include <linux/rwsem.h>
1245 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1246 dummy_semaphore.activity = 0;
1249 AC_DEFINE(HAVE_RWSEM_ACTIVITY, 1,
1250 [struct rw_semaphore has member activity])
1254 EXTRA_KCFLAGS="$tmp_flags"
1258 dnl # 4.8 API Change
1260 dnl # rwsem "->count" changed to atomic_long_t type
1262 AC_DEFUN([SPL_AC_RWSEM_ATOMIC_LONG_COUNT], [
1264 [whether struct rw_semaphore has atomic_long_t member count])
1265 tmp_flags="$EXTRA_KCFLAGS"
1266 EXTRA_KCFLAGS="-Werror"
1267 SPL_LINUX_TRY_COMPILE([
1268 #include <linux/rwsem.h>
1270 DECLARE_RWSEM(dummy_semaphore);
1271 (void) atomic_long_read(&dummy_semaphore.count);
1274 AC_DEFINE(HAVE_RWSEM_ATOMIC_LONG_COUNT, 1,
1275 [struct rw_semaphore has atomic_long_t member count])
1279 EXTRA_KCFLAGS="$tmp_flags"
1283 dnl # 3.9 API change,
1284 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1286 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1287 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1288 SPL_LINUX_TRY_COMPILE([
1289 #include <linux/sched.h>
1290 #include <linux/sched/rt.h>
1294 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1302 dnl # 4.11 API change,
1303 dnl # Moved things from linux/sched.h to linux/sched/signal.h
1305 AC_DEFUN([SPL_AC_SCHED_SIGNAL_HEADER],
1306 [AC_MSG_CHECKING([whether header linux/sched/signal.h exists])
1307 SPL_LINUX_TRY_COMPILE([
1308 #include <linux/sched.h>
1309 #include <linux/sched/signal.h>
1313 AC_DEFINE(HAVE_SCHED_SIGNAL_HEADER, 1, [linux/sched/signal.h exists])
1321 dnl # 4.11 API, a528d35e@torvalds/linux
1322 dnl # vfs_getattr(const struct path *p, struct kstat *s, u32 m, unsigned int f)
1324 AC_DEFUN([SPL_AC_4ARGS_VFS_GETATTR], [
1325 AC_MSG_CHECKING([whether vfs_getattr() wants 4 args])
1326 SPL_LINUX_TRY_COMPILE([
1327 #include <linux/fs.h>
1329 vfs_getattr((const struct path *)NULL,
1330 (struct kstat *)NULL,
1335 AC_DEFINE(HAVE_4ARGS_VFS_GETATTR, 1,
1336 [vfs_getattr wants 4 args])
1344 dnl # vfs_getattr(struct path *p, struct kstat *s)
1346 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1347 AC_MSG_CHECKING([whether vfs_getattr() wants 2 args])
1348 SPL_LINUX_TRY_COMPILE([
1349 #include <linux/fs.h>
1351 vfs_getattr((struct path *) NULL,
1352 (struct kstat *)NULL);
1355 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1356 [vfs_getattr wants 2 args])
1364 dnl # vfs_getattr(struct vfsmount *v, struct dentry *d, struct kstat *k)
1366 AC_DEFUN([SPL_AC_3ARGS_VFS_GETATTR], [
1367 AC_MSG_CHECKING([whether vfs_getattr() wants 3 args])
1368 SPL_LINUX_TRY_COMPILE([
1369 #include <linux/fs.h>
1371 vfs_getattr((struct vfsmount *)NULL,
1372 (struct dentry *)NULL,
1373 (struct kstat *)NULL);
1376 AC_DEFINE(HAVE_3ARGS_VFS_GETATTR, 1,
1377 [vfs_getattr wants 3 args])
1384 dnl # 2.6.36 API compatibility.
1385 dnl # Added usleep_range timer.
1386 dnl # usleep_range is a finer precision implementation of msleep
1387 dnl # designed to be a drop-in replacement for udelay where a precise
1388 dnl # sleep / busy-wait is unnecessary.
1390 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1391 AC_MSG_CHECKING([whether usleep_range() is available])
1392 SPL_LINUX_TRY_COMPILE([
1393 #include <linux/delay.h>
1398 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1399 [usleep_range is available])
1406 dnl # 2.6.35 API change,
1407 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1408 dnl # private allocation flags which are applied when allocating a new slab
1409 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1410 dnl # non-default flags.
1412 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1413 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1414 SPL_LINUX_TRY_COMPILE([
1415 #include <linux/slab.h>
1417 struct kmem_cache cachep __attribute__ ((unused));
1418 cachep.allocflags = GFP_KERNEL;
1421 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1422 [struct kmem_cache has allocflags])
1426 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1427 SPL_LINUX_TRY_COMPILE([
1428 #include <linux/slab.h>
1430 struct kmem_cache cachep __attribute__ ((unused));
1431 cachep.gfpflags = GFP_KERNEL;
1434 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1435 [struct kmem_cache has gfpflags])
1443 dnl # 3.17 API change,
1444 dnl # wait_on_bit() no longer requires an action argument. The former
1445 dnl # "wait_on_bit" interface required an 'action' function to be provided
1446 dnl # which does the actual waiting. There were over 20 such functions in the
1447 dnl # kernel, many of them identical, though most cases can be satisfied by one
1448 dnl # of just two functions: one which uses io_schedule() and one which just
1449 dnl # uses schedule(). This API change was made to consolidate all of those
1450 dnl # redundant wait functions.
1452 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1453 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1454 SPL_LINUX_TRY_COMPILE([
1455 #include <linux/wait.h>
1457 int (*action)(void *) = NULL;
1458 wait_on_bit(NULL, 0, action, 0);
1461 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1468 dnl # 4.7 API change
1469 dnl # i_mutex is changed to i_rwsem. Instead of directly using
1470 dnl # i_mutex/i_rwsem, we should use inode_lock() and inode_lock_shared()
1471 dnl # We test inode_lock_shared because inode_lock is introduced earlier.
1473 AC_DEFUN([SPL_AC_INODE_LOCK], [
1474 AC_MSG_CHECKING([whether inode_lock_shared() exists])
1475 tmp_flags="$EXTRA_KCFLAGS"
1476 EXTRA_KCFLAGS="-Werror"
1477 SPL_LINUX_TRY_COMPILE([
1478 #include <linux/fs.h>
1480 struct inode *inode = NULL;
1481 inode_lock_shared(inode);
1484 AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1, [yes])
1488 EXTRA_KCFLAGS="$tmp_flags"
1492 dnl # 4.9 API change
1493 dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
1495 AC_DEFUN([SPL_AC_GROUP_INFO_GID], [
1496 AC_MSG_CHECKING([whether group_info->gid exists])
1497 tmp_flags="$EXTRA_KCFLAGS"
1498 EXTRA_KCFLAGS="-Werror"
1499 SPL_LINUX_TRY_COMPILE([
1500 #include <linux/cred.h>
1502 struct group_info *gi = groups_alloc(1);
1503 gi->gid[0] = KGIDT_INIT(0);
1506 AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
1510 EXTRA_KCFLAGS="$tmp_flags"
1514 dnl # grsecurity API change,
1515 dnl # kmem_cache_create() with SLAB_USERCOPY flag replaced by
1516 dnl # kmem_cache_create_usercopy().
1518 AC_DEFUN([SPL_AC_KMEM_CACHE_CREATE_USERCOPY], [
1519 AC_MSG_CHECKING([whether kmem_cache_create_usercopy() exists])
1520 tmp_flags="$EXTRA_KCFLAGS"
1521 EXTRA_KCFLAGS="-Werror"
1522 SPL_LINUX_TRY_COMPILE([
1523 #include <linux/slab.h>
1524 static void ctor(void *foo)
1529 struct kmem_cache *skc_linux_cache;
1530 const char *name = "test";
1533 unsigned long flags = 0;
1534 size_t useroffset = 0;
1535 size_t usersize = size - useroffset;
1537 skc_linux_cache = kmem_cache_create_usercopy(
1538 name, size, align, flags, useroffset, usersize, ctor);
1541 AC_DEFINE(HAVE_KMEM_CACHE_CREATE_USERCOPY, 1,
1542 [kmem_cache_create_usercopy() exists])
1546 EXTRA_KCFLAGS="$tmp_flags"
1550 dnl # 4.13 API change
1551 dnl # Renamed struct wait_queue -> struct wait_queue_entry.
1553 AC_DEFUN([SPL_AC_WAIT_QUEUE_ENTRY_T], [
1554 AC_MSG_CHECKING([whether wait_queue_entry_t exists])
1555 SPL_LINUX_TRY_COMPILE([
1556 #include <linux/wait.h>
1558 wait_queue_entry_t *entry __attribute__ ((unused));
1561 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_T, 1,
1562 [wait_queue_entry_t exists])
1569 dnl # 4.13 API change
1570 dnl # Renamed wait_queue_head::task_list -> wait_queue_head::head
1571 dnl # Renamed wait_queue_entry::task_list -> wait_queue_entry::entry
1573 AC_DEFUN([SPL_AC_WAIT_QUEUE_HEAD_ENTRY], [
1574 AC_MSG_CHECKING([whether wq_head->head and wq_entry->entry exist])
1575 SPL_LINUX_TRY_COMPILE([
1576 #include <linux/wait.h>
1578 #ifdef HAVE_WAIT_QUEUE_ENTRY_T
1579 typedef wait_queue_head_t spl_wait_queue_head_t;
1580 typedef wait_queue_entry_t spl_wait_queue_entry_t;
1582 typedef wait_queue_head_t spl_wait_queue_head_t;
1583 typedef wait_queue_t spl_wait_queue_entry_t;
1586 spl_wait_queue_head_t wq_head;
1587 spl_wait_queue_entry_t wq_entry;
1588 struct list_head *head __attribute__ ((unused));
1589 struct list_head *entry __attribute__ ((unused));
1591 head = &wq_head.head;
1592 entry = &wq_entry.entry;
1595 AC_DEFINE(HAVE_WAIT_QUEUE_HEAD_ENTRY, 1,
1596 [wq_head->head and wq_entry->entry exist])
1603 dnl # 3.19 API change
1604 dnl # The io_schedule_timeout() function is present in all 2.6.32 kernels
1605 dnl # but it was not exported until Linux 3.19. The RHEL 7.x kernels which
1606 dnl # are based on a 3.10 kernel do export this symbol.
1608 AC_DEFUN([SPL_AC_IO_SCHEDULE_TIMEOUT], [
1609 AC_MSG_CHECKING([whether io_schedule_timeout() is available])
1610 SPL_LINUX_TRY_COMPILE_SYMBOL([
1611 #include <linux/sched.h>
1613 (void) io_schedule_timeout(1);
1614 ], [io_schedule_timeout], [], [
1616 AC_DEFINE(HAVE_IO_SCHEDULE_TIMEOUT, 1, [yes])
1623 dnl # 4.14 API change
1624 dnl # kernel_write() which was introduced in 3.9 was updated to take
1625 dnl # the offset as a pointer which is needed by vn_rdwr().
1627 AC_DEFUN([SPL_AC_KERNEL_WRITE], [
1628 AC_MSG_CHECKING([whether kernel_write() takes loff_t pointer])
1629 tmp_flags="$EXTRA_KCFLAGS"
1630 EXTRA_KCFLAGS="-Werror"
1631 SPL_LINUX_TRY_COMPILE([
1632 #include <linux/fs.h>
1634 struct file *file = NULL;
1635 const void *buf = NULL;
1640 ret = kernel_write(file, buf, count, pos);
1643 AC_DEFINE(HAVE_KERNEL_WRITE_PPOS, 1,
1644 [kernel_write() take loff_t pointer])
1648 EXTRA_KCFLAGS="$tmp_flags"
1652 dnl # 4.14 API change
1653 dnl # kernel_read() which has existed for forever was updated to take
1654 dnl # the offset as a pointer which is needed by vn_rdwr().
1656 AC_DEFUN([SPL_AC_KERNEL_READ], [
1657 AC_MSG_CHECKING([whether kernel_read() takes loff_t pointer])
1658 tmp_flags="$EXTRA_KCFLAGS"
1659 EXTRA_KCFLAGS="-Werror"
1660 SPL_LINUX_TRY_COMPILE([
1661 #include <linux/fs.h>
1663 struct file *file = NULL;
1669 ret = kernel_read(file, buf, count, pos);
1672 AC_DEFINE(HAVE_KERNEL_READ_PPOS, 1,
1673 [kernel_read() take loff_t pointer])
1677 EXTRA_KCFLAGS="$tmp_flags"
1681 dnl # 4.15 API change
1682 dnl # https://lkml.org/lkml/2017/11/25/90
1683 dnl # Check if timer_list.func get passed a timer_list or an unsigned long
1684 dnl # (older kernels). Also sanity check the from_timer() and timer_setup()
1685 dnl # macros are available as well, since they will be used in the same newer
1686 dnl # kernels that support the new timer_list.func signature.
1688 AC_DEFUN([SPL_AC_KERNEL_TIMER_FUNCTION_TIMER_LIST], [
1689 AC_MSG_CHECKING([whether timer_list.function gets a timer_list])
1690 tmp_flags="$EXTRA_KCFLAGS"
1691 EXTRA_KCFLAGS="-Werror"
1692 SPL_LINUX_TRY_COMPILE([
1693 #include <linux/timer.h>
1694 void task_expire(struct timer_list *tl) {}
1697 #error "No from_timer() macro"
1700 struct timer_list timer;
1701 timer.function = task_expire;
1702 timer_setup(&timer, NULL, 0);
1705 AC_DEFINE(HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST, 1,
1706 [timer_list.function gets a timer_list])
1710 EXTRA_KCFLAGS="$tmp_flags"