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_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
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_PUT_TASK_STRUCT
74 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
75 modpost=$LINUX/scripts/Makefile.modpost
76 AC_MSG_CHECKING([kernel file name for module symbols])
77 if test -f "$modpost"; then
78 if grep -q Modules.symvers $modpost; then
79 LINUX_SYMBOLS=Modules.symvers
81 LINUX_SYMBOLS=Module.symvers
86 AC_MSG_RESULT($LINUX_SYMBOLS)
87 AC_SUBST(LINUX_SYMBOLS)
90 AC_DEFUN([SPL_AC_KERNEL], [
92 AS_HELP_STRING([--with-linux=PATH],
93 [Path to kernel source]),
94 [kernelsrc="$withval"])
96 AC_ARG_WITH([linux-obj],
97 AS_HELP_STRING([--with-linux-obj=PATH],
98 [Path to kernel build objects]),
99 [kernelbuild="$withval"])
101 AC_MSG_CHECKING([kernel source directory])
102 if test -z "$kernelsrc"; then
103 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
104 2>/dev/null | grep -v obj | tail -1`
106 if test -e ${sourcelink}; then
107 kernelsrc=`readlink -f ${sourcelink}`
109 AC_MSG_RESULT([Not found])
111 *** Please specify the location of the kernel source
112 *** with the '--with-linux=PATH' option])
115 if test "$kernelsrc" = "NONE"; then
120 AC_MSG_RESULT([$kernelsrc])
121 AC_MSG_CHECKING([kernel build directory])
122 if test -z "$kernelbuild"; then
123 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
124 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
125 elif test -d ${kernelsrc}-obj/`arch`/default; then
126 kernelbuild=${kernelsrc}-obj/`arch`/default
127 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
128 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
130 kernelbuild=${kernelsrc}
133 AC_MSG_RESULT([$kernelbuild])
135 AC_MSG_CHECKING([kernel source version])
136 if test -r $kernelbuild/include/linux/version.h &&
137 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
139 kernsrcver=`(echo "#include <linux/version.h>";
140 echo "kernsrcver=UTS_RELEASE") |
141 cpp -I $kernelbuild/include |
142 grep "^kernsrcver=" | cut -d \" -f 2`
144 elif test -r $kernelbuild/include/linux/utsrelease.h &&
145 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
147 kernsrcver=`(echo "#include <linux/utsrelease.h>";
148 echo "kernsrcver=UTS_RELEASE") |
149 cpp -I $kernelbuild/include |
150 grep "^kernsrcver=" | cut -d \" -f 2`
153 if test -z "$kernsrcver"; then
154 AC_MSG_RESULT([Not found])
156 *** Cannot determine the version of the linux kernel source.
157 *** Please prepare the kernel before running this script])
160 AC_MSG_RESULT([$kernsrcver])
163 LINUX_OBJ=${kernelbuild}
164 LINUX_VERSION=${kernsrcver}
168 AC_SUBST(LINUX_VERSION)
170 SPL_AC_MODULE_SYMVERS
174 dnl # Default SPL user configuration
176 AC_DEFUN([SPL_AC_CONFIG_USER], [])
178 AC_DEFUN([SPL_AC_LICENSE], [
179 AC_MSG_CHECKING([spl license])
181 AC_MSG_RESULT([$LICENSE])
182 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
186 AC_DEFUN([SPL_AC_CONFIG], [
188 AC_ARG_WITH([config],
189 AS_HELP_STRING([--with-config=CONFIG],
190 [Config file 'kernel|user|all']),
191 [SPL_CONFIG="$withval"])
193 AC_MSG_CHECKING([spl config])
194 AC_MSG_RESULT([$SPL_CONFIG]);
197 case "$SPL_CONFIG" in
198 kernel) SPL_AC_CONFIG_KERNEL ;;
199 user) SPL_AC_CONFIG_USER ;;
200 all) SPL_AC_CONFIG_KERNEL
201 SPL_AC_CONFIG_USER ;;
203 AC_MSG_RESULT([Error!])
204 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
205 user kernel|user|all]) ;;
208 AM_CONDITIONAL([CONFIG_USER],
209 [test "$SPL_CONFIG" = user] ||
210 [test "$SPL_CONFIG" = all])
211 AM_CONDITIONAL([CONFIG_KERNEL],
212 [test "$SPL_CONFIG" = kernel] ||
213 [test "$SPL_CONFIG" = all])
216 AC_DEFUN([SPL_AC_DEBUG], [
217 AC_MSG_CHECKING([whether debugging is enabled])
218 AC_ARG_ENABLE( [debug],
219 AS_HELP_STRING([--enable-debug],
220 [Enable generic debug support (default off)]),
221 [ case "$enableval" in
222 yes) spl_ac_debug=yes ;;
223 no) spl_ac_debug=no ;;
224 *) AC_MSG_RESULT([Error!])
225 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
228 if test "$spl_ac_debug" = yes; then
230 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
233 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
237 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
238 AC_MSG_CHECKING([whether kmem debugging is enabled])
239 AC_ARG_ENABLE( [debug-kmem],
240 AS_HELP_STRING([--enable-debug-kmem],
241 [Enable kmem debug support (default off)]),
242 [ case "$enableval" in
243 yes) spl_ac_debug_kmem=yes ;;
244 no) spl_ac_debug_kmem=no ;;
245 *) AC_MSG_RESULT([Error!])
246 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
249 if test "$spl_ac_debug_kmem" = yes; then
251 AC_DEFINE([DEBUG_KMEM], [1],
252 [Define to 1 to enable kmem debugging])
253 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
259 AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
260 AC_MSG_CHECKING([whether mutex debugging is enabled])
261 AC_ARG_ENABLE( [debug-mutex],
262 AS_HELP_STRING([--enable-debug-mutex],
263 [Enable mutex debug support (default off)]),
264 [ case "$enableval" in
265 yes) spl_ac_debug_mutex=yes ;;
266 no) spl_ac_debug_mutex=no ;;
267 *) AC_MSG_RESULT([Error!])
268 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
271 if test "$spl_ac_debug_mutex" = yes; then
273 AC_DEFINE([DEBUG_MUTEX], [1],
274 [Define to 1 to enable mutex debugging])
275 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
281 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
282 AC_MSG_CHECKING([whether kstat debugging is enabled])
283 AC_ARG_ENABLE( [debug-kstat],
284 AS_HELP_STRING([--enable-debug-kstat],
285 [Enable kstat debug support (default off)]),
286 [ case "$enableval" in
287 yes) spl_ac_debug_kstat=yes ;;
288 no) spl_ac_debug_kstat=no ;;
289 *) AC_MSG_RESULT([Error!])
290 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
293 if test "$spl_ac_debug_kstat" = yes; then
295 AC_DEFINE([DEBUG_KSTAT], [1],
296 [Define to 1 to enable kstat debugging])
297 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
303 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
304 AC_MSG_CHECKING([whether callb debugging is enabled])
305 AC_ARG_ENABLE( [debug-callb],
306 AS_HELP_STRING([--enable-debug-callb],
307 [Enable callb debug support (default off)]),
308 [ case "$enableval" in
309 yes) spl_ac_debug_callb=yes ;;
310 no) spl_ac_debug_callb=no ;;
311 *) AC_MSG_RESULT([Error!])
312 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
315 if test "$spl_ac_debug_callb" = yes; then
317 AC_DEFINE([DEBUG_CALLB], [1],
318 [Define to 1 to enable callb debugging])
319 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
326 dnl # SPL_LINUX_CONFTEST
328 AC_DEFUN([SPL_LINUX_CONFTEST], [
329 cat >conftest.c <<_ACEOF
335 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
337 m4_define([SPL_LANG_PROGRAM], [
342 dnl Do *not* indent the following line: there may be CPP directives.
343 dnl Don't move the `;' right after for the same reason.
351 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
353 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
354 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
355 rm -Rf build && mkdir -p build
356 echo "obj-m := conftest.o" >build/Makefile
358 [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])],
360 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
366 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
368 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
369 [SPL_LINUX_COMPILE_IFELSE(
370 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
372 [test -s build/conftest.o],
377 dnl # SPL_LINUX_CONFIG
379 AC_DEFUN([SPL_LINUX_CONFIG],
380 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
381 SPL_LINUX_TRY_COMPILE([
382 #ifndef AUTOCONF_INCLUDED
383 #include <linux/config.h>
387 #error CONFIG_$1 not #defined
399 dnl # SPL_CHECK_SYMBOL_EXPORT
400 dnl # check symbol exported or not
402 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
403 [AC_MSG_CHECKING([whether symbol $1 is exported])
404 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
405 $LINUX_OBJ/Module*.symvers 2>/dev/null
407 if test $rc -ne 0; then
410 grep -q -E "EXPORT_SYMBOL.*($1)" \
411 "$LINUX_OBJ/$file" 2>/dev/null
413 if test $rc -eq 0; then
418 if test $export -eq 0; then
432 dnl # SPL_CHECK_HEADER
433 dnl # check whether header exists and define HAVE_$2_HEADER
435 AC_DEFUN([SPL_CHECK_HEADER],
436 [AC_MSG_CHECKING([whether header $1 exists])
437 SPL_LINUX_TRY_COMPILE([
442 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
452 dnl # 2.6.24 API change,
453 dnl # check if uintptr_t typedef is defined
455 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
456 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
457 SPL_LINUX_TRY_COMPILE([
458 #include <linux/types.h>
463 AC_DEFINE(HAVE_UINTPTR_T, 1,
464 [kernel defines uintptr_t])
471 dnl # 2.6.x API change,
472 dnl # check if atomic64_t typedef is defined
474 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
475 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
476 SPL_LINUX_TRY_COMPILE([
477 #include <asm/atomic.h>
482 AC_DEFINE(HAVE_ATOMIC64_T, 1,
483 [kernel defines atomic64_t])
490 dnl # 2.6.20 API change,
491 dnl # INIT_WORK use 2 args and not store data inside
493 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
494 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
495 SPL_LINUX_TRY_COMPILE([
496 #include <linux/workqueue.h>
498 struct work_struct work;
499 INIT_WORK(&work, NULL, NULL);
502 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
503 [INIT_WORK wants 3 args])
510 dnl # 2.6.21 API change,
511 dnl # 'register_sysctl_table' use only one argument instead of two
513 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
514 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
515 SPL_LINUX_TRY_COMPILE([
516 #include <linux/sysctl.h>
518 return register_sysctl_table(NULL,0);
521 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
522 [register_sysctl_table() wants 2 args])
529 dnl # 2.6.23 API change
530 dnl # Old set_shrinker API replaced with register_shrinker
532 AC_DEFUN([SPL_AC_SET_SHRINKER], [
533 AC_MSG_CHECKING([whether set_shrinker() available])
534 SPL_LINUX_TRY_COMPILE([
535 #include <linux/mm.h>
537 return set_shrinker(DEFAULT_SEEKS, NULL);
540 AC_DEFINE(HAVE_SET_SHRINKER, 1,
541 [set_shrinker() available])
548 dnl # 2.6.25 API change,
549 dnl # struct path entry added to struct nameidata
551 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
552 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
553 SPL_LINUX_TRY_COMPILE([
554 #include <linux/namei.h>
559 nd.path.dentry = NULL;
562 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
563 [struct path used in struct nameidata])
570 dnl # Custom SPL patch may export this system it is not required
572 AC_DEFUN([SPL_AC_TASK_CURR], [
573 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
574 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
579 dnl # 2.6.19 API change,
580 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
582 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
583 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
584 SPL_LINUX_TRY_COMPILE([
585 #include <linux/sysctl.h>
587 #ifndef CTL_UNNUMBERED
588 #error CTL_UNNUMBERED undefined
592 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
593 [unnumbered sysctl support exists])
600 dnl # 2.6.16 API change.
601 dnl # Check if 'fls64()' is available
603 AC_DEFUN([SPL_AC_FLS64],
604 [AC_MSG_CHECKING([whether fls64() is available])
605 SPL_LINUX_TRY_COMPILE([
606 #include <linux/bitops.h>
611 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
618 dnl # 2.6.18 API change, check whether device_create() is available.
619 dnl # Device_create() was introduced in 2.6.18 and depricated
620 dnl # class_device_create() which was fully removed in 2.6.26.
622 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
623 SPL_CHECK_SYMBOL_EXPORT(
625 [drivers/base/core.c],
626 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
627 [device_create() is available])],
632 dnl # 2.6.27 API change,
633 dnl # device_create() uses 5 args, new 'drvdata' argument.
635 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
636 AC_MSG_CHECKING([whether device_create() wants 5 args])
637 tmp_flags="$EXTRA_KCFLAGS"
638 EXTRA_KCFLAGS="-Werror"
639 SPL_LINUX_TRY_COMPILE([
640 #include <linux/device.h>
642 device_create(NULL, NULL, 0, NULL, "%d", 1);
645 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
646 [device_create wants 5 args])
650 EXTRA_KCFLAGS="$tmp_flags"
654 dnl # 2.6.13 API change, check whether class_device_create() is available.
655 dnl # Class_device_create() was introduced in 2.6.13 and depricated
656 dnl # class_simple_device_add() which was fully removed in 2.6.13.
658 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
659 SPL_CHECK_SYMBOL_EXPORT(
660 [class_device_create],
661 [drivers/base/class.c],
662 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
663 [class_device_create() is available])],
668 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
670 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
671 SPL_CHECK_SYMBOL_EXPORT(
672 [set_normalized_timespec],
674 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
675 [set_normalized_timespec() is available as export])],
680 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
681 dnl # previously it was available in time.h as an inline.
683 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
684 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
685 SPL_LINUX_TRY_COMPILE([
686 #include <linux/time.h>
687 void set_normalized_timespec(struct timespec *ts,
688 time_t sec, long nsec) { }
695 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
696 [set_normalized_timespec() is available as inline])
701 dnl # 2.6.18 API change,
702 dnl # timespec_sub() inline function available in linux/time.h
704 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
705 AC_MSG_CHECKING([whether timespec_sub() is available])
706 SPL_LINUX_TRY_COMPILE([
707 #include <linux/time.h>
709 struct timespec a, b, c = { 0 };
710 c = timespec_sub(a, b);
713 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
720 dnl # 2.6.19 API change,
721 dnl # check if init_utsname() is available in linux/utsname.h
723 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
724 AC_MSG_CHECKING([whether init_utsname() is available])
725 SPL_LINUX_TRY_COMPILE([
726 #include <linux/utsname.h>
728 struct new_utsname *a = init_utsname();
731 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
738 dnl # 2.6.26 API change,
739 dnl # definition of struct fdtable relocated to linux/fdtable.h
741 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
742 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
746 dnl # 2.6.14 API change,
747 dnl # check whether 'files_fdtable()' exists
749 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
750 AC_MSG_CHECKING([whether files_fdtable() is available])
751 SPL_LINUX_TRY_COMPILE([
752 #include <linux/sched.h>
753 #include <linux/file.h>
754 #ifdef HAVE_FDTABLE_HEADER
755 #include <linux/fdtable.h>
758 struct files_struct *files = current->files;
759 struct fdtable *fdt = files_fdtable(files);
762 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
769 dnl # 2.6.18 API change,
770 dnl # added linux/uaccess.h
772 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
773 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
777 dnl # 2.6.12 API change,
778 dnl # check whether 'kmalloc_node()' is available.
780 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
781 AC_MSG_CHECKING([whether kmalloc_node() is available])
782 SPL_LINUX_TRY_COMPILE([
783 #include <linux/slab.h>
785 void *a = kmalloc_node(1, GFP_KERNEL, 0);
788 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
795 dnl # 2.6.9 API change,
796 dnl # check whether 'monotonic_clock()' is available it may
797 dnl # be available for some archs but not others.
799 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
800 SPL_CHECK_SYMBOL_EXPORT(
803 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
804 [monotonic_clock() is available])],
809 dnl # 2.6.16 API change,
810 dnl # check whether 'struct inode' has i_mutex
812 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
813 AC_MSG_CHECKING([whether struct inode has i_mutex])
814 SPL_LINUX_TRY_COMPILE([
815 #include <linux/fs.h>
816 #include <linux/mutex.h>
819 mutex_init(&i.i_mutex);
822 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
829 dnl # 2.6.18 API change,
830 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
831 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
832 dnl # if the mutex validator is disabled or otherwise unavailable.
834 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
835 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
836 SPL_LINUX_TRY_COMPILE([
837 #include <linux/mutex.h>
841 mutex_lock_nested(&mutex, 0);
844 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
845 [mutex_lock_nested() is available])
852 dnl # 2.6.22 API change,
853 dnl # First introduced 'div64_64()' in lib/div64.c
855 AC_DEFUN([SPL_AC_DIV64_64], [
856 SPL_CHECK_SYMBOL_EXPORT(
859 [AC_DEFINE(HAVE_DIV64_64, 1,
860 [div64_64() is available])],
865 dnl # 2.6.26 API change,
866 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
868 AC_DEFUN([SPL_AC_DIV64_U64], [
869 SPL_CHECK_SYMBOL_EXPORT(
872 [AC_DEFINE(HAVE_DIV64_U64, 1,
873 [div64_u64() is available])],
878 dnl # 2.6.27 API change,
879 dnl # on_each_cpu() uses 3 args, no 'retry' argument
881 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
882 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
883 SPL_LINUX_TRY_COMPILE([
884 #include <linux/smp.h>
886 on_each_cpu(NULL, NULL, 0);
889 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
890 [on_each_cpu wants 3 args])
897 dnl # 2.6.18 API change,
898 dnl # kallsyms_lookup_name no longer exported
900 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
901 SPL_CHECK_SYMBOL_EXPORT(
902 [kallsyms_lookup_name],
904 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
905 [kallsyms_lookup_name() is available])],
910 dnl # Proposed API change,
911 dnl # This symbol is not available in stock kernels. You may build a
912 dnl # custom kernel with the *-spl-export-symbols.patch which will export
913 dnl # these symbols for use. If your already rolling a custom kernel for
914 dnl # your environment this is recommended.
916 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
917 SPL_CHECK_SYMBOL_EXPORT(
920 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
921 [get_vmalloc_info() is available])],
926 dnl # 2.6.17 API change
927 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
928 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
929 dnl # were exported in 2.6.17 for use by modules which was consistent with
930 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
931 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
932 dnl # were dropped entirely leaving modules no way to directly iterate over
933 dnl # the zone list. Because we need access to the zone helpers we check
934 dnl # if the kernel contains the old or new implementation. Then we check
935 dnl # to see if the symbols we need for each version are available. If they
936 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
938 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
939 AC_MSG_CHECKING([whether symbol *_pgdat exist])
940 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
942 if test $rc -eq 0; then
944 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
951 dnl # Proposed API change,
952 dnl # This symbol is not available in stock kernels. You may build a
953 dnl # custom kernel with the *-spl-export-symbols.patch which will export
954 dnl # these symbols for use. If your already rolling a custom kernel for
955 dnl # your environment this is recommended.
957 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
958 SPL_CHECK_SYMBOL_EXPORT(
959 [first_online_pgdat],
961 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
962 [first_online_pgdat() is available])],
967 dnl # Proposed API change,
968 dnl # This symbol is not available in stock kernels. You may build a
969 dnl # custom kernel with the *-spl-export-symbols.patch which will export
970 dnl # these symbols for use. If your already rolling a custom kernel for
971 dnl # your environment this is recommended.
973 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
974 SPL_CHECK_SYMBOL_EXPORT(
977 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
978 [next_online_pgdat() is available])],
983 dnl # Proposed API change,
984 dnl # This symbol is not available in stock kernels. You may build a
985 dnl # custom kernel with the *-spl-export-symbols.patch which will export
986 dnl # these symbols for use. If your already rolling a custom kernel for
987 dnl # your environment this is recommended.
989 AC_DEFUN([SPL_AC_NEXT_ZONE], [
990 SPL_CHECK_SYMBOL_EXPORT(
993 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
994 [next_zone() is available])],
999 dnl # 2.6.17 API change,
1000 dnl # See SPL_AC_PGDAT_HELPERS for details.
1002 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1003 SPL_CHECK_SYMBOL_EXPORT(
1006 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1007 [pgdat_list is available])],
1012 dnl # 2.6.18 API change,
1013 dnl # First introduced global_page_state() support as an inline.
1015 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1016 AC_MSG_CHECKING([whether global_page_state() is available])
1017 SPL_LINUX_TRY_COMPILE([
1018 #include <linux/mm.h>
1020 unsigned long state;
1021 state = global_page_state(0);
1024 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1025 [global_page_state() is available])
1032 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1033 dnl # Public global zone stats now include a free page count. However
1034 dnl # the enumerated names of the counters have changed since this API
1035 dnl # was introduced. We need to deduce the corrent name to use. This
1036 dnl # replaces the priviate get_zone_counts() interface.
1038 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1039 dnl # is 2.6.30 as of when this was written.
1041 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1042 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1043 SPL_LINUX_TRY_COMPILE([
1044 #include <linux/mm.h>
1046 enum zone_stat_item zsi;
1047 zsi = NR_FREE_PAGES;
1050 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1051 [Page state NR_FREE_PAGES is available])
1058 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1059 dnl # Public global zone stats now include an inactive page count. However
1060 dnl # the enumerated names of the counters have changed since this API
1061 dnl # was introduced. We need to deduce the corrent name to use. This
1062 dnl # replaces the priviate get_zone_counts() interface.
1064 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1065 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1066 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1068 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1069 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1070 SPL_LINUX_TRY_COMPILE([
1071 #include <linux/mm.h>
1073 enum zone_stat_item zsi;
1077 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1078 [Page state NR_INACTIVE is available])
1083 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1084 SPL_LINUX_TRY_COMPILE([
1085 #include <linux/mm.h>
1087 enum zone_stat_item zsi;
1088 zsi = NR_INACTIVE_ANON;
1091 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1092 [Page state NR_INACTIVE_ANON is available])
1097 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1098 SPL_LINUX_TRY_COMPILE([
1099 #include <linux/mm.h>
1101 enum zone_stat_item zsi;
1102 zsi = NR_INACTIVE_FILE;
1105 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1106 [Page state NR_INACTIVE_FILE is available])
1113 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1114 dnl # Public global zone stats now include an active page count. However
1115 dnl # the enumerated names of the counters have changed since this API
1116 dnl # was introduced. We need to deduce the corrent name to use. This
1117 dnl # replaces the priviate get_zone_counts() interface.
1119 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1120 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1121 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1123 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1124 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1125 SPL_LINUX_TRY_COMPILE([
1126 #include <linux/mm.h>
1128 enum zone_stat_item zsi;
1132 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1133 [Page state NR_ACTIVE is available])
1138 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1139 SPL_LINUX_TRY_COMPILE([
1140 #include <linux/mm.h>
1142 enum zone_stat_item zsi;
1143 zsi = NR_ACTIVE_ANON;
1146 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1147 [Page state NR_ACTIVE_ANON is available])
1152 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1153 SPL_LINUX_TRY_COMPILE([
1154 #include <linux/mm.h>
1156 enum zone_stat_item zsi;
1157 zsi = NR_ACTIVE_FILE;
1160 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1161 [Page state NR_ACTIVE_FILE is available])
1168 dnl # Proposed API change for legacy kernels.
1169 dnl # This symbol is not available in older kernels. For kernels post
1170 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1171 dnl # page state information. This symbol is only used in legacy kernels
1172 dnl # any only as a last resort.
1174 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1175 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1176 SPL_LINUX_TRY_COMPILE([
1178 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1179 #error "global_page_state needs NR_FREE_PAGES"
1182 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1183 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1184 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1185 #error "global_page_state needs NR_ACTIVE*"
1188 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1189 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1190 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1191 #error "global_page_state needs NR_INACTIVE*"
1197 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1198 [get_zone_counts() is needed])
1200 SPL_CHECK_SYMBOL_EXPORT(
1203 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1204 [get_zone_counts() is available])],
1210 dnl # SLES API change, never adopted in mainline,
1211 dnl # Third 'struct vfsmount *' argument removed.
1213 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1214 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1215 SPL_LINUX_TRY_COMPILE([
1216 #include <linux/fs.h>
1218 vfs_unlink(NULL, NULL);
1221 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1222 [vfs_unlink() wants 2 args])
1229 dnl # SLES API change, never adopted in mainline,
1230 dnl # Third and sixth 'struct vfsmount *' argument removed.
1232 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1233 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1234 SPL_LINUX_TRY_COMPILE([
1235 #include <linux/fs.h>
1237 vfs_rename(NULL, NULL, NULL, NULL);
1240 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1241 [vfs_rename() wants 4 args])
1248 dnl # 2.6.29 API change,
1249 dnl # check whether 'struct cred' exists
1251 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1252 AC_MSG_CHECKING([whether struct cred exists])
1253 SPL_LINUX_TRY_COMPILE([
1254 #include <linux/cred.h>
1260 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1267 dnl # Custom SPL patch may export this symbol.
1269 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1270 SPL_CHECK_SYMBOL_EXPORT(
1273 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1274 [groups_search() is available])],
1279 dnl # 2.6.x API change,
1280 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1282 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1283 SPL_CHECK_SYMBOL_EXPORT(
1284 [__put_task_struct],
1286 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1287 [__put_task_struct() is available])],