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)
29 SPL_AC_TYPE_ATOMIC64_T
30 SPL_AC_3ARGS_INIT_WORK
31 SPL_AC_2ARGS_REGISTER_SYSCTL
33 SPL_AC_PATH_IN_NAMEIDATA
38 SPL_AC_5ARGS_DEVICE_CREATE
39 SPL_AC_CLASS_DEVICE_CREATE
40 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
41 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
48 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_GLOBAL_PAGE_STATE
63 SPL_AC_ZONE_STAT_ITEM_FREE
64 SPL_AC_ZONE_STAT_ITEM_INACTIVE
65 SPL_AC_ZONE_STAT_ITEM_ACTIVE
66 SPL_AC_GET_ZONE_COUNTS
68 SPL_AC_2ARGS_SET_FS_PWD
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
73 SPL_AC_PUT_TASK_STRUCT
76 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
77 modpost=$LINUX/scripts/Makefile.modpost
78 AC_MSG_CHECKING([kernel file name for module symbols])
79 if test -f "$modpost"; then
80 if grep -q Modules.symvers $modpost; then
81 LINUX_SYMBOLS=Modules.symvers
83 LINUX_SYMBOLS=Module.symvers
88 AC_MSG_RESULT($LINUX_SYMBOLS)
89 AC_SUBST(LINUX_SYMBOLS)
92 AC_DEFUN([SPL_AC_KERNEL], [
94 AS_HELP_STRING([--with-linux=PATH],
95 [Path to kernel source]),
96 [kernelsrc="$withval"])
98 AC_ARG_WITH([linux-obj],
99 AS_HELP_STRING([--with-linux-obj=PATH],
100 [Path to kernel build objects]),
101 [kernelbuild="$withval"])
103 AC_MSG_CHECKING([kernel source directory])
104 if test -z "$kernelsrc"; then
105 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
106 2>/dev/null | grep -v obj | tail -1`
108 if test -e ${sourcelink}; then
109 kernelsrc=`readlink -f ${sourcelink}`
111 AC_MSG_RESULT([Not found])
113 *** Please specify the location of the kernel source
114 *** with the '--with-linux=PATH' option])
117 if test "$kernelsrc" = "NONE"; then
122 AC_MSG_RESULT([$kernelsrc])
123 AC_MSG_CHECKING([kernel build directory])
124 if test -z "$kernelbuild"; then
125 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
126 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
127 elif test -d ${kernelsrc}-obj/`arch`/default; then
128 kernelbuild=${kernelsrc}-obj/`arch`/default
129 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
130 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
132 kernelbuild=${kernelsrc}
135 AC_MSG_RESULT([$kernelbuild])
137 AC_MSG_CHECKING([kernel source version])
138 if test -r $kernelbuild/include/linux/version.h &&
139 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
141 kernsrcver=`(echo "#include <linux/version.h>";
142 echo "kernsrcver=UTS_RELEASE") |
143 cpp -I $kernelbuild/include |
144 grep "^kernsrcver=" | cut -d \" -f 2`
146 elif test -r $kernelbuild/include/linux/utsrelease.h &&
147 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
149 kernsrcver=`(echo "#include <linux/utsrelease.h>";
150 echo "kernsrcver=UTS_RELEASE") |
151 cpp -I $kernelbuild/include |
152 grep "^kernsrcver=" | cut -d \" -f 2`
155 if test -z "$kernsrcver"; then
156 AC_MSG_RESULT([Not found])
158 *** Cannot determine the version of the linux kernel source.
159 *** Please prepare the kernel before running this script])
162 AC_MSG_RESULT([$kernsrcver])
165 LINUX_OBJ=${kernelbuild}
166 LINUX_VERSION=${kernsrcver}
170 AC_SUBST(LINUX_VERSION)
172 SPL_AC_MODULE_SYMVERS
176 dnl # Default SPL user configuration
178 AC_DEFUN([SPL_AC_CONFIG_USER], [])
180 AC_DEFUN([SPL_AC_LICENSE], [
181 AC_MSG_CHECKING([spl license])
183 AC_MSG_RESULT([$LICENSE])
184 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
188 AC_DEFUN([SPL_AC_CONFIG], [
190 AC_ARG_WITH([config],
191 AS_HELP_STRING([--with-config=CONFIG],
192 [Config file 'kernel|user|all']),
193 [SPL_CONFIG="$withval"])
195 AC_MSG_CHECKING([spl config])
196 AC_MSG_RESULT([$SPL_CONFIG]);
199 case "$SPL_CONFIG" in
200 kernel) SPL_AC_CONFIG_KERNEL ;;
201 user) SPL_AC_CONFIG_USER ;;
202 all) SPL_AC_CONFIG_KERNEL
203 SPL_AC_CONFIG_USER ;;
205 AC_MSG_RESULT([Error!])
206 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
207 user kernel|user|all]) ;;
210 AM_CONDITIONAL([CONFIG_USER],
211 [test "$SPL_CONFIG" = user] ||
212 [test "$SPL_CONFIG" = all])
213 AM_CONDITIONAL([CONFIG_KERNEL],
214 [test "$SPL_CONFIG" = kernel] ||
215 [test "$SPL_CONFIG" = all])
218 AC_DEFUN([SPL_AC_DEBUG], [
219 AC_MSG_CHECKING([whether debugging is enabled])
220 AC_ARG_ENABLE( [debug],
221 AS_HELP_STRING([--enable-debug],
222 [Enable generic debug support (default off)]),
223 [ case "$enableval" in
224 yes) spl_ac_debug=yes ;;
225 no) spl_ac_debug=no ;;
226 *) AC_MSG_RESULT([Error!])
227 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
230 if test "$spl_ac_debug" = yes; then
232 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
235 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
239 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
240 AC_MSG_CHECKING([whether kmem debugging is enabled])
241 AC_ARG_ENABLE( [debug-kmem],
242 AS_HELP_STRING([--enable-debug-kmem],
243 [Enable kmem debug support (default off)]),
244 [ case "$enableval" in
245 yes) spl_ac_debug_kmem=yes ;;
246 no) spl_ac_debug_kmem=no ;;
247 *) AC_MSG_RESULT([Error!])
248 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
251 if test "$spl_ac_debug_kmem" = yes; then
253 AC_DEFINE([DEBUG_KMEM], [1],
254 [Define to 1 to enable kmem debugging])
255 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
261 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
262 AC_MSG_CHECKING([whether kstat debugging is enabled])
263 AC_ARG_ENABLE( [debug-kstat],
264 AS_HELP_STRING([--enable-debug-kstat],
265 [Enable kstat debug support (default off)]),
266 [ case "$enableval" in
267 yes) spl_ac_debug_kstat=yes ;;
268 no) spl_ac_debug_kstat=no ;;
269 *) AC_MSG_RESULT([Error!])
270 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
273 if test "$spl_ac_debug_kstat" = yes; then
275 AC_DEFINE([DEBUG_KSTAT], [1],
276 [Define to 1 to enable kstat debugging])
277 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
283 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
284 AC_MSG_CHECKING([whether callb debugging is enabled])
285 AC_ARG_ENABLE( [debug-callb],
286 AS_HELP_STRING([--enable-debug-callb],
287 [Enable callb debug support (default off)]),
288 [ case "$enableval" in
289 yes) spl_ac_debug_callb=yes ;;
290 no) spl_ac_debug_callb=no ;;
291 *) AC_MSG_RESULT([Error!])
292 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
295 if test "$spl_ac_debug_callb" = yes; then
297 AC_DEFINE([DEBUG_CALLB], [1],
298 [Define to 1 to enable callb debugging])
299 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
306 dnl # SPL_LINUX_CONFTEST
308 AC_DEFUN([SPL_LINUX_CONFTEST], [
309 cat >conftest.c <<_ACEOF
315 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
317 m4_define([SPL_LANG_PROGRAM], [
322 dnl Do *not* indent the following line: there may be CPP directives.
323 dnl Don't move the `;' right after for the same reason.
331 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
333 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
334 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
335 rm -Rf build && mkdir -p build
336 echo "obj-m := conftest.o" >build/Makefile
338 [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])],
340 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
346 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
348 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
349 [SPL_LINUX_COMPILE_IFELSE(
350 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
352 [test -s build/conftest.o],
357 dnl # SPL_LINUX_CONFIG
359 AC_DEFUN([SPL_LINUX_CONFIG],
360 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
361 SPL_LINUX_TRY_COMPILE([
362 #ifndef AUTOCONF_INCLUDED
363 #include <linux/config.h>
367 #error CONFIG_$1 not #defined
379 dnl # SPL_CHECK_SYMBOL_EXPORT
380 dnl # check symbol exported or not
382 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
383 [AC_MSG_CHECKING([whether symbol $1 is exported])
384 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
385 $LINUX_OBJ/Module*.symvers 2>/dev/null
387 if test $rc -ne 0; then
390 grep -q -E "EXPORT_SYMBOL.*($1)" \
391 "$LINUX_OBJ/$file" 2>/dev/null
393 if test $rc -eq 0; then
398 if test $export -eq 0; then
412 dnl # SPL_CHECK_HEADER
413 dnl # check whether header exists and define HAVE_$2_HEADER
415 AC_DEFUN([SPL_CHECK_HEADER],
416 [AC_MSG_CHECKING([whether header $1 exists])
417 SPL_LINUX_TRY_COMPILE([
422 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
432 dnl # 2.6.24 API change,
433 dnl # check if uintptr_t typedef is defined
435 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
436 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
437 SPL_LINUX_TRY_COMPILE([
438 #include <linux/types.h>
443 AC_DEFINE(HAVE_UINTPTR_T, 1,
444 [kernel defines uintptr_t])
451 dnl # 2.6.x API change,
452 dnl # check if atomic64_t typedef is defined
454 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
455 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
456 SPL_LINUX_TRY_COMPILE([
457 #include <asm/atomic.h>
462 AC_DEFINE(HAVE_ATOMIC64_T, 1,
463 [kernel defines atomic64_t])
470 dnl # 2.6.20 API change,
471 dnl # INIT_WORK use 2 args and not store data inside
473 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
474 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
475 SPL_LINUX_TRY_COMPILE([
476 #include <linux/workqueue.h>
478 struct work_struct work;
479 INIT_WORK(&work, NULL, NULL);
482 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
483 [INIT_WORK wants 3 args])
490 dnl # 2.6.21 API change,
491 dnl # 'register_sysctl_table' use only one argument instead of two
493 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
494 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
495 SPL_LINUX_TRY_COMPILE([
496 #include <linux/sysctl.h>
498 return register_sysctl_table(NULL,0);
501 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
502 [register_sysctl_table() wants 2 args])
509 dnl # 2.6.23 API change
510 dnl # Old set_shrinker API replaced with register_shrinker
512 AC_DEFUN([SPL_AC_SET_SHRINKER], [
513 AC_MSG_CHECKING([whether set_shrinker() available])
514 SPL_LINUX_TRY_COMPILE([
515 #include <linux/mm.h>
517 return set_shrinker(DEFAULT_SEEKS, NULL);
520 AC_DEFINE(HAVE_SET_SHRINKER, 1,
521 [set_shrinker() available])
528 dnl # 2.6.25 API change,
529 dnl # struct path entry added to struct nameidata
531 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
532 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
533 SPL_LINUX_TRY_COMPILE([
534 #include <linux/namei.h>
539 nd.path.dentry = NULL;
542 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
543 [struct path used in struct nameidata])
550 dnl # Custom SPL patch may export this system it is not required
552 AC_DEFUN([SPL_AC_TASK_CURR], [
553 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
554 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
559 dnl # 2.6.19 API change,
560 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
562 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
563 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
564 SPL_LINUX_TRY_COMPILE([
565 #include <linux/sysctl.h>
567 #ifndef CTL_UNNUMBERED
568 #error CTL_UNNUMBERED undefined
572 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
573 [unnumbered sysctl support exists])
580 dnl # 2.6.16 API change.
581 dnl # Check if 'fls64()' is available
583 AC_DEFUN([SPL_AC_FLS64],
584 [AC_MSG_CHECKING([whether fls64() is available])
585 SPL_LINUX_TRY_COMPILE([
586 #include <linux/bitops.h>
591 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
598 dnl # 2.6.18 API change, check whether device_create() is available.
599 dnl # Device_create() was introduced in 2.6.18 and depricated
600 dnl # class_device_create() which was fully removed in 2.6.26.
602 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
603 SPL_CHECK_SYMBOL_EXPORT(
605 [drivers/base/core.c],
606 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
607 [device_create() is available])],
612 dnl # 2.6.27 API change,
613 dnl # device_create() uses 5 args, new 'drvdata' argument.
615 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
616 AC_MSG_CHECKING([whether device_create() wants 5 args])
617 tmp_flags="$EXTRA_KCFLAGS"
618 EXTRA_KCFLAGS="-Werror"
619 SPL_LINUX_TRY_COMPILE([
620 #include <linux/device.h>
622 device_create(NULL, NULL, 0, NULL, "%d", 1);
625 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
626 [device_create wants 5 args])
630 EXTRA_KCFLAGS="$tmp_flags"
634 dnl # 2.6.13 API change, check whether class_device_create() is available.
635 dnl # Class_device_create() was introduced in 2.6.13 and depricated
636 dnl # class_simple_device_add() which was fully removed in 2.6.13.
638 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
639 SPL_CHECK_SYMBOL_EXPORT(
640 [class_device_create],
641 [drivers/base/class.c],
642 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
643 [class_device_create() is available])],
648 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
650 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
651 SPL_CHECK_SYMBOL_EXPORT(
652 [set_normalized_timespec],
654 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
655 [set_normalized_timespec() is available as export])],
660 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
661 dnl # previously it was available in time.h as an inline.
663 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
664 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
665 SPL_LINUX_TRY_COMPILE([
666 #include <linux/time.h>
667 void set_normalized_timespec(struct timespec *ts,
668 time_t sec, long nsec) { }
675 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
676 [set_normalized_timespec() is available as inline])
681 dnl # 2.6.18 API change,
682 dnl # timespec_sub() inline function available in linux/time.h
684 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
685 AC_MSG_CHECKING([whether timespec_sub() is available])
686 SPL_LINUX_TRY_COMPILE([
687 #include <linux/time.h>
689 struct timespec a, b, c = { 0 };
690 c = timespec_sub(a, b);
693 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
700 dnl # 2.6.19 API change,
701 dnl # check if init_utsname() is available in linux/utsname.h
703 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
704 AC_MSG_CHECKING([whether init_utsname() is available])
705 SPL_LINUX_TRY_COMPILE([
706 #include <linux/utsname.h>
708 struct new_utsname *a = init_utsname();
711 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
718 dnl # 2.6.26 API change,
719 dnl # definition of struct fdtable relocated to linux/fdtable.h
721 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
722 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
726 dnl # 2.6.14 API change,
727 dnl # check whether 'files_fdtable()' exists
729 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
730 AC_MSG_CHECKING([whether files_fdtable() is available])
731 SPL_LINUX_TRY_COMPILE([
732 #include <linux/sched.h>
733 #include <linux/file.h>
734 #ifdef HAVE_FDTABLE_HEADER
735 #include <linux/fdtable.h>
738 struct files_struct *files = current->files;
739 struct fdtable *fdt = files_fdtable(files);
742 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
749 dnl # 2.6.18 API change,
750 dnl # added linux/uaccess.h
752 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
753 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
757 dnl # 2.6.12 API change,
758 dnl # check whether 'kmalloc_node()' is available.
760 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
761 AC_MSG_CHECKING([whether kmalloc_node() is available])
762 SPL_LINUX_TRY_COMPILE([
763 #include <linux/slab.h>
765 void *a = kmalloc_node(1, GFP_KERNEL, 0);
768 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
775 dnl # 2.6.9 API change,
776 dnl # check whether 'monotonic_clock()' is available it may
777 dnl # be available for some archs but not others.
779 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
780 SPL_CHECK_SYMBOL_EXPORT(
783 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
784 [monotonic_clock() is available])],
789 dnl # 2.6.16 API change,
790 dnl # check whether 'struct inode' has i_mutex
792 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
793 AC_MSG_CHECKING([whether struct inode has i_mutex])
794 SPL_LINUX_TRY_COMPILE([
795 #include <linux/fs.h>
796 #include <linux/mutex.h>
799 mutex_init(&i.i_mutex);
802 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
809 dnl # 2.6.29 API change,
810 dnl # Adaptive mutexs introduced.
812 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
813 AC_MSG_CHECKING([whether struct mutex has owner])
814 SPL_LINUX_TRY_COMPILE([
815 #include <linux/mutex.h>
821 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
828 dnl # 2.6.18 API change,
829 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
830 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
831 dnl # if the mutex validator is disabled or otherwise unavailable.
833 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
834 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
835 SPL_LINUX_TRY_COMPILE([
836 #include <linux/mutex.h>
840 mutex_lock_nested(&mutex, 0);
843 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
844 [mutex_lock_nested() is available])
851 dnl # 2.6.22 API change,
852 dnl # First introduced 'div64_64()' in lib/div64.c
854 AC_DEFUN([SPL_AC_DIV64_64], [
855 SPL_CHECK_SYMBOL_EXPORT(
858 [AC_DEFINE(HAVE_DIV64_64, 1,
859 [div64_64() is available])],
864 dnl # 2.6.26 API change,
865 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
867 AC_DEFUN([SPL_AC_DIV64_U64], [
868 SPL_CHECK_SYMBOL_EXPORT(
871 [AC_DEFINE(HAVE_DIV64_U64, 1,
872 [div64_u64() is available])],
877 dnl # 2.6.27 API change,
878 dnl # on_each_cpu() uses 3 args, no 'retry' argument
880 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
881 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
882 SPL_LINUX_TRY_COMPILE([
883 #include <linux/smp.h>
885 on_each_cpu(NULL, NULL, 0);
888 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
889 [on_each_cpu wants 3 args])
896 dnl # 2.6.18 API change,
897 dnl # kallsyms_lookup_name no longer exported
899 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
900 SPL_CHECK_SYMBOL_EXPORT(
901 [kallsyms_lookup_name],
903 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
904 [kallsyms_lookup_name() is available])],
909 dnl # Proposed API change,
910 dnl # This symbol is not available in stock kernels. You may build a
911 dnl # custom kernel with the *-spl-export-symbols.patch which will export
912 dnl # these symbols for use. If your already rolling a custom kernel for
913 dnl # your environment this is recommended.
915 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
916 SPL_CHECK_SYMBOL_EXPORT(
919 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
920 [get_vmalloc_info() is available])],
925 dnl # 2.6.17 API change
926 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
927 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
928 dnl # were exported in 2.6.17 for use by modules which was consistent with
929 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
930 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
931 dnl # were dropped entirely leaving modules no way to directly iterate over
932 dnl # the zone list. Because we need access to the zone helpers we check
933 dnl # if the kernel contains the old or new implementation. Then we check
934 dnl # to see if the symbols we need for each version are available. If they
935 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
937 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
938 AC_MSG_CHECKING([whether symbol *_pgdat exist])
939 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
941 if test $rc -eq 0; then
943 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are 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_FIRST_ONLINE_PGDAT], [
957 SPL_CHECK_SYMBOL_EXPORT(
958 [first_online_pgdat],
960 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
961 [first_online_pgdat() is available])],
966 dnl # Proposed API change,
967 dnl # This symbol is not available in stock kernels. You may build a
968 dnl # custom kernel with the *-spl-export-symbols.patch which will export
969 dnl # these symbols for use. If your already rolling a custom kernel for
970 dnl # your environment this is recommended.
972 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
973 SPL_CHECK_SYMBOL_EXPORT(
976 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
977 [next_online_pgdat() is available])],
982 dnl # Proposed API change,
983 dnl # This symbol is not available in stock kernels. You may build a
984 dnl # custom kernel with the *-spl-export-symbols.patch which will export
985 dnl # these symbols for use. If your already rolling a custom kernel for
986 dnl # your environment this is recommended.
988 AC_DEFUN([SPL_AC_NEXT_ZONE], [
989 SPL_CHECK_SYMBOL_EXPORT(
992 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
993 [next_zone() is available])],
998 dnl # 2.6.17 API change,
999 dnl # See SPL_AC_PGDAT_HELPERS for details.
1001 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1002 SPL_CHECK_SYMBOL_EXPORT(
1005 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1006 [pgdat_list is available])],
1011 dnl # 2.6.18 API change,
1012 dnl # First introduced global_page_state() support as an inline.
1014 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1015 AC_MSG_CHECKING([whether global_page_state() is available])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/mm.h>
1019 unsigned long state;
1020 state = global_page_state(0);
1023 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1024 [global_page_state() is available])
1031 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1032 dnl # Public global zone stats now include a free page count. However
1033 dnl # the enumerated names of the counters have changed since this API
1034 dnl # was introduced. We need to deduce the corrent name to use. This
1035 dnl # replaces the priviate get_zone_counts() interface.
1037 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1038 dnl # is 2.6.30 as of when this was written.
1040 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1041 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1042 SPL_LINUX_TRY_COMPILE([
1043 #include <linux/mm.h>
1045 enum zone_stat_item zsi;
1046 zsi = NR_FREE_PAGES;
1049 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1050 [Page state NR_FREE_PAGES is available])
1057 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1058 dnl # Public global zone stats now include an inactive page count. However
1059 dnl # the enumerated names of the counters have changed since this API
1060 dnl # was introduced. We need to deduce the corrent name to use. This
1061 dnl # replaces the priviate get_zone_counts() interface.
1063 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1064 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1065 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1067 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1068 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1069 SPL_LINUX_TRY_COMPILE([
1070 #include <linux/mm.h>
1072 enum zone_stat_item zsi;
1076 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1077 [Page state NR_INACTIVE is available])
1082 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1083 SPL_LINUX_TRY_COMPILE([
1084 #include <linux/mm.h>
1086 enum zone_stat_item zsi;
1087 zsi = NR_INACTIVE_ANON;
1090 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1091 [Page state NR_INACTIVE_ANON is available])
1096 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1097 SPL_LINUX_TRY_COMPILE([
1098 #include <linux/mm.h>
1100 enum zone_stat_item zsi;
1101 zsi = NR_INACTIVE_FILE;
1104 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1105 [Page state NR_INACTIVE_FILE is available])
1112 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1113 dnl # Public global zone stats now include an active page count. However
1114 dnl # the enumerated names of the counters have changed since this API
1115 dnl # was introduced. We need to deduce the corrent name to use. This
1116 dnl # replaces the priviate get_zone_counts() interface.
1118 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1119 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1120 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1122 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1123 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1124 SPL_LINUX_TRY_COMPILE([
1125 #include <linux/mm.h>
1127 enum zone_stat_item zsi;
1131 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1132 [Page state NR_ACTIVE is available])
1137 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1138 SPL_LINUX_TRY_COMPILE([
1139 #include <linux/mm.h>
1141 enum zone_stat_item zsi;
1142 zsi = NR_ACTIVE_ANON;
1145 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1146 [Page state NR_ACTIVE_ANON is available])
1151 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1152 SPL_LINUX_TRY_COMPILE([
1153 #include <linux/mm.h>
1155 enum zone_stat_item zsi;
1156 zsi = NR_ACTIVE_FILE;
1159 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1160 [Page state NR_ACTIVE_FILE is available])
1167 dnl # Proposed API change for legacy kernels.
1168 dnl # This symbol is not available in older kernels. For kernels post
1169 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1170 dnl # page state information. This symbol is only used in legacy kernels
1171 dnl # any only as a last resort.
1173 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1174 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1175 SPL_LINUX_TRY_COMPILE([
1177 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1178 #error "global_page_state needs NR_FREE_PAGES"
1181 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1182 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1183 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1184 #error "global_page_state needs NR_ACTIVE*"
1187 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1188 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1189 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1190 #error "global_page_state needs NR_INACTIVE*"
1196 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1197 [get_zone_counts() is needed])
1199 SPL_CHECK_SYMBOL_EXPORT(
1202 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1203 [get_zone_counts() is available])],
1209 dnl # Symbol available in RHEL kernels not in stock kernels.
1211 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1212 SPL_CHECK_SYMBOL_EXPORT(
1215 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1216 [set_fs_pwd() is available])],
1221 dnl # 2.6.25 API change,
1222 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1224 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1225 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1226 SPL_LINUX_TRY_COMPILE([
1227 #include <linux/sched.h>
1229 set_fs_pwd(NULL, NULL);
1232 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1233 [set_fs_pwd() wants 2 args])
1240 dnl # SLES API change, never adopted in mainline,
1241 dnl # Third 'struct vfsmount *' argument removed.
1243 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1244 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1245 SPL_LINUX_TRY_COMPILE([
1246 #include <linux/fs.h>
1248 vfs_unlink(NULL, NULL);
1251 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1252 [vfs_unlink() wants 2 args])
1259 dnl # SLES API change, never adopted in mainline,
1260 dnl # Third and sixth 'struct vfsmount *' argument removed.
1262 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1263 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1264 SPL_LINUX_TRY_COMPILE([
1265 #include <linux/fs.h>
1267 vfs_rename(NULL, NULL, NULL, NULL);
1270 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1271 [vfs_rename() wants 4 args])
1278 dnl # 2.6.29 API change,
1279 dnl # check whether 'struct cred' exists
1281 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1282 AC_MSG_CHECKING([whether struct cred exists])
1283 SPL_LINUX_TRY_COMPILE([
1284 #include <linux/cred.h>
1290 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1297 dnl # Custom SPL patch may export this symbol.
1299 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1300 SPL_CHECK_SYMBOL_EXPORT(
1303 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1304 [groups_search() is available])],
1309 dnl # 2.6.x API change,
1310 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1312 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1313 SPL_CHECK_SYMBOL_EXPORT(
1314 [__put_task_struct],
1316 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1317 [__put_task_struct() is available])],