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
71 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
72 modpost=$LINUX/scripts/Makefile.modpost
73 AC_MSG_CHECKING([kernel file name for module symbols])
74 if test -f "$modpost"; then
75 if grep -q Modules.symvers $modpost; then
76 LINUX_SYMBOLS=Modules.symvers
78 LINUX_SYMBOLS=Module.symvers
83 AC_MSG_RESULT($LINUX_SYMBOLS)
84 AC_SUBST(LINUX_SYMBOLS)
87 AC_DEFUN([SPL_AC_KERNEL], [
89 AS_HELP_STRING([--with-linux=PATH],
90 [Path to kernel source]),
91 [kernelsrc="$withval"])
93 AC_ARG_WITH([linux-obj],
94 AS_HELP_STRING([--with-linux-obj=PATH],
95 [Path to kernel build objects]),
96 [kernelbuild="$withval"])
98 AC_MSG_CHECKING([kernel source directory])
99 if test -z "$kernelsrc"; then
100 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
101 2>/dev/null | grep -v obj | tail -1`
103 if test -e ${sourcelink}; then
104 kernelsrc=`readlink -f ${sourcelink}`
106 AC_MSG_RESULT([Not found])
108 *** Please specify the location of the kernel source
109 *** with the '--with-linux=PATH' option])
112 if test "$kernelsrc" = "NONE"; then
117 AC_MSG_RESULT([$kernelsrc])
118 AC_MSG_CHECKING([kernel build directory])
119 if test -z "$kernelbuild"; then
120 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
121 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
122 elif test -d ${kernelsrc}-obj/`arch`/default; then
123 kernelbuild=${kernelsrc}-obj/`arch`/default
124 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
125 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
127 kernelbuild=${kernelsrc}
130 AC_MSG_RESULT([$kernelbuild])
132 AC_MSG_CHECKING([kernel source version])
133 if test -r $kernelbuild/include/linux/version.h &&
134 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
136 kernsrcver=`(echo "#include <linux/version.h>";
137 echo "kernsrcver=UTS_RELEASE") |
138 cpp -I $kernelbuild/include |
139 grep "^kernsrcver=" | cut -d \" -f 2`
141 elif test -r $kernelbuild/include/linux/utsrelease.h &&
142 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
144 kernsrcver=`(echo "#include <linux/utsrelease.h>";
145 echo "kernsrcver=UTS_RELEASE") |
146 cpp -I $kernelbuild/include |
147 grep "^kernsrcver=" | cut -d \" -f 2`
150 if test -z "$kernsrcver"; then
151 AC_MSG_RESULT([Not found])
153 *** Cannot determine the version of the linux kernel source.
154 *** Please prepare the kernel before running this script])
157 AC_MSG_RESULT([$kernsrcver])
160 LINUX_OBJ=${kernelbuild}
161 LINUX_VERSION=${kernsrcver}
165 AC_SUBST(LINUX_VERSION)
167 SPL_AC_MODULE_SYMVERS
171 dnl # Default SPL user configuration
173 AC_DEFUN([SPL_AC_CONFIG_USER], [])
175 AC_DEFUN([SPL_AC_LICENSE], [
176 AC_MSG_CHECKING([spl license])
178 AC_MSG_RESULT([$LICENSE])
179 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
183 AC_DEFUN([SPL_AC_CONFIG], [
185 AC_ARG_WITH([config],
186 AS_HELP_STRING([--with-config=CONFIG],
187 [Config file 'kernel|user|all']),
188 [SPL_CONFIG="$withval"])
190 AC_MSG_CHECKING([spl config])
191 AC_MSG_RESULT([$SPL_CONFIG]);
194 case "$SPL_CONFIG" in
195 kernel) SPL_AC_CONFIG_KERNEL ;;
196 user) SPL_AC_CONFIG_USER ;;
197 all) SPL_AC_CONFIG_KERNEL
198 SPL_AC_CONFIG_USER ;;
200 AC_MSG_RESULT([Error!])
201 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
202 user kernel|user|all]) ;;
205 AM_CONDITIONAL([CONFIG_USER],
206 [test "$SPL_CONFIG" = user] ||
207 [test "$SPL_CONFIG" = all])
208 AM_CONDITIONAL([CONFIG_KERNEL],
209 [test "$SPL_CONFIG" = kernel] ||
210 [test "$SPL_CONFIG" = all])
213 AC_DEFUN([SPL_AC_DEBUG], [
214 AC_MSG_CHECKING([whether debugging is enabled])
215 AC_ARG_ENABLE( [debug],
216 AS_HELP_STRING([--enable-debug],
217 [Enable generic debug support (default off)]),
218 [ case "$enableval" in
219 yes) spl_ac_debug=yes ;;
220 no) spl_ac_debug=no ;;
221 *) AC_MSG_RESULT([Error!])
222 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
225 if test "$spl_ac_debug" = yes; then
227 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
230 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
234 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
235 AC_MSG_CHECKING([whether kmem debugging is enabled])
236 AC_ARG_ENABLE( [debug-kmem],
237 AS_HELP_STRING([--enable-debug-kmem],
238 [Enable kmem debug support (default off)]),
239 [ case "$enableval" in
240 yes) spl_ac_debug_kmem=yes ;;
241 no) spl_ac_debug_kmem=no ;;
242 *) AC_MSG_RESULT([Error!])
243 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
246 if test "$spl_ac_debug_kmem" = yes; then
248 AC_DEFINE([DEBUG_KMEM], [1],
249 [Define to 1 to enable kmem debugging])
250 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
256 AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
257 AC_MSG_CHECKING([whether mutex debugging is enabled])
258 AC_ARG_ENABLE( [debug-mutex],
259 AS_HELP_STRING([--enable-debug-mutex],
260 [Enable mutex debug support (default off)]),
261 [ case "$enableval" in
262 yes) spl_ac_debug_mutex=yes ;;
263 no) spl_ac_debug_mutex=no ;;
264 *) AC_MSG_RESULT([Error!])
265 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
268 if test "$spl_ac_debug_mutex" = yes; then
270 AC_DEFINE([DEBUG_MUTEX], [1],
271 [Define to 1 to enable mutex debugging])
272 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
278 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
279 AC_MSG_CHECKING([whether kstat debugging is enabled])
280 AC_ARG_ENABLE( [debug-kstat],
281 AS_HELP_STRING([--enable-debug-kstat],
282 [Enable kstat debug support (default off)]),
283 [ case "$enableval" in
284 yes) spl_ac_debug_kstat=yes ;;
285 no) spl_ac_debug_kstat=no ;;
286 *) AC_MSG_RESULT([Error!])
287 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
290 if test "$spl_ac_debug_kstat" = yes; then
292 AC_DEFINE([DEBUG_KSTAT], [1],
293 [Define to 1 to enable kstat debugging])
294 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
300 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
301 AC_MSG_CHECKING([whether callb debugging is enabled])
302 AC_ARG_ENABLE( [debug-callb],
303 AS_HELP_STRING([--enable-debug-callb],
304 [Enable callb debug support (default off)]),
305 [ case "$enableval" in
306 yes) spl_ac_debug_callb=yes ;;
307 no) spl_ac_debug_callb=no ;;
308 *) AC_MSG_RESULT([Error!])
309 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
312 if test "$spl_ac_debug_callb" = yes; then
314 AC_DEFINE([DEBUG_CALLB], [1],
315 [Define to 1 to enable callb debugging])
316 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
323 dnl # SPL_LINUX_CONFTEST
325 AC_DEFUN([SPL_LINUX_CONFTEST], [
326 cat >conftest.c <<_ACEOF
332 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
334 m4_define([SPL_LANG_PROGRAM], [
339 dnl Do *not* indent the following line: there may be CPP directives.
340 dnl Don't move the `;' right after for the same reason.
348 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
350 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
351 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
352 rm -Rf build && mkdir -p build
353 echo "obj-m := conftest.o" >build/Makefile
355 [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])],
357 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
363 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
365 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
366 [SPL_LINUX_COMPILE_IFELSE(
367 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
369 [test -s build/conftest.o],
374 dnl # SPL_LINUX_CONFIG
376 AC_DEFUN([SPL_LINUX_CONFIG],
377 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
378 SPL_LINUX_TRY_COMPILE([
379 #ifndef AUTOCONF_INCLUDED
380 #include <linux/config.h>
384 #error CONFIG_$1 not #defined
396 dnl # SPL_CHECK_SYMBOL_EXPORT
397 dnl # check symbol exported or not
399 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
400 [AC_MSG_CHECKING([whether symbol $1 is exported])
401 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
402 $LINUX_OBJ/Module*.symvers 2>/dev/null
404 if test $rc -ne 0; then
407 grep -q -E "EXPORT_SYMBOL.*($1)" \
408 "$LINUX_OBJ/$file" 2>/dev/null
410 if test $rc -eq 0; then
415 if test $export -eq 0; then
429 dnl # SPL_CHECK_HEADER
430 dnl # check whether header exists and define HAVE_$2_HEADER
432 AC_DEFUN([SPL_CHECK_HEADER],
433 [AC_MSG_CHECKING([whether header $1 exists])
434 SPL_LINUX_TRY_COMPILE([
439 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
449 dnl # 2.6.24 API change,
450 dnl # check if uintptr_t typedef is defined
452 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
453 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
454 SPL_LINUX_TRY_COMPILE([
455 #include <linux/types.h>
460 AC_DEFINE(HAVE_UINTPTR_T, 1,
461 [kernel defines uintptr_t])
468 dnl # 2.6.x API change,
469 dnl # check if atomic64_t typedef is defined
471 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
472 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
473 SPL_LINUX_TRY_COMPILE([
474 #include <asm/atomic.h>
479 AC_DEFINE(HAVE_ATOMIC64_T, 1,
480 [kernel defines atomic64_t])
487 dnl # 2.6.20 API change,
488 dnl # INIT_WORK use 2 args and not store data inside
490 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
491 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
492 SPL_LINUX_TRY_COMPILE([
493 #include <linux/workqueue.h>
495 struct work_struct work;
496 INIT_WORK(&work, NULL, NULL);
499 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
500 [INIT_WORK wants 3 args])
507 dnl # 2.6.21 API change,
508 dnl # 'register_sysctl_table' use only one argument instead of two
510 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
511 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
512 SPL_LINUX_TRY_COMPILE([
513 #include <linux/sysctl.h>
515 return register_sysctl_table(NULL,0);
518 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
519 [register_sysctl_table() wants 2 args])
526 dnl # 2.6.23 API change
527 dnl # Old set_shrinker API replaced with register_shrinker
529 AC_DEFUN([SPL_AC_SET_SHRINKER], [
530 AC_MSG_CHECKING([whether set_shrinker() available])
531 SPL_LINUX_TRY_COMPILE([
532 #include <linux/mm.h>
534 return set_shrinker(DEFAULT_SEEKS, NULL);
537 AC_DEFINE(HAVE_SET_SHRINKER, 1,
538 [set_shrinker() available])
545 dnl # 2.6.25 API change,
546 dnl # struct path entry added to struct nameidata
548 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
549 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
550 SPL_LINUX_TRY_COMPILE([
551 #include <linux/namei.h>
556 nd.path.dentry = NULL;
559 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
560 [struct path used in struct nameidata])
567 dnl # Custom SPL patch may export this system it is not required
569 AC_DEFUN([SPL_AC_TASK_CURR], [
570 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
571 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
576 dnl # 2.6.19 API change,
577 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
579 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
580 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
581 SPL_LINUX_TRY_COMPILE([
582 #include <linux/sysctl.h>
584 #ifndef CTL_UNNUMBERED
585 #error CTL_UNNUMBERED undefined
589 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
590 [unnumbered sysctl support exists])
597 dnl # 2.6.16 API change.
598 dnl # Check if 'fls64()' is available
600 AC_DEFUN([SPL_AC_FLS64],
601 [AC_MSG_CHECKING([whether fls64() is available])
602 SPL_LINUX_TRY_COMPILE([
603 #include <linux/bitops.h>
608 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
615 dnl # 2.6.18 API change, check whether device_create() is available.
616 dnl # Device_create() was introduced in 2.6.18 and depricated
617 dnl # class_device_create() which was fully removed in 2.6.26.
619 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
620 SPL_CHECK_SYMBOL_EXPORT(
622 [drivers/base/core.c],
623 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
624 [device_create() is available])],
629 dnl # 2.6.27 API change,
630 dnl # device_create() uses 5 args, new 'drvdata' argument.
632 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
633 AC_MSG_CHECKING([whether device_create() wants 5 args])
634 tmp_flags="$EXTRA_KCFLAGS"
635 EXTRA_KCFLAGS="-Werror"
636 SPL_LINUX_TRY_COMPILE([
637 #include <linux/device.h>
639 device_create(NULL, NULL, 0, NULL, "%d", 1);
642 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
643 [device_create wants 5 args])
647 EXTRA_KCFLAGS="$tmp_flags"
651 dnl # 2.6.13 API change, check whether class_device_create() is available.
652 dnl # Class_device_create() was introduced in 2.6.13 and depricated
653 dnl # class_simple_device_add() which was fully removed in 2.6.13.
655 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
656 SPL_CHECK_SYMBOL_EXPORT(
657 [class_device_create],
658 [drivers/base/class.c],
659 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
660 [class_device_create() is available])],
665 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
667 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
668 SPL_CHECK_SYMBOL_EXPORT(
669 [set_normalized_timespec],
671 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
672 [set_normalized_timespec() is available as export])],
677 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
678 dnl # previously it was available in time.h as an inline.
680 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
681 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
682 SPL_LINUX_TRY_COMPILE([
683 #include <linux/time.h>
684 void set_normalized_timespec(struct timespec *ts,
685 time_t sec, long nsec) { }
692 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
693 [set_normalized_timespec() is available as inline])
698 dnl # 2.6.18 API change,
699 dnl # timespec_sub() inline function available in linux/time.h
701 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
702 AC_MSG_CHECKING([whether timespec_sub() is available])
703 SPL_LINUX_TRY_COMPILE([
704 #include <linux/time.h>
706 struct timespec a, b, c = { 0 };
707 c = timespec_sub(a, b);
710 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
717 dnl # 2.6.19 API change,
718 dnl # check if init_utsname() is available in linux/utsname.h
720 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
721 AC_MSG_CHECKING([whether init_utsname() is available])
722 SPL_LINUX_TRY_COMPILE([
723 #include <linux/utsname.h>
725 struct new_utsname *a = init_utsname();
728 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
735 dnl # 2.6.26 API change,
736 dnl # definition of struct fdtable relocated to linux/fdtable.h
738 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
739 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
743 dnl # 2.6.14 API change,
744 dnl # check whether 'files_fdtable()' exists
746 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
747 AC_MSG_CHECKING([whether files_fdtable() is available])
748 SPL_LINUX_TRY_COMPILE([
749 #include <linux/sched.h>
750 #include <linux/file.h>
751 #ifdef HAVE_FDTABLE_HEADER
752 #include <linux/fdtable.h>
755 struct files_struct *files = current->files;
756 struct fdtable *fdt = files_fdtable(files);
759 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
766 dnl # 2.6.18 API change,
767 dnl # added linux/uaccess.h
769 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
770 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
774 dnl # 2.6.12 API change,
775 dnl # check whether 'kmalloc_node()' is available.
777 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
778 AC_MSG_CHECKING([whether kmalloc_node() is available])
779 SPL_LINUX_TRY_COMPILE([
780 #include <linux/slab.h>
782 void *a = kmalloc_node(1, GFP_KERNEL, 0);
785 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
792 dnl # 2.6.9 API change,
793 dnl # check whether 'monotonic_clock()' is available it may
794 dnl # be available for some archs but not others.
796 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
797 SPL_CHECK_SYMBOL_EXPORT(
800 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
801 [monotonic_clock() is available])],
806 dnl # 2.6.16 API change,
807 dnl # check whether 'struct inode' has i_mutex
809 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
810 AC_MSG_CHECKING([whether struct inode has i_mutex])
811 SPL_LINUX_TRY_COMPILE([
812 #include <linux/fs.h>
813 #include <linux/mutex.h>
816 mutex_init(&i.i_mutex);
819 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
826 dnl # 2.6.18 API change,
827 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
828 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
829 dnl # if the mutex validator is disabled or otherwise unavailable.
831 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
832 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
833 SPL_LINUX_TRY_COMPILE([
834 #include <linux/mutex.h>
838 mutex_lock_nested(&mutex, 0);
841 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
842 [mutex_lock_nested() is available])
849 dnl # 2.6.22 API change,
850 dnl # First introduced 'div64_64()' in lib/div64.c
852 AC_DEFUN([SPL_AC_DIV64_64], [
853 SPL_CHECK_SYMBOL_EXPORT(
856 [AC_DEFINE(HAVE_DIV64_64, 1,
857 [div64_64() is available])],
862 dnl # 2.6.26 API change,
863 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
865 AC_DEFUN([SPL_AC_DIV64_U64], [
866 SPL_CHECK_SYMBOL_EXPORT(
869 [AC_DEFINE(HAVE_DIV64_U64, 1,
870 [div64_u64() is available])],
875 dnl # 2.6.27 API change,
876 dnl # on_each_cpu() uses 3 args, no 'retry' argument
878 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
879 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
880 SPL_LINUX_TRY_COMPILE([
881 #include <linux/smp.h>
883 on_each_cpu(NULL, NULL, 0);
886 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
887 [on_each_cpu wants 3 args])
894 dnl # 2.6.18 API change,
895 dnl # kallsyms_lookup_name no longer exported
897 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
898 SPL_CHECK_SYMBOL_EXPORT(
899 [kallsyms_lookup_name],
901 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
902 [kallsyms_lookup_name() is available])],
907 dnl # Proposed API change,
908 dnl # This symbol is not available in stock kernels. You may build a
909 dnl # custom kernel with the *-spl-export-symbols.patch which will export
910 dnl # these symbols for use. If your already rolling a custom kernel for
911 dnl # your environment this is recommended.
913 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
914 SPL_CHECK_SYMBOL_EXPORT(
917 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
918 [get_vmalloc_info() is available])],
923 dnl # 2.6.17 API change
924 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
925 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
926 dnl # were exported in 2.6.17 for use by modules which was consistent with
927 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
928 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
929 dnl # were dropped entirely leaving modules no way to directly iterate over
930 dnl # the zone list. Because we need access to the zone helpers we check
931 dnl # if the kernel contains the old or new implementation. Then we check
932 dnl # to see if the symbols we need for each version are available. If they
933 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
935 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
936 AC_MSG_CHECKING([whether symbol *_pgdat exist])
937 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
939 if test $rc -eq 0; then
941 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
948 dnl # Proposed API change,
949 dnl # This symbol is not available in stock kernels. You may build a
950 dnl # custom kernel with the *-spl-export-symbols.patch which will export
951 dnl # these symbols for use. If your already rolling a custom kernel for
952 dnl # your environment this is recommended.
954 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
955 SPL_CHECK_SYMBOL_EXPORT(
956 [first_online_pgdat],
958 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
959 [first_online_pgdat() is available])],
964 dnl # Proposed API change,
965 dnl # This symbol is not available in stock kernels. You may build a
966 dnl # custom kernel with the *-spl-export-symbols.patch which will export
967 dnl # these symbols for use. If your already rolling a custom kernel for
968 dnl # your environment this is recommended.
970 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
971 SPL_CHECK_SYMBOL_EXPORT(
974 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
975 [next_online_pgdat() is available])],
980 dnl # Proposed API change,
981 dnl # This symbol is not available in stock kernels. You may build a
982 dnl # custom kernel with the *-spl-export-symbols.patch which will export
983 dnl # these symbols for use. If your already rolling a custom kernel for
984 dnl # your environment this is recommended.
986 AC_DEFUN([SPL_AC_NEXT_ZONE], [
987 SPL_CHECK_SYMBOL_EXPORT(
990 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
991 [next_zone() is available])],
996 dnl # 2.6.17 API change,
997 dnl # See SPL_AC_PGDAT_HELPERS for details.
999 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1000 SPL_CHECK_SYMBOL_EXPORT(
1003 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1004 [pgdat_list is available])],
1009 dnl # Proposed API change,
1010 dnl # This symbol is not available in stock kernels. You may build a
1011 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1012 dnl # these symbols for use. If your already rolling a custom kernel for
1013 dnl # your environment this is recommended.
1015 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1016 SPL_CHECK_SYMBOL_EXPORT(
1019 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1020 [get_zone_counts() is available])],
1025 dnl # 2.6.18 API change,
1026 dnl # First introduced global_page_state() support as an inline.
1028 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1029 AC_MSG_CHECKING([whether global_page_state() is available])
1030 SPL_LINUX_TRY_COMPILE([
1031 #include <linux/vmstat.h>
1033 unsigned long state;
1034 state = global_page_state(NR_FREE_PAGES);
1037 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1038 [global_page_state() is available])
1045 dnl # 2.6.21 API change,
1046 dnl # Public global zone stats now include free/inactive/active page
1047 dnl # counts. This replaced the priviate get_zone_counts() interface.
1049 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FIA], [
1050 AC_MSG_CHECKING([whether free/inactive/active page state is available])
1051 SPL_LINUX_TRY_COMPILE([
1052 #include <linux/mmzone.h>
1054 enum zone_stat_item i1, i2, i3;
1060 AC_DEFINE(HAVE_ZONE_STAT_ITEM_FIA, 1,
1061 [free/inactive/active page state is available])
1068 dnl # SLES API change, never adopted in mainline,
1069 dnl # Third 'struct vfsmount *' argument removed.
1071 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1072 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1073 SPL_LINUX_TRY_COMPILE([
1074 #include <linux/fs.h>
1076 vfs_unlink(NULL, NULL);
1079 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1080 [vfs_unlink() wants 2 args])
1087 dnl # SLES API change, never adopted in mainline,
1088 dnl # Third and sixth 'struct vfsmount *' argument removed.
1090 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1091 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1092 SPL_LINUX_TRY_COMPILE([
1093 #include <linux/fs.h>
1095 vfs_rename(NULL, NULL, NULL, NULL);
1098 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1099 [vfs_rename() wants 4 args])
1106 dnl # 2.6.29 API change,
1107 dnl # check whether 'struct cred' exists
1109 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1110 AC_MSG_CHECKING([whether struct cred exists])
1111 SPL_LINUX_TRY_COMPILE([
1112 #include <linux/cred.h>
1118 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1125 dnl # Custom SPL patch may export this symbol
1127 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1128 SPL_CHECK_SYMBOL_EXPORT(
1131 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1132 [groups_search() is available])],