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], [
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
16 AC_SUBST(KERNELMAKE_PARAMS)
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_TYPE_ATOMIC64_CMPXCHG
26 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_3ARGS_INIT_WORK
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
48 SPL_AC_MONOTONIC_CLOCK
51 SPL_AC_MUTEX_OWNER_TASK_STRUCT
52 SPL_AC_MUTEX_LOCK_NESTED
53 SPL_AC_3ARGS_ON_EACH_CPU
54 SPL_AC_KALLSYMS_LOOKUP_NAME
55 SPL_AC_GET_VMALLOC_INFO
57 SPL_AC_FIRST_ONLINE_PGDAT
58 SPL_AC_NEXT_ONLINE_PGDAT
61 SPL_AC_GLOBAL_PAGE_STATE
62 SPL_AC_ZONE_STAT_ITEM_FREE
63 SPL_AC_ZONE_STAT_ITEM_INACTIVE
64 SPL_AC_ZONE_STAT_ITEM_ACTIVE
65 SPL_AC_GET_ZONE_COUNTS
68 SPL_AC_2ARGS_SET_FS_PWD
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_FS_STRUCT_SPINLOCK
74 SPL_AC_PUT_TASK_STRUCT
75 SPL_AC_5ARGS_PROC_HANDLER
77 SPL_AC_3ARGS_FILE_FSYNC
78 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
79 SPL_AC_KERNEL_INVALIDATE_INODES
80 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
81 SPL_AC_SHRINK_DCACHE_MEMORY
82 SPL_AC_SHRINK_ICACHE_MEMORY
83 SPL_AC_KERN_PATH_PARENT_HEADER
84 SPL_AC_KERN_PATH_PARENT_SYMBOL
85 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
86 SPL_AC_SHRINK_CONTROL_STRUCT
89 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
90 modpost=$LINUX/scripts/Makefile.modpost
91 AC_MSG_CHECKING([kernel file name for module symbols])
92 if test -f "$modpost"; then
93 if grep -q Modules.symvers $modpost; then
94 LINUX_SYMBOLS=Modules.symvers
96 LINUX_SYMBOLS=Module.symvers
99 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
101 *** Please make sure the kernel devel package for your distribution
102 *** is installed. If your building with a custom kernel make sure the
103 *** kernel is configured, built, and the '--with-linux=PATH' configure
104 *** option refers to the location of the kernel source.])
109 AC_MSG_RESULT($LINUX_SYMBOLS)
110 AC_SUBST(LINUX_SYMBOLS)
113 AC_DEFUN([SPL_AC_KERNEL], [
115 AS_HELP_STRING([--with-linux=PATH],
116 [Path to kernel source]),
117 [kernelsrc="$withval"])
119 AC_ARG_WITH([linux-obj],
120 AS_HELP_STRING([--with-linux-obj=PATH],
121 [Path to kernel build objects]),
122 [kernelbuild="$withval"])
124 AC_MSG_CHECKING([kernel source directory])
125 if test -z "$kernelsrc"; then
126 if test -e "/lib/modules/$(uname -r)/source"; then
127 headersdir="/lib/modules/$(uname -r)/source"
128 sourcelink=$(readlink -f "$headersdir")
129 elif test -e "/lib/modules/$(uname -r)/build"; then
130 headersdir="/lib/modules/$(uname -r)/build"
131 sourcelink=$(readlink -f "$headersdir")
133 sourcelink=$(ls -1d /usr/src/kernels/* \
135 2>/dev/null | grep -v obj | tail -1)
138 if test -n "$sourcelink" && test -e ${sourcelink}; then
139 kernelsrc=`readlink -f ${sourcelink}`
141 AC_MSG_RESULT([Not found])
143 *** Please make sure the kernel devel package for your distribution
144 *** is installed then try again. If that fails you can specify the
145 *** location of the kernel source with the '--with-linux=PATH' option.])
148 if test "$kernelsrc" = "NONE"; then
153 AC_MSG_RESULT([$kernelsrc])
154 AC_MSG_CHECKING([kernel build directory])
155 if test -z "$kernelbuild"; then
156 if test -e "/lib/modules/$(uname -r)/build"; then
157 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
158 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
159 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
160 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
161 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
162 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
163 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
165 kernelbuild=${kernelsrc}
168 AC_MSG_RESULT([$kernelbuild])
170 AC_MSG_CHECKING([kernel source version])
171 utsrelease1=$kernelbuild/include/linux/version.h
172 utsrelease2=$kernelbuild/include/linux/utsrelease.h
173 utsrelease3=$kernelbuild/include/generated/utsrelease.h
174 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
175 utsrelease=linux/version.h
176 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
177 utsrelease=linux/utsrelease.h
178 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
179 utsrelease=generated/utsrelease.h
182 if test "$utsrelease"; then
183 kernsrcver=`(echo "#include <$utsrelease>";
184 echo "kernsrcver=UTS_RELEASE") |
185 cpp -I $kernelbuild/include |
186 grep "^kernsrcver=" | cut -d \" -f 2`
188 if test -z "$kernsrcver"; then
189 AC_MSG_RESULT([Not found])
190 AC_MSG_ERROR([*** Cannot determine kernel version.])
193 AC_MSG_RESULT([Not found])
194 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
197 AC_MSG_RESULT([$kernsrcver])
200 LINUX_OBJ=${kernelbuild}
201 LINUX_VERSION=${kernsrcver}
205 AC_SUBST(LINUX_VERSION)
207 SPL_AC_MODULE_SYMVERS
210 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
211 SPL_LINUX_CONFIG([PREEMPT],
213 *** Kernel built with CONFIG_PREEMPT which is not supported.
214 ** You must rebuild your kernel without this option.]), [])
218 dnl # Default SPL user configuration
220 AC_DEFUN([SPL_AC_CONFIG_USER], [])
223 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
224 dnl # are missing it is non-fatal but you will not be able to build
225 dnl # RPM packages and will be warned if you try too.
227 AC_DEFUN([SPL_AC_RPM], [
231 AC_MSG_CHECKING([whether $RPM is available])
232 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
233 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
235 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
238 AC_MSG_RESULT([$HAVE_RPM])
241 AC_MSG_CHECKING([whether $RPMBUILD is available])
242 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
243 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
245 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
248 AC_MSG_RESULT([$HAVE_RPMBUILD])
253 AC_SUBST(RPM_VERSION)
255 AC_SUBST(HAVE_RPMBUILD)
257 AC_SUBST(RPMBUILD_VERSION)
261 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
262 dnl # tools are missing it is non-fatal but you will not be able to build
263 dnl # DEB packages and will be warned if you try too.
265 AC_DEFUN([SPL_AC_DPKG], [
267 DPKGBUILD=dpkg-buildpackage
269 AC_MSG_CHECKING([whether $DPKG is available])
270 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
271 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
273 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
276 AC_MSG_RESULT([$HAVE_DPKG])
279 AC_MSG_CHECKING([whether $DPKGBUILD is available])
280 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
281 DPKGBUILD_VERSION=$(echo $tmp | \
282 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
284 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
287 AC_MSG_RESULT([$HAVE_DPKGBUILD])
292 AC_SUBST(DPKG_VERSION)
294 AC_SUBST(HAVE_DPKGBUILD)
296 AC_SUBST(DPKGBUILD_VERSION)
300 dnl # Until native packaging for various different packing systems
301 dnl # can be added the least we can do is attempt to use alien to
302 dnl # convert the RPM packages to the needed package type. This is
303 dnl # a hack but so far it has worked reasonable well.
305 AC_DEFUN([SPL_AC_ALIEN], [
308 AC_MSG_CHECKING([whether $ALIEN is available])
309 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
310 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
312 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
315 AC_MSG_RESULT([$HAVE_ALIEN])
320 AC_SUBST(ALIEN_VERSION)
324 dnl # Using the VENDOR tag from config.guess set the default
325 dnl # package type for 'make pkg': (rpm | deb | tgz)
327 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
328 AC_MSG_CHECKING([linux distribution])
329 if test -f /etc/redhat-release ; then
331 elif test -f /etc/fedora-release ; then
333 elif test -f /etc/lsb-release ; then
335 elif test -f /etc/debian_version ; then
337 elif test -f /etc/SuSE-release ; then
339 elif test -f /etc/slackware-version ; then
341 elif test -f /etc/gentoo-release ; then
346 AC_MSG_RESULT([$VENDOR])
349 AC_MSG_CHECKING([default package type])
351 fedora) DEFAULT_PACKAGE=rpm ;;
352 redhat) DEFAULT_PACKAGE=rpm ;;
353 sles) DEFAULT_PACKAGE=rpm ;;
354 ubuntu) DEFAULT_PACKAGE=deb ;;
355 debian) DEFAULT_PACKAGE=deb ;;
356 slackware) DEFAULT_PACKAGE=tgz ;;
357 *) DEFAULT_PACKAGE=rpm ;;
360 AC_MSG_RESULT([$DEFAULT_PACKAGE])
361 AC_SUBST(DEFAULT_PACKAGE)
365 dnl # Default SPL user configuration
367 AC_DEFUN([SPL_AC_PACKAGE], [
371 SPL_AC_DEFAULT_PACKAGE
374 AC_DEFUN([SPL_AC_LICENSE], [
375 AC_MSG_CHECKING([spl license])
377 AC_MSG_RESULT([$LICENSE])
378 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
382 AC_DEFUN([SPL_AC_CONFIG], [
384 AC_ARG_WITH([config],
385 AS_HELP_STRING([--with-config=CONFIG],
386 [Config file 'kernel|user|all|srpm']),
387 [SPL_CONFIG="$withval"])
389 AC_MSG_CHECKING([spl config])
390 AC_MSG_RESULT([$SPL_CONFIG]);
393 case "$SPL_CONFIG" in
394 kernel) SPL_AC_CONFIG_KERNEL ;;
395 user) SPL_AC_CONFIG_USER ;;
396 all) SPL_AC_CONFIG_KERNEL
397 SPL_AC_CONFIG_USER ;;
400 AC_MSG_RESULT([Error!])
401 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
402 user kernel|user|all|srpm]) ;;
405 AM_CONDITIONAL([CONFIG_USER],
406 [test "$SPL_CONFIG" = user] ||
407 [test "$SPL_CONFIG" = all])
408 AM_CONDITIONAL([CONFIG_KERNEL],
409 [test "$SPL_CONFIG" = kernel] ||
410 [test "$SPL_CONFIG" = all])
414 dnl # Enable if the SPL should be compiled with internal debugging enabled.
415 dnl # By default this support is disabled.
417 AC_DEFUN([SPL_AC_DEBUG], [
418 AC_MSG_CHECKING([whether debugging is enabled])
419 AC_ARG_ENABLE([debug],
420 [AS_HELP_STRING([--enable-debug],
421 [Enable generic debug support @<:@default=no@:>@])],
425 AS_IF([test "x$enable_debug" = xyes],
427 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
428 DEBUG_CFLAGS="-DDEBUG -Werror"
431 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
432 DEBUG_CFLAGS="-DNDEBUG"
435 AC_SUBST(DEBUG_CFLAGS)
436 AC_MSG_RESULT([$enable_debug])
440 dnl # Enabled by default it provides a minimal level of memory tracking.
441 dnl # A total count of bytes allocated is kept for each alloc and free.
442 dnl # Then at module unload time a report to the console will be printed
443 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
444 dnl # and provide an easy way to inspect the kmem based slab.
446 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
447 AC_ARG_ENABLE([debug-kmem],
448 [AS_HELP_STRING([--enable-debug-kmem],
449 [Enable basic kmem accounting @<:@default=yes@:>@])],
451 [enable_debug_kmem=yes])
453 AS_IF([test "x$enable_debug_kmem" = xyes],
454 [AC_DEFINE([DEBUG_KMEM], [1],
455 [Define to 1 to enable basic kmem accounting])
456 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
458 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
459 AC_MSG_RESULT([$enable_debug_kmem])
463 dnl # Disabled by default it provides detailed memory tracking. This
464 dnl # feature also requires --enable-debug-kmem to be set. When enabled
465 dnl # not only will total bytes be tracked but also the location of every
466 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
467 dnl # addresses and where they were allocated will be dumped to the console.
468 dnl # Enabling this feature has a significant impact on performance but it
469 dnl # makes finding memory leaks pretty straight forward.
471 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
472 AC_ARG_ENABLE([debug-kmem-tracking],
473 [AS_HELP_STRING([--enable-debug-kmem-tracking],
474 [Enable detailed kmem tracking @<:@default=no@:>@])],
476 [enable_debug_kmem_tracking=no])
478 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
479 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
480 [Define to 1 to enable detailed kmem tracking])
481 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
483 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
484 AC_MSG_RESULT([$enable_debug_kmem_tracking])
488 dnl # SPL_LINUX_CONFTEST
490 AC_DEFUN([SPL_LINUX_CONFTEST], [
491 cat confdefs.h - <<_ACEOF >conftest.c
497 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
499 m4_define([SPL_LANG_PROGRAM], [
504 dnl Do *not* indent the following line: there may be CPP directives.
505 dnl Don't move the `;' right after for the same reason.
513 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
515 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
516 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
517 rm -Rf build && mkdir -p build
518 echo "obj-m := conftest.o" >build/Makefile
520 [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) >/dev/null && AC_TRY_COMMAND([$3])],
522 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
528 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
530 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
531 [SPL_LINUX_COMPILE_IFELSE(
532 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
534 [test -s build/conftest.o],
539 dnl # SPL_LINUX_CONFIG
541 AC_DEFUN([SPL_LINUX_CONFIG],
542 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
543 SPL_LINUX_TRY_COMPILE([
544 #include <linux/module.h>
547 #error CONFIG_$1 not #defined
559 dnl # SPL_CHECK_SYMBOL_EXPORT
560 dnl # check symbol exported or not
562 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
563 [AC_MSG_CHECKING([whether symbol $1 is exported])
564 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
565 $LINUX_OBJ/Module*.symvers 2>/dev/null
567 if test $rc -ne 0; then
570 grep -q -E "EXPORT_SYMBOL.*($1)" \
571 "$LINUX_OBJ/$file" 2>/dev/null
573 if test $rc -eq 0; then
578 if test $export -eq 0; then
592 dnl # SPL_CHECK_SYMBOL_HEADER
593 dnl # check if a symbol prototype is defined in listed headers.
595 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
596 AC_MSG_CHECKING([whether symbol $1 exists in header])
599 grep -q "$2" "$LINUX/$file" 2>/dev/null
601 if test $rc -eq 0; then
606 if test $header -eq 0; then
616 dnl # SPL_CHECK_HEADER
617 dnl # check whether header exists and define HAVE_$2_HEADER
619 AC_DEFUN([SPL_CHECK_HEADER],
620 [AC_MSG_CHECKING([whether header $1 exists])
621 SPL_LINUX_TRY_COMPILE([
626 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
636 dnl # Use the atomic implemenation based on global spinlocks. This
637 dnl # should only be needed by 32-bit kernels which do not provide
638 dnl # the atomic64_* API. It may be optionally enabled as a fallback
639 dnl # if problems are observed with the direct mapping to the native
640 dnl # Linux atomic operations. You may not disable atomic spinlocks
641 dnl # if you kernel does not an atomic64_* API.
643 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
644 AC_ARG_ENABLE([atomic-spinlocks],
645 [AS_HELP_STRING([--enable-atomic-spinlocks],
646 [Atomic types use spinlocks @<:@default=check@:>@])],
648 [enable_atomic_spinlocks=check])
650 SPL_LINUX_TRY_COMPILE([
651 #include <asm/atomic.h>
653 atomic64_t *ptr __attribute__ ((unused));
656 AC_DEFINE(HAVE_ATOMIC64_T, 1,
657 [kernel defines atomic64_t])
662 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
663 AS_IF([test "x$have_atomic64_t" = xyes], [
664 enable_atomic_spinlocks=no
666 enable_atomic_spinlocks=yes
670 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
671 AC_DEFINE([ATOMIC_SPINLOCK], [1],
672 [Atomic types use spinlocks])
674 AS_IF([test "x$have_atomic64_t" = xno], [
676 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
680 AC_MSG_CHECKING([whether atomic types use spinlocks])
681 AC_MSG_RESULT([$enable_atomic_spinlocks])
683 AC_MSG_CHECKING([whether kernel defines atomic64_t])
684 AC_MSG_RESULT([$have_atomic64_t])
688 dnl # 2.6.24 API change,
689 dnl # check if atomic64_cmpxchg is defined
691 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
692 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
693 SPL_LINUX_TRY_COMPILE([
694 #include <asm/atomic.h>
695 #include <asm/system.h>
697 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
700 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
701 [kernel defines atomic64_cmpxchg])
708 dnl # 2.6.24 API change,
709 dnl # check if atomic64_xchg is defined
711 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
712 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
713 SPL_LINUX_TRY_COMPILE([
714 #include <asm/atomic.h>
716 atomic64_xchg((atomic64_t *)NULL, 0);
719 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
720 [kernel defines atomic64_xchg])
727 dnl # 2.6.24 API change,
728 dnl # check if uintptr_t typedef is defined
730 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
731 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
732 SPL_LINUX_TRY_COMPILE([
733 #include <linux/types.h>
735 uintptr_t *ptr __attribute__ ((unused));
738 AC_DEFINE(HAVE_UINTPTR_T, 1,
739 [kernel defines uintptr_t])
746 dnl # 2.6.20 API change,
747 dnl # INIT_WORK use 2 args and not store data inside
749 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
750 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
751 SPL_LINUX_TRY_COMPILE([
752 #include <linux/workqueue.h>
754 struct work_struct work __attribute__ ((unused));
755 INIT_WORK(&work, NULL, NULL);
758 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
759 [INIT_WORK wants 3 args])
766 dnl # 2.6.21 API change,
767 dnl # 'register_sysctl_table' use only one argument instead of two
769 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
770 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
771 SPL_LINUX_TRY_COMPILE([
772 #include <linux/sysctl.h>
774 (void) register_sysctl_table(NULL, 0);
777 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
778 [register_sysctl_table() wants 2 args])
785 dnl # 2.6.23 API change
786 dnl # Old set_shrinker API replaced with register_shrinker
788 AC_DEFUN([SPL_AC_SET_SHRINKER], [
789 AC_MSG_CHECKING([whether set_shrinker() available])
790 SPL_LINUX_TRY_COMPILE([
791 #include <linux/mm.h>
793 return set_shrinker(DEFAULT_SEEKS, NULL);
796 AC_DEFINE(HAVE_SET_SHRINKER, 1,
797 [set_shrinker() available])
804 dnl # 2.6.35 API change,
805 dnl # Add context to shrinker callback
807 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
808 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
809 tmp_flags="$EXTRA_KCFLAGS"
810 EXTRA_KCFLAGS="-Werror"
811 SPL_LINUX_TRY_COMPILE([
812 #include <linux/mm.h>
814 int shrinker_cb(struct shrinker *, int, unsigned int);
816 struct shrinker cache_shrinker = {
817 .shrink = shrinker_cb,
818 .seeks = DEFAULT_SEEKS,
820 register_shrinker(&cache_shrinker);
823 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
824 [shrinker callback wants 3 args])
828 EXTRA_KCFLAGS="$tmp_flags"
832 dnl # 2.6.25 API change,
833 dnl # struct path entry added to struct nameidata
835 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
836 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
837 SPL_LINUX_TRY_COMPILE([
838 #include <linux/namei.h>
840 struct nameidata nd __attribute__ ((unused));
843 nd.path.dentry = NULL;
846 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
847 [struct path used in struct nameidata])
854 dnl # Custom SPL patch may export this system it is not required
856 AC_DEFUN([SPL_AC_TASK_CURR], [
857 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
858 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
863 dnl # 2.6.19 API change,
864 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
866 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
867 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
868 SPL_LINUX_TRY_COMPILE([
869 #include <linux/sysctl.h>
871 #ifndef CTL_UNNUMBERED
872 #error CTL_UNNUMBERED undefined
876 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
877 [unnumbered sysctl support exists])
884 dnl # 2.6.33 API change,
885 dnl # Removed .ctl_name from struct ctl_table.
887 AC_DEFUN([SPL_AC_CTL_NAME], [
888 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
889 SPL_LINUX_TRY_COMPILE([
890 #include <linux/sysctl.h>
892 struct ctl_table ctl __attribute__ ((unused));
896 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
903 dnl # 2.6.16 API change.
904 dnl # Check if 'fls64()' is available
906 AC_DEFUN([SPL_AC_FLS64],
907 [AC_MSG_CHECKING([whether fls64() is available])
908 SPL_LINUX_TRY_COMPILE([
909 #include <linux/bitops.h>
914 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
921 dnl # 2.6.18 API change, check whether device_create() is available.
922 dnl # Device_create() was introduced in 2.6.18 and depricated
923 dnl # class_device_create() which was fully removed in 2.6.26.
925 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
926 SPL_CHECK_SYMBOL_EXPORT(
928 [drivers/base/core.c],
929 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
930 [device_create() is available])],
935 dnl # 2.6.27 API change,
936 dnl # device_create() uses 5 args, new 'drvdata' argument.
938 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
939 AC_MSG_CHECKING([whether device_create() wants 5 args])
940 tmp_flags="$EXTRA_KCFLAGS"
941 EXTRA_KCFLAGS="-Werror"
942 SPL_LINUX_TRY_COMPILE([
943 #include <linux/device.h>
945 device_create(NULL, NULL, 0, NULL, "%d", 1);
948 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
949 [device_create wants 5 args])
953 EXTRA_KCFLAGS="$tmp_flags"
957 dnl # 2.6.13 API change, check whether class_device_create() is available.
958 dnl # Class_device_create() was introduced in 2.6.13 and depricated
959 dnl # class_simple_device_add() which was fully removed in 2.6.13.
961 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
962 SPL_CHECK_SYMBOL_EXPORT(
963 [class_device_create],
964 [drivers/base/class.c],
965 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
966 [class_device_create() is available])],
971 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
973 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
974 SPL_CHECK_SYMBOL_EXPORT(
975 [set_normalized_timespec],
977 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
978 [set_normalized_timespec() is available as export])],
983 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
984 dnl # previously it was available in time.h as an inline.
986 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
987 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
988 SPL_LINUX_TRY_COMPILE([
989 #include <linux/time.h>
990 void set_normalized_timespec(struct timespec *ts,
991 time_t sec, long nsec) { }
998 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
999 [set_normalized_timespec() is available as inline])
1004 dnl # 2.6.18 API change,
1005 dnl # timespec_sub() inline function available in linux/time.h
1007 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1008 AC_MSG_CHECKING([whether timespec_sub() is available])
1009 SPL_LINUX_TRY_COMPILE([
1010 #include <linux/time.h>
1012 struct timespec a = { 0 };
1013 struct timespec b = { 0 };
1014 struct timespec c __attribute__ ((unused));
1015 c = timespec_sub(a, b);
1018 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1025 dnl # 2.6.19 API change,
1026 dnl # check if init_utsname() is available in linux/utsname.h
1028 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1029 AC_MSG_CHECKING([whether init_utsname() is available])
1030 SPL_LINUX_TRY_COMPILE([
1031 #include <linux/utsname.h>
1033 struct new_utsname *a __attribute__ ((unused));
1037 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1044 dnl # 2.6.26 API change,
1045 dnl # definition of struct fdtable relocated to linux/fdtable.h
1047 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1048 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1052 dnl # 2.6.14 API change,
1053 dnl # check whether 'files_fdtable()' exists
1055 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1056 AC_MSG_CHECKING([whether files_fdtable() is available])
1057 SPL_LINUX_TRY_COMPILE([
1058 #include <linux/sched.h>
1059 #include <linux/file.h>
1060 #ifdef HAVE_FDTABLE_HEADER
1061 #include <linux/fdtable.h>
1064 struct files_struct *files = current->files;
1065 struct fdtable *fdt __attribute__ ((unused));
1066 fdt = files_fdtable(files);
1069 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1076 dnl # 2.6.18 API change,
1077 dnl # added linux/uaccess.h
1079 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1080 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1084 dnl # 2.6.12 API change,
1085 dnl # check whether 'kmalloc_node()' is available.
1087 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1088 AC_MSG_CHECKING([whether kmalloc_node() is available])
1089 SPL_LINUX_TRY_COMPILE([
1090 #include <linux/slab.h>
1092 void *a __attribute__ ((unused));
1093 a = kmalloc_node(1, GFP_KERNEL, 0);
1096 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1103 dnl # 2.6.9 API change,
1104 dnl # check whether 'monotonic_clock()' is available it may
1105 dnl # be available for some archs but not others.
1107 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1108 SPL_CHECK_SYMBOL_EXPORT(
1111 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1112 [monotonic_clock() is available])],
1117 dnl # 2.6.16 API change,
1118 dnl # check whether 'struct inode' has i_mutex
1120 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1121 AC_MSG_CHECKING([whether struct inode has i_mutex])
1122 SPL_LINUX_TRY_COMPILE([
1123 #include <linux/fs.h>
1124 #include <linux/mutex.h>
1127 mutex_init(&i.i_mutex);
1130 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1137 dnl # 2.6.29 API change,
1138 dnl # Adaptive mutexs introduced.
1140 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1141 AC_MSG_CHECKING([whether struct mutex has owner])
1142 SPL_LINUX_TRY_COMPILE([
1143 #include <linux/mutex.h>
1145 struct mutex mtx __attribute__ ((unused));
1149 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1156 dnl # 2.6.39 API change,
1157 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1158 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1159 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1160 dnl # pointer which frankly makes a lot more sense.
1162 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1163 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1164 tmp_flags="$EXTRA_KCFLAGS"
1165 EXTRA_KCFLAGS="-Werror"
1166 SPL_LINUX_TRY_COMPILE([
1167 #include <linux/mutex.h>
1169 struct mutex mtx __attribute__ ((unused));
1170 mtx.owner = current;
1173 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1174 [struct mutex owner is a task_struct])
1178 EXTRA_KCFLAGS="$tmp_flags"
1182 dnl # 2.6.18 API change,
1183 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1184 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1185 dnl # if the mutex validator is disabled or otherwise unavailable.
1187 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1188 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1189 SPL_LINUX_TRY_COMPILE([
1190 #include <linux/mutex.h>
1194 mutex_lock_nested(&mutex, 0);
1197 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1198 [mutex_lock_nested() is available])
1205 dnl # 2.6.27 API change,
1206 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1208 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1209 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1210 SPL_LINUX_TRY_COMPILE([
1211 #include <linux/smp.h>
1213 on_each_cpu(NULL, NULL, 0);
1216 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1217 [on_each_cpu wants 3 args])
1224 dnl # 2.6.18 API change,
1225 dnl # kallsyms_lookup_name no longer exported
1227 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1228 SPL_CHECK_SYMBOL_EXPORT(
1229 [kallsyms_lookup_name],
1231 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1232 [kallsyms_lookup_name() is available])],
1237 dnl # Proposed API change,
1238 dnl # This symbol is not available in stock kernels. You may build a
1239 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1240 dnl # these symbols for use. If your already rolling a custom kernel for
1241 dnl # your environment this is recommended.
1243 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1244 SPL_CHECK_SYMBOL_EXPORT(
1247 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1248 [get_vmalloc_info() is available])],
1253 dnl # 2.6.17 API change
1254 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1255 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1256 dnl # were exported in 2.6.17 for use by modules which was consistent with
1257 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1258 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1259 dnl # were dropped entirely leaving modules no way to directly iterate over
1260 dnl # the zone list. Because we need access to the zone helpers we check
1261 dnl # if the kernel contains the old or new implementation. Then we check
1262 dnl # to see if the symbols we need for each version are available. If they
1263 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1265 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1266 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1267 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1269 if test $rc -eq 0; then
1270 AC_MSG_RESULT([yes])
1271 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1278 dnl # Proposed API change,
1279 dnl # This symbol is not available in stock kernels. You may build a
1280 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1281 dnl # these symbols for use. If your already rolling a custom kernel for
1282 dnl # your environment this is recommended.
1284 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1285 SPL_CHECK_SYMBOL_EXPORT(
1286 [first_online_pgdat],
1288 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1289 [first_online_pgdat() is available])],
1294 dnl # Proposed API change,
1295 dnl # This symbol is not available in stock kernels. You may build a
1296 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1297 dnl # these symbols for use. If your already rolling a custom kernel for
1298 dnl # your environment this is recommended.
1300 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1301 SPL_CHECK_SYMBOL_EXPORT(
1302 [next_online_pgdat],
1304 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1305 [next_online_pgdat() is available])],
1310 dnl # Proposed API change,
1311 dnl # This symbol is not available in stock kernels. You may build a
1312 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1313 dnl # these symbols for use. If your already rolling a custom kernel for
1314 dnl # your environment this is recommended.
1316 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1317 SPL_CHECK_SYMBOL_EXPORT(
1320 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1321 [next_zone() is available])],
1326 dnl # 2.6.17 API change,
1327 dnl # See SPL_AC_PGDAT_HELPERS for details.
1329 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1330 SPL_CHECK_SYMBOL_EXPORT(
1333 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1334 [pgdat_list is available])],
1339 dnl # 2.6.18 API change,
1340 dnl # First introduced global_page_state() support as an inline.
1342 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1343 AC_MSG_CHECKING([whether global_page_state() is available])
1344 SPL_LINUX_TRY_COMPILE([
1345 #include <linux/mm.h>
1347 unsigned long state __attribute__ ((unused));
1348 state = global_page_state(0);
1351 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1352 [global_page_state() is available])
1359 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1360 dnl # Public global zone stats now include a free page count. However
1361 dnl # the enumerated names of the counters have changed since this API
1362 dnl # was introduced. We need to deduce the corrent name to use. This
1363 dnl # replaces the priviate get_zone_counts() interface.
1365 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1366 dnl # is 2.6.30 as of when this was written.
1368 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1369 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1370 SPL_LINUX_TRY_COMPILE([
1371 #include <linux/mm.h>
1373 enum zone_stat_item zsi __attribute__ ((unused));
1374 zsi = NR_FREE_PAGES;
1377 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1378 [Page state NR_FREE_PAGES is available])
1385 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1386 dnl # Public global zone stats now include an inactive page count. However
1387 dnl # the enumerated names of the counters have changed since this API
1388 dnl # was introduced. We need to deduce the corrent name to use. This
1389 dnl # replaces the priviate get_zone_counts() interface.
1391 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1392 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1393 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1395 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1396 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1397 SPL_LINUX_TRY_COMPILE([
1398 #include <linux/mm.h>
1400 enum zone_stat_item zsi __attribute__ ((unused));
1404 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1405 [Page state NR_INACTIVE is available])
1410 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1411 SPL_LINUX_TRY_COMPILE([
1412 #include <linux/mm.h>
1414 enum zone_stat_item zsi __attribute__ ((unused));
1415 zsi = NR_INACTIVE_ANON;
1418 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1419 [Page state NR_INACTIVE_ANON is available])
1424 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1425 SPL_LINUX_TRY_COMPILE([
1426 #include <linux/mm.h>
1428 enum zone_stat_item zsi __attribute__ ((unused));
1429 zsi = NR_INACTIVE_FILE;
1432 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1433 [Page state NR_INACTIVE_FILE is available])
1440 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1441 dnl # Public global zone stats now include an active page count. However
1442 dnl # the enumerated names of the counters have changed since this API
1443 dnl # was introduced. We need to deduce the corrent name to use. This
1444 dnl # replaces the priviate get_zone_counts() interface.
1446 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1447 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1448 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1450 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1451 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1452 SPL_LINUX_TRY_COMPILE([
1453 #include <linux/mm.h>
1455 enum zone_stat_item zsi __attribute__ ((unused));
1459 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1460 [Page state NR_ACTIVE is available])
1465 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1466 SPL_LINUX_TRY_COMPILE([
1467 #include <linux/mm.h>
1469 enum zone_stat_item zsi __attribute__ ((unused));
1470 zsi = NR_ACTIVE_ANON;
1473 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1474 [Page state NR_ACTIVE_ANON is available])
1479 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1480 SPL_LINUX_TRY_COMPILE([
1481 #include <linux/mm.h>
1483 enum zone_stat_item zsi __attribute__ ((unused));
1484 zsi = NR_ACTIVE_FILE;
1487 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1488 [Page state NR_ACTIVE_FILE is available])
1495 dnl # Proposed API change for legacy kernels.
1496 dnl # This symbol is not available in older kernels. For kernels post
1497 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1498 dnl # page state information. This symbol is only used in legacy kernels
1499 dnl # any only as a last resort.
1501 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1502 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1503 SPL_LINUX_TRY_COMPILE([
1505 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1506 #error "global_page_state needs NR_FREE_PAGES"
1509 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1510 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1511 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1512 #error "global_page_state needs NR_ACTIVE*"
1515 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1516 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1517 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1518 #error "global_page_state needs NR_INACTIVE*"
1524 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1525 [get_zone_counts() is needed])
1527 SPL_CHECK_SYMBOL_EXPORT(
1530 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1531 [get_zone_counts() is available])],
1537 dnl # 2.6.27 API change,
1538 dnl # The user_path_dir() replaces __user_walk()
1540 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1541 SPL_CHECK_SYMBOL_EXPORT(
1544 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1545 [user_path_dir() is available])],
1550 dnl # Symbol available in RHEL kernels not in stock kernels.
1552 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1553 SPL_CHECK_SYMBOL_EXPORT(
1556 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1557 [set_fs_pwd() is available])],
1562 dnl # 2.6.25 API change,
1563 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1565 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1566 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1567 SPL_LINUX_TRY_COMPILE([
1568 #include <linux/sched.h>
1569 #include <linux/fs_struct.h>
1571 set_fs_pwd(NULL, NULL);
1574 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1575 [set_fs_pwd() wants 2 args])
1582 dnl # SLES API change, never adopted in mainline,
1583 dnl # Third 'struct vfsmount *' argument removed.
1585 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1586 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1587 SPL_LINUX_TRY_COMPILE([
1588 #include <linux/fs.h>
1590 vfs_unlink(NULL, NULL);
1593 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1594 [vfs_unlink() wants 2 args])
1601 dnl # SLES API change, never adopted in mainline,
1602 dnl # Third and sixth 'struct vfsmount *' argument removed.
1604 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1605 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1606 SPL_LINUX_TRY_COMPILE([
1607 #include <linux/fs.h>
1609 vfs_rename(NULL, NULL, NULL, NULL);
1612 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1613 [vfs_rename() wants 4 args])
1620 dnl # 2.6.36 API change,
1621 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1622 dnl # a spinlock_t to improve the fastpath performance.
1624 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1625 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1626 tmp_flags="$EXTRA_KCFLAGS"
1627 EXTRA_KCFLAGS="-Werror"
1628 SPL_LINUX_TRY_COMPILE([
1629 #include <linux/sched.h>
1630 #include <linux/fs_struct.h>
1632 struct fs_struct fs;
1633 spin_lock_init(&fs.lock);
1636 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1637 [struct fs_struct uses spinlock_t])
1641 EXTRA_KCFLAGS="$tmp_flags"
1645 dnl # 2.6.29 API change,
1646 dnl # check whether 'struct cred' exists
1648 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1649 AC_MSG_CHECKING([whether struct cred exists])
1650 SPL_LINUX_TRY_COMPILE([
1651 #include <linux/cred.h>
1653 struct cred *cr __attribute__ ((unused));
1657 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1664 dnl # Custom SPL patch may export this symbol.
1666 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1667 SPL_CHECK_SYMBOL_EXPORT(
1670 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1671 [groups_search() is available])],
1676 dnl # 2.6.x API change,
1677 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1679 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1680 SPL_CHECK_SYMBOL_EXPORT(
1681 [__put_task_struct],
1683 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1684 [__put_task_struct() is available])],
1689 dnl # 2.6.32 API change,
1690 dnl # Unused 'struct file *' removed from prototype.
1692 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1693 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1694 SPL_LINUX_TRY_COMPILE([
1695 #include <linux/sysctl.h>
1697 proc_dostring(NULL, 0, NULL, NULL, NULL);
1700 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1701 [proc_handler() wants 5 args])
1708 dnl # 2.6.x API change,
1709 dnl # kvasprintf() function added.
1711 AC_DEFUN([SPL_AC_KVASPRINTF], [
1712 SPL_CHECK_SYMBOL_EXPORT(
1715 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1716 [kvasprintf() is available])],
1721 dnl # 2.6.35 API change,
1722 dnl # Unused 'struct dentry *' removed from prototype.
1724 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1725 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1726 SPL_LINUX_TRY_COMPILE([
1727 #include <linux/buffer_head.h>
1729 file_fsync(NULL, NULL, 0);
1732 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1733 [file_fsync() wants 3 args])
1740 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1741 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1742 dnl # condition. The fixed version is exported as a symbol. The race
1743 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1744 dnl # call that version while holding sem->wait_lock.
1746 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1747 SPL_CHECK_SYMBOL_EXPORT(
1749 [lib/rwsem-spinlock.c],
1750 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1751 [rwsem_is_locked() acquires sem->wait_lock])],
1756 dnl # 2.6.37 API compat,
1757 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1758 dnl # The prototype however is still available which means it is safe
1759 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1761 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1762 SPL_CHECK_SYMBOL_EXPORT(
1763 [invalidate_inodes],
1765 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1766 [invalidate_inodes() is available])],
1771 dnl # 2.6.39 API compat,
1772 dnl # The function invalidate_inodes() now take 2 arguments. The second
1773 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1774 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1775 dnl # otherwise they will be handled as busy.
1777 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1778 dnl # prototype so it's not easy to check how many arguments it takes.
1779 dnl # However, this change was done for the benefit of invalidate_device()
1780 dnl # which also added an argument. The invalidate_device() symbol does
1781 dnl # exist in the development headers so if it takes two arguments we
1782 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1783 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1785 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1786 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1787 SPL_LINUX_TRY_COMPILE([
1788 #include <linux/fs.h>
1790 return __invalidate_device(NULL, 0);
1793 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1794 [invalidate_inodes() wants 2 args])
1801 dnl # 2.6.xx API compat,
1802 dnl # There currently exists no exposed API to partially shrink the dcache.
1803 dnl # The expected mechanism to shrink the cache is a registered shrinker
1804 dnl # which is called during memory pressure.
1806 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1807 SPL_CHECK_SYMBOL_EXPORT(
1808 [shrink_dcache_memory],
1810 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1811 [shrink_dcache_memory() is available])],
1816 dnl # 2.6.xx API compat,
1817 dnl # There currently exists no exposed API to partially shrink the icache.
1818 dnl # The expected mechanism to shrink the cache is a registered shrinker
1819 dnl # which is called during memory pressure.
1821 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1822 SPL_CHECK_SYMBOL_EXPORT(
1823 [shrink_icache_memory],
1825 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1826 [shrink_icache_memory() is available])],
1831 dnl # 2.6.39 API compat,
1832 dnl # The path_lookup() function has been renamed to kern_path_parent()
1833 dnl # and the flags argument has been removed. The only behavior now
1834 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1835 dnl # this flag so dropping the flag does not impact us.
1837 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1838 SPL_CHECK_SYMBOL_HEADER(
1840 [int kern_path_parent(const char \*, struct nameidata \*)],
1841 [include/linux/namei.h],
1842 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1843 [kern_path_parent() is available])],
1848 dnl # 3.1 API compat,
1849 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
1850 dnl # However, it remains the prefered interface and since we still have
1851 dnl # access to the prototype we dynamically lookup the required address.
1853 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
1854 SPL_CHECK_SYMBOL_EXPORT(
1857 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
1858 [kern_path_parent() is available])],
1863 dnl # 2.6.39 API compat,
1864 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1865 dnl # This was done to avoid always having to allocate the maximum size
1866 dnl # workspace (268K). The caller can now specific the windowBits and
1867 dnl # memLevel compression parameters to get a smaller workspace.
1869 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1870 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1871 SPL_LINUX_TRY_COMPILE([
1872 #include <linux/zlib.h>
1874 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1877 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1878 [zlib_deflate_workspacesize() wants 2 args])
1885 dnl # 2.6.39 API change,
1886 dnl # Shrinker adjust to use common shrink_control structure.
1888 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1889 AC_MSG_CHECKING([whether struct shrink_control exists])
1890 SPL_LINUX_TRY_COMPILE([
1891 #include <linux/mm.h>
1893 struct shrink_control sc __attribute__ ((unused));
1896 sc.gfp_mask = GFP_KERNEL;
1899 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1900 [struct shrink_control exists])