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 AC_MSG_CHECKING([kernel file name for module symbols])
71 if grep -q Modules.symvers $LINUX/scripts/Makefile.modpost; then
72 LINUX_SYMBOLS=Modules.symvers
74 LINUX_SYMBOLS=Module.symvers
76 AC_MSG_RESULT($LINUX_SYMBOLS)
77 AC_SUBST(LINUX_SYMBOLS)
80 AC_DEFUN([SPL_AC_KERNEL], [
82 AS_HELP_STRING([--with-linux=PATH],
83 [Path to kernel source]),
84 [kernelsrc="$withval"])
86 AC_ARG_WITH([linux-obj],
87 AS_HELP_STRING([--with-linux-obj=PATH],
88 [Path to kernel build objects]),
89 [kernelbuild="$withval"])
91 AC_MSG_CHECKING([kernel source directory])
92 if test -z "$kernelsrc"; then
93 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
94 2>/dev/null | grep -v obj | tail -1`
96 if test -e ${sourcelink}; then
97 kernelsrc=`readlink -f ${sourcelink}`
99 AC_MSG_RESULT([Not found])
101 *** Please specify the location of the kernel source
102 *** with the '--with-linux=PATH' option])
105 if test "$kernelsrc" = "NONE"; then
110 AC_MSG_RESULT([$kernelsrc])
111 AC_MSG_CHECKING([kernel build directory])
112 if test -z "$kernelbuild"; then
113 if test -d ${kernelsrc}-obj; then
114 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
115 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
116 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
118 kernelbuild=${kernelsrc}
121 AC_MSG_RESULT([$kernelbuild])
123 AC_MSG_CHECKING([kernel source version])
124 if test -r $kernelbuild/include/linux/version.h &&
125 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
127 kernsrcver=`(echo "#include <linux/version.h>";
128 echo "kernsrcver=UTS_RELEASE") |
129 cpp -I $kernelbuild/include |
130 grep "^kernsrcver=" | cut -d \" -f 2`
132 elif test -r $kernelbuild/include/linux/utsrelease.h &&
133 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
135 kernsrcver=`(echo "#include <linux/utsrelease.h>";
136 echo "kernsrcver=UTS_RELEASE") |
137 cpp -I $kernelbuild/include |
138 grep "^kernsrcver=" | cut -d \" -f 2`
141 if test -z "$kernsrcver"; then
142 AC_MSG_RESULT([Not found])
144 *** Cannot determine the version of the linux kernel source.
145 *** Please prepare the kernel before running this script])
148 AC_MSG_RESULT([$kernsrcver])
151 LINUX_OBJ=${kernelbuild}
152 LINUX_VERSION=${kernsrcver}
156 AC_SUBST(LINUX_VERSION)
158 SPL_AC_MODULE_SYMVERS
162 dnl # Default SPL user configuration
164 AC_DEFUN([SPL_AC_CONFIG_USER], [])
166 AC_DEFUN([SPL_AC_LICENSE], [
167 AC_MSG_CHECKING([spl license])
169 AC_MSG_RESULT([$LICENSE])
170 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
174 AC_DEFUN([SPL_AC_CONFIG], [
176 AC_ARG_WITH([config],
177 AS_HELP_STRING([--with-config=CONFIG],
178 [Config file 'kernel|user|all']),
179 [SPL_CONFIG="$withval"])
181 AC_MSG_CHECKING([spl config])
182 AC_MSG_RESULT([$SPL_CONFIG]);
185 case "$SPL_CONFIG" in
186 kernel) SPL_AC_CONFIG_KERNEL ;;
187 user) SPL_AC_CONFIG_USER ;;
188 all) SPL_AC_CONFIG_KERNEL
189 SPL_AC_CONFIG_USER ;;
191 AC_MSG_RESULT([Error!])
192 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
193 user kernel|user|all]) ;;
196 AM_CONDITIONAL([CONFIG_USER],
197 [test "$SPL_CONFIG" = user] ||
198 [test "$SPL_CONFIG" = all])
199 AM_CONDITIONAL([CONFIG_KERNEL],
200 [test "$SPL_CONFIG" = kernel] ||
201 [test "$SPL_CONFIG" = all])
204 AC_DEFUN([SPL_AC_DEBUG], [
205 AC_MSG_CHECKING([whether debugging is enabled])
206 AC_ARG_ENABLE( [debug],
207 AS_HELP_STRING([--enable-debug],
208 [Enable generic debug support (default off)]),
209 [ case "$enableval" in
210 yes) spl_ac_debug=yes ;;
211 no) spl_ac_debug=no ;;
212 *) AC_MSG_RESULT([Error!])
213 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
216 if test "$spl_ac_debug" = yes; then
218 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
221 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
225 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
226 AC_MSG_CHECKING([whether kmem debugging is enabled])
227 AC_ARG_ENABLE( [debug-kmem],
228 AS_HELP_STRING([--enable-debug-kmem],
229 [Enable kmem debug support (default off)]),
230 [ case "$enableval" in
231 yes) spl_ac_debug_kmem=yes ;;
232 no) spl_ac_debug_kmem=no ;;
233 *) AC_MSG_RESULT([Error!])
234 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
237 if test "$spl_ac_debug_kmem" = yes; then
239 AC_DEFINE([DEBUG_KMEM], [1],
240 [Define to 1 to enable kmem debugging])
241 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
247 AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
248 AC_MSG_CHECKING([whether mutex debugging is enabled])
249 AC_ARG_ENABLE( [debug-mutex],
250 AS_HELP_STRING([--enable-debug-mutex],
251 [Enable mutex debug support (default off)]),
252 [ case "$enableval" in
253 yes) spl_ac_debug_mutex=yes ;;
254 no) spl_ac_debug_mutex=no ;;
255 *) AC_MSG_RESULT([Error!])
256 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
259 if test "$spl_ac_debug_mutex" = yes; then
261 AC_DEFINE([DEBUG_MUTEX], [1],
262 [Define to 1 to enable mutex debugging])
263 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
269 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
270 AC_MSG_CHECKING([whether kstat debugging is enabled])
271 AC_ARG_ENABLE( [debug-kstat],
272 AS_HELP_STRING([--enable-debug-kstat],
273 [Enable kstat debug support (default off)]),
274 [ case "$enableval" in
275 yes) spl_ac_debug_kstat=yes ;;
276 no) spl_ac_debug_kstat=no ;;
277 *) AC_MSG_RESULT([Error!])
278 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
281 if test "$spl_ac_debug_kstat" = yes; then
283 AC_DEFINE([DEBUG_KSTAT], [1],
284 [Define to 1 to enable kstat debugging])
285 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
291 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
292 AC_MSG_CHECKING([whether callb debugging is enabled])
293 AC_ARG_ENABLE( [debug-callb],
294 AS_HELP_STRING([--enable-debug-callb],
295 [Enable callb debug support (default off)]),
296 [ case "$enableval" in
297 yes) spl_ac_debug_callb=yes ;;
298 no) spl_ac_debug_callb=no ;;
299 *) AC_MSG_RESULT([Error!])
300 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
303 if test "$spl_ac_debug_callb" = yes; then
305 AC_DEFINE([DEBUG_CALLB], [1],
306 [Define to 1 to enable callb debugging])
307 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
314 dnl # SPL_LINUX_CONFTEST
316 AC_DEFUN([SPL_LINUX_CONFTEST], [
317 cat >conftest.c <<_ACEOF
323 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
325 m4_define([SPL_LANG_PROGRAM], [
330 dnl Do *not* indent the following line: there may be CPP directives.
331 dnl Don't move the `;' right after for the same reason.
339 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
341 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
342 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
343 rm -Rf build && mkdir -p build
344 echo "obj-m := conftest.o" >build/Makefile
346 [AC_TRY_COMMAND(cp conftest.c build && make [$2] LINUXINCLUDE="-Iinclude -Iinclude2 -I$LINUX/include -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
348 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
354 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
356 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
357 [SPL_LINUX_COMPILE_IFELSE(
358 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
360 [test -s build/conftest.o],
365 dnl # SPL_LINUX_CONFIG
367 AC_DEFUN([SPL_LINUX_CONFIG],
368 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
369 SPL_LINUX_TRY_COMPILE([
370 #ifndef AUTOCONF_INCLUDED
371 #include <linux/config.h>
375 #error CONFIG_$1 not #defined
387 dnl # SPL_CHECK_SYMBOL_EXPORT
388 dnl # check symbol exported or not
390 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
391 [AC_MSG_CHECKING([whether symbol $1 is exported])
392 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
393 $LINUX_OBJ/Module*.symvers 2>/dev/null
395 if test $rc -ne 0; then
398 grep -q -E "EXPORT_SYMBOL.*($1)" \
399 "$LINUX_OBJ/$file" 2>/dev/null
401 if test $rc -eq 0; then
406 if test $export -eq 0; then
420 dnl # SPL_CHECK_HEADER
421 dnl # check whether header exists and define HAVE_$2_HEADER
423 AC_DEFUN([SPL_CHECK_HEADER],
424 [AC_MSG_CHECKING([whether header $1 exists])
425 SPL_LINUX_TRY_COMPILE([
430 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
440 dnl # 2.6.24 API change,
441 dnl # check if uintptr_t typedef is defined
443 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
444 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
445 SPL_LINUX_TRY_COMPILE([
446 #include <linux/types.h>
451 AC_DEFINE(HAVE_UINTPTR_T, 1,
452 [kernel defines uintptr_t])
459 dnl # 2.6.x API change,
460 dnl # check if atomic64_t typedef is defined
462 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
463 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
464 SPL_LINUX_TRY_COMPILE([
465 #include <asm/atomic.h>
470 AC_DEFINE(HAVE_ATOMIC64_T, 1,
471 [kernel defines atomic64_t])
478 dnl # 2.6.20 API change,
479 dnl # INIT_WORK use 2 args and not store data inside
481 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
482 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
483 SPL_LINUX_TRY_COMPILE([
484 #include <linux/workqueue.h>
486 struct work_struct work;
487 INIT_WORK(&work, NULL, NULL);
490 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
491 [INIT_WORK wants 3 args])
498 dnl # 2.6.21 API change,
499 dnl # 'register_sysctl_table' use only one argument instead of two
501 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
502 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
503 SPL_LINUX_TRY_COMPILE([
504 #include <linux/sysctl.h>
506 return register_sysctl_table(NULL,0);
509 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
510 [register_sysctl_table() wants 2 args])
517 dnl # 2.6.23 API change
518 dnl # Old set_shrinker API replaced with register_shrinker
520 AC_DEFUN([SPL_AC_SET_SHRINKER], [
521 AC_MSG_CHECKING([whether set_shrinker() available])
522 SPL_LINUX_TRY_COMPILE([
523 #include <linux/mm.h>
525 return set_shrinker(DEFAULT_SEEKS, NULL);
528 AC_DEFINE(HAVE_SET_SHRINKER, 1,
529 [set_shrinker() available])
536 dnl # 2.6.25 API change,
537 dnl # struct path entry added to struct nameidata
539 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
540 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
541 SPL_LINUX_TRY_COMPILE([
542 #include <linux/namei.h>
547 nd.path.dentry = NULL;
550 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
551 [struct path used in struct nameidata])
558 dnl # Custom SPL patch may export this system it is not required
560 AC_DEFUN([SPL_AC_TASK_CURR], [
561 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
562 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
567 dnl # 2.6.19 API change,
568 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
570 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
571 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
572 SPL_LINUX_TRY_COMPILE([
573 #include <linux/sysctl.h>
575 #ifndef CTL_UNNUMBERED
576 #error CTL_UNNUMBERED undefined
580 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
581 [unnumbered sysctl support exists])
588 dnl # 2.6.16 API change.
589 dnl # Check if 'fls64()' is available
591 AC_DEFUN([SPL_AC_FLS64],
592 [AC_MSG_CHECKING([whether fls64() is available])
593 SPL_LINUX_TRY_COMPILE([
594 #include <linux/bitops.h>
599 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
606 dnl # 2.6.18 API change, check whether device_create() is available.
607 dnl # Device_create() was introduced in 2.6.18 and depricated
608 dnl # class_device_create() which was fully removed in 2.6.26.
610 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
611 SPL_CHECK_SYMBOL_EXPORT(
613 [drivers/base/core.c],
614 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
615 [device_create() is available])],
620 dnl # 2.6.27 API change,
621 dnl # device_create() uses 5 args, new 'drvdata' argument.
623 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
624 AC_MSG_CHECKING([whether device_create() wants 5 args])
625 tmp_flags="$EXTRA_KCFLAGS"
626 EXTRA_KCFLAGS="-Werror"
627 SPL_LINUX_TRY_COMPILE([
628 #include <linux/device.h>
630 device_create(NULL, NULL, 0, NULL, "%d", 1);
633 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
634 [device_create wants 5 args])
638 EXTRA_KCFLAGS="$tmp_flags"
642 dnl # 2.6.13 API change, check whether class_device_create() is available.
643 dnl # Class_device_create() was introduced in 2.6.13 and depricated
644 dnl # class_simple_device_add() which was fully removed in 2.6.13.
646 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
647 SPL_CHECK_SYMBOL_EXPORT(
648 [class_device_create],
649 [drivers/base/class.c],
650 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
651 [class_device_create() is available])],
656 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
658 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
659 SPL_CHECK_SYMBOL_EXPORT(
660 [set_normalized_timespec],
662 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
663 [set_normalized_timespec() is available as export])],
668 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
669 dnl # previously it was available in time.h as an inline.
671 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
672 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
673 SPL_LINUX_TRY_COMPILE([
674 #include <linux/time.h>
675 void set_normalized_timespec(struct timespec *ts,
676 time_t sec, long nsec) { }
683 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
684 [set_normalized_timespec() is available as inline])
689 dnl # 2.6.18 API change,
690 dnl # timespec_sub() inline function available in linux/time.h
692 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
693 AC_MSG_CHECKING([whether timespec_sub() is available])
694 SPL_LINUX_TRY_COMPILE([
695 #include <linux/time.h>
697 struct timespec a, b, c = { 0 };
698 c = timespec_sub(a, b);
701 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
708 dnl # 2.6.19 API change,
709 dnl # check if init_utsname() is available in linux/utsname.h
711 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
712 AC_MSG_CHECKING([whether init_utsname() is available])
713 SPL_LINUX_TRY_COMPILE([
714 #include <linux/utsname.h>
716 struct new_utsname *a = init_utsname();
719 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
726 dnl # 2.6.26 API change,
727 dnl # definition of struct fdtable relocated to linux/fdtable.h
729 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
730 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
734 dnl # 2.6.14 API change,
735 dnl # check whether 'files_fdtable()' exists
737 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
738 AC_MSG_CHECKING([whether files_fdtable() is available])
739 SPL_LINUX_TRY_COMPILE([
740 #include <linux/sched.h>
741 #include <linux/file.h>
742 #ifdef HAVE_FDTABLE_HEADER
743 #include <linux/fdtable.h>
746 struct files_struct *files = current->files;
747 struct fdtable *fdt = files_fdtable(files);
750 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
757 dnl # 2.6.18 API change,
758 dnl # added linux/uaccess.h
760 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
761 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
765 dnl # 2.6.12 API change,
766 dnl # check whether 'kmalloc_node()' is available.
768 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
769 AC_MSG_CHECKING([whether kmalloc_node() is available])
770 SPL_LINUX_TRY_COMPILE([
771 #include <linux/slab.h>
773 void *a = kmalloc_node(1, GFP_KERNEL, 0);
776 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
783 dnl # 2.6.9 API change,
784 dnl # check whether 'monotonic_clock()' is available it may
785 dnl # be available for some archs but not others.
787 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
788 SPL_CHECK_SYMBOL_EXPORT(
791 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
792 [monotonic_clock() is available])],
797 dnl # 2.6.16 API change,
798 dnl # check whether 'struct inode' has i_mutex
800 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
801 AC_MSG_CHECKING([whether struct inode has i_mutex])
802 SPL_LINUX_TRY_COMPILE([
803 #include <linux/fs.h>
804 #include <linux/mutex.h>
807 mutex_init(&i.i_mutex);
810 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
817 dnl # 2.6.18 API change,
818 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
819 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
820 dnl # if the mutex validator is disabled or otherwise unavailable.
822 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
823 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
824 SPL_LINUX_TRY_COMPILE([
825 #include <linux/mutex.h>
829 mutex_lock_nested(&mutex, 0);
832 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
833 [mutex_lock_nested() is available])
840 dnl # 2.6.22 API change,
841 dnl # First introduced 'div64_64()' in lib/div64.c
843 AC_DEFUN([SPL_AC_DIV64_64], [
844 SPL_CHECK_SYMBOL_EXPORT(
847 [AC_DEFINE(HAVE_DIV64_64, 1,
848 [div64_64() is available])],
853 dnl # 2.6.26 API change,
854 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
856 AC_DEFUN([SPL_AC_DIV64_U64], [
857 SPL_CHECK_SYMBOL_EXPORT(
860 [AC_DEFINE(HAVE_DIV64_U64, 1,
861 [div64_u64() is available])],
866 dnl # 2.6.27 API change,
867 dnl # on_each_cpu() uses 3 args, no 'retry' argument
869 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
870 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
871 SPL_LINUX_TRY_COMPILE([
872 #include <linux/smp.h>
874 on_each_cpu(NULL, NULL, 0);
877 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
878 [on_each_cpu wants 3 args])
885 dnl # 2.6.18 API change,
886 dnl # kallsyms_lookup_name no longer exported
888 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
889 SPL_CHECK_SYMBOL_EXPORT(
890 [kallsyms_lookup_name],
892 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
893 [kallsyms_lookup_name() is available])],
898 dnl # Proposed API change,
899 dnl # This symbol is not available in stock kernels. You may build a
900 dnl # custom kernel with the *-spl-export-symbols.patch which will export
901 dnl # these symbols for use. If your already rolling a custom kernel for
902 dnl # your environment this is recommended.
904 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
905 SPL_CHECK_SYMBOL_EXPORT(
908 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
909 [get_vmalloc_info() is available])],
914 dnl # 2.6.17 API change
915 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
916 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
917 dnl # were exported in 2.6.17 for use by modules which was consistent with
918 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
919 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
920 dnl # were dropped entirely leaving modules no way to directly iterate over
921 dnl # the zone list. Because we need access to the zone helpers we check
922 dnl # if the kernel contains the old or new implementation. Then we check
923 dnl # to see if the symbols we need for each version are available. If they
924 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
926 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
927 AC_MSG_CHECKING([whether symbol *_pgdat exist])
928 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
930 if test $rc -eq 0; then
932 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
939 dnl # Proposed API change,
940 dnl # This symbol is not available in stock kernels. You may build a
941 dnl # custom kernel with the *-spl-export-symbols.patch which will export
942 dnl # these symbols for use. If your already rolling a custom kernel for
943 dnl # your environment this is recommended.
945 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
946 SPL_CHECK_SYMBOL_EXPORT(
947 [first_online_pgdat],
949 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
950 [first_online_pgdat() is available])],
955 dnl # Proposed API change,
956 dnl # This symbol is not available in stock kernels. You may build a
957 dnl # custom kernel with the *-spl-export-symbols.patch which will export
958 dnl # these symbols for use. If your already rolling a custom kernel for
959 dnl # your environment this is recommended.
961 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
962 SPL_CHECK_SYMBOL_EXPORT(
965 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
966 [next_online_pgdat() is available])],
971 dnl # Proposed API change,
972 dnl # This symbol is not available in stock kernels. You may build a
973 dnl # custom kernel with the *-spl-export-symbols.patch which will export
974 dnl # these symbols for use. If your already rolling a custom kernel for
975 dnl # your environment this is recommended.
977 AC_DEFUN([SPL_AC_NEXT_ZONE], [
978 SPL_CHECK_SYMBOL_EXPORT(
981 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
982 [next_zone() is available])],
987 dnl # 2.6.17 API change,
988 dnl # See SPL_AC_PGDAT_HELPERS for details.
990 AC_DEFUN([SPL_AC_PGDAT_LIST], [
991 SPL_CHECK_SYMBOL_EXPORT(
994 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
995 [pgdat_list is available])],
1000 dnl # Proposed API change,
1001 dnl # This symbol is not available in stock kernels. You may build a
1002 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1003 dnl # these symbols for use. If your already rolling a custom kernel for
1004 dnl # your environment this is recommended.
1006 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1007 SPL_CHECK_SYMBOL_EXPORT(
1010 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1011 [get_zone_counts() is available])],
1016 dnl # 2.6.18 API change,
1017 dnl # First introduced global_page_state() support as an inline.
1019 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1020 AC_MSG_CHECKING([whether global_page_state() is available])
1021 SPL_LINUX_TRY_COMPILE([
1022 #include <linux/vmstat.h>
1024 unsigned long state;
1025 state = global_page_state(NR_FREE_PAGES);
1028 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1029 [global_page_state() is available])
1036 dnl # 2.6.21 API change,
1037 dnl # Public global zone stats now include free/inactive/active page
1038 dnl # counts. This replaced the priviate get_zone_counts() interface.
1040 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FIA], [
1041 AC_MSG_CHECKING([whether free/inactive/active page state is available])
1042 SPL_LINUX_TRY_COMPILE([
1043 #include <linux/mmzone.h>
1045 enum zone_stat_item i1, i2, i3;
1051 AC_DEFINE(HAVE_ZONE_STAT_ITEM_FIA, 1,
1052 [free/inactive/active page state is available])
1059 dnl # SLES API change, never adopted in mainline,
1060 dnl # Third 'struct vfsmount *' argument removed.
1062 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1063 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1064 SPL_LINUX_TRY_COMPILE([
1065 #include <linux/fs.h>
1067 vfs_unlink(NULL, NULL);
1070 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1071 [vfs_unlink() wants 2 args])
1078 dnl # SLES API change, never adopted in mainline,
1079 dnl # Third and sixth 'struct vfsmount *' argument removed.
1081 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1082 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1083 SPL_LINUX_TRY_COMPILE([
1084 #include <linux/fs.h>
1086 vfs_rename(NULL, NULL, NULL, NULL);
1089 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1090 [vfs_rename() wants 4 args])