1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 AC_SUBST(KERNELMAKE_PARAMS)
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
29 SPL_AC_2ARGS_REGISTER_SYSCTL
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
46 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_MUTEX_OWNER_TASK_STRUCT
50 SPL_AC_MUTEX_LOCK_NESTED
51 SPL_AC_3ARGS_ON_EACH_CPU
52 SPL_AC_KALLSYMS_LOOKUP_NAME
53 SPL_AC_GET_VMALLOC_INFO
55 SPL_AC_FIRST_ONLINE_PGDAT
56 SPL_AC_NEXT_ONLINE_PGDAT
59 SPL_AC_GLOBAL_PAGE_STATE
60 SPL_AC_ZONE_STAT_ITEM_FREE
61 SPL_AC_ZONE_STAT_ITEM_INACTIVE
62 SPL_AC_ZONE_STAT_ITEM_ACTIVE
63 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_SET_FS_PWD_WITH_CONST
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
70 SPL_AC_2ARGS_VFS_FSYNC
71 SPL_AC_INODE_TRUNCATE_RANGE
72 SPL_AC_FS_STRUCT_SPINLOCK
75 SPL_AC_PUT_TASK_STRUCT
76 SPL_AC_5ARGS_PROC_HANDLER
78 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
79 SPL_AC_KERNEL_FALLOCATE
80 SPL_AC_SHRINK_DCACHE_MEMORY
81 SPL_AC_SHRINK_ICACHE_MEMORY
82 SPL_AC_KERN_PATH_PARENT_HEADER
83 SPL_AC_KERN_PATH_PARENT_SYMBOL
84 SPL_AC_KERN_PATH_LOCKED
85 SPL_AC_CONFIG_KALLSYMS
86 SPL_AC_CONFIG_ZLIB_INFLATE
87 SPL_AC_CONFIG_ZLIB_DEFLATE
88 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
89 SPL_AC_SHRINK_CONTROL_STRUCT
90 SPL_AC_RWSEM_SPINLOCK_IS_RAW
91 SPL_AC_SCHED_RT_HEADER
92 SPL_AC_2ARGS_VFS_GETATTR
95 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
96 modpost=$LINUX/scripts/Makefile.modpost
97 AC_MSG_CHECKING([kernel file name for module symbols])
98 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
99 if grep -q Modules.symvers $modpost; then
100 LINUX_SYMBOLS=Modules.symvers
102 LINUX_SYMBOLS=Module.symvers
105 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
107 *** Please make sure the kernel devel package for your distribution
108 *** is installed. If you are building with a custom kernel, make sure the
109 *** kernel is configured, built, and the '--with-linux=PATH' configure
110 *** option refers to the location of the kernel source.])
115 AC_MSG_RESULT($LINUX_SYMBOLS)
116 AC_SUBST(LINUX_SYMBOLS)
119 AC_DEFUN([SPL_AC_KERNEL], [
121 AS_HELP_STRING([--with-linux=PATH],
122 [Path to kernel source]),
123 [kernelsrc="$withval"])
125 AC_ARG_WITH([linux-obj],
126 AS_HELP_STRING([--with-linux-obj=PATH],
127 [Path to kernel build objects]),
128 [kernelbuild="$withval"])
130 AC_MSG_CHECKING([kernel source directory])
131 if test -z "$kernelsrc"; then
132 if test -e "/lib/modules/$(uname -r)/source"; then
133 headersdir="/lib/modules/$(uname -r)/source"
134 sourcelink=$(readlink -f "$headersdir")
135 elif test -e "/lib/modules/$(uname -r)/build"; then
136 headersdir="/lib/modules/$(uname -r)/build"
137 sourcelink=$(readlink -f "$headersdir")
139 sourcelink=$(ls -1d /usr/src/kernels/* \
141 2>/dev/null | grep -v obj | tail -1)
144 if test -n "$sourcelink" && test -e ${sourcelink}; then
145 kernelsrc=`readlink -f ${sourcelink}`
147 kernelsrc="[Not found]"
150 if test "$kernelsrc" = "NONE"; then
155 AC_MSG_RESULT([$kernelsrc])
156 if test ! -d "$kernelsrc"; then
158 *** Please make sure the kernel devel package for your distribution
159 *** is installed and then try again. If that fails, you can specify the
160 *** location of the kernel source with the '--with-linux=PATH' option.])
163 AC_MSG_CHECKING([kernel build directory])
164 if test -z "$kernelbuild"; then
165 if test -e "/lib/modules/$(uname -r)/build"; then
166 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
167 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
168 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
169 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
170 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
171 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
172 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
174 kernelbuild=${kernelsrc}
177 AC_MSG_RESULT([$kernelbuild])
179 AC_MSG_CHECKING([kernel source version])
180 utsrelease1=$kernelbuild/include/linux/version.h
181 utsrelease2=$kernelbuild/include/linux/utsrelease.h
182 utsrelease3=$kernelbuild/include/generated/utsrelease.h
183 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
184 utsrelease=linux/version.h
185 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
186 utsrelease=linux/utsrelease.h
187 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
188 utsrelease=generated/utsrelease.h
191 if test "$utsrelease"; then
192 kernsrcver=`(echo "#include <$utsrelease>";
193 echo "kernsrcver=UTS_RELEASE") |
194 cpp -I $kernelbuild/include |
195 grep "^kernsrcver=" | cut -d \" -f 2`
197 if test -z "$kernsrcver"; then
198 AC_MSG_RESULT([Not found])
199 AC_MSG_ERROR([*** Cannot determine kernel version.])
202 AC_MSG_RESULT([Not found])
203 if test "x$enable_linux_builtin" != xyes; then
204 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
207 *** Cannot find UTS_RELEASE definition.
208 *** Please run 'make prepare' inside the kernel source tree.])
212 AC_MSG_RESULT([$kernsrcver])
215 LINUX_OBJ=${kernelbuild}
216 LINUX_VERSION=${kernsrcver}
220 AC_SUBST(LINUX_VERSION)
222 SPL_AC_MODULE_SYMVERS
226 dnl # Default SPL user configuration
228 AC_DEFUN([SPL_AC_CONFIG_USER], [])
231 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
232 dnl # are missing, it is non-fatal, but you will not be able to build
233 dnl # RPM packages and will be warned if you try too.
235 dnl # By default, the generic spec file will be used because it requires
236 dnl # minimal dependencies. Distribution specific spec files can be
237 dnl # placed under the 'rpm/<distribution>' directory and enabled using
238 dnl # the --with-spec=<distribution> configure option.
240 AC_DEFUN([SPL_AC_RPM], [
244 AC_MSG_CHECKING([whether $RPM is available])
245 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
246 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
248 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
251 AC_MSG_RESULT([$HAVE_RPM])
254 AC_MSG_CHECKING([whether $RPMBUILD is available])
255 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
256 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
258 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
261 AC_MSG_RESULT([$HAVE_RPMBUILD])
264 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
266 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
269 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
274 RPM_SPEC_DIR="rpm/generic"
276 AS_HELP_STRING([--with-spec=SPEC],
277 [Spec files 'generic|fedora']),
278 [RPM_SPEC_DIR="rpm/$withval"])
280 AC_MSG_CHECKING([whether spec files are available])
281 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
285 AC_SUBST(RPM_VERSION)
287 AC_SUBST(HAVE_RPMBUILD)
289 AC_SUBST(RPMBUILD_VERSION)
291 AC_SUBST(RPM_SPEC_DIR)
292 AC_SUBST(RPM_DEFINE_UTIL)
293 AC_SUBST(RPM_DEFINE_KMOD)
294 AC_SUBST(RPM_DEFINE_DKMS)
295 AC_SUBST(RPM_DEFINE_COMMON)
296 AC_SUBST(SRPM_DEFINE_UTIL)
297 AC_SUBST(SRPM_DEFINE_KMOD)
298 AC_SUBST(SRPM_DEFINE_DKMS)
299 AC_SUBST(SRPM_DEFINE_COMMON)
303 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
304 dnl # tools are missing it is non-fatal but you will not be able to build
305 dnl # DEB packages and will be warned if you try too.
307 AC_DEFUN([SPL_AC_DPKG], [
309 DPKGBUILD=dpkg-buildpackage
311 AC_MSG_CHECKING([whether $DPKG is available])
312 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
313 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
315 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
318 AC_MSG_RESULT([$HAVE_DPKG])
321 AC_MSG_CHECKING([whether $DPKGBUILD is available])
322 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
323 DPKGBUILD_VERSION=$(echo $tmp | \
324 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
326 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
329 AC_MSG_RESULT([$HAVE_DPKGBUILD])
334 AC_SUBST(DPKG_VERSION)
336 AC_SUBST(HAVE_DPKGBUILD)
338 AC_SUBST(DPKGBUILD_VERSION)
342 dnl # Until native packaging for various different packing systems
343 dnl # can be added the least we can do is attempt to use alien to
344 dnl # convert the RPM packages to the needed package type. This is
345 dnl # a hack but so far it has worked reasonable well.
347 AC_DEFUN([SPL_AC_ALIEN], [
350 AC_MSG_CHECKING([whether $ALIEN is available])
351 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
352 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
354 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
357 AC_MSG_RESULT([$HAVE_ALIEN])
362 AC_SUBST(ALIEN_VERSION)
366 dnl # Using the VENDOR tag from config.guess set the default
367 dnl # package type for 'make pkg': (rpm | deb | tgz)
369 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
370 AC_MSG_CHECKING([linux distribution])
371 if test -f /etc/toss-release ; then
373 elif test -f /etc/fedora-release ; then
375 elif test -f /etc/redhat-release ; then
377 elif test -f /etc/gentoo-release ; then
379 elif test -f /etc/arch-release ; then
381 elif test -f /etc/SuSE-release ; then
383 elif test -f /etc/slackware-version ; then
385 elif test -f /etc/lunar.release ; then
387 elif test -f /etc/lsb-release ; then
389 elif test -f /etc/debian_version ; then
394 AC_MSG_RESULT([$VENDOR])
397 AC_MSG_CHECKING([default package type])
399 toss) DEFAULT_PACKAGE=rpm ;;
400 redhat) DEFAULT_PACKAGE=rpm ;;
401 fedora) DEFAULT_PACKAGE=rpm ;;
402 gentoo) DEFAULT_PACKAGE=tgz ;;
403 arch) DEFAULT_PACKAGE=tgz ;;
404 sles) DEFAULT_PACKAGE=rpm ;;
405 slackware) DEFAULT_PACKAGE=tgz ;;
406 lunar) DEFAULT_PACKAGE=tgz ;;
407 ubuntu) DEFAULT_PACKAGE=deb ;;
408 debian) DEFAULT_PACKAGE=deb ;;
409 *) DEFAULT_PACKAGE=rpm ;;
412 AC_MSG_RESULT([$DEFAULT_PACKAGE])
413 AC_SUBST(DEFAULT_PACKAGE)
417 dnl # Default SPL user configuration
419 AC_DEFUN([SPL_AC_PACKAGE], [
420 SPL_AC_DEFAULT_PACKAGE
426 AC_DEFUN([SPL_AC_LICENSE], [
427 AC_MSG_CHECKING([spl license])
429 AC_MSG_RESULT([$LICENSE])
430 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
434 AC_DEFUN([SPL_AC_CONFIG], [
436 AC_ARG_WITH([config],
437 AS_HELP_STRING([--with-config=CONFIG],
438 [Config file 'kernel|user|all|srpm']),
439 [SPL_CONFIG="$withval"])
440 AC_ARG_ENABLE([linux-builtin],
441 [AC_HELP_STRING([--enable-linux-builtin],
442 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
444 [enable_linux_builtin=no])
446 AC_MSG_CHECKING([spl config])
447 AC_MSG_RESULT([$SPL_CONFIG]);
450 case "$SPL_CONFIG" in
451 kernel) SPL_AC_CONFIG_KERNEL ;;
452 user) SPL_AC_CONFIG_USER ;;
453 all) SPL_AC_CONFIG_KERNEL
454 SPL_AC_CONFIG_USER ;;
457 AC_MSG_RESULT([Error!])
458 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
459 user kernel|user|all|srpm]) ;;
462 AM_CONDITIONAL([CONFIG_USER],
463 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
464 AM_CONDITIONAL([CONFIG_KERNEL],
465 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
466 [test "x$enable_linux_builtin" != xyes ])
470 dnl # Enable if the SPL should be compiled with internal debugging enabled.
471 dnl # By default this support is disabled.
473 AC_DEFUN([SPL_AC_DEBUG], [
474 AC_MSG_CHECKING([whether debugging is enabled])
475 AC_ARG_ENABLE([debug],
476 [AS_HELP_STRING([--enable-debug],
477 [Enable generic debug support @<:@default=no@:>@])],
481 AS_IF([test "x$enable_debug" = xyes],
483 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
484 DEBUG_CFLAGS="-DDEBUG -Werror"
485 DEBUG_SPL="_with_debug"
487 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
488 DEBUG_CFLAGS="-DNDEBUG"
489 DEBUG_SPL="_without_debug"
492 AC_SUBST(DEBUG_CFLAGS)
494 AC_MSG_RESULT([$enable_debug])
498 dnl # Enabled by default it provides a basic debug log infrastructure.
499 dnl # Each subsystem registers itself with a name and logs messages
500 dnl # using predefined types. If the debug mask it set to allow the
501 dnl # message type it will be written to the internal log. The log
502 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
503 dnl # after dumping the log it must be decoded using the spl utility.
505 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
506 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
508 AC_DEFUN([SPL_AC_DEBUG_LOG], [
509 AC_ARG_ENABLE([debug-log],
510 [AS_HELP_STRING([--enable-debug-log],
511 [Enable basic debug logging @<:@default=yes@:>@])],
513 [enable_debug_log=yes])
515 AS_IF([test "x$enable_debug_log" = xyes],
517 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
518 DEBUG_LOG="_with_debug_log"
519 AC_DEFINE([DEBUG_LOG], [1],
520 [Define to 1 to enable basic debug logging])
522 DEBUG_LOG="_without_debug_log"
526 AC_MSG_CHECKING([whether basic debug logging is enabled])
527 AC_MSG_RESULT([$enable_debug_log])
531 dnl # Enabled by default it provides a minimal level of memory tracking.
532 dnl # A total count of bytes allocated is kept for each alloc and free.
533 dnl # Then at module unload time a report to the console will be printed
534 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
535 dnl # and provide an easy way to inspect the kmem based slab.
537 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
538 AC_ARG_ENABLE([debug-kmem],
539 [AS_HELP_STRING([--enable-debug-kmem],
540 [Enable basic kmem accounting @<:@default=yes@:>@])],
542 [enable_debug_kmem=yes])
544 AS_IF([test "x$enable_debug_kmem" = xyes],
546 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
547 DEBUG_KMEM="_with_debug_kmem"
548 AC_DEFINE([DEBUG_KMEM], [1],
549 [Define to 1 to enable basic kmem accounting])
551 DEBUG_KMEM="_without_debug_kmem"
555 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
556 AC_MSG_RESULT([$enable_debug_kmem])
560 dnl # Disabled by default it provides detailed memory tracking. This
561 dnl # feature also requires --enable-debug-kmem to be set. When enabled
562 dnl # not only will total bytes be tracked but also the location of every
563 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
564 dnl # addresses and where they were allocated will be dumped to the console.
565 dnl # Enabling this feature has a significant impact on performance but it
566 dnl # makes finding memory leaks pretty straight forward.
568 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
569 AC_ARG_ENABLE([debug-kmem-tracking],
570 [AS_HELP_STRING([--enable-debug-kmem-tracking],
571 [Enable detailed kmem tracking @<:@default=no@:>@])],
573 [enable_debug_kmem_tracking=no])
575 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
577 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
578 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
579 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
580 [Define to 1 to enable detailed kmem tracking])
582 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
585 AC_SUBST(DEBUG_KMEM_TRACKING)
586 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
587 AC_MSG_RESULT([$enable_debug_kmem_tracking])
591 dnl # SPL_LINUX_CONFTEST
593 AC_DEFUN([SPL_LINUX_CONFTEST], [
594 cat confdefs.h - <<_ACEOF >conftest.c
600 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
602 m4_define([SPL_LANG_PROGRAM], [
607 dnl Do *not* indent the following line: there may be CPP directives.
608 dnl Don't move the `;' right after for the same reason.
616 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
618 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
619 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
620 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
621 echo "obj-m := conftest.o" >build/Makefile
623 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
625 [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])],
627 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
633 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
635 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
636 [SPL_LINUX_COMPILE_IFELSE(
637 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
639 [test -s build/conftest.o],
644 dnl # SPL_CHECK_SYMBOL_EXPORT
645 dnl # check symbol exported or not
647 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
648 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
649 $LINUX_OBJ/Module*.symvers 2>/dev/null
651 if test $rc -ne 0; then
654 grep -q -E "EXPORT_SYMBOL.*($1)" \
655 "$LINUX_OBJ/$file" 2>/dev/null
657 if test $rc -eq 0; then
662 if test $export -eq 0; then :
673 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
674 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
675 dnl # is called if not compiling for builtin
677 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
678 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
679 if test $rc -ne 0; then :
682 if test "x$enable_linux_builtin" != xyes; then
683 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
685 if test $rc -ne 0; then :
694 dnl # SPL_CHECK_SYMBOL_HEADER
695 dnl # check if a symbol prototype is defined in listed headers.
697 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
698 AC_MSG_CHECKING([whether symbol $1 exists in header])
701 grep -q "$2" "$LINUX/$file" 2>/dev/null
703 if test $rc -eq 0; then
708 if test $header -eq 0; then
718 dnl # SPL_CHECK_HEADER
719 dnl # check whether header exists and define HAVE_$2_HEADER
721 AC_DEFUN([SPL_CHECK_HEADER],
722 [AC_MSG_CHECKING([whether header $1 exists])
723 SPL_LINUX_TRY_COMPILE([
728 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
738 dnl # Basic toolchain sanity check.
740 AC_DEFUN([SPL_AC_TEST_MODULE],
741 [AC_MSG_CHECKING([whether modules can be built])
742 SPL_LINUX_TRY_COMPILE([],[],[
746 if test "x$enable_linux_builtin" != xyes; then
747 AC_MSG_ERROR([*** Unable to build an empty module.])
750 *** Unable to build an empty module.
751 *** Please run 'make scripts' inside the kernel source tree.])
757 dnl # Use the atomic implemenation based on global spinlocks. This
758 dnl # should only be needed by 32-bit kernels which do not provide
759 dnl # the atomic64_* API. It may be optionally enabled as a fallback
760 dnl # if problems are observed with the direct mapping to the native
761 dnl # Linux atomic operations. You may not disable atomic spinlocks
762 dnl # if you kernel does not an atomic64_* API.
764 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
765 AC_ARG_ENABLE([atomic-spinlocks],
766 [AS_HELP_STRING([--enable-atomic-spinlocks],
767 [Atomic types use spinlocks @<:@default=check@:>@])],
769 [enable_atomic_spinlocks=check])
771 SPL_LINUX_TRY_COMPILE([
772 #include <linux/fs.h>
774 atomic64_t *ptr __attribute__ ((unused));
777 AC_DEFINE(HAVE_ATOMIC64_T, 1,
778 [kernel defines atomic64_t])
783 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
784 AS_IF([test "x$have_atomic64_t" = xyes], [
785 enable_atomic_spinlocks=no
787 enable_atomic_spinlocks=yes
791 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
792 AC_DEFINE([ATOMIC_SPINLOCK], [1],
793 [Atomic types use spinlocks])
795 AS_IF([test "x$have_atomic64_t" = xno], [
797 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
801 AC_MSG_CHECKING([whether atomic types use spinlocks])
802 AC_MSG_RESULT([$enable_atomic_spinlocks])
804 AC_MSG_CHECKING([whether kernel defines atomic64_t])
805 AC_MSG_RESULT([$have_atomic64_t])
809 dnl # 2.6.24 API change,
810 dnl # check if atomic64_cmpxchg is defined
812 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
813 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
814 SPL_LINUX_TRY_COMPILE([
815 #include <linux/fs.h>
817 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
820 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
821 [kernel defines atomic64_cmpxchg])
828 dnl # 2.6.24 API change,
829 dnl # check if atomic64_xchg is defined
831 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
832 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
833 SPL_LINUX_TRY_COMPILE([
834 #include <linux/fs.h>
836 atomic64_xchg((atomic64_t *)NULL, 0);
839 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
840 [kernel defines atomic64_xchg])
847 dnl # 2.6.24 API change,
848 dnl # check if uintptr_t typedef is defined
850 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
851 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
852 SPL_LINUX_TRY_COMPILE([
853 #include <linux/types.h>
855 uintptr_t *ptr __attribute__ ((unused));
858 AC_DEFINE(HAVE_UINTPTR_T, 1,
859 [kernel defines uintptr_t])
866 dnl # 2.6.21 API change,
867 dnl # 'register_sysctl_table' use only one argument instead of two
869 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
870 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
871 SPL_LINUX_TRY_COMPILE([
872 #include <linux/sysctl.h>
874 (void) register_sysctl_table(NULL, 0);
877 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
878 [register_sysctl_table() wants 2 args])
885 dnl # 2.6.23 API change
886 dnl # Old set_shrinker API replaced with register_shrinker
888 AC_DEFUN([SPL_AC_SET_SHRINKER], [
889 AC_MSG_CHECKING([whether set_shrinker() available])
890 SPL_LINUX_TRY_COMPILE([
891 #include <linux/mm.h>
893 return set_shrinker(DEFAULT_SEEKS, NULL);
896 AC_DEFINE(HAVE_SET_SHRINKER, 1,
897 [set_shrinker() available])
904 dnl # 2.6.35 API change,
905 dnl # Add context to shrinker callback
907 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
908 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
909 tmp_flags="$EXTRA_KCFLAGS"
910 EXTRA_KCFLAGS="-Werror"
911 SPL_LINUX_TRY_COMPILE([
912 #include <linux/mm.h>
914 int shrinker_cb(struct shrinker *, int, unsigned int);
916 struct shrinker cache_shrinker = {
917 .shrink = shrinker_cb,
918 .seeks = DEFAULT_SEEKS,
920 register_shrinker(&cache_shrinker);
923 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
924 [shrinker callback wants 3 args])
928 EXTRA_KCFLAGS="$tmp_flags"
932 dnl # 2.6.25 API change,
933 dnl # struct path entry added to struct nameidata
935 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
936 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
937 SPL_LINUX_TRY_COMPILE([
938 #include <linux/namei.h>
940 struct nameidata nd __attribute__ ((unused));
943 nd.path.dentry = NULL;
946 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
947 [struct path used in struct nameidata])
954 dnl # Custom SPL patch may export this system it is not required
956 AC_DEFUN([SPL_AC_TASK_CURR],
957 [AC_MSG_CHECKING([whether task_curr() is available])
958 SPL_LINUX_TRY_COMPILE_SYMBOL([
959 #include <linux/sched.h>
962 ], [task_curr], [kernel/sched.c], [
964 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
971 dnl # 2.6.19 API change,
972 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
974 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
975 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
976 SPL_LINUX_TRY_COMPILE([
977 #include <linux/sysctl.h>
979 #ifndef CTL_UNNUMBERED
980 #error CTL_UNNUMBERED undefined
984 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
985 [unnumbered sysctl support exists])
992 dnl # 2.6.33 API change,
993 dnl # Removed .ctl_name from struct ctl_table.
995 AC_DEFUN([SPL_AC_CTL_NAME], [
996 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
997 SPL_LINUX_TRY_COMPILE([
998 #include <linux/sysctl.h>
1000 struct ctl_table ctl __attribute__ ((unused));
1004 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1011 dnl # 2.6.16 API change.
1012 dnl # Check if 'fls64()' is available
1014 AC_DEFUN([SPL_AC_FLS64],
1015 [AC_MSG_CHECKING([whether fls64() is available])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/bitops.h>
1022 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1029 dnl # 2.6.18 API change, check whether device_create() is available.
1030 dnl # Device_create() was introduced in 2.6.18 and depricated
1031 dnl # class_device_create() which was fully removed in 2.6.26.
1033 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1034 [AC_MSG_CHECKING([whether device_create() is available])
1035 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1037 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1038 [device_create() is available])
1045 dnl # 2.6.27 API change,
1046 dnl # device_create() uses 5 args, new 'drvdata' argument.
1048 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1049 AC_MSG_CHECKING([whether device_create() wants 5 args])
1050 tmp_flags="$EXTRA_KCFLAGS"
1051 EXTRA_KCFLAGS="-Werror"
1052 SPL_LINUX_TRY_COMPILE([
1053 #include <linux/device.h>
1055 device_create(NULL, NULL, 0, NULL, "%d", 1);
1058 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1059 [device_create wants 5 args])
1063 EXTRA_KCFLAGS="$tmp_flags"
1067 dnl # 2.6.13 API change, check whether class_device_create() is available.
1068 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1069 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1071 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1072 [AC_MSG_CHECKING([whether class_device_create() is available])
1073 SPL_LINUX_TRY_COMPILE_SYMBOL([
1074 #include <linux/device.h>
1076 class_device_create(NULL, NULL, 0, NULL, NULL);
1077 ], [class_device_create], [drivers/base/class.c], [
1079 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1080 [class_device_create() is available])
1087 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1089 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1090 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1091 SPL_LINUX_TRY_COMPILE_SYMBOL([
1092 #include <linux/time.h>
1094 set_normalized_timespec(NULL, 0, 0);
1095 ], [set_normalized_timespec], [kernel/time.c], [
1097 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1098 [set_normalized_timespec() is available as export])
1105 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1106 dnl # previously it was available in time.h as an inline.
1108 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1109 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1110 SPL_LINUX_TRY_COMPILE([
1111 #include <linux/time.h>
1112 void set_normalized_timespec(struct timespec *ts,
1113 time_t sec, long nsec) { }
1120 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1121 [set_normalized_timespec() is available as inline])
1126 dnl # 2.6.18 API change,
1127 dnl # timespec_sub() inline function available in linux/time.h
1129 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1130 AC_MSG_CHECKING([whether timespec_sub() is available])
1131 SPL_LINUX_TRY_COMPILE([
1132 #include <linux/time.h>
1134 struct timespec a = { 0 };
1135 struct timespec b = { 0 };
1136 struct timespec c __attribute__ ((unused));
1137 c = timespec_sub(a, b);
1140 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1147 dnl # 2.6.19 API change,
1148 dnl # check if init_utsname() is available in linux/utsname.h
1150 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1151 AC_MSG_CHECKING([whether init_utsname() is available])
1152 SPL_LINUX_TRY_COMPILE([
1153 #include <linux/utsname.h>
1155 struct new_utsname *a __attribute__ ((unused));
1159 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1166 dnl # 2.6.18 API change,
1167 dnl # added linux/uaccess.h
1169 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1170 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1174 dnl # 2.6.12 API change,
1175 dnl # check whether 'kmalloc_node()' is available.
1177 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1178 AC_MSG_CHECKING([whether kmalloc_node() is available])
1179 SPL_LINUX_TRY_COMPILE([
1180 #include <linux/slab.h>
1182 void *a __attribute__ ((unused));
1183 a = kmalloc_node(1, GFP_KERNEL, 0);
1186 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1193 dnl # 2.6.9 API change,
1194 dnl # check whether 'monotonic_clock()' is available it may
1195 dnl # be available for some archs but not others.
1197 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1198 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1199 SPL_LINUX_TRY_COMPILE_SYMBOL([
1200 #include <linux/timex.h>
1203 ], [monotonic_clock], [], [
1205 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1206 [monotonic_clock() is available])
1213 dnl # 2.6.16 API change,
1214 dnl # check whether 'struct inode' has i_mutex
1216 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1217 AC_MSG_CHECKING([whether struct inode has i_mutex])
1218 SPL_LINUX_TRY_COMPILE([
1219 #include <linux/fs.h>
1220 #include <linux/mutex.h>
1223 mutex_init(&i.i_mutex);
1226 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1233 dnl # 2.6.29 API change,
1234 dnl # Adaptive mutexs introduced.
1236 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1237 AC_MSG_CHECKING([whether struct mutex has owner])
1238 SPL_LINUX_TRY_COMPILE([
1239 #include <linux/mutex.h>
1241 struct mutex mtx __attribute__ ((unused));
1245 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1252 dnl # 2.6.39 API change,
1253 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1254 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1255 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1256 dnl # pointer which frankly makes a lot more sense.
1258 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1259 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1260 tmp_flags="$EXTRA_KCFLAGS"
1261 EXTRA_KCFLAGS="-Werror"
1262 SPL_LINUX_TRY_COMPILE([
1263 #include <linux/mutex.h>
1264 #include <linux/sched.h>
1266 struct mutex mtx __attribute__ ((unused));
1267 mtx.owner = current;
1270 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1271 [struct mutex owner is a task_struct])
1275 EXTRA_KCFLAGS="$tmp_flags"
1279 dnl # 2.6.18 API change,
1280 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1281 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1282 dnl # if the mutex validator is disabled or otherwise unavailable.
1284 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1285 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1286 SPL_LINUX_TRY_COMPILE([
1287 #include <linux/mutex.h>
1291 mutex_lock_nested(&mutex, 0);
1294 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1295 [mutex_lock_nested() is available])
1302 dnl # 2.6.27 API change,
1303 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1305 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1306 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1307 SPL_LINUX_TRY_COMPILE([
1308 #include <linux/interrupt.h>
1309 #include <linux/smp.h>
1311 void on_each_cpu_func(void *data) { return; }
1313 on_each_cpu(on_each_cpu_func, NULL, 0);
1316 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1317 [on_each_cpu wants 3 args])
1324 dnl # 2.6.18 API change,
1325 dnl # kallsyms_lookup_name no longer exported
1327 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1328 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1329 SPL_LINUX_TRY_COMPILE_SYMBOL([
1330 #include <linux/kallsyms.h>
1332 kallsyms_lookup_name(NULL);
1333 ], [kallsyms_lookup_name], [], [
1335 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1336 [kallsyms_lookup_name() is available])
1343 dnl # Proposed API change,
1344 dnl # This symbol is not available in stock kernels. You may build a
1345 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1346 dnl # these symbols for use. If your already rolling a custom kernel for
1347 dnl # your environment this is recommended.
1349 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1350 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1351 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1353 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1354 [get_vmalloc_info() is available])
1361 dnl # 2.6.17 API change
1362 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1363 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1364 dnl # were exported in 2.6.17 for use by modules which was consistent with
1365 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1366 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1367 dnl # were dropped entirely leaving modules no way to directly iterate over
1368 dnl # the zone list. Because we need access to the zone helpers we check
1369 dnl # if the kernel contains the old or new implementation. Then we check
1370 dnl # to see if the symbols we need for each version are available. If they
1371 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1373 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1374 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1375 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1377 if test $rc -eq 0; then
1378 AC_MSG_RESULT([yes])
1379 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1386 dnl # Proposed API change,
1387 dnl # This symbol is not available in stock kernels. You may build a
1388 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1389 dnl # these symbols for use. If your already rolling a custom kernel for
1390 dnl # your environment this is recommended.
1392 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1393 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1394 SPL_LINUX_TRY_COMPILE_SYMBOL([
1395 #include <linux/mmzone.h>
1397 first_online_pgdat();
1398 ], [first_online_pgdat], [], [
1400 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1401 [first_online_pgdat() is available])
1408 dnl # Proposed API change,
1409 dnl # This symbol is not available in stock kernels. You may build a
1410 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1411 dnl # these symbols for use. If your already rolling a custom kernel for
1412 dnl # your environment this is recommended.
1414 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1415 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1416 SPL_LINUX_TRY_COMPILE_SYMBOL([
1417 #include <linux/mmzone.h>
1419 next_online_pgdat(NULL);
1420 ], [next_online_pgdat], [], [
1422 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1423 [next_online_pgdat() is available])
1430 dnl # Proposed API change,
1431 dnl # This symbol is not available in stock kernels. You may build a
1432 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1433 dnl # these symbols for use. If your already rolling a custom kernel for
1434 dnl # your environment this is recommended.
1436 AC_DEFUN([SPL_AC_NEXT_ZONE],
1437 [AC_MSG_CHECKING([whether next_zone() is available])
1438 SPL_LINUX_TRY_COMPILE_SYMBOL([
1439 #include <linux/mmzone.h>
1442 ], [next_zone], [], [
1444 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1451 dnl # 2.6.17 API change,
1452 dnl # See SPL_AC_PGDAT_HELPERS for details.
1454 AC_DEFUN([SPL_AC_PGDAT_LIST],
1455 [AC_MSG_CHECKING([whether pgdat_list is available])
1456 SPL_LINUX_TRY_COMPILE_SYMBOL([
1457 #include <linux/topology.h>
1458 pg_data_t *tmp = pgdat_list;
1459 ], [], [pgdat_list], [], [
1461 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1468 dnl # 2.6.18 API change,
1469 dnl # First introduced global_page_state() support as an inline.
1471 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1472 AC_MSG_CHECKING([whether global_page_state() is available])
1473 SPL_LINUX_TRY_COMPILE([
1474 #include <linux/mm.h>
1476 unsigned long state __attribute__ ((unused));
1477 state = global_page_state(0);
1480 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1481 [global_page_state() is available])
1488 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1489 dnl # Public global zone stats now include a free page count. However
1490 dnl # the enumerated names of the counters have changed since this API
1491 dnl # was introduced. We need to deduce the corrent name to use. This
1492 dnl # replaces the priviate get_zone_counts() interface.
1494 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1495 dnl # is 2.6.30 as of when this was written.
1497 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1498 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1499 SPL_LINUX_TRY_COMPILE([
1500 #include <linux/mm.h>
1502 enum zone_stat_item zsi __attribute__ ((unused));
1503 zsi = NR_FREE_PAGES;
1506 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1507 [Page state NR_FREE_PAGES is available])
1514 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1515 dnl # Public global zone stats now include an inactive page count. However
1516 dnl # the enumerated names of the counters have changed since this API
1517 dnl # was introduced. We need to deduce the corrent name to use. This
1518 dnl # replaces the priviate get_zone_counts() interface.
1520 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1521 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1522 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1524 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1525 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1526 SPL_LINUX_TRY_COMPILE([
1527 #include <linux/mm.h>
1529 enum zone_stat_item zsi __attribute__ ((unused));
1533 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1534 [Page state NR_INACTIVE is available])
1539 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1540 SPL_LINUX_TRY_COMPILE([
1541 #include <linux/mm.h>
1543 enum zone_stat_item zsi __attribute__ ((unused));
1544 zsi = NR_INACTIVE_ANON;
1547 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1548 [Page state NR_INACTIVE_ANON is available])
1553 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1554 SPL_LINUX_TRY_COMPILE([
1555 #include <linux/mm.h>
1557 enum zone_stat_item zsi __attribute__ ((unused));
1558 zsi = NR_INACTIVE_FILE;
1561 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1562 [Page state NR_INACTIVE_FILE is available])
1569 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1570 dnl # Public global zone stats now include an active page count. However
1571 dnl # the enumerated names of the counters have changed since this API
1572 dnl # was introduced. We need to deduce the corrent name to use. This
1573 dnl # replaces the priviate get_zone_counts() interface.
1575 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1576 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1577 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1579 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1580 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1581 SPL_LINUX_TRY_COMPILE([
1582 #include <linux/mm.h>
1584 enum zone_stat_item zsi __attribute__ ((unused));
1588 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1589 [Page state NR_ACTIVE is available])
1594 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1595 SPL_LINUX_TRY_COMPILE([
1596 #include <linux/mm.h>
1598 enum zone_stat_item zsi __attribute__ ((unused));
1599 zsi = NR_ACTIVE_ANON;
1602 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1603 [Page state NR_ACTIVE_ANON is available])
1608 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1609 SPL_LINUX_TRY_COMPILE([
1610 #include <linux/mm.h>
1612 enum zone_stat_item zsi __attribute__ ((unused));
1613 zsi = NR_ACTIVE_FILE;
1616 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1617 [Page state NR_ACTIVE_FILE is available])
1624 dnl # Proposed API change for legacy kernels.
1625 dnl # This symbol is not available in older kernels. For kernels post
1626 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1627 dnl # page state information. This symbol is only used in legacy kernels
1628 dnl # any only as a last resort.
1630 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1631 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1632 SPL_LINUX_TRY_COMPILE([
1634 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1635 #error "global_page_state needs NR_FREE_PAGES"
1638 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1639 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1640 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1641 #error "global_page_state needs NR_ACTIVE*"
1644 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1645 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1646 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1647 #error "global_page_state needs NR_INACTIVE*"
1653 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1654 [get_zone_counts() is needed])
1656 AC_MSG_CHECKING([whether get_zone_counts() is available])
1657 SPL_LINUX_TRY_COMPILE_SYMBOL([
1658 #include <linux/mmzone.h>
1660 get_zone_counts(NULL, NULL, NULL);
1661 ], [get_zone_counts], [], [
1663 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1664 [get_zone_counts() is available])
1672 dnl # 2.6.27 API change,
1673 dnl # The user_path_dir() replaces __user_walk()
1675 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1676 [AC_MSG_CHECKING([whether user_path_dir() is available])
1677 SPL_LINUX_TRY_COMPILE_SYMBOL([
1678 #include <linux/fcntl.h>
1679 #include <linux/namei.h>
1681 user_path_dir(NULL, NULL);
1682 ], [user_path_at], [], [
1684 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1691 dnl # Symbol available in RHEL kernels not in stock kernels.
1693 AC_DEFUN([SPL_AC_SET_FS_PWD],
1694 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1695 SPL_LINUX_TRY_COMPILE_SYMBOL([
1696 #include <linux/spinlock.h>
1697 #include <linux/fs_struct.h>
1700 ], [set_fs_pwd], [], [
1702 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1709 dnl # 3.9 API change
1710 dnl # set_fs_pwd takes const struct path *
1712 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1713 tmp_flags="$EXTRA_KCFLAGS"
1714 EXTRA_KCFLAGS="-Werror"
1715 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1716 SPL_LINUX_TRY_COMPILE([
1717 #include <linux/spinlock.h>
1718 #include <linux/fs_struct.h>
1719 #include <linux/path.h>
1720 void (*const set_fs_pwd_func)
1721 (struct fs_struct *, const struct path *)
1727 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1728 [set_fs_pwd() needs const path *])
1730 SPL_LINUX_TRY_COMPILE([
1731 #include <linux/spinlock.h>
1732 #include <linux/fs_struct.h>
1733 #include <linux/path.h>
1734 void (*const set_fs_pwd_func)
1735 (struct fs_struct *, struct path *)
1742 AC_MSG_ERROR(unknown)
1745 EXTRA_KCFLAGS="$tmp_flags"
1749 dnl # SLES API change, never adopted in mainline,
1750 dnl # Third 'struct vfsmount *' argument removed.
1752 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1753 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1754 SPL_LINUX_TRY_COMPILE([
1755 #include <linux/fs.h>
1757 vfs_unlink(NULL, NULL);
1760 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1761 [vfs_unlink() wants 2 args])
1768 dnl # SLES API change, never adopted in mainline,
1769 dnl # Third and sixth 'struct vfsmount *' argument removed.
1771 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1772 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1773 SPL_LINUX_TRY_COMPILE([
1774 #include <linux/fs.h>
1776 vfs_rename(NULL, NULL, NULL, NULL);
1779 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1780 [vfs_rename() wants 4 args])
1787 dnl # 2.6.36 API change,
1788 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1789 dnl # a spinlock_t to improve the fastpath performance.
1791 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1792 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1793 tmp_flags="$EXTRA_KCFLAGS"
1794 EXTRA_KCFLAGS="-Werror"
1795 SPL_LINUX_TRY_COMPILE([
1796 #include <linux/sched.h>
1797 #include <linux/fs_struct.h>
1799 struct fs_struct fs;
1800 spin_lock_init(&fs.lock);
1803 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1804 [struct fs_struct uses spinlock_t])
1808 EXTRA_KCFLAGS="$tmp_flags"
1812 dnl # 2.6.29 API change,
1813 dnl # check whether 'struct cred' exists
1815 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1816 AC_MSG_CHECKING([whether struct cred exists])
1817 SPL_LINUX_TRY_COMPILE([
1818 #include <linux/cred.h>
1820 struct cred *cr __attribute__ ((unused));
1824 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1831 dnl # Custom SPL patch may export this symbol.
1833 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1834 [AC_MSG_CHECKING([whether groups_search() is available])
1835 SPL_LINUX_TRY_COMPILE_SYMBOL([
1836 #include <linux/cred.h>
1838 groups_search(NULL, 0);
1839 ], [groups_search], [], [
1841 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1848 dnl # 2.6.x API change,
1849 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1851 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1852 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1853 SPL_LINUX_TRY_COMPILE_SYMBOL([
1854 #include <linux/sched.h>
1856 __put_task_struct(NULL);
1857 ], [__put_task_struct], [], [
1859 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1860 [__put_task_struct() is available])
1867 dnl # 2.6.32 API change,
1868 dnl # Unused 'struct file *' removed from prototype.
1870 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1871 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1872 SPL_LINUX_TRY_COMPILE([
1873 #include <linux/sysctl.h>
1875 proc_dostring(NULL, 0, NULL, NULL, NULL);
1878 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1879 [proc_handler() wants 5 args])
1886 dnl # 2.6.x API change,
1887 dnl # kvasprintf() function added.
1889 AC_DEFUN([SPL_AC_KVASPRINTF],
1890 [AC_MSG_CHECKING([whether kvasprintf() is available])
1891 SPL_LINUX_TRY_COMPILE_SYMBOL([
1892 #include <linux/kernel.h>
1894 kvasprintf(0, NULL, *((va_list*)NULL));
1895 ], [kvasprintf], [], [
1897 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1904 dnl # 2.6.29 API change,
1905 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1907 AC_DEFUN([SPL_AC_VFS_FSYNC],
1908 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1909 SPL_LINUX_TRY_COMPILE_SYMBOL([
1910 #include <linux/fs.h>
1913 ], [vfs_fsync], [fs/sync.c], [
1915 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1922 dnl # 2.6.35 API change,
1923 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1925 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1926 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1927 SPL_LINUX_TRY_COMPILE([
1928 #include <linux/fs.h>
1933 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1940 dnl # 3.5 API change,
1941 dnl # inode_operations.truncate_range removed
1943 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1944 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1945 SPL_LINUX_TRY_COMPILE([
1946 #include <linux/fs.h>
1948 struct inode_operations ops;
1949 ops.truncate_range = NULL;
1952 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1953 [truncate_range() inode operation is available])
1960 dnl # Linux 2.6.38 - 3.x API
1962 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1963 AC_MSG_CHECKING([whether fops->fallocate() exists])
1964 SPL_LINUX_TRY_COMPILE([
1965 #include <linux/fs.h>
1967 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1968 struct file_operations fops __attribute__ ((unused)) = {
1969 .fallocate = fallocate,
1973 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1980 dnl # Linux 2.6.x - 2.6.37 API
1982 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1983 AC_MSG_CHECKING([whether iops->fallocate() exists])
1984 SPL_LINUX_TRY_COMPILE([
1985 #include <linux/fs.h>
1987 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1988 struct inode_operations fops __attribute__ ((unused)) = {
1989 .fallocate = fallocate,
1993 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2000 dnl # PaX Linux 2.6.38 - 3.x API
2002 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2003 AC_MSG_CHECKING([whether fops->fallocate() exists])
2004 SPL_LINUX_TRY_COMPILE([
2005 #include <linux/fs.h>
2007 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2008 struct file_operations_no_const fops __attribute__ ((unused)) = {
2009 .fallocate = fallocate,
2013 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2020 dnl # The fallocate callback was moved from the inode_operations
2021 dnl # structure to the file_operations structure.
2023 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2024 SPL_AC_KERNEL_FILE_FALLOCATE
2025 SPL_AC_KERNEL_INODE_FALLOCATE
2026 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2030 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2031 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2032 dnl # condition. The fixed version is exported as a symbol. The race
2033 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2034 dnl # call that version while holding sem->wait_lock.
2036 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2037 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2038 SPL_LINUX_TRY_COMPILE_SYMBOL([
2039 #include <linux/rwsem.h>
2040 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2041 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2043 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2044 [rwsem_is_locked() acquires sem->wait_lock])
2051 dnl # 2.6.xx API compat,
2052 dnl # There currently exists no exposed API to partially shrink the dcache.
2053 dnl # The expected mechanism to shrink the cache is a registered shrinker
2054 dnl # which is called during memory pressure.
2056 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2057 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2058 SPL_LINUX_TRY_COMPILE_SYMBOL([
2059 #include <linux/dcache.h>
2061 shrink_dcache_memory(0, 0);
2062 ], [shrink_dcache_memory], [fs/dcache.c], [
2064 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2065 [shrink_dcache_memory() is available])
2072 dnl # 2.6.xx API compat,
2073 dnl # There currently exists no exposed API to partially shrink the icache.
2074 dnl # The expected mechanism to shrink the cache is a registered shrinker
2075 dnl # which is called during memory pressure.
2077 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2078 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2079 SPL_LINUX_TRY_COMPILE_SYMBOL([
2080 #include <linux/dcache.h>
2082 shrink_icache_memory(0, 0);
2083 ], [shrink_icache_memory], [fs/inode.c], [
2085 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2086 [shrink_icache_memory() is available])
2093 dnl # 2.6.39 API compat,
2094 dnl # The path_lookup() function has been renamed to kern_path_parent()
2095 dnl # and the flags argument has been removed. The only behavior now
2096 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2097 dnl # this flag so dropping the flag does not impact us.
2099 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2100 SPL_CHECK_SYMBOL_HEADER(
2102 [int kern_path_parent(const char \*, struct nameidata \*)],
2103 [include/linux/namei.h],
2104 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2105 [kern_path_parent() is available])],
2110 dnl # 3.1 API compat,
2111 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2112 dnl # However, it remains the prefered interface and since we still have
2113 dnl # access to the prototype we dynamically lookup the required address.
2115 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2116 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2117 SPL_LINUX_TRY_COMPILE_SYMBOL([
2118 #include <linux/namei.h>
2120 kern_path_parent(NULL, NULL);
2121 ], [kern_path_parent], [fs/namei.c], [
2123 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2124 [kern_path_parent() is available])
2131 dnl # 3.6 API compat,
2132 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2133 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2135 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2136 SPL_CHECK_SYMBOL_HEADER(
2138 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2139 [include/linux/namei.h],
2140 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2141 [kern_path_locked() is available])],
2146 dnl # /proc/kallsyms support,
2147 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2149 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2150 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2151 SPL_LINUX_TRY_COMPILE([
2152 #if !defined(CONFIG_KALLSYMS)
2153 #error CONFIG_KALLSYMS not defined
2156 AC_MSG_RESULT([yes])
2160 *** This kernel does not include the required kallsyms support.
2161 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2166 dnl # zlib inflate compat,
2167 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2169 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2170 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2171 SPL_LINUX_TRY_COMPILE([
2172 #if !defined(CONFIG_ZLIB_INFLATE) && \
2173 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2174 #error CONFIG_ZLIB_INFLATE not defined
2177 AC_MSG_RESULT([yes])
2181 *** This kernel does not include the required zlib inflate support.
2182 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2187 dnl # zlib deflate compat,
2188 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2190 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2191 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2192 SPL_LINUX_TRY_COMPILE([
2193 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2194 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2195 #error CONFIG_ZLIB_DEFLATE not defined
2198 AC_MSG_RESULT([yes])
2202 *** This kernel does not include the required zlib deflate support.
2203 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2208 dnl # 2.6.39 API compat,
2209 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2210 dnl # This was done to avoid always having to allocate the maximum size
2211 dnl # workspace (268K). The caller can now specific the windowBits and
2212 dnl # memLevel compression parameters to get a smaller workspace.
2214 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2215 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2216 SPL_LINUX_TRY_COMPILE([
2217 #include <linux/zlib.h>
2219 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2222 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2223 [zlib_deflate_workspacesize() wants 2 args])
2230 dnl # 2.6.39 API change,
2231 dnl # Shrinker adjust to use common shrink_control structure.
2233 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2234 AC_MSG_CHECKING([whether struct shrink_control exists])
2235 SPL_LINUX_TRY_COMPILE([
2236 #include <linux/mm.h>
2238 struct shrink_control sc __attribute__ ((unused));
2241 sc.gfp_mask = GFP_KERNEL;
2244 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2245 [struct shrink_control exists])
2252 dnl # 3.1 API Change
2254 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2255 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2257 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2258 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2259 tmp_flags="$EXTRA_KCFLAGS"
2260 EXTRA_KCFLAGS="-Werror"
2261 SPL_LINUX_TRY_COMPILE([
2262 #include <linux/rwsem.h>
2264 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2265 raw_spinlock_t dummy_lock __attribute__ ((unused));
2266 dummy_semaphore.wait_lock = dummy_lock;
2269 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2270 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2274 EXTRA_KCFLAGS="$tmp_flags"
2278 dnl # 3.9 API change,
2279 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2281 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2282 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2283 SPL_LINUX_TRY_COMPILE([
2284 #include <linux/sched.h>
2285 #include <linux/sched/rt.h>
2289 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2297 dnl # 3.9 API change,
2298 dnl # vfs_getattr() uses 2 args
2299 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2301 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2302 AC_MSG_CHECKING([whether vfs_getattr() wants])
2303 SPL_LINUX_TRY_COMPILE([
2304 #include <linux/fs.h>
2306 vfs_getattr((struct path *) NULL,
2307 (struct kstat *)NULL);
2309 AC_MSG_RESULT(2 args)
2310 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2311 [vfs_getattr wants 2 args])
2313 SPL_LINUX_TRY_COMPILE([
2314 #include <linux/fs.h>
2316 vfs_getattr((struct vfsmount *)NULL,
2317 (struct dentry *)NULL,
2318 (struct kstat *)NULL);
2320 AC_MSG_RESULT(3 args)
2322 AC_MSG_ERROR(unknown)