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']),
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 ;;
207 AC_MSG_RESULT([Error!])
208 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
209 user kernel|user|all]) ;;
212 AM_CONDITIONAL([CONFIG_USER],
213 [test "$SPL_CONFIG" = user] ||
214 [test "$SPL_CONFIG" = all])
215 AM_CONDITIONAL([CONFIG_KERNEL],
216 [test "$SPL_CONFIG" = kernel] ||
217 [test "$SPL_CONFIG" = all])
221 dnl # Enable if the SPL should be compiled with internal debugging enabled.
222 dnl # By default this support is disabled.
224 AC_DEFUN([SPL_AC_DEBUG], [
225 AC_ARG_ENABLE([debug],
226 [AS_HELP_STRING([--enable-debug],
227 [Enable generic debug support @<:@default=no@:>@])],
231 AS_IF([test "x$enable_debug" = xyes],
232 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"],
233 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"])
235 AC_MSG_CHECKING([whether debugging is enabled])
236 AC_MSG_RESULT([$enable_debug])
240 dnl # Enabled by default it provides a minimal level of memory tracking.
241 dnl # A total count of bytes allocated is kept for each alloc and free.
242 dnl # Then at module unload time a report to the console will be printed
243 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
244 dnl # and provide an easy way to inspect the kmem based slab.
246 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
247 AC_ARG_ENABLE([debug-kmem],
248 [AS_HELP_STRING([--enable-debug-kmem],
249 [Enable basic kmem accounting @<:@default=yes@:>@])],
251 [enable_debug_kmem=yes])
253 AS_IF([test "x$enable_debug_kmem" = xyes],
254 [AC_DEFINE([DEBUG_KMEM], [1],
255 [Define to 1 to enable basic kmem accounting])
256 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
258 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
259 AC_MSG_RESULT([$enable_debug_kmem])
263 dnl # Disabled by default it provides detailed memory tracking. This
264 dnl # feature also requires --enable-debug-kmem to be set. When enabled
265 dnl # not only will total bytes be tracked but also the location of every
266 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
267 dnl # addresses and where they were allocated will be dumped to the console.
268 dnl # Enabling this feature has a significant impact on performance but it
269 dnl # makes finding memory leaks pretty straight forward.
271 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
272 AC_ARG_ENABLE([debug-kmem-tracking],
273 [AS_HELP_STRING([--enable-debug-kmem-tracking],
274 [Enable detailed kmem tracking @<:@default=no@:>@])],
276 [enable_debug_kmem_tracking=no])
278 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
279 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
280 [Define to 1 to enable detailed kmem tracking])
281 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
283 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
284 AC_MSG_RESULT([$enable_debug_kmem_tracking])
288 dnl # Use the atomic implemenation based on global spinlocks. This
289 dnl # should never be needed, however it has been left in place as
290 dnl # a fallback option in case problems are observed with directly
291 dnl # mapping to the native Linux atomic operations.
293 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
294 AC_ARG_ENABLE([atomic-spinlocks],
295 [AS_HELP_STRING([--enable-atomic-spinlocks],
296 [Atomic types use spinlocks @<:@default=no@:>@])],
298 [enable_atomic_spinlocks=no])
300 AS_IF([test "x$enable_atomic_spinlocks" = xyes],
301 [AC_DEFINE([ATOMIC_SPINLOCK], [1],
302 [Atomic types use spinlocks])])
304 AC_MSG_CHECKING([whether atomic types use spinlocks])
305 AC_MSG_RESULT([$enable_atomic_spinlocks])
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 # 2.6.24 API change,
436 dnl # check if uintptr_t typedef is defined
438 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
439 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
440 SPL_LINUX_TRY_COMPILE([
441 #include <linux/types.h>
446 AC_DEFINE(HAVE_UINTPTR_T, 1,
447 [kernel defines uintptr_t])
454 dnl # 2.6.x API change,
455 dnl # check if atomic64_t typedef is defined
457 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
458 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
459 SPL_LINUX_TRY_COMPILE([
460 #include <asm/atomic.h>
465 AC_DEFINE(HAVE_ATOMIC64_T, 1,
466 [kernel defines 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.20 API change,
512 dnl # INIT_WORK use 2 args and not store data inside
514 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
515 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
516 SPL_LINUX_TRY_COMPILE([
517 #include <linux/workqueue.h>
519 struct work_struct work;
520 INIT_WORK(&work, NULL, NULL);
523 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
524 [INIT_WORK wants 3 args])
531 dnl # 2.6.21 API change,
532 dnl # 'register_sysctl_table' use only one argument instead of two
534 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
535 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
536 SPL_LINUX_TRY_COMPILE([
537 #include <linux/sysctl.h>
539 return register_sysctl_table(NULL,0);
542 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
543 [register_sysctl_table() wants 2 args])
550 dnl # 2.6.23 API change
551 dnl # Old set_shrinker API replaced with register_shrinker
553 AC_DEFUN([SPL_AC_SET_SHRINKER], [
554 AC_MSG_CHECKING([whether set_shrinker() available])
555 SPL_LINUX_TRY_COMPILE([
556 #include <linux/mm.h>
558 return set_shrinker(DEFAULT_SEEKS, NULL);
561 AC_DEFINE(HAVE_SET_SHRINKER, 1,
562 [set_shrinker() available])
569 dnl # 2.6.25 API change,
570 dnl # struct path entry added to struct nameidata
572 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
573 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
574 SPL_LINUX_TRY_COMPILE([
575 #include <linux/namei.h>
580 nd.path.dentry = NULL;
583 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
584 [struct path used in struct nameidata])
591 dnl # Custom SPL patch may export this system it is not required
593 AC_DEFUN([SPL_AC_TASK_CURR], [
594 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
595 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
600 dnl # 2.6.19 API change,
601 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
603 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
604 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
605 SPL_LINUX_TRY_COMPILE([
606 #include <linux/sysctl.h>
608 #ifndef CTL_UNNUMBERED
609 #error CTL_UNNUMBERED undefined
613 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
614 [unnumbered sysctl support exists])
621 dnl # 2.6.16 API change.
622 dnl # Check if 'fls64()' is available
624 AC_DEFUN([SPL_AC_FLS64],
625 [AC_MSG_CHECKING([whether fls64() is available])
626 SPL_LINUX_TRY_COMPILE([
627 #include <linux/bitops.h>
632 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
639 dnl # 2.6.18 API change, check whether device_create() is available.
640 dnl # Device_create() was introduced in 2.6.18 and depricated
641 dnl # class_device_create() which was fully removed in 2.6.26.
643 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
644 SPL_CHECK_SYMBOL_EXPORT(
646 [drivers/base/core.c],
647 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
648 [device_create() is available])],
653 dnl # 2.6.27 API change,
654 dnl # device_create() uses 5 args, new 'drvdata' argument.
656 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
657 AC_MSG_CHECKING([whether device_create() wants 5 args])
658 tmp_flags="$EXTRA_KCFLAGS"
659 EXTRA_KCFLAGS="-Werror"
660 SPL_LINUX_TRY_COMPILE([
661 #include <linux/device.h>
663 device_create(NULL, NULL, 0, NULL, "%d", 1);
666 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
667 [device_create wants 5 args])
671 EXTRA_KCFLAGS="$tmp_flags"
675 dnl # 2.6.13 API change, check whether class_device_create() is available.
676 dnl # Class_device_create() was introduced in 2.6.13 and depricated
677 dnl # class_simple_device_add() which was fully removed in 2.6.13.
679 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
680 SPL_CHECK_SYMBOL_EXPORT(
681 [class_device_create],
682 [drivers/base/class.c],
683 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
684 [class_device_create() is available])],
689 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
691 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
692 SPL_CHECK_SYMBOL_EXPORT(
693 [set_normalized_timespec],
695 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
696 [set_normalized_timespec() is available as export])],
701 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
702 dnl # previously it was available in time.h as an inline.
704 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
705 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
706 SPL_LINUX_TRY_COMPILE([
707 #include <linux/time.h>
708 void set_normalized_timespec(struct timespec *ts,
709 time_t sec, long nsec) { }
716 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
717 [set_normalized_timespec() is available as inline])
722 dnl # 2.6.18 API change,
723 dnl # timespec_sub() inline function available in linux/time.h
725 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
726 AC_MSG_CHECKING([whether timespec_sub() is available])
727 SPL_LINUX_TRY_COMPILE([
728 #include <linux/time.h>
730 struct timespec a, b, c = { 0 };
731 c = timespec_sub(a, b);
734 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
741 dnl # 2.6.19 API change,
742 dnl # check if init_utsname() is available in linux/utsname.h
744 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
745 AC_MSG_CHECKING([whether init_utsname() is available])
746 SPL_LINUX_TRY_COMPILE([
747 #include <linux/utsname.h>
749 struct new_utsname *a = init_utsname();
752 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
759 dnl # 2.6.26 API change,
760 dnl # definition of struct fdtable relocated to linux/fdtable.h
762 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
763 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
767 dnl # 2.6.14 API change,
768 dnl # check whether 'files_fdtable()' exists
770 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
771 AC_MSG_CHECKING([whether files_fdtable() is available])
772 SPL_LINUX_TRY_COMPILE([
773 #include <linux/sched.h>
774 #include <linux/file.h>
775 #ifdef HAVE_FDTABLE_HEADER
776 #include <linux/fdtable.h>
779 struct files_struct *files = current->files;
780 struct fdtable *fdt = files_fdtable(files);
783 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
790 dnl # 2.6.18 API change,
791 dnl # added linux/uaccess.h
793 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
794 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
798 dnl # 2.6.12 API change,
799 dnl # check whether 'kmalloc_node()' is available.
801 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
802 AC_MSG_CHECKING([whether kmalloc_node() is available])
803 SPL_LINUX_TRY_COMPILE([
804 #include <linux/slab.h>
806 void *a = kmalloc_node(1, GFP_KERNEL, 0);
809 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
816 dnl # 2.6.9 API change,
817 dnl # check whether 'monotonic_clock()' is available it may
818 dnl # be available for some archs but not others.
820 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
821 SPL_CHECK_SYMBOL_EXPORT(
824 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
825 [monotonic_clock() is available])],
830 dnl # 2.6.16 API change,
831 dnl # check whether 'struct inode' has i_mutex
833 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
834 AC_MSG_CHECKING([whether struct inode has i_mutex])
835 SPL_LINUX_TRY_COMPILE([
836 #include <linux/fs.h>
837 #include <linux/mutex.h>
840 mutex_init(&i.i_mutex);
843 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
850 dnl # 2.6.29 API change,
851 dnl # Adaptive mutexs introduced.
853 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
854 AC_MSG_CHECKING([whether struct mutex has owner])
855 SPL_LINUX_TRY_COMPILE([
856 #include <linux/mutex.h>
862 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
869 dnl # 2.6.18 API change,
870 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
871 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
872 dnl # if the mutex validator is disabled or otherwise unavailable.
874 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
875 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
876 SPL_LINUX_TRY_COMPILE([
877 #include <linux/mutex.h>
881 mutex_lock_nested(&mutex, 0);
884 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
885 [mutex_lock_nested() is available])
892 dnl # 2.6.22 API change,
893 dnl # First introduced 'div64_64()' in lib/div64.c
895 AC_DEFUN([SPL_AC_DIV64_64], [
896 SPL_CHECK_SYMBOL_EXPORT(
899 [AC_DEFINE(HAVE_DIV64_64, 1,
900 [div64_64() is available])],
905 dnl # 2.6.26 API change,
906 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
908 AC_DEFUN([SPL_AC_DIV64_U64], [
909 SPL_CHECK_SYMBOL_EXPORT(
912 [AC_DEFINE(HAVE_DIV64_U64, 1,
913 [div64_u64() is available])],
918 dnl # 2.6.27 API change,
919 dnl # on_each_cpu() uses 3 args, no 'retry' argument
921 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
922 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
923 SPL_LINUX_TRY_COMPILE([
924 #include <linux/smp.h>
926 on_each_cpu(NULL, NULL, 0);
929 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
930 [on_each_cpu wants 3 args])
937 dnl # 2.6.18 API change,
938 dnl # kallsyms_lookup_name no longer exported
940 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
941 SPL_CHECK_SYMBOL_EXPORT(
942 [kallsyms_lookup_name],
944 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
945 [kallsyms_lookup_name() is available])],
950 dnl # Proposed API change,
951 dnl # This symbol is not available in stock kernels. You may build a
952 dnl # custom kernel with the *-spl-export-symbols.patch which will export
953 dnl # these symbols for use. If your already rolling a custom kernel for
954 dnl # your environment this is recommended.
956 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
957 SPL_CHECK_SYMBOL_EXPORT(
960 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
961 [get_vmalloc_info() is available])],
966 dnl # 2.6.17 API change
967 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
968 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
969 dnl # were exported in 2.6.17 for use by modules which was consistent with
970 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
971 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
972 dnl # were dropped entirely leaving modules no way to directly iterate over
973 dnl # the zone list. Because we need access to the zone helpers we check
974 dnl # if the kernel contains the old or new implementation. Then we check
975 dnl # to see if the symbols we need for each version are available. If they
976 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
978 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
979 AC_MSG_CHECKING([whether symbol *_pgdat exist])
980 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
982 if test $rc -eq 0; then
984 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
991 dnl # Proposed API change,
992 dnl # This symbol is not available in stock kernels. You may build a
993 dnl # custom kernel with the *-spl-export-symbols.patch which will export
994 dnl # these symbols for use. If your already rolling a custom kernel for
995 dnl # your environment this is recommended.
997 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
998 SPL_CHECK_SYMBOL_EXPORT(
999 [first_online_pgdat],
1001 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1002 [first_online_pgdat() is available])],
1007 dnl # Proposed API change,
1008 dnl # This symbol is not available in stock kernels. You may build a
1009 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1010 dnl # these symbols for use. If your already rolling a custom kernel for
1011 dnl # your environment this is recommended.
1013 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1014 SPL_CHECK_SYMBOL_EXPORT(
1015 [next_online_pgdat],
1017 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1018 [next_online_pgdat() is available])],
1023 dnl # Proposed API change,
1024 dnl # This symbol is not available in stock kernels. You may build a
1025 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1026 dnl # these symbols for use. If your already rolling a custom kernel for
1027 dnl # your environment this is recommended.
1029 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1030 SPL_CHECK_SYMBOL_EXPORT(
1033 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1034 [next_zone() is available])],
1039 dnl # 2.6.17 API change,
1040 dnl # See SPL_AC_PGDAT_HELPERS for details.
1042 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1043 SPL_CHECK_SYMBOL_EXPORT(
1046 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1047 [pgdat_list is available])],
1052 dnl # 2.6.18 API change,
1053 dnl # First introduced global_page_state() support as an inline.
1055 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1056 AC_MSG_CHECKING([whether global_page_state() is available])
1057 SPL_LINUX_TRY_COMPILE([
1058 #include <linux/mm.h>
1060 unsigned long state;
1061 state = global_page_state(0);
1064 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1065 [global_page_state() is available])
1072 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1073 dnl # Public global zone stats now include a free page count. However
1074 dnl # the enumerated names of the counters have changed since this API
1075 dnl # was introduced. We need to deduce the corrent name to use. This
1076 dnl # replaces the priviate get_zone_counts() interface.
1078 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1079 dnl # is 2.6.30 as of when this was written.
1081 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1082 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1083 SPL_LINUX_TRY_COMPILE([
1084 #include <linux/mm.h>
1086 enum zone_stat_item zsi;
1087 zsi = NR_FREE_PAGES;
1090 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1091 [Page state NR_FREE_PAGES is available])
1098 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1099 dnl # Public global zone stats now include an inactive page count. However
1100 dnl # the enumerated names of the counters have changed since this API
1101 dnl # was introduced. We need to deduce the corrent name to use. This
1102 dnl # replaces the priviate get_zone_counts() interface.
1104 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1105 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1106 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1108 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1109 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1110 SPL_LINUX_TRY_COMPILE([
1111 #include <linux/mm.h>
1113 enum zone_stat_item zsi;
1117 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1118 [Page state NR_INACTIVE is available])
1123 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1124 SPL_LINUX_TRY_COMPILE([
1125 #include <linux/mm.h>
1127 enum zone_stat_item zsi;
1128 zsi = NR_INACTIVE_ANON;
1131 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1132 [Page state NR_INACTIVE_ANON is available])
1137 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1138 SPL_LINUX_TRY_COMPILE([
1139 #include <linux/mm.h>
1141 enum zone_stat_item zsi;
1142 zsi = NR_INACTIVE_FILE;
1145 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1146 [Page state NR_INACTIVE_FILE is available])
1153 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1154 dnl # Public global zone stats now include an active page count. However
1155 dnl # the enumerated names of the counters have changed since this API
1156 dnl # was introduced. We need to deduce the corrent name to use. This
1157 dnl # replaces the priviate get_zone_counts() interface.
1159 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1160 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1161 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1163 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1164 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1165 SPL_LINUX_TRY_COMPILE([
1166 #include <linux/mm.h>
1168 enum zone_stat_item zsi;
1172 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1173 [Page state NR_ACTIVE is available])
1178 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1179 SPL_LINUX_TRY_COMPILE([
1180 #include <linux/mm.h>
1182 enum zone_stat_item zsi;
1183 zsi = NR_ACTIVE_ANON;
1186 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1187 [Page state NR_ACTIVE_ANON is available])
1192 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1193 SPL_LINUX_TRY_COMPILE([
1194 #include <linux/mm.h>
1196 enum zone_stat_item zsi;
1197 zsi = NR_ACTIVE_FILE;
1200 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1201 [Page state NR_ACTIVE_FILE is available])
1208 dnl # Proposed API change for legacy kernels.
1209 dnl # This symbol is not available in older kernels. For kernels post
1210 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1211 dnl # page state information. This symbol is only used in legacy kernels
1212 dnl # any only as a last resort.
1214 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1215 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1216 SPL_LINUX_TRY_COMPILE([
1218 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1219 #error "global_page_state needs NR_FREE_PAGES"
1222 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1223 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1224 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1225 #error "global_page_state needs NR_ACTIVE*"
1228 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1229 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1230 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1231 #error "global_page_state needs NR_INACTIVE*"
1237 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1238 [get_zone_counts() is needed])
1240 SPL_CHECK_SYMBOL_EXPORT(
1243 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1244 [get_zone_counts() is available])],
1250 dnl # Symbol available in RHEL kernels not in stock kernels.
1252 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1253 SPL_CHECK_SYMBOL_EXPORT(
1256 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1257 [set_fs_pwd() is available])],
1262 dnl # 2.6.25 API change,
1263 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1265 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1266 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1267 SPL_LINUX_TRY_COMPILE([
1268 #include <linux/sched.h>
1270 set_fs_pwd(NULL, NULL);
1273 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1274 [set_fs_pwd() wants 2 args])
1281 dnl # SLES API change, never adopted in mainline,
1282 dnl # Third 'struct vfsmount *' argument removed.
1284 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1285 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1286 SPL_LINUX_TRY_COMPILE([
1287 #include <linux/fs.h>
1289 vfs_unlink(NULL, NULL);
1292 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1293 [vfs_unlink() wants 2 args])
1300 dnl # SLES API change, never adopted in mainline,
1301 dnl # Third and sixth 'struct vfsmount *' argument removed.
1303 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1304 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1305 SPL_LINUX_TRY_COMPILE([
1306 #include <linux/fs.h>
1308 vfs_rename(NULL, NULL, NULL, NULL);
1311 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1312 [vfs_rename() wants 4 args])
1319 dnl # 2.6.29 API change,
1320 dnl # check whether 'struct cred' exists
1322 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1323 AC_MSG_CHECKING([whether struct cred exists])
1324 SPL_LINUX_TRY_COMPILE([
1325 #include <linux/cred.h>
1331 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1338 dnl # Custom SPL patch may export this symbol.
1340 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1341 SPL_CHECK_SYMBOL_EXPORT(
1344 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1345 [groups_search() is available])],
1350 dnl # 2.6.x API change,
1351 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1353 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1354 SPL_CHECK_SYMBOL_EXPORT(
1355 [__put_task_struct],
1357 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1358 [__put_task_struct() is available])],