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 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
13 dnl # compiler options are added by the kernel build system.
14 abs_srcdir=`readlink -f ${srcdir}`
15 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
16 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir}/include"
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -include ${abs_srcdir}/spl_config.h"
19 if test "${LINUX_OBJ}" != "${LINUX}"; then
20 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
23 AC_SUBST(KERNELMAKE_PARAMS)
24 AC_SUBST(KERNELCPPFLAGS)
28 SPL_AC_DEBUG_KMEM_TRACKING
29 SPL_AC_ATOMIC_SPINLOCK
30 SPL_AC_TYPE_ATOMIC64_CMPXCHG
31 SPL_AC_TYPE_ATOMIC64_XCHG
33 SPL_AC_3ARGS_INIT_WORK
34 SPL_AC_2ARGS_REGISTER_SYSCTL
36 SPL_AC_PATH_IN_NAMEIDATA
42 SPL_AC_5ARGS_DEVICE_CREATE
43 SPL_AC_CLASS_DEVICE_CREATE
44 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
45 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
52 SPL_AC_MONOTONIC_CLOCK
55 SPL_AC_MUTEX_LOCK_NESTED
58 SPL_AC_3ARGS_ON_EACH_CPU
59 SPL_AC_KALLSYMS_LOOKUP_NAME
60 SPL_AC_GET_VMALLOC_INFO
62 SPL_AC_FIRST_ONLINE_PGDAT
63 SPL_AC_NEXT_ONLINE_PGDAT
66 SPL_AC_GLOBAL_PAGE_STATE
67 SPL_AC_ZONE_STAT_ITEM_FREE
68 SPL_AC_ZONE_STAT_ITEM_INACTIVE
69 SPL_AC_ZONE_STAT_ITEM_ACTIVE
70 SPL_AC_GET_ZONE_COUNTS
72 SPL_AC_2ARGS_SET_FS_PWD
73 SPL_AC_2ARGS_VFS_UNLINK
74 SPL_AC_4ARGS_VFS_RENAME
77 SPL_AC_PUT_TASK_STRUCT
78 SPL_AC_5ARGS_PROC_HANDLER
82 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
83 modpost=$LINUX/scripts/Makefile.modpost
84 AC_MSG_CHECKING([kernel file name for module symbols])
85 if test -f "$modpost"; then
86 if grep -q Modules.symvers $modpost; then
87 LINUX_SYMBOLS=Modules.symvers
89 LINUX_SYMBOLS=Module.symvers
94 AC_MSG_RESULT($LINUX_SYMBOLS)
95 AC_SUBST(LINUX_SYMBOLS)
98 AC_DEFUN([SPL_AC_KERNEL], [
100 AS_HELP_STRING([--with-linux=PATH],
101 [Path to kernel source]),
102 [kernelsrc="$withval"])
104 AC_ARG_WITH([linux-obj],
105 AS_HELP_STRING([--with-linux-obj=PATH],
106 [Path to kernel build objects]),
107 [kernelbuild="$withval"])
109 AC_MSG_CHECKING([kernel source directory])
110 if test -z "$kernelsrc"; then
111 headersdir="/lib/modules/$(uname -r)/build"
112 if test -e "$headersdir"; then
113 sourcelink=$(readlink -f "$headersdir")
115 sourcelink=$(ls -1d /usr/src/kernels/* \
117 2>/dev/null | grep -v obj | tail -1)
120 if test -n "$sourcelink" && test -e ${sourcelink}; then
121 kernelsrc=`readlink -f ${sourcelink}`
123 AC_MSG_RESULT([Not found])
125 *** Please make sure the kernel devel package for your distribution
126 *** is installed then try again. If that fails you can specify the
127 *** location of the kernel source with the '--with-linux=PATH' option.])
130 if test "$kernelsrc" = "NONE"; then
135 AC_MSG_RESULT([$kernelsrc])
136 AC_MSG_CHECKING([kernel build directory])
137 if test -z "$kernelbuild"; then
138 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
139 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
140 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
141 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
142 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
143 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
145 kernelbuild=${kernelsrc}
148 AC_MSG_RESULT([$kernelbuild])
150 AC_MSG_CHECKING([kernel source version])
151 utsrelease1=$kernelbuild/include/linux/version.h
152 utsrelease2=$kernelbuild/include/linux/utsrelease.h
153 utsrelease3=$kernelbuild/include/generated/utsrelease.h
154 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
155 utsrelease=linux/version.h
156 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
157 utsrelease=linux/utsrelease.h
158 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
159 utsrelease=generated/utsrelease.h
162 if test "$utsrelease"; then
163 kernsrcver=`(echo "#include <$utsrelease>";
164 echo "kernsrcver=UTS_RELEASE") |
165 cpp -I $kernelbuild/include |
166 grep "^kernsrcver=" | cut -d \" -f 2`
168 if test -z "$kernsrcver"; then
169 AC_MSG_RESULT([Not found])
170 AC_MSG_ERROR([*** Cannot determine kernel version.])
173 AC_MSG_RESULT([Not found])
174 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
177 AC_MSG_RESULT([$kernsrcver])
180 LINUX_OBJ=${kernelbuild}
181 LINUX_VERSION=${kernsrcver}
185 AC_SUBST(LINUX_VERSION)
187 SPL_AC_MODULE_SYMVERS
191 dnl # Default SPL user configuration
193 AC_DEFUN([SPL_AC_CONFIG_USER], [])
195 AC_DEFUN([SPL_AC_LICENSE], [
196 AC_MSG_CHECKING([spl license])
198 AC_MSG_RESULT([$LICENSE])
199 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
203 AC_DEFUN([SPL_AC_CONFIG], [
205 AC_ARG_WITH([config],
206 AS_HELP_STRING([--with-config=CONFIG],
207 [Config file 'kernel|user|all|srpm']),
208 [SPL_CONFIG="$withval"])
210 AC_MSG_CHECKING([spl config])
211 AC_MSG_RESULT([$SPL_CONFIG]);
214 case "$SPL_CONFIG" in
215 kernel) SPL_AC_CONFIG_KERNEL ;;
216 user) SPL_AC_CONFIG_USER ;;
217 all) SPL_AC_CONFIG_KERNEL
218 SPL_AC_CONFIG_USER ;;
221 AC_MSG_RESULT([Error!])
222 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
223 user kernel|user|all|srpm]) ;;
226 AM_CONDITIONAL([CONFIG_USER],
227 [test "$SPL_CONFIG" = user] ||
228 [test "$SPL_CONFIG" = all])
229 AM_CONDITIONAL([CONFIG_KERNEL],
230 [test "$SPL_CONFIG" = kernel] ||
231 [test "$SPL_CONFIG" = all])
235 dnl # Enable if the SPL should be compiled with internal debugging enabled.
236 dnl # By default this support is disabled.
238 AC_DEFUN([SPL_AC_DEBUG], [
239 AC_MSG_CHECKING([whether debugging is enabled])
240 AC_ARG_ENABLE([debug],
241 [AS_HELP_STRING([--enable-debug],
242 [Enable generic debug support @<:@default=no@:>@])],
246 AS_IF([test "x$enable_debug" = xyes],
248 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
249 DEBUG_CFLAGS="-DDEBUG -Werror"
252 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
253 DEBUG_CFLAGS="-DNDEBUG"
256 AC_SUBST(DEBUG_CFLAGS)
257 AC_MSG_RESULT([$enable_debug])
261 dnl # Enabled by default it provides a minimal level of memory tracking.
262 dnl # A total count of bytes allocated is kept for each alloc and free.
263 dnl # Then at module unload time a report to the console will be printed
264 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
265 dnl # and provide an easy way to inspect the kmem based slab.
267 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
268 AC_ARG_ENABLE([debug-kmem],
269 [AS_HELP_STRING([--enable-debug-kmem],
270 [Enable basic kmem accounting @<:@default=yes@:>@])],
272 [enable_debug_kmem=yes])
274 AS_IF([test "x$enable_debug_kmem" = xyes],
275 [AC_DEFINE([DEBUG_KMEM], [1],
276 [Define to 1 to enable basic kmem accounting])
277 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
279 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
280 AC_MSG_RESULT([$enable_debug_kmem])
284 dnl # Disabled by default it provides detailed memory tracking. This
285 dnl # feature also requires --enable-debug-kmem to be set. When enabled
286 dnl # not only will total bytes be tracked but also the location of every
287 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
288 dnl # addresses and where they were allocated will be dumped to the console.
289 dnl # Enabling this feature has a significant impact on performance but it
290 dnl # makes finding memory leaks pretty straight forward.
292 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
293 AC_ARG_ENABLE([debug-kmem-tracking],
294 [AS_HELP_STRING([--enable-debug-kmem-tracking],
295 [Enable detailed kmem tracking @<:@default=no@:>@])],
297 [enable_debug_kmem_tracking=no])
299 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
300 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
301 [Define to 1 to enable detailed kmem tracking])
302 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
304 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
305 AC_MSG_RESULT([$enable_debug_kmem_tracking])
309 dnl # SPL_LINUX_CONFTEST
311 AC_DEFUN([SPL_LINUX_CONFTEST], [
312 cat >conftest.c <<_ACEOF
318 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
320 m4_define([SPL_LANG_PROGRAM], [
325 dnl Do *not* indent the following line: there may be CPP directives.
326 dnl Don't move the `;' right after for the same reason.
334 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
336 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
337 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
338 rm -Rf build && mkdir -p build
339 echo "obj-m := conftest.o" >build/Makefile
341 [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])],
343 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
349 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
351 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
352 [SPL_LINUX_COMPILE_IFELSE(
353 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
355 [test -s build/conftest.o],
360 dnl # SPL_LINUX_CONFIG
362 AC_DEFUN([SPL_LINUX_CONFIG],
363 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
364 SPL_LINUX_TRY_COMPILE([
365 #ifndef AUTOCONF_INCLUDED
366 #include <linux/config.h>
370 #error CONFIG_$1 not #defined
382 dnl # SPL_CHECK_SYMBOL_EXPORT
383 dnl # check symbol exported or not
385 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
386 [AC_MSG_CHECKING([whether symbol $1 is exported])
387 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
388 $LINUX_OBJ/Module*.symvers 2>/dev/null
390 if test $rc -ne 0; then
393 grep -q -E "EXPORT_SYMBOL.*($1)" \
394 "$LINUX_OBJ/$file" 2>/dev/null
396 if test $rc -eq 0; then
401 if test $export -eq 0; then
415 dnl # SPL_CHECK_HEADER
416 dnl # check whether header exists and define HAVE_$2_HEADER
418 AC_DEFUN([SPL_CHECK_HEADER],
419 [AC_MSG_CHECKING([whether header $1 exists])
420 SPL_LINUX_TRY_COMPILE([
425 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
435 dnl # Use the atomic implemenation based on global spinlocks. This
436 dnl # should only be needed by 32-bit kernels which do not provide
437 dnl # the atomic64_* API. It may be optionally enabled as a fallback
438 dnl # if problems are observed with the direct mapping to the native
439 dnl # Linux atomic operations. You may not disable atomic spinlocks
440 dnl # if you kernel does not an atomic64_* API.
442 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
443 AC_ARG_ENABLE([atomic-spinlocks],
444 [AS_HELP_STRING([--enable-atomic-spinlocks],
445 [Atomic types use spinlocks @<:@default=check@:>@])],
447 [enable_atomic_spinlocks=check])
449 SPL_LINUX_TRY_COMPILE([
450 #include <asm/atomic.h>
455 AC_DEFINE(HAVE_ATOMIC64_T, 1,
456 [kernel defines atomic64_t])
461 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
462 AS_IF([test "x$have_atomic64_t" = xyes], [
463 enable_atomic_spinlocks=no
465 enable_atomic_spinlocks=yes
469 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
470 AC_DEFINE([ATOMIC_SPINLOCK], [1],
471 [Atomic types use spinlocks])
473 AS_IF([test "x$have_atomic64_t" = xno], [
475 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
479 AC_MSG_CHECKING([whether atomic types use spinlocks])
480 AC_MSG_RESULT([$enable_atomic_spinlocks])
482 AC_MSG_CHECKING([whether kernel defines atomic64_t])
483 AC_MSG_RESULT([$have_atomic64_t])
487 dnl # 2.6.24 API change,
488 dnl # check if atomic64_cmpxchg is defined
490 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
491 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
492 SPL_LINUX_TRY_COMPILE([
493 #include <asm/atomic.h>
495 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
498 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
499 [kernel defines atomic64_cmpxchg])
506 dnl # 2.6.24 API change,
507 dnl # check if atomic64_xchg is defined
509 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
510 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
511 SPL_LINUX_TRY_COMPILE([
512 #include <asm/atomic.h>
514 atomic64_xchg((atomic64_t *)NULL, 0);
517 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
518 [kernel defines atomic64_xchg])
525 dnl # 2.6.24 API change,
526 dnl # check if uintptr_t typedef is defined
528 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
529 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
530 SPL_LINUX_TRY_COMPILE([
531 #include <linux/types.h>
536 AC_DEFINE(HAVE_UINTPTR_T, 1,
537 [kernel defines uintptr_t])
544 dnl # 2.6.20 API change,
545 dnl # INIT_WORK use 2 args and not store data inside
547 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
548 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
549 SPL_LINUX_TRY_COMPILE([
550 #include <linux/workqueue.h>
552 struct work_struct work;
553 INIT_WORK(&work, NULL, NULL);
556 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
557 [INIT_WORK wants 3 args])
564 dnl # 2.6.21 API change,
565 dnl # 'register_sysctl_table' use only one argument instead of two
567 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
568 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
569 SPL_LINUX_TRY_COMPILE([
570 #include <linux/sysctl.h>
572 return register_sysctl_table(NULL,0);
575 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
576 [register_sysctl_table() wants 2 args])
583 dnl # 2.6.23 API change
584 dnl # Old set_shrinker API replaced with register_shrinker
586 AC_DEFUN([SPL_AC_SET_SHRINKER], [
587 AC_MSG_CHECKING([whether set_shrinker() available])
588 SPL_LINUX_TRY_COMPILE([
589 #include <linux/mm.h>
591 return set_shrinker(DEFAULT_SEEKS, NULL);
594 AC_DEFINE(HAVE_SET_SHRINKER, 1,
595 [set_shrinker() available])
602 dnl # 2.6.25 API change,
603 dnl # struct path entry added to struct nameidata
605 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
606 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
607 SPL_LINUX_TRY_COMPILE([
608 #include <linux/namei.h>
613 nd.path.dentry = NULL;
616 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
617 [struct path used in struct nameidata])
624 dnl # Custom SPL patch may export this system it is not required
626 AC_DEFUN([SPL_AC_TASK_CURR], [
627 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
628 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
633 dnl # 2.6.19 API change,
634 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
636 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
637 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
638 SPL_LINUX_TRY_COMPILE([
639 #include <linux/sysctl.h>
641 #ifndef CTL_UNNUMBERED
642 #error CTL_UNNUMBERED undefined
646 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
647 [unnumbered sysctl support exists])
654 dnl # 2.6.33 API change,
655 dnl # Removed .ctl_name from struct ctl_table.
657 AC_DEFUN([SPL_AC_CTL_NAME], [
658 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
659 SPL_LINUX_TRY_COMPILE([
660 #include <linux/sysctl.h>
662 struct ctl_table ctl;
666 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
673 dnl # 2.6.16 API change.
674 dnl # Check if 'fls64()' is available
676 AC_DEFUN([SPL_AC_FLS64],
677 [AC_MSG_CHECKING([whether fls64() is available])
678 SPL_LINUX_TRY_COMPILE([
679 #include <linux/bitops.h>
684 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
691 dnl # 2.6.18 API change, check whether device_create() is available.
692 dnl # Device_create() was introduced in 2.6.18 and depricated
693 dnl # class_device_create() which was fully removed in 2.6.26.
695 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
696 SPL_CHECK_SYMBOL_EXPORT(
698 [drivers/base/core.c],
699 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
700 [device_create() is available])],
705 dnl # 2.6.27 API change,
706 dnl # device_create() uses 5 args, new 'drvdata' argument.
708 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
709 AC_MSG_CHECKING([whether device_create() wants 5 args])
710 tmp_flags="$EXTRA_KCFLAGS"
711 EXTRA_KCFLAGS="-Werror"
712 SPL_LINUX_TRY_COMPILE([
713 #include <linux/device.h>
715 device_create(NULL, NULL, 0, NULL, "%d", 1);
718 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
719 [device_create wants 5 args])
723 EXTRA_KCFLAGS="$tmp_flags"
727 dnl # 2.6.13 API change, check whether class_device_create() is available.
728 dnl # Class_device_create() was introduced in 2.6.13 and depricated
729 dnl # class_simple_device_add() which was fully removed in 2.6.13.
731 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
732 SPL_CHECK_SYMBOL_EXPORT(
733 [class_device_create],
734 [drivers/base/class.c],
735 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
736 [class_device_create() is available])],
741 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
743 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
744 SPL_CHECK_SYMBOL_EXPORT(
745 [set_normalized_timespec],
747 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
748 [set_normalized_timespec() is available as export])],
753 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
754 dnl # previously it was available in time.h as an inline.
756 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
757 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
758 SPL_LINUX_TRY_COMPILE([
759 #include <linux/time.h>
760 void set_normalized_timespec(struct timespec *ts,
761 time_t sec, long nsec) { }
768 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
769 [set_normalized_timespec() is available as inline])
774 dnl # 2.6.18 API change,
775 dnl # timespec_sub() inline function available in linux/time.h
777 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
778 AC_MSG_CHECKING([whether timespec_sub() is available])
779 SPL_LINUX_TRY_COMPILE([
780 #include <linux/time.h>
782 struct timespec a, b, c = { 0 };
783 c = timespec_sub(a, b);
786 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
793 dnl # 2.6.19 API change,
794 dnl # check if init_utsname() is available in linux/utsname.h
796 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
797 AC_MSG_CHECKING([whether init_utsname() is available])
798 SPL_LINUX_TRY_COMPILE([
799 #include <linux/utsname.h>
801 struct new_utsname *a = init_utsname();
804 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
811 dnl # 2.6.26 API change,
812 dnl # definition of struct fdtable relocated to linux/fdtable.h
814 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
815 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
819 dnl # 2.6.14 API change,
820 dnl # check whether 'files_fdtable()' exists
822 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
823 AC_MSG_CHECKING([whether files_fdtable() is available])
824 SPL_LINUX_TRY_COMPILE([
825 #include <linux/sched.h>
826 #include <linux/file.h>
827 #ifdef HAVE_FDTABLE_HEADER
828 #include <linux/fdtable.h>
831 struct files_struct *files = current->files;
832 struct fdtable *fdt = files_fdtable(files);
835 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
842 dnl # 2.6.18 API change,
843 dnl # added linux/uaccess.h
845 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
846 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
850 dnl # 2.6.12 API change,
851 dnl # check whether 'kmalloc_node()' is available.
853 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
854 AC_MSG_CHECKING([whether kmalloc_node() is available])
855 SPL_LINUX_TRY_COMPILE([
856 #include <linux/slab.h>
858 void *a = kmalloc_node(1, GFP_KERNEL, 0);
861 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
868 dnl # 2.6.9 API change,
869 dnl # check whether 'monotonic_clock()' is available it may
870 dnl # be available for some archs but not others.
872 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
873 SPL_CHECK_SYMBOL_EXPORT(
876 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
877 [monotonic_clock() is available])],
882 dnl # 2.6.16 API change,
883 dnl # check whether 'struct inode' has i_mutex
885 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
886 AC_MSG_CHECKING([whether struct inode has i_mutex])
887 SPL_LINUX_TRY_COMPILE([
888 #include <linux/fs.h>
889 #include <linux/mutex.h>
892 mutex_init(&i.i_mutex);
895 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
902 dnl # 2.6.29 API change,
903 dnl # Adaptive mutexs introduced.
905 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
906 AC_MSG_CHECKING([whether struct mutex has owner])
907 SPL_LINUX_TRY_COMPILE([
908 #include <linux/mutex.h>
914 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
921 dnl # 2.6.18 API change,
922 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
923 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
924 dnl # if the mutex validator is disabled or otherwise unavailable.
926 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
927 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
928 SPL_LINUX_TRY_COMPILE([
929 #include <linux/mutex.h>
933 mutex_lock_nested(&mutex, 0);
936 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
937 [mutex_lock_nested() is available])
944 dnl # 2.6.22 API change,
945 dnl # First introduced 'div64_64()' in lib/div64.c
947 AC_DEFUN([SPL_AC_DIV64_64], [
948 SPL_CHECK_SYMBOL_EXPORT(
951 [AC_DEFINE(HAVE_DIV64_64, 1,
952 [div64_64() is available])],
957 dnl # 2.6.26 API change,
958 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
960 AC_DEFUN([SPL_AC_DIV64_U64], [
961 SPL_CHECK_SYMBOL_EXPORT(
964 [AC_DEFINE(HAVE_DIV64_U64, 1,
965 [div64_u64() is available])],
970 dnl # 2.6.27 API change,
971 dnl # on_each_cpu() uses 3 args, no 'retry' argument
973 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
974 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
975 SPL_LINUX_TRY_COMPILE([
976 #include <linux/smp.h>
978 on_each_cpu(NULL, NULL, 0);
981 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
982 [on_each_cpu wants 3 args])
989 dnl # 2.6.18 API change,
990 dnl # kallsyms_lookup_name no longer exported
992 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
993 SPL_CHECK_SYMBOL_EXPORT(
994 [kallsyms_lookup_name],
996 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
997 [kallsyms_lookup_name() is available])],
1002 dnl # Proposed API change,
1003 dnl # This symbol is not available in stock kernels. You may build a
1004 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1005 dnl # these symbols for use. If your already rolling a custom kernel for
1006 dnl # your environment this is recommended.
1008 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1009 SPL_CHECK_SYMBOL_EXPORT(
1012 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1013 [get_vmalloc_info() is available])],
1018 dnl # 2.6.17 API change
1019 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1020 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1021 dnl # were exported in 2.6.17 for use by modules which was consistent with
1022 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1023 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1024 dnl # were dropped entirely leaving modules no way to directly iterate over
1025 dnl # the zone list. Because we need access to the zone helpers we check
1026 dnl # if the kernel contains the old or new implementation. Then we check
1027 dnl # to see if the symbols we need for each version are available. If they
1028 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1030 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1031 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1032 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1034 if test $rc -eq 0; then
1035 AC_MSG_RESULT([yes])
1036 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1043 dnl # Proposed API change,
1044 dnl # This symbol is not available in stock kernels. You may build a
1045 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1046 dnl # these symbols for use. If your already rolling a custom kernel for
1047 dnl # your environment this is recommended.
1049 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1050 SPL_CHECK_SYMBOL_EXPORT(
1051 [first_online_pgdat],
1053 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1054 [first_online_pgdat() is available])],
1059 dnl # Proposed API change,
1060 dnl # This symbol is not available in stock kernels. You may build a
1061 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1062 dnl # these symbols for use. If your already rolling a custom kernel for
1063 dnl # your environment this is recommended.
1065 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1066 SPL_CHECK_SYMBOL_EXPORT(
1067 [next_online_pgdat],
1069 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1070 [next_online_pgdat() is available])],
1075 dnl # Proposed API change,
1076 dnl # This symbol is not available in stock kernels. You may build a
1077 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1078 dnl # these symbols for use. If your already rolling a custom kernel for
1079 dnl # your environment this is recommended.
1081 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1082 SPL_CHECK_SYMBOL_EXPORT(
1085 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1086 [next_zone() is available])],
1091 dnl # 2.6.17 API change,
1092 dnl # See SPL_AC_PGDAT_HELPERS for details.
1094 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1095 SPL_CHECK_SYMBOL_EXPORT(
1098 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1099 [pgdat_list is available])],
1104 dnl # 2.6.18 API change,
1105 dnl # First introduced global_page_state() support as an inline.
1107 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1108 AC_MSG_CHECKING([whether global_page_state() is available])
1109 SPL_LINUX_TRY_COMPILE([
1110 #include <linux/mm.h>
1112 unsigned long state;
1113 state = global_page_state(0);
1116 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1117 [global_page_state() is available])
1124 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1125 dnl # Public global zone stats now include a free page count. However
1126 dnl # the enumerated names of the counters have changed since this API
1127 dnl # was introduced. We need to deduce the corrent name to use. This
1128 dnl # replaces the priviate get_zone_counts() interface.
1130 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1131 dnl # is 2.6.30 as of when this was written.
1133 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1134 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1135 SPL_LINUX_TRY_COMPILE([
1136 #include <linux/mm.h>
1138 enum zone_stat_item zsi;
1139 zsi = NR_FREE_PAGES;
1142 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1143 [Page state NR_FREE_PAGES is available])
1150 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1151 dnl # Public global zone stats now include an inactive page count. However
1152 dnl # the enumerated names of the counters have changed since this API
1153 dnl # was introduced. We need to deduce the corrent name to use. This
1154 dnl # replaces the priviate get_zone_counts() interface.
1156 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1157 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1158 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1160 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1161 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1162 SPL_LINUX_TRY_COMPILE([
1163 #include <linux/mm.h>
1165 enum zone_stat_item zsi;
1169 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1170 [Page state NR_INACTIVE is available])
1175 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1176 SPL_LINUX_TRY_COMPILE([
1177 #include <linux/mm.h>
1179 enum zone_stat_item zsi;
1180 zsi = NR_INACTIVE_ANON;
1183 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1184 [Page state NR_INACTIVE_ANON is available])
1189 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1190 SPL_LINUX_TRY_COMPILE([
1191 #include <linux/mm.h>
1193 enum zone_stat_item zsi;
1194 zsi = NR_INACTIVE_FILE;
1197 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1198 [Page state NR_INACTIVE_FILE is available])
1205 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1206 dnl # Public global zone stats now include an active page count. However
1207 dnl # the enumerated names of the counters have changed since this API
1208 dnl # was introduced. We need to deduce the corrent name to use. This
1209 dnl # replaces the priviate get_zone_counts() interface.
1211 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1212 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1213 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1215 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1216 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1217 SPL_LINUX_TRY_COMPILE([
1218 #include <linux/mm.h>
1220 enum zone_stat_item zsi;
1224 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1225 [Page state NR_ACTIVE is available])
1230 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1231 SPL_LINUX_TRY_COMPILE([
1232 #include <linux/mm.h>
1234 enum zone_stat_item zsi;
1235 zsi = NR_ACTIVE_ANON;
1238 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1239 [Page state NR_ACTIVE_ANON is available])
1244 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1245 SPL_LINUX_TRY_COMPILE([
1246 #include <linux/mm.h>
1248 enum zone_stat_item zsi;
1249 zsi = NR_ACTIVE_FILE;
1252 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1253 [Page state NR_ACTIVE_FILE is available])
1260 dnl # Proposed API change for legacy kernels.
1261 dnl # This symbol is not available in older kernels. For kernels post
1262 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1263 dnl # page state information. This symbol is only used in legacy kernels
1264 dnl # any only as a last resort.
1266 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1267 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1268 SPL_LINUX_TRY_COMPILE([
1270 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1271 #error "global_page_state needs NR_FREE_PAGES"
1274 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1275 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1276 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1277 #error "global_page_state needs NR_ACTIVE*"
1280 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1281 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1282 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1283 #error "global_page_state needs NR_INACTIVE*"
1289 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1290 [get_zone_counts() is needed])
1292 SPL_CHECK_SYMBOL_EXPORT(
1295 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1296 [get_zone_counts() is available])],
1302 dnl # Symbol available in RHEL kernels not in stock kernels.
1304 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1305 SPL_CHECK_SYMBOL_EXPORT(
1308 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1309 [set_fs_pwd() is available])],
1314 dnl # 2.6.25 API change,
1315 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1317 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1318 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1319 SPL_LINUX_TRY_COMPILE([
1320 #include <linux/sched.h>
1321 #include <linux/fs_struct.h>
1323 set_fs_pwd(NULL, NULL);
1326 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1327 [set_fs_pwd() wants 2 args])
1334 dnl # SLES API change, never adopted in mainline,
1335 dnl # Third 'struct vfsmount *' argument removed.
1337 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1338 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1339 SPL_LINUX_TRY_COMPILE([
1340 #include <linux/fs.h>
1342 vfs_unlink(NULL, NULL);
1345 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1346 [vfs_unlink() wants 2 args])
1353 dnl # SLES API change, never adopted in mainline,
1354 dnl # Third and sixth 'struct vfsmount *' argument removed.
1356 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1357 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1358 SPL_LINUX_TRY_COMPILE([
1359 #include <linux/fs.h>
1361 vfs_rename(NULL, NULL, NULL, NULL);
1364 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1365 [vfs_rename() wants 4 args])
1372 dnl # 2.6.29 API change,
1373 dnl # check whether 'struct cred' exists
1375 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1376 AC_MSG_CHECKING([whether struct cred exists])
1377 SPL_LINUX_TRY_COMPILE([
1378 #include <linux/cred.h>
1384 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1391 dnl # Custom SPL patch may export this symbol.
1393 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1394 SPL_CHECK_SYMBOL_EXPORT(
1397 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1398 [groups_search() is available])],
1403 dnl # 2.6.x API change,
1404 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1406 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1407 SPL_CHECK_SYMBOL_EXPORT(
1408 [__put_task_struct],
1410 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1411 [__put_task_struct() is available])],
1416 dnl # 2.6.32 API change,
1417 dnl # Unused 'struct file *' removed from prototype.
1419 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1420 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1421 SPL_LINUX_TRY_COMPILE([
1422 #include <linux/sysctl.h>
1424 proc_dostring(NULL, 0, NULL, NULL, NULL);
1427 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1428 [proc_handler() wants 5 args])
1435 dnl # 2.6.x API change,
1436 dnl # kvasprintf() function added.
1438 AC_DEFUN([SPL_AC_KVASPRINTF], [
1439 SPL_CHECK_SYMBOL_EXPORT(
1442 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1443 [kvasprintf() is available])],