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
29 SPL_AC_TYPE_ATOMIC64_T
30 SPL_AC_TYPE_ATOMIC64_CMPXCHG
31 SPL_AC_TYPE_ATOMIC64_XCHG
32 SPL_AC_3ARGS_INIT_WORK
33 SPL_AC_2ARGS_REGISTER_SYSCTL
35 SPL_AC_PATH_IN_NAMEIDATA
40 SPL_AC_5ARGS_DEVICE_CREATE
41 SPL_AC_CLASS_DEVICE_CREATE
42 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
43 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
50 SPL_AC_MONOTONIC_CLOCK
53 SPL_AC_MUTEX_LOCK_NESTED
56 SPL_AC_3ARGS_ON_EACH_CPU
57 SPL_AC_KALLSYMS_LOOKUP_NAME
58 SPL_AC_GET_VMALLOC_INFO
60 SPL_AC_FIRST_ONLINE_PGDAT
61 SPL_AC_NEXT_ONLINE_PGDAT
64 SPL_AC_GLOBAL_PAGE_STATE
65 SPL_AC_ZONE_STAT_ITEM_FREE
66 SPL_AC_ZONE_STAT_ITEM_INACTIVE
67 SPL_AC_ZONE_STAT_ITEM_ACTIVE
68 SPL_AC_GET_ZONE_COUNTS
70 SPL_AC_2ARGS_SET_FS_PWD
71 SPL_AC_2ARGS_VFS_UNLINK
72 SPL_AC_4ARGS_VFS_RENAME
75 SPL_AC_PUT_TASK_STRUCT
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 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
108 2>/dev/null | grep -v obj | tail -1`
110 if test -e ${sourcelink}; then
111 kernelsrc=`readlink -f ${sourcelink}`
113 AC_MSG_RESULT([Not found])
115 *** Please specify the location of the kernel source
116 *** with the '--with-linux=PATH' option])
119 if test "$kernelsrc" = "NONE"; then
124 AC_MSG_RESULT([$kernelsrc])
125 AC_MSG_CHECKING([kernel build directory])
126 if test -z "$kernelbuild"; then
127 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
128 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
129 elif test -d ${kernelsrc}-obj/`arch`/default; then
130 kernelbuild=${kernelsrc}-obj/`arch`/default
131 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
132 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
134 kernelbuild=${kernelsrc}
137 AC_MSG_RESULT([$kernelbuild])
139 AC_MSG_CHECKING([kernel source version])
140 if test -r $kernelbuild/include/linux/version.h &&
141 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
143 kernsrcver=`(echo "#include <linux/version.h>";
144 echo "kernsrcver=UTS_RELEASE") |
145 cpp -I $kernelbuild/include |
146 grep "^kernsrcver=" | cut -d \" -f 2`
148 elif test -r $kernelbuild/include/linux/utsrelease.h &&
149 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
151 kernsrcver=`(echo "#include <linux/utsrelease.h>";
152 echo "kernsrcver=UTS_RELEASE") |
153 cpp -I $kernelbuild/include |
154 grep "^kernsrcver=" | cut -d \" -f 2`
157 if test -z "$kernsrcver"; then
158 AC_MSG_RESULT([Not found])
160 *** Cannot determine the version of the linux kernel source.
161 *** Please prepare the kernel before running this script])
164 AC_MSG_RESULT([$kernsrcver])
167 LINUX_OBJ=${kernelbuild}
168 LINUX_VERSION=${kernsrcver}
172 AC_SUBST(LINUX_VERSION)
174 SPL_AC_MODULE_SYMVERS
178 dnl # Default SPL user configuration
180 AC_DEFUN([SPL_AC_CONFIG_USER], [])
182 AC_DEFUN([SPL_AC_LICENSE], [
183 AC_MSG_CHECKING([spl license])
185 AC_MSG_RESULT([$LICENSE])
186 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
190 AC_DEFUN([SPL_AC_CONFIG], [
192 AC_ARG_WITH([config],
193 AS_HELP_STRING([--with-config=CONFIG],
194 [Config file 'kernel|user|all|srpm']),
195 [SPL_CONFIG="$withval"])
197 AC_MSG_CHECKING([spl config])
198 AC_MSG_RESULT([$SPL_CONFIG]);
201 case "$SPL_CONFIG" in
202 kernel) SPL_AC_CONFIG_KERNEL ;;
203 user) SPL_AC_CONFIG_USER ;;
204 all) SPL_AC_CONFIG_KERNEL
205 SPL_AC_CONFIG_USER ;;
208 AC_MSG_RESULT([Error!])
209 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
210 user kernel|user|all|srpm]) ;;
213 AM_CONDITIONAL([CONFIG_USER],
214 [test "$SPL_CONFIG" = user] ||
215 [test "$SPL_CONFIG" = all])
216 AM_CONDITIONAL([CONFIG_KERNEL],
217 [test "$SPL_CONFIG" = kernel] ||
218 [test "$SPL_CONFIG" = all])
222 dnl # Enable if the SPL should be compiled with internal debugging enabled.
223 dnl # By default this support is disabled.
225 AC_DEFUN([SPL_AC_DEBUG], [
226 AC_ARG_ENABLE([debug],
227 [AS_HELP_STRING([--enable-debug],
228 [Enable generic debug support @<:@default=no@:>@])],
232 AS_IF([test "x$enable_debug" = xyes],
233 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"],
234 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"])
236 AC_MSG_CHECKING([whether debugging is enabled])
237 AC_MSG_RESULT([$enable_debug])
241 dnl # Enabled by default it provides a minimal level of memory tracking.
242 dnl # A total count of bytes allocated is kept for each alloc and free.
243 dnl # Then at module unload time a report to the console will be printed
244 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
245 dnl # and provide an easy way to inspect the kmem based slab.
247 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
248 AC_ARG_ENABLE([debug-kmem],
249 [AS_HELP_STRING([--enable-debug-kmem],
250 [Enable basic kmem accounting @<:@default=yes@:>@])],
252 [enable_debug_kmem=yes])
254 AS_IF([test "x$enable_debug_kmem" = xyes],
255 [AC_DEFINE([DEBUG_KMEM], [1],
256 [Define to 1 to enable basic kmem accounting])
257 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
259 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
260 AC_MSG_RESULT([$enable_debug_kmem])
264 dnl # Disabled by default it provides detailed memory tracking. This
265 dnl # feature also requires --enable-debug-kmem to be set. When enabled
266 dnl # not only will total bytes be tracked but also the location of every
267 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
268 dnl # addresses and where they were allocated will be dumped to the console.
269 dnl # Enabling this feature has a significant impact on performance but it
270 dnl # makes finding memory leaks pretty straight forward.
272 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
273 AC_ARG_ENABLE([debug-kmem-tracking],
274 [AS_HELP_STRING([--enable-debug-kmem-tracking],
275 [Enable detailed kmem tracking @<:@default=no@:>@])],
277 [enable_debug_kmem_tracking=no])
279 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
280 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
281 [Define to 1 to enable detailed kmem tracking])
282 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
284 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
285 AC_MSG_RESULT([$enable_debug_kmem_tracking])
289 dnl # Use the atomic implemenation based on global spinlocks. This
290 dnl # should never be needed, however it has been left in place as
291 dnl # a fallback option in case problems are observed with directly
292 dnl # mapping to the native Linux atomic operations.
294 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
295 AC_ARG_ENABLE([atomic-spinlocks],
296 [AS_HELP_STRING([--enable-atomic-spinlocks],
297 [Atomic types use spinlocks @<:@default=no@:>@])],
299 [enable_atomic_spinlocks=no])
301 AS_IF([test "x$enable_atomic_spinlocks" = xyes],
302 [AC_DEFINE([ATOMIC_SPINLOCK], [1],
303 [Atomic types use spinlocks])])
305 AC_MSG_CHECKING([whether atomic types use spinlocks])
306 AC_MSG_RESULT([$enable_atomic_spinlocks])
310 dnl # SPL_LINUX_CONFTEST
312 AC_DEFUN([SPL_LINUX_CONFTEST], [
313 cat >conftest.c <<_ACEOF
319 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
321 m4_define([SPL_LANG_PROGRAM], [
326 dnl Do *not* indent the following line: there may be CPP directives.
327 dnl Don't move the `;' right after for the same reason.
335 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
337 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
338 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
339 rm -Rf build && mkdir -p build
340 echo "obj-m := conftest.o" >build/Makefile
342 [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])],
344 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
350 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
352 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
353 [SPL_LINUX_COMPILE_IFELSE(
354 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
356 [test -s build/conftest.o],
361 dnl # SPL_LINUX_CONFIG
363 AC_DEFUN([SPL_LINUX_CONFIG],
364 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
365 SPL_LINUX_TRY_COMPILE([
366 #ifndef AUTOCONF_INCLUDED
367 #include <linux/config.h>
371 #error CONFIG_$1 not #defined
383 dnl # SPL_CHECK_SYMBOL_EXPORT
384 dnl # check symbol exported or not
386 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
387 [AC_MSG_CHECKING([whether symbol $1 is exported])
388 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
389 $LINUX_OBJ/Module*.symvers 2>/dev/null
391 if test $rc -ne 0; then
394 grep -q -E "EXPORT_SYMBOL.*($1)" \
395 "$LINUX_OBJ/$file" 2>/dev/null
397 if test $rc -eq 0; then
402 if test $export -eq 0; then
416 dnl # SPL_CHECK_HEADER
417 dnl # check whether header exists and define HAVE_$2_HEADER
419 AC_DEFUN([SPL_CHECK_HEADER],
420 [AC_MSG_CHECKING([whether header $1 exists])
421 SPL_LINUX_TRY_COMPILE([
426 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
436 dnl # 2.6.24 API change,
437 dnl # check if uintptr_t typedef is defined
439 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
440 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
441 SPL_LINUX_TRY_COMPILE([
442 #include <linux/types.h>
447 AC_DEFINE(HAVE_UINTPTR_T, 1,
448 [kernel defines uintptr_t])
455 dnl # 2.6.x API change,
456 dnl # check if atomic64_t typedef is defined
458 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
459 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
460 SPL_LINUX_TRY_COMPILE([
461 #include <asm/atomic.h>
466 AC_DEFINE(HAVE_ATOMIC64_T, 1,
467 [kernel defines atomic64_t])
474 dnl # 2.6.24 API change,
475 dnl # check if atomic64_cmpxchg is defined
477 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
478 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
479 SPL_LINUX_TRY_COMPILE([
480 #include <asm/atomic.h>
482 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
485 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
486 [kernel defines atomic64_cmpxchg])
493 dnl # 2.6.24 API change,
494 dnl # check if atomic64_xchg is defined
496 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
497 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
498 SPL_LINUX_TRY_COMPILE([
499 #include <asm/atomic.h>
501 atomic64_xchg((atomic64_t *)NULL, 0);
504 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
505 [kernel defines atomic64_xchg])
512 dnl # 2.6.20 API change,
513 dnl # INIT_WORK use 2 args and not store data inside
515 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
516 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
517 SPL_LINUX_TRY_COMPILE([
518 #include <linux/workqueue.h>
520 struct work_struct work;
521 INIT_WORK(&work, NULL, NULL);
524 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
525 [INIT_WORK wants 3 args])
532 dnl # 2.6.21 API change,
533 dnl # 'register_sysctl_table' use only one argument instead of two
535 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
536 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
537 SPL_LINUX_TRY_COMPILE([
538 #include <linux/sysctl.h>
540 return register_sysctl_table(NULL,0);
543 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
544 [register_sysctl_table() wants 2 args])
551 dnl # 2.6.23 API change
552 dnl # Old set_shrinker API replaced with register_shrinker
554 AC_DEFUN([SPL_AC_SET_SHRINKER], [
555 AC_MSG_CHECKING([whether set_shrinker() available])
556 SPL_LINUX_TRY_COMPILE([
557 #include <linux/mm.h>
559 return set_shrinker(DEFAULT_SEEKS, NULL);
562 AC_DEFINE(HAVE_SET_SHRINKER, 1,
563 [set_shrinker() available])
570 dnl # 2.6.25 API change,
571 dnl # struct path entry added to struct nameidata
573 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
574 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
575 SPL_LINUX_TRY_COMPILE([
576 #include <linux/namei.h>
581 nd.path.dentry = NULL;
584 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
585 [struct path used in struct nameidata])
592 dnl # Custom SPL patch may export this system it is not required
594 AC_DEFUN([SPL_AC_TASK_CURR], [
595 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
596 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
601 dnl # 2.6.19 API change,
602 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
604 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
605 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
606 SPL_LINUX_TRY_COMPILE([
607 #include <linux/sysctl.h>
609 #ifndef CTL_UNNUMBERED
610 #error CTL_UNNUMBERED undefined
614 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
615 [unnumbered sysctl support exists])
622 dnl # 2.6.16 API change.
623 dnl # Check if 'fls64()' is available
625 AC_DEFUN([SPL_AC_FLS64],
626 [AC_MSG_CHECKING([whether fls64() is available])
627 SPL_LINUX_TRY_COMPILE([
628 #include <linux/bitops.h>
633 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
640 dnl # 2.6.18 API change, check whether device_create() is available.
641 dnl # Device_create() was introduced in 2.6.18 and depricated
642 dnl # class_device_create() which was fully removed in 2.6.26.
644 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
645 SPL_CHECK_SYMBOL_EXPORT(
647 [drivers/base/core.c],
648 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
649 [device_create() is available])],
654 dnl # 2.6.27 API change,
655 dnl # device_create() uses 5 args, new 'drvdata' argument.
657 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
658 AC_MSG_CHECKING([whether device_create() wants 5 args])
659 tmp_flags="$EXTRA_KCFLAGS"
660 EXTRA_KCFLAGS="-Werror"
661 SPL_LINUX_TRY_COMPILE([
662 #include <linux/device.h>
664 device_create(NULL, NULL, 0, NULL, "%d", 1);
667 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
668 [device_create wants 5 args])
672 EXTRA_KCFLAGS="$tmp_flags"
676 dnl # 2.6.13 API change, check whether class_device_create() is available.
677 dnl # Class_device_create() was introduced in 2.6.13 and depricated
678 dnl # class_simple_device_add() which was fully removed in 2.6.13.
680 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
681 SPL_CHECK_SYMBOL_EXPORT(
682 [class_device_create],
683 [drivers/base/class.c],
684 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
685 [class_device_create() is available])],
690 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
692 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
693 SPL_CHECK_SYMBOL_EXPORT(
694 [set_normalized_timespec],
696 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
697 [set_normalized_timespec() is available as export])],
702 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
703 dnl # previously it was available in time.h as an inline.
705 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
706 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
707 SPL_LINUX_TRY_COMPILE([
708 #include <linux/time.h>
709 void set_normalized_timespec(struct timespec *ts,
710 time_t sec, long nsec) { }
717 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
718 [set_normalized_timespec() is available as inline])
723 dnl # 2.6.18 API change,
724 dnl # timespec_sub() inline function available in linux/time.h
726 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
727 AC_MSG_CHECKING([whether timespec_sub() is available])
728 SPL_LINUX_TRY_COMPILE([
729 #include <linux/time.h>
731 struct timespec a, b, c = { 0 };
732 c = timespec_sub(a, b);
735 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
742 dnl # 2.6.19 API change,
743 dnl # check if init_utsname() is available in linux/utsname.h
745 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
746 AC_MSG_CHECKING([whether init_utsname() is available])
747 SPL_LINUX_TRY_COMPILE([
748 #include <linux/utsname.h>
750 struct new_utsname *a = init_utsname();
753 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
760 dnl # 2.6.26 API change,
761 dnl # definition of struct fdtable relocated to linux/fdtable.h
763 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
764 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
768 dnl # 2.6.14 API change,
769 dnl # check whether 'files_fdtable()' exists
771 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
772 AC_MSG_CHECKING([whether files_fdtable() is available])
773 SPL_LINUX_TRY_COMPILE([
774 #include <linux/sched.h>
775 #include <linux/file.h>
776 #ifdef HAVE_FDTABLE_HEADER
777 #include <linux/fdtable.h>
780 struct files_struct *files = current->files;
781 struct fdtable *fdt = files_fdtable(files);
784 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
791 dnl # 2.6.18 API change,
792 dnl # added linux/uaccess.h
794 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
795 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
799 dnl # 2.6.12 API change,
800 dnl # check whether 'kmalloc_node()' is available.
802 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
803 AC_MSG_CHECKING([whether kmalloc_node() is available])
804 SPL_LINUX_TRY_COMPILE([
805 #include <linux/slab.h>
807 void *a = kmalloc_node(1, GFP_KERNEL, 0);
810 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
817 dnl # 2.6.9 API change,
818 dnl # check whether 'monotonic_clock()' is available it may
819 dnl # be available for some archs but not others.
821 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
822 SPL_CHECK_SYMBOL_EXPORT(
825 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
826 [monotonic_clock() is available])],
831 dnl # 2.6.16 API change,
832 dnl # check whether 'struct inode' has i_mutex
834 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
835 AC_MSG_CHECKING([whether struct inode has i_mutex])
836 SPL_LINUX_TRY_COMPILE([
837 #include <linux/fs.h>
838 #include <linux/mutex.h>
841 mutex_init(&i.i_mutex);
844 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
851 dnl # 2.6.29 API change,
852 dnl # Adaptive mutexs introduced.
854 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
855 AC_MSG_CHECKING([whether struct mutex has owner])
856 SPL_LINUX_TRY_COMPILE([
857 #include <linux/mutex.h>
863 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
870 dnl # 2.6.18 API change,
871 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
872 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
873 dnl # if the mutex validator is disabled or otherwise unavailable.
875 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
876 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
877 SPL_LINUX_TRY_COMPILE([
878 #include <linux/mutex.h>
882 mutex_lock_nested(&mutex, 0);
885 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
886 [mutex_lock_nested() is available])
893 dnl # 2.6.22 API change,
894 dnl # First introduced 'div64_64()' in lib/div64.c
896 AC_DEFUN([SPL_AC_DIV64_64], [
897 SPL_CHECK_SYMBOL_EXPORT(
900 [AC_DEFINE(HAVE_DIV64_64, 1,
901 [div64_64() is available])],
906 dnl # 2.6.26 API change,
907 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
909 AC_DEFUN([SPL_AC_DIV64_U64], [
910 SPL_CHECK_SYMBOL_EXPORT(
913 [AC_DEFINE(HAVE_DIV64_U64, 1,
914 [div64_u64() is available])],
919 dnl # 2.6.27 API change,
920 dnl # on_each_cpu() uses 3 args, no 'retry' argument
922 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
923 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
924 SPL_LINUX_TRY_COMPILE([
925 #include <linux/smp.h>
927 on_each_cpu(NULL, NULL, 0);
930 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
931 [on_each_cpu wants 3 args])
938 dnl # 2.6.18 API change,
939 dnl # kallsyms_lookup_name no longer exported
941 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
942 SPL_CHECK_SYMBOL_EXPORT(
943 [kallsyms_lookup_name],
945 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
946 [kallsyms_lookup_name() is available])],
951 dnl # Proposed API change,
952 dnl # This symbol is not available in stock kernels. You may build a
953 dnl # custom kernel with the *-spl-export-symbols.patch which will export
954 dnl # these symbols for use. If your already rolling a custom kernel for
955 dnl # your environment this is recommended.
957 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
958 SPL_CHECK_SYMBOL_EXPORT(
961 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
962 [get_vmalloc_info() is available])],
967 dnl # 2.6.17 API change
968 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
969 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
970 dnl # were exported in 2.6.17 for use by modules which was consistent with
971 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
972 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
973 dnl # were dropped entirely leaving modules no way to directly iterate over
974 dnl # the zone list. Because we need access to the zone helpers we check
975 dnl # if the kernel contains the old or new implementation. Then we check
976 dnl # to see if the symbols we need for each version are available. If they
977 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
979 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
980 AC_MSG_CHECKING([whether symbol *_pgdat exist])
981 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
983 if test $rc -eq 0; then
985 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
992 dnl # Proposed API change,
993 dnl # This symbol is not available in stock kernels. You may build a
994 dnl # custom kernel with the *-spl-export-symbols.patch which will export
995 dnl # these symbols for use. If your already rolling a custom kernel for
996 dnl # your environment this is recommended.
998 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
999 SPL_CHECK_SYMBOL_EXPORT(
1000 [first_online_pgdat],
1002 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1003 [first_online_pgdat() is available])],
1008 dnl # Proposed API change,
1009 dnl # This symbol is not available in stock kernels. You may build a
1010 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1011 dnl # these symbols for use. If your already rolling a custom kernel for
1012 dnl # your environment this is recommended.
1014 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1015 SPL_CHECK_SYMBOL_EXPORT(
1016 [next_online_pgdat],
1018 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1019 [next_online_pgdat() is available])],
1024 dnl # Proposed API change,
1025 dnl # This symbol is not available in stock kernels. You may build a
1026 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1027 dnl # these symbols for use. If your already rolling a custom kernel for
1028 dnl # your environment this is recommended.
1030 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1031 SPL_CHECK_SYMBOL_EXPORT(
1034 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1035 [next_zone() is available])],
1040 dnl # 2.6.17 API change,
1041 dnl # See SPL_AC_PGDAT_HELPERS for details.
1043 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1044 SPL_CHECK_SYMBOL_EXPORT(
1047 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1048 [pgdat_list is available])],
1053 dnl # 2.6.18 API change,
1054 dnl # First introduced global_page_state() support as an inline.
1056 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1057 AC_MSG_CHECKING([whether global_page_state() is available])
1058 SPL_LINUX_TRY_COMPILE([
1059 #include <linux/mm.h>
1061 unsigned long state;
1062 state = global_page_state(0);
1065 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1066 [global_page_state() is available])
1073 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1074 dnl # Public global zone stats now include a free page count. However
1075 dnl # the enumerated names of the counters have changed since this API
1076 dnl # was introduced. We need to deduce the corrent name to use. This
1077 dnl # replaces the priviate get_zone_counts() interface.
1079 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1080 dnl # is 2.6.30 as of when this was written.
1082 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1083 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1084 SPL_LINUX_TRY_COMPILE([
1085 #include <linux/mm.h>
1087 enum zone_stat_item zsi;
1088 zsi = NR_FREE_PAGES;
1091 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1092 [Page state NR_FREE_PAGES is available])
1099 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1100 dnl # Public global zone stats now include an inactive page count. However
1101 dnl # the enumerated names of the counters have changed since this API
1102 dnl # was introduced. We need to deduce the corrent name to use. This
1103 dnl # replaces the priviate get_zone_counts() interface.
1105 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1106 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1107 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1109 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1110 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1111 SPL_LINUX_TRY_COMPILE([
1112 #include <linux/mm.h>
1114 enum zone_stat_item zsi;
1118 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1119 [Page state NR_INACTIVE is available])
1124 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1125 SPL_LINUX_TRY_COMPILE([
1126 #include <linux/mm.h>
1128 enum zone_stat_item zsi;
1129 zsi = NR_INACTIVE_ANON;
1132 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1133 [Page state NR_INACTIVE_ANON is available])
1138 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1139 SPL_LINUX_TRY_COMPILE([
1140 #include <linux/mm.h>
1142 enum zone_stat_item zsi;
1143 zsi = NR_INACTIVE_FILE;
1146 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1147 [Page state NR_INACTIVE_FILE is available])
1154 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1155 dnl # Public global zone stats now include an active page count. However
1156 dnl # the enumerated names of the counters have changed since this API
1157 dnl # was introduced. We need to deduce the corrent name to use. This
1158 dnl # replaces the priviate get_zone_counts() interface.
1160 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1161 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1162 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1164 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1165 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1166 SPL_LINUX_TRY_COMPILE([
1167 #include <linux/mm.h>
1169 enum zone_stat_item zsi;
1173 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1174 [Page state NR_ACTIVE is available])
1179 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1180 SPL_LINUX_TRY_COMPILE([
1181 #include <linux/mm.h>
1183 enum zone_stat_item zsi;
1184 zsi = NR_ACTIVE_ANON;
1187 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1188 [Page state NR_ACTIVE_ANON is available])
1193 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1194 SPL_LINUX_TRY_COMPILE([
1195 #include <linux/mm.h>
1197 enum zone_stat_item zsi;
1198 zsi = NR_ACTIVE_FILE;
1201 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1202 [Page state NR_ACTIVE_FILE is available])
1209 dnl # Proposed API change for legacy kernels.
1210 dnl # This symbol is not available in older kernels. For kernels post
1211 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1212 dnl # page state information. This symbol is only used in legacy kernels
1213 dnl # any only as a last resort.
1215 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1216 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1217 SPL_LINUX_TRY_COMPILE([
1219 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1220 #error "global_page_state needs NR_FREE_PAGES"
1223 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1224 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1225 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1226 #error "global_page_state needs NR_ACTIVE*"
1229 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1230 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1231 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1232 #error "global_page_state needs NR_INACTIVE*"
1238 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1239 [get_zone_counts() is needed])
1241 SPL_CHECK_SYMBOL_EXPORT(
1244 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1245 [get_zone_counts() is available])],
1251 dnl # Symbol available in RHEL kernels not in stock kernels.
1253 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1254 SPL_CHECK_SYMBOL_EXPORT(
1257 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1258 [set_fs_pwd() is available])],
1263 dnl # 2.6.25 API change,
1264 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1266 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1267 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1268 SPL_LINUX_TRY_COMPILE([
1269 #include <linux/sched.h>
1270 #include <linux/fs_struct.h>
1272 set_fs_pwd(NULL, NULL);
1275 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1276 [set_fs_pwd() wants 2 args])
1283 dnl # SLES API change, never adopted in mainline,
1284 dnl # Third 'struct vfsmount *' argument removed.
1286 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1287 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1288 SPL_LINUX_TRY_COMPILE([
1289 #include <linux/fs.h>
1291 vfs_unlink(NULL, NULL);
1294 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1295 [vfs_unlink() wants 2 args])
1302 dnl # SLES API change, never adopted in mainline,
1303 dnl # Third and sixth 'struct vfsmount *' argument removed.
1305 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1306 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1307 SPL_LINUX_TRY_COMPILE([
1308 #include <linux/fs.h>
1310 vfs_rename(NULL, NULL, NULL, NULL);
1313 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1314 [vfs_rename() wants 4 args])
1321 dnl # 2.6.29 API change,
1322 dnl # check whether 'struct cred' exists
1324 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1325 AC_MSG_CHECKING([whether struct cred exists])
1326 SPL_LINUX_TRY_COMPILE([
1327 #include <linux/cred.h>
1333 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1340 dnl # Custom SPL patch may export this symbol.
1342 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1343 SPL_CHECK_SYMBOL_EXPORT(
1346 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1347 [groups_search() is available])],
1352 dnl # 2.6.x API change,
1353 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1355 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1356 SPL_CHECK_SYMBOL_EXPORT(
1357 [__put_task_struct],
1359 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1360 [__put_task_struct() is available])],