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)
28 SPL_AC_ATOMIC_SPINLOCK
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
52 SPL_AC_MUTEX_LOCK_NESTED
55 SPL_AC_3ARGS_ON_EACH_CPU
56 SPL_AC_KALLSYMS_LOOKUP_NAME
57 SPL_AC_GET_VMALLOC_INFO
59 SPL_AC_FIRST_ONLINE_PGDAT
60 SPL_AC_NEXT_ONLINE_PGDAT
63 SPL_AC_GLOBAL_PAGE_STATE
64 SPL_AC_ZONE_STAT_ITEM_FREE
65 SPL_AC_ZONE_STAT_ITEM_INACTIVE
66 SPL_AC_ZONE_STAT_ITEM_ACTIVE
67 SPL_AC_GET_ZONE_COUNTS
69 SPL_AC_2ARGS_SET_FS_PWD
70 SPL_AC_2ARGS_VFS_UNLINK
71 SPL_AC_4ARGS_VFS_RENAME
74 SPL_AC_PUT_TASK_STRUCT
77 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
78 modpost=$LINUX/scripts/Makefile.modpost
79 AC_MSG_CHECKING([kernel file name for module symbols])
80 if test -f "$modpost"; then
81 if grep -q Modules.symvers $modpost; then
82 LINUX_SYMBOLS=Modules.symvers
84 LINUX_SYMBOLS=Module.symvers
89 AC_MSG_RESULT($LINUX_SYMBOLS)
90 AC_SUBST(LINUX_SYMBOLS)
93 AC_DEFUN([SPL_AC_KERNEL], [
95 AS_HELP_STRING([--with-linux=PATH],
96 [Path to kernel source]),
97 [kernelsrc="$withval"])
99 AC_ARG_WITH([linux-obj],
100 AS_HELP_STRING([--with-linux-obj=PATH],
101 [Path to kernel build objects]),
102 [kernelbuild="$withval"])
104 AC_MSG_CHECKING([kernel source directory])
105 if test -z "$kernelsrc"; then
106 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
107 2>/dev/null | grep -v obj | tail -1`
109 if test -e ${sourcelink}; then
110 kernelsrc=`readlink -f ${sourcelink}`
112 AC_MSG_RESULT([Not found])
114 *** Please specify the location of the kernel source
115 *** with the '--with-linux=PATH' option])
118 if test "$kernelsrc" = "NONE"; then
123 AC_MSG_RESULT([$kernelsrc])
124 AC_MSG_CHECKING([kernel build directory])
125 if test -z "$kernelbuild"; then
126 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
127 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
128 elif test -d ${kernelsrc}-obj/`arch`/default; then
129 kernelbuild=${kernelsrc}-obj/`arch`/default
130 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
131 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
133 kernelbuild=${kernelsrc}
136 AC_MSG_RESULT([$kernelbuild])
138 AC_MSG_CHECKING([kernel source version])
139 if test -r $kernelbuild/include/linux/version.h &&
140 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
142 kernsrcver=`(echo "#include <linux/version.h>";
143 echo "kernsrcver=UTS_RELEASE") |
144 cpp -I $kernelbuild/include |
145 grep "^kernsrcver=" | cut -d \" -f 2`
147 elif test -r $kernelbuild/include/linux/utsrelease.h &&
148 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
150 kernsrcver=`(echo "#include <linux/utsrelease.h>";
151 echo "kernsrcver=UTS_RELEASE") |
152 cpp -I $kernelbuild/include |
153 grep "^kernsrcver=" | cut -d \" -f 2`
156 if test -z "$kernsrcver"; then
157 AC_MSG_RESULT([Not found])
159 *** Cannot determine the version of the linux kernel source.
160 *** Please prepare the kernel before running this script])
163 AC_MSG_RESULT([$kernsrcver])
166 LINUX_OBJ=${kernelbuild}
167 LINUX_VERSION=${kernsrcver}
171 AC_SUBST(LINUX_VERSION)
173 SPL_AC_MODULE_SYMVERS
177 dnl # Default SPL user configuration
179 AC_DEFUN([SPL_AC_CONFIG_USER], [])
181 AC_DEFUN([SPL_AC_LICENSE], [
182 AC_MSG_CHECKING([spl license])
184 AC_MSG_RESULT([$LICENSE])
185 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
189 AC_DEFUN([SPL_AC_CONFIG], [
191 AC_ARG_WITH([config],
192 AS_HELP_STRING([--with-config=CONFIG],
193 [Config file 'kernel|user|all']),
194 [SPL_CONFIG="$withval"])
196 AC_MSG_CHECKING([spl config])
197 AC_MSG_RESULT([$SPL_CONFIG]);
200 case "$SPL_CONFIG" in
201 kernel) SPL_AC_CONFIG_KERNEL ;;
202 user) SPL_AC_CONFIG_USER ;;
203 all) SPL_AC_CONFIG_KERNEL
204 SPL_AC_CONFIG_USER ;;
206 AC_MSG_RESULT([Error!])
207 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
208 user kernel|user|all]) ;;
211 AM_CONDITIONAL([CONFIG_USER],
212 [test "$SPL_CONFIG" = user] ||
213 [test "$SPL_CONFIG" = all])
214 AM_CONDITIONAL([CONFIG_KERNEL],
215 [test "$SPL_CONFIG" = kernel] ||
216 [test "$SPL_CONFIG" = all])
219 AC_DEFUN([SPL_AC_DEBUG], [
220 AC_MSG_CHECKING([whether debugging is enabled])
221 AC_ARG_ENABLE( [debug],
222 AS_HELP_STRING([--enable-debug],
223 [Enable generic debug support (default off)]),
224 [ case "$enableval" in
225 yes) spl_ac_debug=yes ;;
226 no) spl_ac_debug=no ;;
227 *) AC_MSG_RESULT([Error!])
228 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
231 if test "$spl_ac_debug" = yes; then
233 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
236 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
240 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
241 AC_MSG_CHECKING([whether kmem debugging is enabled])
242 AC_ARG_ENABLE( [debug-kmem],
243 AS_HELP_STRING([--enable-debug-kmem],
244 [Enable kmem debug support (default off)]),
245 [ case "$enableval" in
246 yes) spl_ac_debug_kmem=yes ;;
247 no) spl_ac_debug_kmem=no ;;
248 *) AC_MSG_RESULT([Error!])
249 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
252 if test "$spl_ac_debug_kmem" = yes; then
254 AC_DEFINE([DEBUG_KMEM], [1],
255 [Define to 1 to enable kmem debugging])
256 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
262 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
263 AC_MSG_CHECKING([whether kstat debugging is enabled])
264 AC_ARG_ENABLE( [debug-kstat],
265 AS_HELP_STRING([--enable-debug-kstat],
266 [Enable kstat debug support (default off)]),
267 [ case "$enableval" in
268 yes) spl_ac_debug_kstat=yes ;;
269 no) spl_ac_debug_kstat=no ;;
270 *) AC_MSG_RESULT([Error!])
271 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
274 if test "$spl_ac_debug_kstat" = yes; then
276 AC_DEFINE([DEBUG_KSTAT], [1],
277 [Define to 1 to enable kstat debugging])
278 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
284 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
285 AC_MSG_CHECKING([whether callb debugging is enabled])
286 AC_ARG_ENABLE( [debug-callb],
287 AS_HELP_STRING([--enable-debug-callb],
288 [Enable callb debug support (default off)]),
289 [ case "$enableval" in
290 yes) spl_ac_debug_callb=yes ;;
291 no) spl_ac_debug_callb=no ;;
292 *) AC_MSG_RESULT([Error!])
293 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
296 if test "$spl_ac_debug_callb" = yes; then
298 AC_DEFINE([DEBUG_CALLB], [1],
299 [Define to 1 to enable callb debugging])
300 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
307 dnl # Use the atomic implemenation based on global spinlocks. This
308 dnl # should never be needed, however it has been left in place as
309 dnl # a fallback option in case problems are observed with directly
310 dnl # mapping to the native Linux atomic operations.
312 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
313 AC_ARG_ENABLE([atomic-spinlocks],
314 [AS_HELP_STRING([--enable-atomic-spinlocks],
315 [Atomic types use spinlocks @<:@default=no@:>@])],
317 [enable_atomic_spinlocks=no])
319 AS_IF([test "x$enable_atomic_spinlocks" = xyes],
320 [AC_DEFINE([ATOMIC_SPINLOCK], [1],
321 [Atomic types use spinlocks])])
323 AC_MSG_CHECKING([whether atomic types use spinlocks])
324 AC_MSG_RESULT([$enable_atomic_spinlocks])
328 dnl # SPL_LINUX_CONFTEST
330 AC_DEFUN([SPL_LINUX_CONFTEST], [
331 cat >conftest.c <<_ACEOF
337 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
339 m4_define([SPL_LANG_PROGRAM], [
344 dnl Do *not* indent the following line: there may be CPP directives.
345 dnl Don't move the `;' right after for the same reason.
353 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
355 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
356 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
357 rm -Rf build && mkdir -p build
358 echo "obj-m := conftest.o" >build/Makefile
360 [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])],
362 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
368 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
370 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
371 [SPL_LINUX_COMPILE_IFELSE(
372 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
374 [test -s build/conftest.o],
379 dnl # SPL_LINUX_CONFIG
381 AC_DEFUN([SPL_LINUX_CONFIG],
382 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
383 SPL_LINUX_TRY_COMPILE([
384 #ifndef AUTOCONF_INCLUDED
385 #include <linux/config.h>
389 #error CONFIG_$1 not #defined
401 dnl # SPL_CHECK_SYMBOL_EXPORT
402 dnl # check symbol exported or not
404 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
405 [AC_MSG_CHECKING([whether symbol $1 is exported])
406 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
407 $LINUX_OBJ/Module*.symvers 2>/dev/null
409 if test $rc -ne 0; then
412 grep -q -E "EXPORT_SYMBOL.*($1)" \
413 "$LINUX_OBJ/$file" 2>/dev/null
415 if test $rc -eq 0; then
420 if test $export -eq 0; then
434 dnl # SPL_CHECK_HEADER
435 dnl # check whether header exists and define HAVE_$2_HEADER
437 AC_DEFUN([SPL_CHECK_HEADER],
438 [AC_MSG_CHECKING([whether header $1 exists])
439 SPL_LINUX_TRY_COMPILE([
444 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
454 dnl # 2.6.24 API change,
455 dnl # check if uintptr_t typedef is defined
457 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
458 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
459 SPL_LINUX_TRY_COMPILE([
460 #include <linux/types.h>
465 AC_DEFINE(HAVE_UINTPTR_T, 1,
466 [kernel defines uintptr_t])
473 dnl # 2.6.x API change,
474 dnl # check if atomic64_t typedef is defined
476 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
477 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
478 SPL_LINUX_TRY_COMPILE([
479 #include <asm/atomic.h>
484 AC_DEFINE(HAVE_ATOMIC64_T, 1,
485 [kernel defines atomic64_t])
492 dnl # 2.6.20 API change,
493 dnl # INIT_WORK use 2 args and not store data inside
495 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
496 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
497 SPL_LINUX_TRY_COMPILE([
498 #include <linux/workqueue.h>
500 struct work_struct work;
501 INIT_WORK(&work, NULL, NULL);
504 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
505 [INIT_WORK wants 3 args])
512 dnl # 2.6.21 API change,
513 dnl # 'register_sysctl_table' use only one argument instead of two
515 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
516 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
517 SPL_LINUX_TRY_COMPILE([
518 #include <linux/sysctl.h>
520 return register_sysctl_table(NULL,0);
523 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
524 [register_sysctl_table() wants 2 args])
531 dnl # 2.6.23 API change
532 dnl # Old set_shrinker API replaced with register_shrinker
534 AC_DEFUN([SPL_AC_SET_SHRINKER], [
535 AC_MSG_CHECKING([whether set_shrinker() available])
536 SPL_LINUX_TRY_COMPILE([
537 #include <linux/mm.h>
539 return set_shrinker(DEFAULT_SEEKS, NULL);
542 AC_DEFINE(HAVE_SET_SHRINKER, 1,
543 [set_shrinker() available])
550 dnl # 2.6.25 API change,
551 dnl # struct path entry added to struct nameidata
553 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
554 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
555 SPL_LINUX_TRY_COMPILE([
556 #include <linux/namei.h>
561 nd.path.dentry = NULL;
564 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
565 [struct path used in struct nameidata])
572 dnl # Custom SPL patch may export this system it is not required
574 AC_DEFUN([SPL_AC_TASK_CURR], [
575 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
576 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
581 dnl # 2.6.19 API change,
582 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
584 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
585 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
586 SPL_LINUX_TRY_COMPILE([
587 #include <linux/sysctl.h>
589 #ifndef CTL_UNNUMBERED
590 #error CTL_UNNUMBERED undefined
594 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
595 [unnumbered sysctl support exists])
602 dnl # 2.6.16 API change.
603 dnl # Check if 'fls64()' is available
605 AC_DEFUN([SPL_AC_FLS64],
606 [AC_MSG_CHECKING([whether fls64() is available])
607 SPL_LINUX_TRY_COMPILE([
608 #include <linux/bitops.h>
613 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
620 dnl # 2.6.18 API change, check whether device_create() is available.
621 dnl # Device_create() was introduced in 2.6.18 and depricated
622 dnl # class_device_create() which was fully removed in 2.6.26.
624 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
625 SPL_CHECK_SYMBOL_EXPORT(
627 [drivers/base/core.c],
628 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
629 [device_create() is available])],
634 dnl # 2.6.27 API change,
635 dnl # device_create() uses 5 args, new 'drvdata' argument.
637 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
638 AC_MSG_CHECKING([whether device_create() wants 5 args])
639 tmp_flags="$EXTRA_KCFLAGS"
640 EXTRA_KCFLAGS="-Werror"
641 SPL_LINUX_TRY_COMPILE([
642 #include <linux/device.h>
644 device_create(NULL, NULL, 0, NULL, "%d", 1);
647 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
648 [device_create wants 5 args])
652 EXTRA_KCFLAGS="$tmp_flags"
656 dnl # 2.6.13 API change, check whether class_device_create() is available.
657 dnl # Class_device_create() was introduced in 2.6.13 and depricated
658 dnl # class_simple_device_add() which was fully removed in 2.6.13.
660 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
661 SPL_CHECK_SYMBOL_EXPORT(
662 [class_device_create],
663 [drivers/base/class.c],
664 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
665 [class_device_create() is available])],
670 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
672 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
673 SPL_CHECK_SYMBOL_EXPORT(
674 [set_normalized_timespec],
676 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
677 [set_normalized_timespec() is available as export])],
682 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
683 dnl # previously it was available in time.h as an inline.
685 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
686 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
687 SPL_LINUX_TRY_COMPILE([
688 #include <linux/time.h>
689 void set_normalized_timespec(struct timespec *ts,
690 time_t sec, long nsec) { }
697 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
698 [set_normalized_timespec() is available as inline])
703 dnl # 2.6.18 API change,
704 dnl # timespec_sub() inline function available in linux/time.h
706 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
707 AC_MSG_CHECKING([whether timespec_sub() is available])
708 SPL_LINUX_TRY_COMPILE([
709 #include <linux/time.h>
711 struct timespec a, b, c = { 0 };
712 c = timespec_sub(a, b);
715 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
722 dnl # 2.6.19 API change,
723 dnl # check if init_utsname() is available in linux/utsname.h
725 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
726 AC_MSG_CHECKING([whether init_utsname() is available])
727 SPL_LINUX_TRY_COMPILE([
728 #include <linux/utsname.h>
730 struct new_utsname *a = init_utsname();
733 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
740 dnl # 2.6.26 API change,
741 dnl # definition of struct fdtable relocated to linux/fdtable.h
743 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
744 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
748 dnl # 2.6.14 API change,
749 dnl # check whether 'files_fdtable()' exists
751 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
752 AC_MSG_CHECKING([whether files_fdtable() is available])
753 SPL_LINUX_TRY_COMPILE([
754 #include <linux/sched.h>
755 #include <linux/file.h>
756 #ifdef HAVE_FDTABLE_HEADER
757 #include <linux/fdtable.h>
760 struct files_struct *files = current->files;
761 struct fdtable *fdt = files_fdtable(files);
764 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
771 dnl # 2.6.18 API change,
772 dnl # added linux/uaccess.h
774 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
775 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
779 dnl # 2.6.12 API change,
780 dnl # check whether 'kmalloc_node()' is available.
782 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
783 AC_MSG_CHECKING([whether kmalloc_node() is available])
784 SPL_LINUX_TRY_COMPILE([
785 #include <linux/slab.h>
787 void *a = kmalloc_node(1, GFP_KERNEL, 0);
790 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
797 dnl # 2.6.9 API change,
798 dnl # check whether 'monotonic_clock()' is available it may
799 dnl # be available for some archs but not others.
801 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
802 SPL_CHECK_SYMBOL_EXPORT(
805 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
806 [monotonic_clock() is available])],
811 dnl # 2.6.16 API change,
812 dnl # check whether 'struct inode' has i_mutex
814 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
815 AC_MSG_CHECKING([whether struct inode has i_mutex])
816 SPL_LINUX_TRY_COMPILE([
817 #include <linux/fs.h>
818 #include <linux/mutex.h>
821 mutex_init(&i.i_mutex);
824 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
831 dnl # 2.6.29 API change,
832 dnl # Adaptive mutexs introduced.
834 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
835 AC_MSG_CHECKING([whether struct mutex has owner])
836 SPL_LINUX_TRY_COMPILE([
837 #include <linux/mutex.h>
843 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
850 dnl # 2.6.18 API change,
851 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
852 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
853 dnl # if the mutex validator is disabled or otherwise unavailable.
855 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
856 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
857 SPL_LINUX_TRY_COMPILE([
858 #include <linux/mutex.h>
862 mutex_lock_nested(&mutex, 0);
865 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
866 [mutex_lock_nested() is available])
873 dnl # 2.6.22 API change,
874 dnl # First introduced 'div64_64()' in lib/div64.c
876 AC_DEFUN([SPL_AC_DIV64_64], [
877 SPL_CHECK_SYMBOL_EXPORT(
880 [AC_DEFINE(HAVE_DIV64_64, 1,
881 [div64_64() is available])],
886 dnl # 2.6.26 API change,
887 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
889 AC_DEFUN([SPL_AC_DIV64_U64], [
890 SPL_CHECK_SYMBOL_EXPORT(
893 [AC_DEFINE(HAVE_DIV64_U64, 1,
894 [div64_u64() is available])],
899 dnl # 2.6.27 API change,
900 dnl # on_each_cpu() uses 3 args, no 'retry' argument
902 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
903 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
904 SPL_LINUX_TRY_COMPILE([
905 #include <linux/smp.h>
907 on_each_cpu(NULL, NULL, 0);
910 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
911 [on_each_cpu wants 3 args])
918 dnl # 2.6.18 API change,
919 dnl # kallsyms_lookup_name no longer exported
921 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
922 SPL_CHECK_SYMBOL_EXPORT(
923 [kallsyms_lookup_name],
925 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
926 [kallsyms_lookup_name() is available])],
931 dnl # Proposed API change,
932 dnl # This symbol is not available in stock kernels. You may build a
933 dnl # custom kernel with the *-spl-export-symbols.patch which will export
934 dnl # these symbols for use. If your already rolling a custom kernel for
935 dnl # your environment this is recommended.
937 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
938 SPL_CHECK_SYMBOL_EXPORT(
941 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
942 [get_vmalloc_info() is available])],
947 dnl # 2.6.17 API change
948 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
949 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
950 dnl # were exported in 2.6.17 for use by modules which was consistent with
951 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
952 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
953 dnl # were dropped entirely leaving modules no way to directly iterate over
954 dnl # the zone list. Because we need access to the zone helpers we check
955 dnl # if the kernel contains the old or new implementation. Then we check
956 dnl # to see if the symbols we need for each version are available. If they
957 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
959 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
960 AC_MSG_CHECKING([whether symbol *_pgdat exist])
961 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
963 if test $rc -eq 0; then
965 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
972 dnl # Proposed API change,
973 dnl # This symbol is not available in stock kernels. You may build a
974 dnl # custom kernel with the *-spl-export-symbols.patch which will export
975 dnl # these symbols for use. If your already rolling a custom kernel for
976 dnl # your environment this is recommended.
978 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
979 SPL_CHECK_SYMBOL_EXPORT(
980 [first_online_pgdat],
982 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
983 [first_online_pgdat() is available])],
988 dnl # Proposed API change,
989 dnl # This symbol is not available in stock kernels. You may build a
990 dnl # custom kernel with the *-spl-export-symbols.patch which will export
991 dnl # these symbols for use. If your already rolling a custom kernel for
992 dnl # your environment this is recommended.
994 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
995 SPL_CHECK_SYMBOL_EXPORT(
998 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
999 [next_online_pgdat() is available])],
1004 dnl # Proposed API change,
1005 dnl # This symbol is not available in stock kernels. You may build a
1006 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1007 dnl # these symbols for use. If your already rolling a custom kernel for
1008 dnl # your environment this is recommended.
1010 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1011 SPL_CHECK_SYMBOL_EXPORT(
1014 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1015 [next_zone() is available])],
1020 dnl # 2.6.17 API change,
1021 dnl # See SPL_AC_PGDAT_HELPERS for details.
1023 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1024 SPL_CHECK_SYMBOL_EXPORT(
1027 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1028 [pgdat_list is available])],
1033 dnl # 2.6.18 API change,
1034 dnl # First introduced global_page_state() support as an inline.
1036 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1037 AC_MSG_CHECKING([whether global_page_state() is available])
1038 SPL_LINUX_TRY_COMPILE([
1039 #include <linux/mm.h>
1041 unsigned long state;
1042 state = global_page_state(0);
1045 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1046 [global_page_state() is available])
1053 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1054 dnl # Public global zone stats now include a free page count. However
1055 dnl # the enumerated names of the counters have changed since this API
1056 dnl # was introduced. We need to deduce the corrent name to use. This
1057 dnl # replaces the priviate get_zone_counts() interface.
1059 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1060 dnl # is 2.6.30 as of when this was written.
1062 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1063 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1064 SPL_LINUX_TRY_COMPILE([
1065 #include <linux/mm.h>
1067 enum zone_stat_item zsi;
1068 zsi = NR_FREE_PAGES;
1071 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1072 [Page state NR_FREE_PAGES is available])
1079 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1080 dnl # Public global zone stats now include an inactive page count. However
1081 dnl # the enumerated names of the counters have changed since this API
1082 dnl # was introduced. We need to deduce the corrent name to use. This
1083 dnl # replaces the priviate get_zone_counts() interface.
1085 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1086 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1087 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1089 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1090 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1091 SPL_LINUX_TRY_COMPILE([
1092 #include <linux/mm.h>
1094 enum zone_stat_item zsi;
1098 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1099 [Page state NR_INACTIVE is available])
1104 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1105 SPL_LINUX_TRY_COMPILE([
1106 #include <linux/mm.h>
1108 enum zone_stat_item zsi;
1109 zsi = NR_INACTIVE_ANON;
1112 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1113 [Page state NR_INACTIVE_ANON is available])
1118 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1119 SPL_LINUX_TRY_COMPILE([
1120 #include <linux/mm.h>
1122 enum zone_stat_item zsi;
1123 zsi = NR_INACTIVE_FILE;
1126 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1127 [Page state NR_INACTIVE_FILE is available])
1134 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1135 dnl # Public global zone stats now include an active page count. However
1136 dnl # the enumerated names of the counters have changed since this API
1137 dnl # was introduced. We need to deduce the corrent name to use. This
1138 dnl # replaces the priviate get_zone_counts() interface.
1140 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1141 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1142 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1144 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1145 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1146 SPL_LINUX_TRY_COMPILE([
1147 #include <linux/mm.h>
1149 enum zone_stat_item zsi;
1153 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1154 [Page state NR_ACTIVE is available])
1159 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1160 SPL_LINUX_TRY_COMPILE([
1161 #include <linux/mm.h>
1163 enum zone_stat_item zsi;
1164 zsi = NR_ACTIVE_ANON;
1167 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1168 [Page state NR_ACTIVE_ANON is available])
1173 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1174 SPL_LINUX_TRY_COMPILE([
1175 #include <linux/mm.h>
1177 enum zone_stat_item zsi;
1178 zsi = NR_ACTIVE_FILE;
1181 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1182 [Page state NR_ACTIVE_FILE is available])
1189 dnl # Proposed API change for legacy kernels.
1190 dnl # This symbol is not available in older kernels. For kernels post
1191 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1192 dnl # page state information. This symbol is only used in legacy kernels
1193 dnl # any only as a last resort.
1195 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1196 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1197 SPL_LINUX_TRY_COMPILE([
1199 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1200 #error "global_page_state needs NR_FREE_PAGES"
1203 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1204 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1205 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1206 #error "global_page_state needs NR_ACTIVE*"
1209 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1210 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1211 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1212 #error "global_page_state needs NR_INACTIVE*"
1218 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1219 [get_zone_counts() is needed])
1221 SPL_CHECK_SYMBOL_EXPORT(
1224 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1225 [get_zone_counts() is available])],
1231 dnl # Symbol available in RHEL kernels not in stock kernels.
1233 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1234 SPL_CHECK_SYMBOL_EXPORT(
1237 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1238 [set_fs_pwd() is available])],
1243 dnl # 2.6.25 API change,
1244 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1246 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1247 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1248 SPL_LINUX_TRY_COMPILE([
1249 #include <linux/sched.h>
1251 set_fs_pwd(NULL, NULL);
1254 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1255 [set_fs_pwd() wants 2 args])
1262 dnl # SLES API change, never adopted in mainline,
1263 dnl # Third 'struct vfsmount *' argument removed.
1265 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1266 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1267 SPL_LINUX_TRY_COMPILE([
1268 #include <linux/fs.h>
1270 vfs_unlink(NULL, NULL);
1273 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1274 [vfs_unlink() wants 2 args])
1281 dnl # SLES API change, never adopted in mainline,
1282 dnl # Third and sixth 'struct vfsmount *' argument removed.
1284 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1285 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1286 SPL_LINUX_TRY_COMPILE([
1287 #include <linux/fs.h>
1289 vfs_rename(NULL, NULL, NULL, NULL);
1292 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1293 [vfs_rename() wants 4 args])
1300 dnl # 2.6.29 API change,
1301 dnl # check whether 'struct cred' exists
1303 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1304 AC_MSG_CHECKING([whether struct cred exists])
1305 SPL_LINUX_TRY_COMPILE([
1306 #include <linux/cred.h>
1312 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1319 dnl # Custom SPL patch may export this symbol.
1321 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1322 SPL_CHECK_SYMBOL_EXPORT(
1325 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1326 [groups_search() is available])],
1331 dnl # 2.6.x API change,
1332 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1334 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1335 SPL_CHECK_SYMBOL_EXPORT(
1336 [__put_task_struct],
1338 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1339 [__put_task_struct() is available])],