2 dnl # Default SPL kernel configuration
4 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
7 dnl # Kernel build make options
8 dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build
9 KERNELMAKE_PARAMS="V=1"
11 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
12 dnl # compiler options are added by the kernel build system.
13 abs_srcdir=`readlink -f ${srcdir}`
14 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes -Werror"
15 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir} -I${abs_srcdir}/include"
17 if test "${LINUX_OBJ}" != "${LINUX}"; then
18 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
21 AC_SUBST(KERNELMAKE_PARAMS)
22 AC_SUBST(KERNELCPPFLAGS)
26 SPL_AC_DEBUG_KMEM_TRACKING
27 SPL_AC_ATOMIC_SPINLOCK
28 SPL_AC_TYPE_ATOMIC64_CMPXCHG
29 SPL_AC_TYPE_ATOMIC64_XCHG
31 SPL_AC_3ARGS_INIT_WORK
32 SPL_AC_2ARGS_REGISTER_SYSCTL
34 SPL_AC_PATH_IN_NAMEIDATA
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
49 SPL_AC_MONOTONIC_CLOCK
52 SPL_AC_MUTEX_LOCK_NESTED
55 SPL_AC_3ARGS_ON_EACH_CPU
56 SPL_AC_KALLSYMS_LOOKUP_NAME
57 SPL_AC_GET_VMALLOC_INFO
59 SPL_AC_FIRST_ONLINE_PGDAT
60 SPL_AC_NEXT_ONLINE_PGDAT
63 SPL_AC_GLOBAL_PAGE_STATE
64 SPL_AC_ZONE_STAT_ITEM_FREE
65 SPL_AC_ZONE_STAT_ITEM_INACTIVE
66 SPL_AC_ZONE_STAT_ITEM_ACTIVE
67 SPL_AC_GET_ZONE_COUNTS
69 SPL_AC_2ARGS_SET_FS_PWD
70 SPL_AC_2ARGS_VFS_UNLINK
71 SPL_AC_4ARGS_VFS_RENAME
74 SPL_AC_PUT_TASK_STRUCT
75 SPL_AC_5ARGS_PROC_HANDLER
78 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
79 modpost=$LINUX/scripts/Makefile.modpost
80 AC_MSG_CHECKING([kernel file name for module symbols])
81 if test -f "$modpost"; then
82 if grep -q Modules.symvers $modpost; then
83 LINUX_SYMBOLS=Modules.symvers
85 LINUX_SYMBOLS=Module.symvers
90 AC_MSG_RESULT($LINUX_SYMBOLS)
91 AC_SUBST(LINUX_SYMBOLS)
94 AC_DEFUN([SPL_AC_KERNEL], [
96 AS_HELP_STRING([--with-linux=PATH],
97 [Path to kernel source]),
98 [kernelsrc="$withval"])
100 AC_ARG_WITH([linux-obj],
101 AS_HELP_STRING([--with-linux-obj=PATH],
102 [Path to kernel build objects]),
103 [kernelbuild="$withval"])
105 AC_MSG_CHECKING([kernel source directory])
106 if test -z "$kernelsrc"; then
107 headersdir="/lib/modules/$(uname -r)/build"
108 if test -e "$headersdir"; then
109 sourcelink=$(readlink -f "$headersdir")
111 sourcelink=$(ls -1d /usr/src/kernels/* \
113 2>/dev/null | grep -v obj | tail -1)
116 if test -e ${sourcelink}; then
117 kernelsrc=`readlink -f ${sourcelink}`
119 AC_MSG_RESULT([Not found])
121 *** Please specify the location of the kernel source
122 *** with the '--with-linux=PATH' option])
125 if test "$kernelsrc" = "NONE"; then
130 AC_MSG_RESULT([$kernelsrc])
131 AC_MSG_CHECKING([kernel build directory])
132 if test -z "$kernelbuild"; then
133 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
134 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
135 elif test -d ${kernelsrc}-obj/`arch`/default; then
136 kernelbuild=${kernelsrc}-obj/`arch`/default
137 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
138 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
140 kernelbuild=${kernelsrc}
143 AC_MSG_RESULT([$kernelbuild])
145 AC_MSG_CHECKING([kernel source version])
146 if test -r $kernelbuild/include/linux/version.h &&
147 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
149 kernsrcver=`(echo "#include <linux/version.h>";
150 echo "kernsrcver=UTS_RELEASE") |
151 cpp -I $kernelbuild/include |
152 grep "^kernsrcver=" | cut -d \" -f 2`
154 elif test -r $kernelbuild/include/linux/utsrelease.h &&
155 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
157 kernsrcver=`(echo "#include <linux/utsrelease.h>";
158 echo "kernsrcver=UTS_RELEASE") |
159 cpp -I $kernelbuild/include |
160 grep "^kernsrcver=" | cut -d \" -f 2`
163 if test -z "$kernsrcver"; then
164 AC_MSG_RESULT([Not found])
166 *** Cannot determine the version of the linux kernel source.
167 *** Please prepare the kernel before running this script])
170 AC_MSG_RESULT([$kernsrcver])
173 LINUX_OBJ=${kernelbuild}
174 LINUX_VERSION=${kernsrcver}
178 AC_SUBST(LINUX_VERSION)
180 SPL_AC_MODULE_SYMVERS
184 dnl # Default SPL user configuration
186 AC_DEFUN([SPL_AC_CONFIG_USER], [])
188 AC_DEFUN([SPL_AC_LICENSE], [
189 AC_MSG_CHECKING([spl license])
191 AC_MSG_RESULT([$LICENSE])
192 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
196 AC_DEFUN([SPL_AC_CONFIG], [
198 AC_ARG_WITH([config],
199 AS_HELP_STRING([--with-config=CONFIG],
200 [Config file 'kernel|user|all|srpm']),
201 [SPL_CONFIG="$withval"])
203 AC_MSG_CHECKING([spl config])
204 AC_MSG_RESULT([$SPL_CONFIG]);
207 case "$SPL_CONFIG" in
208 kernel) SPL_AC_CONFIG_KERNEL ;;
209 user) SPL_AC_CONFIG_USER ;;
210 all) SPL_AC_CONFIG_KERNEL
211 SPL_AC_CONFIG_USER ;;
214 AC_MSG_RESULT([Error!])
215 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
216 user kernel|user|all|srpm]) ;;
219 AM_CONDITIONAL([CONFIG_USER],
220 [test "$SPL_CONFIG" = user] ||
221 [test "$SPL_CONFIG" = all])
222 AM_CONDITIONAL([CONFIG_KERNEL],
223 [test "$SPL_CONFIG" = kernel] ||
224 [test "$SPL_CONFIG" = all])
228 dnl # Enable if the SPL should be compiled with internal debugging enabled.
229 dnl # By default this support is disabled.
231 AC_DEFUN([SPL_AC_DEBUG], [
232 AC_ARG_ENABLE([debug],
233 [AS_HELP_STRING([--enable-debug],
234 [Enable generic debug support @<:@default=no@:>@])],
238 AS_IF([test "x$enable_debug" = xyes],
239 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"],
240 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"])
242 AC_MSG_CHECKING([whether debugging is enabled])
243 AC_MSG_RESULT([$enable_debug])
247 dnl # Enabled by default it provides a minimal level of memory tracking.
248 dnl # A total count of bytes allocated is kept for each alloc and free.
249 dnl # Then at module unload time a report to the console will be printed
250 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
251 dnl # and provide an easy way to inspect the kmem based slab.
253 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
254 AC_ARG_ENABLE([debug-kmem],
255 [AS_HELP_STRING([--enable-debug-kmem],
256 [Enable basic kmem accounting @<:@default=yes@:>@])],
258 [enable_debug_kmem=yes])
260 AS_IF([test "x$enable_debug_kmem" = xyes],
261 [AC_DEFINE([DEBUG_KMEM], [1],
262 [Define to 1 to enable basic kmem accounting])
263 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
265 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
266 AC_MSG_RESULT([$enable_debug_kmem])
270 dnl # Disabled by default it provides detailed memory tracking. This
271 dnl # feature also requires --enable-debug-kmem to be set. When enabled
272 dnl # not only will total bytes be tracked but also the location of every
273 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
274 dnl # addresses and where they were allocated will be dumped to the console.
275 dnl # Enabling this feature has a significant impact on performance but it
276 dnl # makes finding memory leaks pretty straight forward.
278 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
279 AC_ARG_ENABLE([debug-kmem-tracking],
280 [AS_HELP_STRING([--enable-debug-kmem-tracking],
281 [Enable detailed kmem tracking @<:@default=no@:>@])],
283 [enable_debug_kmem_tracking=no])
285 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
286 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
287 [Define to 1 to enable detailed kmem tracking])
288 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
290 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
291 AC_MSG_RESULT([$enable_debug_kmem_tracking])
295 dnl # SPL_LINUX_CONFTEST
297 AC_DEFUN([SPL_LINUX_CONFTEST], [
298 cat >conftest.c <<_ACEOF
304 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
306 m4_define([SPL_LANG_PROGRAM], [
311 dnl Do *not* indent the following line: there may be CPP directives.
312 dnl Don't move the `;' right after for the same reason.
320 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
322 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
323 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
324 rm -Rf build && mkdir -p build
325 echo "obj-m := conftest.o" >build/Makefile
327 [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])],
329 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
335 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
337 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
338 [SPL_LINUX_COMPILE_IFELSE(
339 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
341 [test -s build/conftest.o],
346 dnl # SPL_LINUX_CONFIG
348 AC_DEFUN([SPL_LINUX_CONFIG],
349 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
350 SPL_LINUX_TRY_COMPILE([
351 #ifndef AUTOCONF_INCLUDED
352 #include <linux/config.h>
356 #error CONFIG_$1 not #defined
368 dnl # SPL_CHECK_SYMBOL_EXPORT
369 dnl # check symbol exported or not
371 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
372 [AC_MSG_CHECKING([whether symbol $1 is exported])
373 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
374 $LINUX_OBJ/Module*.symvers 2>/dev/null
376 if test $rc -ne 0; then
379 grep -q -E "EXPORT_SYMBOL.*($1)" \
380 "$LINUX_OBJ/$file" 2>/dev/null
382 if test $rc -eq 0; then
387 if test $export -eq 0; then
401 dnl # SPL_CHECK_HEADER
402 dnl # check whether header exists and define HAVE_$2_HEADER
404 AC_DEFUN([SPL_CHECK_HEADER],
405 [AC_MSG_CHECKING([whether header $1 exists])
406 SPL_LINUX_TRY_COMPILE([
411 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
421 dnl # Use the atomic implemenation based on global spinlocks. This
422 dnl # should only be needed by 32-bit kernels which do not provide
423 dnl # the atomic64_* API. It may be optionally enabled as a fallback
424 dnl # if problems are observed with the direct mapping to the native
425 dnl # Linux atomic operations. You may not disable atomic spinlocks
426 dnl # if you kernel does not an atomic64_* API.
428 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
429 AC_ARG_ENABLE([atomic-spinlocks],
430 [AS_HELP_STRING([--enable-atomic-spinlocks],
431 [Atomic types use spinlocks @<:@default=check@:>@])],
433 [enable_atomic_spinlocks=check])
435 SPL_LINUX_TRY_COMPILE([
436 #include <asm/atomic.h>
441 AC_DEFINE(HAVE_ATOMIC64_T, 1,
442 [kernel defines atomic64_t])
447 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
448 AS_IF([test "x$have_atomic64_t" = xyes], [
449 enable_atomic_spinlocks=no
451 enable_atomic_spinlocks=yes
455 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
456 AC_DEFINE([ATOMIC_SPINLOCK], [1],
457 [Atomic types use spinlocks])
459 AS_IF([test "x$have_atomic64_t" = xno], [
461 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
465 AC_MSG_CHECKING([whether atomic types use spinlocks])
466 AC_MSG_RESULT([$enable_atomic_spinlocks])
468 AC_MSG_CHECKING([whether kernel defines atomic64_t])
469 AC_MSG_RESULT([$have_atomic64_t])
473 dnl # 2.6.24 API change,
474 dnl # check if atomic64_cmpxchg is defined
476 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
477 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
478 SPL_LINUX_TRY_COMPILE([
479 #include <asm/atomic.h>
481 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
484 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
485 [kernel defines atomic64_cmpxchg])
492 dnl # 2.6.24 API change,
493 dnl # check if atomic64_xchg is defined
495 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
496 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
497 SPL_LINUX_TRY_COMPILE([
498 #include <asm/atomic.h>
500 atomic64_xchg((atomic64_t *)NULL, 0);
503 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
504 [kernel defines atomic64_xchg])
511 dnl # 2.6.24 API change,
512 dnl # check if uintptr_t typedef is defined
514 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
515 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
516 SPL_LINUX_TRY_COMPILE([
517 #include <linux/types.h>
522 AC_DEFINE(HAVE_UINTPTR_T, 1,
523 [kernel defines uintptr_t])
530 dnl # 2.6.20 API change,
531 dnl # INIT_WORK use 2 args and not store data inside
533 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
534 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
535 SPL_LINUX_TRY_COMPILE([
536 #include <linux/workqueue.h>
538 struct work_struct work;
539 INIT_WORK(&work, NULL, NULL);
542 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
543 [INIT_WORK wants 3 args])
550 dnl # 2.6.21 API change,
551 dnl # 'register_sysctl_table' use only one argument instead of two
553 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
554 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
555 SPL_LINUX_TRY_COMPILE([
556 #include <linux/sysctl.h>
558 return register_sysctl_table(NULL,0);
561 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
562 [register_sysctl_table() wants 2 args])
569 dnl # 2.6.23 API change
570 dnl # Old set_shrinker API replaced with register_shrinker
572 AC_DEFUN([SPL_AC_SET_SHRINKER], [
573 AC_MSG_CHECKING([whether set_shrinker() available])
574 SPL_LINUX_TRY_COMPILE([
575 #include <linux/mm.h>
577 return set_shrinker(DEFAULT_SEEKS, NULL);
580 AC_DEFINE(HAVE_SET_SHRINKER, 1,
581 [set_shrinker() available])
588 dnl # 2.6.25 API change,
589 dnl # struct path entry added to struct nameidata
591 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
592 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
593 SPL_LINUX_TRY_COMPILE([
594 #include <linux/namei.h>
599 nd.path.dentry = NULL;
602 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
603 [struct path used in struct nameidata])
610 dnl # Custom SPL patch may export this system it is not required
612 AC_DEFUN([SPL_AC_TASK_CURR], [
613 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
614 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
619 dnl # 2.6.19 API change,
620 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
622 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
623 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
624 SPL_LINUX_TRY_COMPILE([
625 #include <linux/sysctl.h>
627 #ifndef CTL_UNNUMBERED
628 #error CTL_UNNUMBERED undefined
632 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
633 [unnumbered sysctl support exists])
640 dnl # 2.6.16 API change.
641 dnl # Check if 'fls64()' is available
643 AC_DEFUN([SPL_AC_FLS64],
644 [AC_MSG_CHECKING([whether fls64() is available])
645 SPL_LINUX_TRY_COMPILE([
646 #include <linux/bitops.h>
651 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
658 dnl # 2.6.18 API change, check whether device_create() is available.
659 dnl # Device_create() was introduced in 2.6.18 and depricated
660 dnl # class_device_create() which was fully removed in 2.6.26.
662 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
663 SPL_CHECK_SYMBOL_EXPORT(
665 [drivers/base/core.c],
666 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
667 [device_create() is available])],
672 dnl # 2.6.27 API change,
673 dnl # device_create() uses 5 args, new 'drvdata' argument.
675 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
676 AC_MSG_CHECKING([whether device_create() wants 5 args])
677 tmp_flags="$EXTRA_KCFLAGS"
678 EXTRA_KCFLAGS="-Werror"
679 SPL_LINUX_TRY_COMPILE([
680 #include <linux/device.h>
682 device_create(NULL, NULL, 0, NULL, "%d", 1);
685 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
686 [device_create wants 5 args])
690 EXTRA_KCFLAGS="$tmp_flags"
694 dnl # 2.6.13 API change, check whether class_device_create() is available.
695 dnl # Class_device_create() was introduced in 2.6.13 and depricated
696 dnl # class_simple_device_add() which was fully removed in 2.6.13.
698 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
699 SPL_CHECK_SYMBOL_EXPORT(
700 [class_device_create],
701 [drivers/base/class.c],
702 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
703 [class_device_create() is available])],
708 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
710 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
711 SPL_CHECK_SYMBOL_EXPORT(
712 [set_normalized_timespec],
714 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
715 [set_normalized_timespec() is available as export])],
720 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
721 dnl # previously it was available in time.h as an inline.
723 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
724 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
725 SPL_LINUX_TRY_COMPILE([
726 #include <linux/time.h>
727 void set_normalized_timespec(struct timespec *ts,
728 time_t sec, long nsec) { }
735 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
736 [set_normalized_timespec() is available as inline])
741 dnl # 2.6.18 API change,
742 dnl # timespec_sub() inline function available in linux/time.h
744 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
745 AC_MSG_CHECKING([whether timespec_sub() is available])
746 SPL_LINUX_TRY_COMPILE([
747 #include <linux/time.h>
749 struct timespec a, b, c = { 0 };
750 c = timespec_sub(a, b);
753 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
760 dnl # 2.6.19 API change,
761 dnl # check if init_utsname() is available in linux/utsname.h
763 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
764 AC_MSG_CHECKING([whether init_utsname() is available])
765 SPL_LINUX_TRY_COMPILE([
766 #include <linux/utsname.h>
768 struct new_utsname *a = init_utsname();
771 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
778 dnl # 2.6.26 API change,
779 dnl # definition of struct fdtable relocated to linux/fdtable.h
781 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
782 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
786 dnl # 2.6.14 API change,
787 dnl # check whether 'files_fdtable()' exists
789 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
790 AC_MSG_CHECKING([whether files_fdtable() is available])
791 SPL_LINUX_TRY_COMPILE([
792 #include <linux/sched.h>
793 #include <linux/file.h>
794 #ifdef HAVE_FDTABLE_HEADER
795 #include <linux/fdtable.h>
798 struct files_struct *files = current->files;
799 struct fdtable *fdt = files_fdtable(files);
802 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
809 dnl # 2.6.18 API change,
810 dnl # added linux/uaccess.h
812 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
813 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
817 dnl # 2.6.12 API change,
818 dnl # check whether 'kmalloc_node()' is available.
820 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
821 AC_MSG_CHECKING([whether kmalloc_node() is available])
822 SPL_LINUX_TRY_COMPILE([
823 #include <linux/slab.h>
825 void *a = kmalloc_node(1, GFP_KERNEL, 0);
828 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
835 dnl # 2.6.9 API change,
836 dnl # check whether 'monotonic_clock()' is available it may
837 dnl # be available for some archs but not others.
839 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
840 SPL_CHECK_SYMBOL_EXPORT(
843 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
844 [monotonic_clock() is available])],
849 dnl # 2.6.16 API change,
850 dnl # check whether 'struct inode' has i_mutex
852 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
853 AC_MSG_CHECKING([whether struct inode has i_mutex])
854 SPL_LINUX_TRY_COMPILE([
855 #include <linux/fs.h>
856 #include <linux/mutex.h>
859 mutex_init(&i.i_mutex);
862 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
869 dnl # 2.6.29 API change,
870 dnl # Adaptive mutexs introduced.
872 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
873 AC_MSG_CHECKING([whether struct mutex has owner])
874 SPL_LINUX_TRY_COMPILE([
875 #include <linux/mutex.h>
881 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
888 dnl # 2.6.18 API change,
889 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
890 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
891 dnl # if the mutex validator is disabled or otherwise unavailable.
893 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
894 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
895 SPL_LINUX_TRY_COMPILE([
896 #include <linux/mutex.h>
900 mutex_lock_nested(&mutex, 0);
903 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
904 [mutex_lock_nested() is available])
911 dnl # 2.6.22 API change,
912 dnl # First introduced 'div64_64()' in lib/div64.c
914 AC_DEFUN([SPL_AC_DIV64_64], [
915 SPL_CHECK_SYMBOL_EXPORT(
918 [AC_DEFINE(HAVE_DIV64_64, 1,
919 [div64_64() is available])],
924 dnl # 2.6.26 API change,
925 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
927 AC_DEFUN([SPL_AC_DIV64_U64], [
928 SPL_CHECK_SYMBOL_EXPORT(
931 [AC_DEFINE(HAVE_DIV64_U64, 1,
932 [div64_u64() is available])],
937 dnl # 2.6.27 API change,
938 dnl # on_each_cpu() uses 3 args, no 'retry' argument
940 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
941 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
942 SPL_LINUX_TRY_COMPILE([
943 #include <linux/smp.h>
945 on_each_cpu(NULL, NULL, 0);
948 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
949 [on_each_cpu wants 3 args])
956 dnl # 2.6.18 API change,
957 dnl # kallsyms_lookup_name no longer exported
959 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
960 SPL_CHECK_SYMBOL_EXPORT(
961 [kallsyms_lookup_name],
963 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
964 [kallsyms_lookup_name() is available])],
969 dnl # Proposed API change,
970 dnl # This symbol is not available in stock kernels. You may build a
971 dnl # custom kernel with the *-spl-export-symbols.patch which will export
972 dnl # these symbols for use. If your already rolling a custom kernel for
973 dnl # your environment this is recommended.
975 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
976 SPL_CHECK_SYMBOL_EXPORT(
979 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
980 [get_vmalloc_info() is available])],
985 dnl # 2.6.17 API change
986 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
987 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
988 dnl # were exported in 2.6.17 for use by modules which was consistent with
989 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
990 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
991 dnl # were dropped entirely leaving modules no way to directly iterate over
992 dnl # the zone list. Because we need access to the zone helpers we check
993 dnl # if the kernel contains the old or new implementation. Then we check
994 dnl # to see if the symbols we need for each version are available. If they
995 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
997 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
998 AC_MSG_CHECKING([whether symbol *_pgdat exist])
999 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1001 if test $rc -eq 0; then
1002 AC_MSG_RESULT([yes])
1003 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1010 dnl # Proposed API change,
1011 dnl # This symbol is not available in stock kernels. You may build a
1012 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1013 dnl # these symbols for use. If your already rolling a custom kernel for
1014 dnl # your environment this is recommended.
1016 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1017 SPL_CHECK_SYMBOL_EXPORT(
1018 [first_online_pgdat],
1020 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1021 [first_online_pgdat() is available])],
1026 dnl # Proposed API change,
1027 dnl # This symbol is not available in stock kernels. You may build a
1028 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1029 dnl # these symbols for use. If your already rolling a custom kernel for
1030 dnl # your environment this is recommended.
1032 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1033 SPL_CHECK_SYMBOL_EXPORT(
1034 [next_online_pgdat],
1036 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1037 [next_online_pgdat() is available])],
1042 dnl # Proposed API change,
1043 dnl # This symbol is not available in stock kernels. You may build a
1044 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1045 dnl # these symbols for use. If your already rolling a custom kernel for
1046 dnl # your environment this is recommended.
1048 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1049 SPL_CHECK_SYMBOL_EXPORT(
1052 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1053 [next_zone() is available])],
1058 dnl # 2.6.17 API change,
1059 dnl # See SPL_AC_PGDAT_HELPERS for details.
1061 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1062 SPL_CHECK_SYMBOL_EXPORT(
1065 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1066 [pgdat_list is available])],
1071 dnl # 2.6.18 API change,
1072 dnl # First introduced global_page_state() support as an inline.
1074 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1075 AC_MSG_CHECKING([whether global_page_state() is available])
1076 SPL_LINUX_TRY_COMPILE([
1077 #include <linux/mm.h>
1079 unsigned long state;
1080 state = global_page_state(0);
1083 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1084 [global_page_state() is available])
1091 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1092 dnl # Public global zone stats now include a free page count. However
1093 dnl # the enumerated names of the counters have changed since this API
1094 dnl # was introduced. We need to deduce the corrent name to use. This
1095 dnl # replaces the priviate get_zone_counts() interface.
1097 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1098 dnl # is 2.6.30 as of when this was written.
1100 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1101 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1102 SPL_LINUX_TRY_COMPILE([
1103 #include <linux/mm.h>
1105 enum zone_stat_item zsi;
1106 zsi = NR_FREE_PAGES;
1109 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1110 [Page state NR_FREE_PAGES is available])
1117 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1118 dnl # Public global zone stats now include an inactive page count. However
1119 dnl # the enumerated names of the counters have changed since this API
1120 dnl # was introduced. We need to deduce the corrent name to use. This
1121 dnl # replaces the priviate get_zone_counts() interface.
1123 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1124 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1125 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1127 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1128 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1129 SPL_LINUX_TRY_COMPILE([
1130 #include <linux/mm.h>
1132 enum zone_stat_item zsi;
1136 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1137 [Page state NR_INACTIVE is available])
1142 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1143 SPL_LINUX_TRY_COMPILE([
1144 #include <linux/mm.h>
1146 enum zone_stat_item zsi;
1147 zsi = NR_INACTIVE_ANON;
1150 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1151 [Page state NR_INACTIVE_ANON is available])
1156 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1157 SPL_LINUX_TRY_COMPILE([
1158 #include <linux/mm.h>
1160 enum zone_stat_item zsi;
1161 zsi = NR_INACTIVE_FILE;
1164 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1165 [Page state NR_INACTIVE_FILE is available])
1172 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1173 dnl # Public global zone stats now include an active page count. However
1174 dnl # the enumerated names of the counters have changed since this API
1175 dnl # was introduced. We need to deduce the corrent name to use. This
1176 dnl # replaces the priviate get_zone_counts() interface.
1178 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1179 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1180 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1182 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1183 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1184 SPL_LINUX_TRY_COMPILE([
1185 #include <linux/mm.h>
1187 enum zone_stat_item zsi;
1191 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1192 [Page state NR_ACTIVE is available])
1197 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1198 SPL_LINUX_TRY_COMPILE([
1199 #include <linux/mm.h>
1201 enum zone_stat_item zsi;
1202 zsi = NR_ACTIVE_ANON;
1205 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1206 [Page state NR_ACTIVE_ANON is available])
1211 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1212 SPL_LINUX_TRY_COMPILE([
1213 #include <linux/mm.h>
1215 enum zone_stat_item zsi;
1216 zsi = NR_ACTIVE_FILE;
1219 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1220 [Page state NR_ACTIVE_FILE is available])
1227 dnl # Proposed API change for legacy kernels.
1228 dnl # This symbol is not available in older kernels. For kernels post
1229 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1230 dnl # page state information. This symbol is only used in legacy kernels
1231 dnl # any only as a last resort.
1233 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1234 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1235 SPL_LINUX_TRY_COMPILE([
1237 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1238 #error "global_page_state needs NR_FREE_PAGES"
1241 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1242 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1243 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1244 #error "global_page_state needs NR_ACTIVE*"
1247 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1248 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1249 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1250 #error "global_page_state needs NR_INACTIVE*"
1256 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1257 [get_zone_counts() is needed])
1259 SPL_CHECK_SYMBOL_EXPORT(
1262 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1263 [get_zone_counts() is available])],
1269 dnl # Symbol available in RHEL kernels not in stock kernels.
1271 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1272 SPL_CHECK_SYMBOL_EXPORT(
1275 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1276 [set_fs_pwd() is available])],
1281 dnl # 2.6.25 API change,
1282 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1284 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1285 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1286 SPL_LINUX_TRY_COMPILE([
1287 #include <linux/sched.h>
1288 #include <linux/fs_struct.h>
1290 set_fs_pwd(NULL, NULL);
1293 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1294 [set_fs_pwd() wants 2 args])
1301 dnl # SLES API change, never adopted in mainline,
1302 dnl # Third 'struct vfsmount *' argument removed.
1304 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1305 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1306 SPL_LINUX_TRY_COMPILE([
1307 #include <linux/fs.h>
1309 vfs_unlink(NULL, NULL);
1312 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1313 [vfs_unlink() wants 2 args])
1320 dnl # SLES API change, never adopted in mainline,
1321 dnl # Third and sixth 'struct vfsmount *' argument removed.
1323 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1324 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1325 SPL_LINUX_TRY_COMPILE([
1326 #include <linux/fs.h>
1328 vfs_rename(NULL, NULL, NULL, NULL);
1331 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1332 [vfs_rename() wants 4 args])
1339 dnl # 2.6.29 API change,
1340 dnl # check whether 'struct cred' exists
1342 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1343 AC_MSG_CHECKING([whether struct cred exists])
1344 SPL_LINUX_TRY_COMPILE([
1345 #include <linux/cred.h>
1351 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1358 dnl # Custom SPL patch may export this symbol.
1360 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1361 SPL_CHECK_SYMBOL_EXPORT(
1364 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1365 [groups_search() is available])],
1370 dnl # 2.6.x API change,
1371 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1373 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1374 SPL_CHECK_SYMBOL_EXPORT(
1375 [__put_task_struct],
1377 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1378 [__put_task_struct() is available])],
1383 dnl # 2.6.32 API change,
1384 dnl # Unused 'struct file *' removed from prototype.
1386 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1387 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1388 SPL_LINUX_TRY_COMPILE([
1389 #include <linux/sysctl.h>
1391 proc_dostring(NULL, 0, NULL, NULL, NULL);
1394 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1395 [proc_handler() wants 5 args])