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)
30 SPL_AC_TYPE_ATOMIC64_T
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
51 SPL_AC_MUTEX_LOCK_NESTED
54 SPL_AC_3ARGS_ON_EACH_CPU
55 SPL_AC_KALLSYMS_LOOKUP_NAME
56 SPL_AC_GET_VMALLOC_INFO
58 SPL_AC_FIRST_ONLINE_PGDAT
59 SPL_AC_NEXT_ONLINE_PGDAT
62 SPL_AC_GET_ZONE_COUNTS
63 SPL_AC_GLOBAL_PAGE_STATE
64 SPL_AC_ZONE_STAT_ITEM_FIA
65 SPL_AC_2ARGS_VFS_UNLINK
66 SPL_AC_4ARGS_VFS_RENAME
69 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
70 modpost=$LINUX/scripts/Makefile.modpost
71 AC_MSG_CHECKING([kernel file name for module symbols])
72 if test -f "$modpost"; then
73 if grep -q Modules.symvers $modpost; then
74 LINUX_SYMBOLS=Modules.symvers
76 LINUX_SYMBOLS=Module.symvers
81 AC_MSG_RESULT($LINUX_SYMBOLS)
82 AC_SUBST(LINUX_SYMBOLS)
85 AC_DEFUN([SPL_AC_KERNEL], [
87 AS_HELP_STRING([--with-linux=PATH],
88 [Path to kernel source]),
89 [kernelsrc="$withval"])
91 AC_ARG_WITH([linux-obj],
92 AS_HELP_STRING([--with-linux-obj=PATH],
93 [Path to kernel build objects]),
94 [kernelbuild="$withval"])
96 AC_MSG_CHECKING([kernel source directory])
97 if test -z "$kernelsrc"; then
98 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
99 2>/dev/null | grep -v obj | tail -1`
101 if test -e ${sourcelink}; then
102 kernelsrc=`readlink -f ${sourcelink}`
104 AC_MSG_RESULT([Not found])
106 *** Please specify the location of the kernel source
107 *** with the '--with-linux=PATH' option])
110 if test "$kernelsrc" = "NONE"; then
115 AC_MSG_RESULT([$kernelsrc])
116 AC_MSG_CHECKING([kernel build directory])
117 if test -z "$kernelbuild"; then
118 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
119 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
120 elif test -d ${kernelsrc}-obj/`arch`/default; then
121 kernelbuild=${kernelsrc}-obj/`arch`/default
122 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
123 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
125 kernelbuild=${kernelsrc}
128 AC_MSG_RESULT([$kernelbuild])
130 AC_MSG_CHECKING([kernel source version])
131 if test -r $kernelbuild/include/linux/version.h &&
132 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
134 kernsrcver=`(echo "#include <linux/version.h>";
135 echo "kernsrcver=UTS_RELEASE") |
136 cpp -I $kernelbuild/include |
137 grep "^kernsrcver=" | cut -d \" -f 2`
139 elif test -r $kernelbuild/include/linux/utsrelease.h &&
140 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
142 kernsrcver=`(echo "#include <linux/utsrelease.h>";
143 echo "kernsrcver=UTS_RELEASE") |
144 cpp -I $kernelbuild/include |
145 grep "^kernsrcver=" | cut -d \" -f 2`
148 if test -z "$kernsrcver"; then
149 AC_MSG_RESULT([Not found])
151 *** Cannot determine the version of the linux kernel source.
152 *** Please prepare the kernel before running this script])
155 AC_MSG_RESULT([$kernsrcver])
158 LINUX_OBJ=${kernelbuild}
159 LINUX_VERSION=${kernsrcver}
163 AC_SUBST(LINUX_VERSION)
165 SPL_AC_MODULE_SYMVERS
169 dnl # Default SPL user configuration
171 AC_DEFUN([SPL_AC_CONFIG_USER], [])
173 AC_DEFUN([SPL_AC_LICENSE], [
174 AC_MSG_CHECKING([spl license])
176 AC_MSG_RESULT([$LICENSE])
177 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
181 AC_DEFUN([SPL_AC_CONFIG], [
183 AC_ARG_WITH([config],
184 AS_HELP_STRING([--with-config=CONFIG],
185 [Config file 'kernel|user|all']),
186 [SPL_CONFIG="$withval"])
188 AC_MSG_CHECKING([spl config])
189 AC_MSG_RESULT([$SPL_CONFIG]);
192 case "$SPL_CONFIG" in
193 kernel) SPL_AC_CONFIG_KERNEL ;;
194 user) SPL_AC_CONFIG_USER ;;
195 all) SPL_AC_CONFIG_KERNEL
196 SPL_AC_CONFIG_USER ;;
198 AC_MSG_RESULT([Error!])
199 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
200 user kernel|user|all]) ;;
203 AM_CONDITIONAL([CONFIG_USER],
204 [test "$SPL_CONFIG" = user] ||
205 [test "$SPL_CONFIG" = all])
206 AM_CONDITIONAL([CONFIG_KERNEL],
207 [test "$SPL_CONFIG" = kernel] ||
208 [test "$SPL_CONFIG" = all])
211 AC_DEFUN([SPL_AC_DEBUG], [
212 AC_MSG_CHECKING([whether debugging is enabled])
213 AC_ARG_ENABLE( [debug],
214 AS_HELP_STRING([--enable-debug],
215 [Enable generic debug support (default off)]),
216 [ case "$enableval" in
217 yes) spl_ac_debug=yes ;;
218 no) spl_ac_debug=no ;;
219 *) AC_MSG_RESULT([Error!])
220 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
223 if test "$spl_ac_debug" = yes; then
225 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
228 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
232 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
233 AC_MSG_CHECKING([whether kmem debugging is enabled])
234 AC_ARG_ENABLE( [debug-kmem],
235 AS_HELP_STRING([--enable-debug-kmem],
236 [Enable kmem debug support (default off)]),
237 [ case "$enableval" in
238 yes) spl_ac_debug_kmem=yes ;;
239 no) spl_ac_debug_kmem=no ;;
240 *) AC_MSG_RESULT([Error!])
241 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
244 if test "$spl_ac_debug_kmem" = yes; then
246 AC_DEFINE([DEBUG_KMEM], [1],
247 [Define to 1 to enable kmem debugging])
248 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
254 AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
255 AC_MSG_CHECKING([whether mutex debugging is enabled])
256 AC_ARG_ENABLE( [debug-mutex],
257 AS_HELP_STRING([--enable-debug-mutex],
258 [Enable mutex debug support (default off)]),
259 [ case "$enableval" in
260 yes) spl_ac_debug_mutex=yes ;;
261 no) spl_ac_debug_mutex=no ;;
262 *) AC_MSG_RESULT([Error!])
263 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
266 if test "$spl_ac_debug_mutex" = yes; then
268 AC_DEFINE([DEBUG_MUTEX], [1],
269 [Define to 1 to enable mutex debugging])
270 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
276 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
277 AC_MSG_CHECKING([whether kstat debugging is enabled])
278 AC_ARG_ENABLE( [debug-kstat],
279 AS_HELP_STRING([--enable-debug-kstat],
280 [Enable kstat debug support (default off)]),
281 [ case "$enableval" in
282 yes) spl_ac_debug_kstat=yes ;;
283 no) spl_ac_debug_kstat=no ;;
284 *) AC_MSG_RESULT([Error!])
285 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
288 if test "$spl_ac_debug_kstat" = yes; then
290 AC_DEFINE([DEBUG_KSTAT], [1],
291 [Define to 1 to enable kstat debugging])
292 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
298 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
299 AC_MSG_CHECKING([whether callb debugging is enabled])
300 AC_ARG_ENABLE( [debug-callb],
301 AS_HELP_STRING([--enable-debug-callb],
302 [Enable callb debug support (default off)]),
303 [ case "$enableval" in
304 yes) spl_ac_debug_callb=yes ;;
305 no) spl_ac_debug_callb=no ;;
306 *) AC_MSG_RESULT([Error!])
307 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
310 if test "$spl_ac_debug_callb" = yes; then
312 AC_DEFINE([DEBUG_CALLB], [1],
313 [Define to 1 to enable callb debugging])
314 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
321 dnl # SPL_LINUX_CONFTEST
323 AC_DEFUN([SPL_LINUX_CONFTEST], [
324 cat >conftest.c <<_ACEOF
330 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
332 m4_define([SPL_LANG_PROGRAM], [
337 dnl Do *not* indent the following line: there may be CPP directives.
338 dnl Don't move the `;' right after for the same reason.
346 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
348 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
349 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
350 rm -Rf build && mkdir -p build
351 echo "obj-m := conftest.o" >build/Makefile
353 [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])],
355 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
361 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
363 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
364 [SPL_LINUX_COMPILE_IFELSE(
365 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
367 [test -s build/conftest.o],
372 dnl # SPL_LINUX_CONFIG
374 AC_DEFUN([SPL_LINUX_CONFIG],
375 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
376 SPL_LINUX_TRY_COMPILE([
377 #ifndef AUTOCONF_INCLUDED
378 #include <linux/config.h>
382 #error CONFIG_$1 not #defined
394 dnl # SPL_CHECK_SYMBOL_EXPORT
395 dnl # check symbol exported or not
397 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
398 [AC_MSG_CHECKING([whether symbol $1 is exported])
399 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
400 $LINUX_OBJ/Module*.symvers 2>/dev/null
402 if test $rc -ne 0; then
405 grep -q -E "EXPORT_SYMBOL.*($1)" \
406 "$LINUX_OBJ/$file" 2>/dev/null
408 if test $rc -eq 0; then
413 if test $export -eq 0; then
427 dnl # SPL_CHECK_HEADER
428 dnl # check whether header exists and define HAVE_$2_HEADER
430 AC_DEFUN([SPL_CHECK_HEADER],
431 [AC_MSG_CHECKING([whether header $1 exists])
432 SPL_LINUX_TRY_COMPILE([
437 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
447 dnl # 2.6.24 API change,
448 dnl # check if uintptr_t typedef is defined
450 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
451 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
452 SPL_LINUX_TRY_COMPILE([
453 #include <linux/types.h>
458 AC_DEFINE(HAVE_UINTPTR_T, 1,
459 [kernel defines uintptr_t])
466 dnl # 2.6.x API change,
467 dnl # check if atomic64_t typedef is defined
469 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
470 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
471 SPL_LINUX_TRY_COMPILE([
472 #include <asm/atomic.h>
477 AC_DEFINE(HAVE_ATOMIC64_T, 1,
478 [kernel defines atomic64_t])
485 dnl # 2.6.20 API change,
486 dnl # INIT_WORK use 2 args and not store data inside
488 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
489 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
490 SPL_LINUX_TRY_COMPILE([
491 #include <linux/workqueue.h>
493 struct work_struct work;
494 INIT_WORK(&work, NULL, NULL);
497 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
498 [INIT_WORK wants 3 args])
505 dnl # 2.6.21 API change,
506 dnl # 'register_sysctl_table' use only one argument instead of two
508 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
509 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
510 SPL_LINUX_TRY_COMPILE([
511 #include <linux/sysctl.h>
513 return register_sysctl_table(NULL,0);
516 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
517 [register_sysctl_table() wants 2 args])
524 dnl # 2.6.23 API change
525 dnl # Old set_shrinker API replaced with register_shrinker
527 AC_DEFUN([SPL_AC_SET_SHRINKER], [
528 AC_MSG_CHECKING([whether set_shrinker() available])
529 SPL_LINUX_TRY_COMPILE([
530 #include <linux/mm.h>
532 return set_shrinker(DEFAULT_SEEKS, NULL);
535 AC_DEFINE(HAVE_SET_SHRINKER, 1,
536 [set_shrinker() available])
543 dnl # 2.6.25 API change,
544 dnl # struct path entry added to struct nameidata
546 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
547 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
548 SPL_LINUX_TRY_COMPILE([
549 #include <linux/namei.h>
554 nd.path.dentry = NULL;
557 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
558 [struct path used in struct nameidata])
565 dnl # Custom SPL patch may export this system it is not required
567 AC_DEFUN([SPL_AC_TASK_CURR], [
568 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
569 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
574 dnl # 2.6.19 API change,
575 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
577 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
578 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
579 SPL_LINUX_TRY_COMPILE([
580 #include <linux/sysctl.h>
582 #ifndef CTL_UNNUMBERED
583 #error CTL_UNNUMBERED undefined
587 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
588 [unnumbered sysctl support exists])
595 dnl # 2.6.16 API change.
596 dnl # Check if 'fls64()' is available
598 AC_DEFUN([SPL_AC_FLS64],
599 [AC_MSG_CHECKING([whether fls64() is available])
600 SPL_LINUX_TRY_COMPILE([
601 #include <linux/bitops.h>
606 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
613 dnl # 2.6.18 API change, check whether device_create() is available.
614 dnl # Device_create() was introduced in 2.6.18 and depricated
615 dnl # class_device_create() which was fully removed in 2.6.26.
617 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
618 SPL_CHECK_SYMBOL_EXPORT(
620 [drivers/base/core.c],
621 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
622 [device_create() is available])],
627 dnl # 2.6.27 API change,
628 dnl # device_create() uses 5 args, new 'drvdata' argument.
630 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
631 AC_MSG_CHECKING([whether device_create() wants 5 args])
632 tmp_flags="$EXTRA_KCFLAGS"
633 EXTRA_KCFLAGS="-Werror"
634 SPL_LINUX_TRY_COMPILE([
635 #include <linux/device.h>
637 device_create(NULL, NULL, 0, NULL, "%d", 1);
640 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
641 [device_create wants 5 args])
645 EXTRA_KCFLAGS="$tmp_flags"
649 dnl # 2.6.13 API change, check whether class_device_create() is available.
650 dnl # Class_device_create() was introduced in 2.6.13 and depricated
651 dnl # class_simple_device_add() which was fully removed in 2.6.13.
653 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
654 SPL_CHECK_SYMBOL_EXPORT(
655 [class_device_create],
656 [drivers/base/class.c],
657 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
658 [class_device_create() is available])],
663 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
665 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
666 SPL_CHECK_SYMBOL_EXPORT(
667 [set_normalized_timespec],
669 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
670 [set_normalized_timespec() is available as export])],
675 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
676 dnl # previously it was available in time.h as an inline.
678 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
679 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
680 SPL_LINUX_TRY_COMPILE([
681 #include <linux/time.h>
682 void set_normalized_timespec(struct timespec *ts,
683 time_t sec, long nsec) { }
690 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
691 [set_normalized_timespec() is available as inline])
696 dnl # 2.6.18 API change,
697 dnl # timespec_sub() inline function available in linux/time.h
699 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
700 AC_MSG_CHECKING([whether timespec_sub() is available])
701 SPL_LINUX_TRY_COMPILE([
702 #include <linux/time.h>
704 struct timespec a, b, c = { 0 };
705 c = timespec_sub(a, b);
708 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
715 dnl # 2.6.19 API change,
716 dnl # check if init_utsname() is available in linux/utsname.h
718 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
719 AC_MSG_CHECKING([whether init_utsname() is available])
720 SPL_LINUX_TRY_COMPILE([
721 #include <linux/utsname.h>
723 struct new_utsname *a = init_utsname();
726 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
733 dnl # 2.6.26 API change,
734 dnl # definition of struct fdtable relocated to linux/fdtable.h
736 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
737 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
741 dnl # 2.6.14 API change,
742 dnl # check whether 'files_fdtable()' exists
744 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
745 AC_MSG_CHECKING([whether files_fdtable() is available])
746 SPL_LINUX_TRY_COMPILE([
747 #include <linux/sched.h>
748 #include <linux/file.h>
749 #ifdef HAVE_FDTABLE_HEADER
750 #include <linux/fdtable.h>
753 struct files_struct *files = current->files;
754 struct fdtable *fdt = files_fdtable(files);
757 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
764 dnl # 2.6.18 API change,
765 dnl # added linux/uaccess.h
767 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
768 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
772 dnl # 2.6.12 API change,
773 dnl # check whether 'kmalloc_node()' is available.
775 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
776 AC_MSG_CHECKING([whether kmalloc_node() is available])
777 SPL_LINUX_TRY_COMPILE([
778 #include <linux/slab.h>
780 void *a = kmalloc_node(1, GFP_KERNEL, 0);
783 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
790 dnl # 2.6.9 API change,
791 dnl # check whether 'monotonic_clock()' is available it may
792 dnl # be available for some archs but not others.
794 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
795 SPL_CHECK_SYMBOL_EXPORT(
798 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
799 [monotonic_clock() is available])],
804 dnl # 2.6.16 API change,
805 dnl # check whether 'struct inode' has i_mutex
807 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
808 AC_MSG_CHECKING([whether struct inode has i_mutex])
809 SPL_LINUX_TRY_COMPILE([
810 #include <linux/fs.h>
811 #include <linux/mutex.h>
814 mutex_init(&i.i_mutex);
817 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
824 dnl # 2.6.18 API change,
825 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
826 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
827 dnl # if the mutex validator is disabled or otherwise unavailable.
829 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
830 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
831 SPL_LINUX_TRY_COMPILE([
832 #include <linux/mutex.h>
836 mutex_lock_nested(&mutex, 0);
839 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
840 [mutex_lock_nested() is available])
847 dnl # 2.6.22 API change,
848 dnl # First introduced 'div64_64()' in lib/div64.c
850 AC_DEFUN([SPL_AC_DIV64_64], [
851 SPL_CHECK_SYMBOL_EXPORT(
854 [AC_DEFINE(HAVE_DIV64_64, 1,
855 [div64_64() is available])],
860 dnl # 2.6.26 API change,
861 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
863 AC_DEFUN([SPL_AC_DIV64_U64], [
864 SPL_CHECK_SYMBOL_EXPORT(
867 [AC_DEFINE(HAVE_DIV64_U64, 1,
868 [div64_u64() is available])],
873 dnl # 2.6.27 API change,
874 dnl # on_each_cpu() uses 3 args, no 'retry' argument
876 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
877 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
878 SPL_LINUX_TRY_COMPILE([
879 #include <linux/smp.h>
881 on_each_cpu(NULL, NULL, 0);
884 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
885 [on_each_cpu wants 3 args])
892 dnl # 2.6.18 API change,
893 dnl # kallsyms_lookup_name no longer exported
895 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
896 SPL_CHECK_SYMBOL_EXPORT(
897 [kallsyms_lookup_name],
899 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
900 [kallsyms_lookup_name() is available])],
905 dnl # Proposed API change,
906 dnl # This symbol is not available in stock kernels. You may build a
907 dnl # custom kernel with the *-spl-export-symbols.patch which will export
908 dnl # these symbols for use. If your already rolling a custom kernel for
909 dnl # your environment this is recommended.
911 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
912 SPL_CHECK_SYMBOL_EXPORT(
915 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
916 [get_vmalloc_info() is available])],
921 dnl # 2.6.17 API change
922 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
923 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
924 dnl # were exported in 2.6.17 for use by modules which was consistent with
925 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
926 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
927 dnl # were dropped entirely leaving modules no way to directly iterate over
928 dnl # the zone list. Because we need access to the zone helpers we check
929 dnl # if the kernel contains the old or new implementation. Then we check
930 dnl # to see if the symbols we need for each version are available. If they
931 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
933 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
934 AC_MSG_CHECKING([whether symbol *_pgdat exist])
935 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
937 if test $rc -eq 0; then
939 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
946 dnl # Proposed API change,
947 dnl # This symbol is not available in stock kernels. You may build a
948 dnl # custom kernel with the *-spl-export-symbols.patch which will export
949 dnl # these symbols for use. If your already rolling a custom kernel for
950 dnl # your environment this is recommended.
952 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
953 SPL_CHECK_SYMBOL_EXPORT(
954 [first_online_pgdat],
956 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
957 [first_online_pgdat() is available])],
962 dnl # Proposed API change,
963 dnl # This symbol is not available in stock kernels. You may build a
964 dnl # custom kernel with the *-spl-export-symbols.patch which will export
965 dnl # these symbols for use. If your already rolling a custom kernel for
966 dnl # your environment this is recommended.
968 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
969 SPL_CHECK_SYMBOL_EXPORT(
972 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
973 [next_online_pgdat() is available])],
978 dnl # Proposed API change,
979 dnl # This symbol is not available in stock kernels. You may build a
980 dnl # custom kernel with the *-spl-export-symbols.patch which will export
981 dnl # these symbols for use. If your already rolling a custom kernel for
982 dnl # your environment this is recommended.
984 AC_DEFUN([SPL_AC_NEXT_ZONE], [
985 SPL_CHECK_SYMBOL_EXPORT(
988 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
989 [next_zone() is available])],
994 dnl # 2.6.17 API change,
995 dnl # See SPL_AC_PGDAT_HELPERS for details.
997 AC_DEFUN([SPL_AC_PGDAT_LIST], [
998 SPL_CHECK_SYMBOL_EXPORT(
1001 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1002 [pgdat_list 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_GET_ZONE_COUNTS], [
1014 SPL_CHECK_SYMBOL_EXPORT(
1017 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1018 [get_zone_counts() is available])],
1023 dnl # 2.6.18 API change,
1024 dnl # First introduced global_page_state() support as an inline.
1026 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1027 AC_MSG_CHECKING([whether global_page_state() is available])
1028 SPL_LINUX_TRY_COMPILE([
1029 #include <linux/vmstat.h>
1031 unsigned long state;
1032 state = global_page_state(NR_FREE_PAGES);
1035 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1036 [global_page_state() is available])
1043 dnl # 2.6.21 API change,
1044 dnl # Public global zone stats now include free/inactive/active page
1045 dnl # counts. This replaced the priviate get_zone_counts() interface.
1047 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FIA], [
1048 AC_MSG_CHECKING([whether free/inactive/active page state is available])
1049 SPL_LINUX_TRY_COMPILE([
1050 #include <linux/mmzone.h>
1052 enum zone_stat_item i1, i2, i3;
1058 AC_DEFINE(HAVE_ZONE_STAT_ITEM_FIA, 1,
1059 [free/inactive/active page state is available])
1066 dnl # SLES API change, never adopted in mainline,
1067 dnl # Third 'struct vfsmount *' argument removed.
1069 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1070 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1071 SPL_LINUX_TRY_COMPILE([
1072 #include <linux/fs.h>
1074 vfs_unlink(NULL, NULL);
1077 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1078 [vfs_unlink() wants 2 args])
1085 dnl # SLES API change, never adopted in mainline,
1086 dnl # Third and sixth 'struct vfsmount *' argument removed.
1088 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1089 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1090 SPL_LINUX_TRY_COMPILE([
1091 #include <linux/fs.h>
1093 vfs_rename(NULL, NULL, NULL, NULL);
1096 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1097 [vfs_rename() wants 4 args])