2 dnl # Default SPL kernel configuration
4 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
7 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
8 dnl # compiler options are added by the kernel build system.
9 abs_srcdir=`readlink -f ${srcdir}`
10 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes -Werror"
11 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir}/include"
12 KERNELCPPFLAGS="$KERNELCPPFLAGS -include ${abs_srcdir}/spl_config.h"
14 if test "${LINUX_OBJ}" != "${LINUX}"; then
15 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
18 AC_SUBST(KERNELMAKE_PARAMS)
19 AC_SUBST(KERNELCPPFLAGS)
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_TYPE_ATOMIC64_CMPXCHG
26 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_3ARGS_INIT_WORK
29 SPL_AC_2ARGS_REGISTER_SYSCTL
31 SPL_AC_PATH_IN_NAMEIDATA
36 SPL_AC_5ARGS_DEVICE_CREATE
37 SPL_AC_CLASS_DEVICE_CREATE
38 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
39 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
46 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_MUTEX_LOCK_NESTED
52 SPL_AC_3ARGS_ON_EACH_CPU
53 SPL_AC_KALLSYMS_LOOKUP_NAME
54 SPL_AC_GET_VMALLOC_INFO
56 SPL_AC_FIRST_ONLINE_PGDAT
57 SPL_AC_NEXT_ONLINE_PGDAT
60 SPL_AC_GLOBAL_PAGE_STATE
61 SPL_AC_ZONE_STAT_ITEM_FREE
62 SPL_AC_ZONE_STAT_ITEM_INACTIVE
63 SPL_AC_ZONE_STAT_ITEM_ACTIVE
64 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_2ARGS_SET_FS_PWD
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_PUT_TASK_STRUCT
72 SPL_AC_5ARGS_PROC_HANDLER
75 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
76 modpost=$LINUX/scripts/Makefile.modpost
77 AC_MSG_CHECKING([kernel file name for module symbols])
78 if test -f "$modpost"; then
79 if grep -q Modules.symvers $modpost; then
80 LINUX_SYMBOLS=Modules.symvers
82 LINUX_SYMBOLS=Module.symvers
87 AC_MSG_RESULT($LINUX_SYMBOLS)
88 AC_SUBST(LINUX_SYMBOLS)
91 AC_DEFUN([SPL_AC_KERNEL], [
93 AS_HELP_STRING([--with-linux=PATH],
94 [Path to kernel source]),
95 [kernelsrc="$withval"])
97 AC_ARG_WITH([linux-obj],
98 AS_HELP_STRING([--with-linux-obj=PATH],
99 [Path to kernel build objects]),
100 [kernelbuild="$withval"])
102 AC_MSG_CHECKING([kernel source directory])
103 if test -z "$kernelsrc"; then
104 headersdir="/lib/modules/$(uname -r)/build"
105 if test -e "$headersdir"; then
106 sourcelink=$(readlink -f "$headersdir")
108 sourcelink=$(ls -1d /usr/src/kernels/* \
110 2>/dev/null | grep -v obj | tail -1)
113 if test -e ${sourcelink}; then
114 kernelsrc=`readlink -f ${sourcelink}`
116 AC_MSG_RESULT([Not found])
118 *** Please specify the location of the kernel source
119 *** with the '--with-linux=PATH' option])
122 if test "$kernelsrc" = "NONE"; then
127 AC_MSG_RESULT([$kernelsrc])
128 AC_MSG_CHECKING([kernel build directory])
129 if test -z "$kernelbuild"; then
130 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
131 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
132 elif test -d ${kernelsrc}-obj/`arch`/default; then
133 kernelbuild=${kernelsrc}-obj/`arch`/default
134 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
135 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
137 kernelbuild=${kernelsrc}
140 AC_MSG_RESULT([$kernelbuild])
142 AC_MSG_CHECKING([kernel source version])
143 if test -r $kernelbuild/include/linux/version.h &&
144 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
146 kernsrcver=`(echo "#include <linux/version.h>";
147 echo "kernsrcver=UTS_RELEASE") |
148 cpp -I $kernelbuild/include |
149 grep "^kernsrcver=" | cut -d \" -f 2`
151 elif test -r $kernelbuild/include/linux/utsrelease.h &&
152 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
154 kernsrcver=`(echo "#include <linux/utsrelease.h>";
155 echo "kernsrcver=UTS_RELEASE") |
156 cpp -I $kernelbuild/include |
157 grep "^kernsrcver=" | cut -d \" -f 2`
160 if test -z "$kernsrcver"; then
161 AC_MSG_RESULT([Not found])
163 *** Cannot determine the version of the linux kernel source.
164 *** Please prepare the kernel before running this script])
167 AC_MSG_RESULT([$kernsrcver])
170 LINUX_OBJ=${kernelbuild}
171 LINUX_VERSION=${kernsrcver}
175 AC_SUBST(LINUX_VERSION)
177 SPL_AC_MODULE_SYMVERS
181 dnl # Default SPL user configuration
183 AC_DEFUN([SPL_AC_CONFIG_USER], [])
185 AC_DEFUN([SPL_AC_LICENSE], [
186 AC_MSG_CHECKING([spl license])
188 AC_MSG_RESULT([$LICENSE])
189 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
193 AC_DEFUN([SPL_AC_CONFIG], [
195 AC_ARG_WITH([config],
196 AS_HELP_STRING([--with-config=CONFIG],
197 [Config file 'kernel|user|all|srpm']),
198 [SPL_CONFIG="$withval"])
200 AC_MSG_CHECKING([spl config])
201 AC_MSG_RESULT([$SPL_CONFIG]);
204 case "$SPL_CONFIG" in
205 kernel) SPL_AC_CONFIG_KERNEL ;;
206 user) SPL_AC_CONFIG_USER ;;
207 all) SPL_AC_CONFIG_KERNEL
208 SPL_AC_CONFIG_USER ;;
211 AC_MSG_RESULT([Error!])
212 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
213 user kernel|user|all|srpm]) ;;
216 AM_CONDITIONAL([CONFIG_USER],
217 [test "$SPL_CONFIG" = user] ||
218 [test "$SPL_CONFIG" = all])
219 AM_CONDITIONAL([CONFIG_KERNEL],
220 [test "$SPL_CONFIG" = kernel] ||
221 [test "$SPL_CONFIG" = all])
225 dnl # Enable if the SPL should be compiled with internal debugging enabled.
226 dnl # By default this support is disabled.
228 AC_DEFUN([SPL_AC_DEBUG], [
229 AC_ARG_ENABLE([debug],
230 [AS_HELP_STRING([--enable-debug],
231 [Enable generic debug support @<:@default=no@:>@])],
235 AS_IF([test "x$enable_debug" = xyes],
236 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"],
237 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"])
239 AC_MSG_CHECKING([whether debugging is enabled])
240 AC_MSG_RESULT([$enable_debug])
244 dnl # Enabled by default it provides a minimal level of memory tracking.
245 dnl # A total count of bytes allocated is kept for each alloc and free.
246 dnl # Then at module unload time a report to the console will be printed
247 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
248 dnl # and provide an easy way to inspect the kmem based slab.
250 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
251 AC_ARG_ENABLE([debug-kmem],
252 [AS_HELP_STRING([--enable-debug-kmem],
253 [Enable basic kmem accounting @<:@default=yes@:>@])],
255 [enable_debug_kmem=yes])
257 AS_IF([test "x$enable_debug_kmem" = xyes],
258 [AC_DEFINE([DEBUG_KMEM], [1],
259 [Define to 1 to enable basic kmem accounting])
260 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
262 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
263 AC_MSG_RESULT([$enable_debug_kmem])
267 dnl # Disabled by default it provides detailed memory tracking. This
268 dnl # feature also requires --enable-debug-kmem to be set. When enabled
269 dnl # not only will total bytes be tracked but also the location of every
270 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
271 dnl # addresses and where they were allocated will be dumped to the console.
272 dnl # Enabling this feature has a significant impact on performance but it
273 dnl # makes finding memory leaks pretty straight forward.
275 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
276 AC_ARG_ENABLE([debug-kmem-tracking],
277 [AS_HELP_STRING([--enable-debug-kmem-tracking],
278 [Enable detailed kmem tracking @<:@default=no@:>@])],
280 [enable_debug_kmem_tracking=no])
282 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
283 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
284 [Define to 1 to enable detailed kmem tracking])
285 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
287 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
288 AC_MSG_RESULT([$enable_debug_kmem_tracking])
292 dnl # SPL_LINUX_CONFTEST
294 AC_DEFUN([SPL_LINUX_CONFTEST], [
295 cat >conftest.c <<_ACEOF
301 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
303 m4_define([SPL_LANG_PROGRAM], [
308 dnl Do *not* indent the following line: there may be CPP directives.
309 dnl Don't move the `;' right after for the same reason.
317 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
319 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
320 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
321 rm -Rf build && mkdir -p build
322 echo "obj-m := conftest.o" >build/Makefile
324 [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])],
326 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
332 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
334 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
335 [SPL_LINUX_COMPILE_IFELSE(
336 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
338 [test -s build/conftest.o],
343 dnl # SPL_LINUX_CONFIG
345 AC_DEFUN([SPL_LINUX_CONFIG],
346 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
347 SPL_LINUX_TRY_COMPILE([
348 #ifndef AUTOCONF_INCLUDED
349 #include <linux/config.h>
353 #error CONFIG_$1 not #defined
365 dnl # SPL_CHECK_SYMBOL_EXPORT
366 dnl # check symbol exported or not
368 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
369 [AC_MSG_CHECKING([whether symbol $1 is exported])
370 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
371 $LINUX_OBJ/Module*.symvers 2>/dev/null
373 if test $rc -ne 0; then
376 grep -q -E "EXPORT_SYMBOL.*($1)" \
377 "$LINUX_OBJ/$file" 2>/dev/null
379 if test $rc -eq 0; then
384 if test $export -eq 0; then
398 dnl # SPL_CHECK_HEADER
399 dnl # check whether header exists and define HAVE_$2_HEADER
401 AC_DEFUN([SPL_CHECK_HEADER],
402 [AC_MSG_CHECKING([whether header $1 exists])
403 SPL_LINUX_TRY_COMPILE([
408 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
418 dnl # Use the atomic implemenation based on global spinlocks. This
419 dnl # should only be needed by 32-bit kernels which do not provide
420 dnl # the atomic64_* API. It may be optionally enabled as a fallback
421 dnl # if problems are observed with the direct mapping to the native
422 dnl # Linux atomic operations. You may not disable atomic spinlocks
423 dnl # if you kernel does not an atomic64_* API.
425 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
426 AC_ARG_ENABLE([atomic-spinlocks],
427 [AS_HELP_STRING([--enable-atomic-spinlocks],
428 [Atomic types use spinlocks @<:@default=check@:>@])],
430 [enable_atomic_spinlocks=check])
432 SPL_LINUX_TRY_COMPILE([
433 #include <asm/atomic.h>
438 AC_DEFINE(HAVE_ATOMIC64_T, 1,
439 [kernel defines atomic64_t])
444 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
445 AS_IF([test "x$have_atomic64_t" = xyes], [
446 enable_atomic_spinlocks=no
448 enable_atomic_spinlocks=yes
452 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
453 AC_DEFINE([ATOMIC_SPINLOCK], [1],
454 [Atomic types use spinlocks])
456 AS_IF([test "x$have_atomic64_t" = xno], [
458 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
462 AC_MSG_CHECKING([whether atomic types use spinlocks])
463 AC_MSG_RESULT([$enable_atomic_spinlocks])
465 AC_MSG_CHECKING([whether kernel defines atomic64_t])
466 AC_MSG_RESULT([$have_atomic64_t])
470 dnl # 2.6.24 API change,
471 dnl # check if atomic64_cmpxchg is defined
473 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
474 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
475 SPL_LINUX_TRY_COMPILE([
476 #include <asm/atomic.h>
478 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
481 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
482 [kernel defines atomic64_cmpxchg])
489 dnl # 2.6.24 API change,
490 dnl # check if atomic64_xchg is defined
492 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
493 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
494 SPL_LINUX_TRY_COMPILE([
495 #include <asm/atomic.h>
497 atomic64_xchg((atomic64_t *)NULL, 0);
500 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
501 [kernel defines atomic64_xchg])
508 dnl # 2.6.24 API change,
509 dnl # check if uintptr_t typedef is defined
511 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
512 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
513 SPL_LINUX_TRY_COMPILE([
514 #include <linux/types.h>
519 AC_DEFINE(HAVE_UINTPTR_T, 1,
520 [kernel defines uintptr_t])
527 dnl # 2.6.20 API change,
528 dnl # INIT_WORK use 2 args and not store data inside
530 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
531 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
532 SPL_LINUX_TRY_COMPILE([
533 #include <linux/workqueue.h>
535 struct work_struct work;
536 INIT_WORK(&work, NULL, NULL);
539 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
540 [INIT_WORK wants 3 args])
547 dnl # 2.6.21 API change,
548 dnl # 'register_sysctl_table' use only one argument instead of two
550 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
551 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
552 SPL_LINUX_TRY_COMPILE([
553 #include <linux/sysctl.h>
555 return register_sysctl_table(NULL,0);
558 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
559 [register_sysctl_table() wants 2 args])
566 dnl # 2.6.23 API change
567 dnl # Old set_shrinker API replaced with register_shrinker
569 AC_DEFUN([SPL_AC_SET_SHRINKER], [
570 AC_MSG_CHECKING([whether set_shrinker() available])
571 SPL_LINUX_TRY_COMPILE([
572 #include <linux/mm.h>
574 return set_shrinker(DEFAULT_SEEKS, NULL);
577 AC_DEFINE(HAVE_SET_SHRINKER, 1,
578 [set_shrinker() available])
585 dnl # 2.6.25 API change,
586 dnl # struct path entry added to struct nameidata
588 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
589 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
590 SPL_LINUX_TRY_COMPILE([
591 #include <linux/namei.h>
596 nd.path.dentry = NULL;
599 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
600 [struct path used in struct nameidata])
607 dnl # Custom SPL patch may export this system it is not required
609 AC_DEFUN([SPL_AC_TASK_CURR], [
610 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
611 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
616 dnl # 2.6.19 API change,
617 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
619 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
620 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
621 SPL_LINUX_TRY_COMPILE([
622 #include <linux/sysctl.h>
624 #ifndef CTL_UNNUMBERED
625 #error CTL_UNNUMBERED undefined
629 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
630 [unnumbered sysctl support exists])
637 dnl # 2.6.16 API change.
638 dnl # Check if 'fls64()' is available
640 AC_DEFUN([SPL_AC_FLS64],
641 [AC_MSG_CHECKING([whether fls64() is available])
642 SPL_LINUX_TRY_COMPILE([
643 #include <linux/bitops.h>
648 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
655 dnl # 2.6.18 API change, check whether device_create() is available.
656 dnl # Device_create() was introduced in 2.6.18 and depricated
657 dnl # class_device_create() which was fully removed in 2.6.26.
659 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
660 SPL_CHECK_SYMBOL_EXPORT(
662 [drivers/base/core.c],
663 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
664 [device_create() is available])],
669 dnl # 2.6.27 API change,
670 dnl # device_create() uses 5 args, new 'drvdata' argument.
672 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
673 AC_MSG_CHECKING([whether device_create() wants 5 args])
674 tmp_flags="$EXTRA_KCFLAGS"
675 EXTRA_KCFLAGS="-Werror"
676 SPL_LINUX_TRY_COMPILE([
677 #include <linux/device.h>
679 device_create(NULL, NULL, 0, NULL, "%d", 1);
682 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
683 [device_create wants 5 args])
687 EXTRA_KCFLAGS="$tmp_flags"
691 dnl # 2.6.13 API change, check whether class_device_create() is available.
692 dnl # Class_device_create() was introduced in 2.6.13 and depricated
693 dnl # class_simple_device_add() which was fully removed in 2.6.13.
695 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
696 SPL_CHECK_SYMBOL_EXPORT(
697 [class_device_create],
698 [drivers/base/class.c],
699 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
700 [class_device_create() is available])],
705 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
707 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
708 SPL_CHECK_SYMBOL_EXPORT(
709 [set_normalized_timespec],
711 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
712 [set_normalized_timespec() is available as export])],
717 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
718 dnl # previously it was available in time.h as an inline.
720 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
721 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
722 SPL_LINUX_TRY_COMPILE([
723 #include <linux/time.h>
724 void set_normalized_timespec(struct timespec *ts,
725 time_t sec, long nsec) { }
732 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
733 [set_normalized_timespec() is available as inline])
738 dnl # 2.6.18 API change,
739 dnl # timespec_sub() inline function available in linux/time.h
741 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
742 AC_MSG_CHECKING([whether timespec_sub() is available])
743 SPL_LINUX_TRY_COMPILE([
744 #include <linux/time.h>
746 struct timespec a, b, c = { 0 };
747 c = timespec_sub(a, b);
750 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
757 dnl # 2.6.19 API change,
758 dnl # check if init_utsname() is available in linux/utsname.h
760 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
761 AC_MSG_CHECKING([whether init_utsname() is available])
762 SPL_LINUX_TRY_COMPILE([
763 #include <linux/utsname.h>
765 struct new_utsname *a = init_utsname();
768 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
775 dnl # 2.6.26 API change,
776 dnl # definition of struct fdtable relocated to linux/fdtable.h
778 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
779 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
783 dnl # 2.6.14 API change,
784 dnl # check whether 'files_fdtable()' exists
786 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
787 AC_MSG_CHECKING([whether files_fdtable() is available])
788 SPL_LINUX_TRY_COMPILE([
789 #include <linux/sched.h>
790 #include <linux/file.h>
791 #ifdef HAVE_FDTABLE_HEADER
792 #include <linux/fdtable.h>
795 struct files_struct *files = current->files;
796 struct fdtable *fdt = files_fdtable(files);
799 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
806 dnl # 2.6.18 API change,
807 dnl # added linux/uaccess.h
809 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
810 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
814 dnl # 2.6.12 API change,
815 dnl # check whether 'kmalloc_node()' is available.
817 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
818 AC_MSG_CHECKING([whether kmalloc_node() is available])
819 SPL_LINUX_TRY_COMPILE([
820 #include <linux/slab.h>
822 void *a = kmalloc_node(1, GFP_KERNEL, 0);
825 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
832 dnl # 2.6.9 API change,
833 dnl # check whether 'monotonic_clock()' is available it may
834 dnl # be available for some archs but not others.
836 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
837 SPL_CHECK_SYMBOL_EXPORT(
840 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
841 [monotonic_clock() is available])],
846 dnl # 2.6.16 API change,
847 dnl # check whether 'struct inode' has i_mutex
849 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
850 AC_MSG_CHECKING([whether struct inode has i_mutex])
851 SPL_LINUX_TRY_COMPILE([
852 #include <linux/fs.h>
853 #include <linux/mutex.h>
856 mutex_init(&i.i_mutex);
859 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
866 dnl # 2.6.29 API change,
867 dnl # Adaptive mutexs introduced.
869 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
870 AC_MSG_CHECKING([whether struct mutex has owner])
871 SPL_LINUX_TRY_COMPILE([
872 #include <linux/mutex.h>
878 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
885 dnl # 2.6.18 API change,
886 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
887 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
888 dnl # if the mutex validator is disabled or otherwise unavailable.
890 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
891 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
892 SPL_LINUX_TRY_COMPILE([
893 #include <linux/mutex.h>
897 mutex_lock_nested(&mutex, 0);
900 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
901 [mutex_lock_nested() is available])
908 dnl # 2.6.22 API change,
909 dnl # First introduced 'div64_64()' in lib/div64.c
911 AC_DEFUN([SPL_AC_DIV64_64], [
912 SPL_CHECK_SYMBOL_EXPORT(
915 [AC_DEFINE(HAVE_DIV64_64, 1,
916 [div64_64() is available])],
921 dnl # 2.6.26 API change,
922 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
924 AC_DEFUN([SPL_AC_DIV64_U64], [
925 SPL_CHECK_SYMBOL_EXPORT(
928 [AC_DEFINE(HAVE_DIV64_U64, 1,
929 [div64_u64() is available])],
934 dnl # 2.6.27 API change,
935 dnl # on_each_cpu() uses 3 args, no 'retry' argument
937 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
938 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
939 SPL_LINUX_TRY_COMPILE([
940 #include <linux/smp.h>
942 on_each_cpu(NULL, NULL, 0);
945 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
946 [on_each_cpu wants 3 args])
953 dnl # 2.6.18 API change,
954 dnl # kallsyms_lookup_name no longer exported
956 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
957 SPL_CHECK_SYMBOL_EXPORT(
958 [kallsyms_lookup_name],
960 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
961 [kallsyms_lookup_name() 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_GET_VMALLOC_INFO], [
973 SPL_CHECK_SYMBOL_EXPORT(
976 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
977 [get_vmalloc_info() is available])],
982 dnl # 2.6.17 API change
983 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
984 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
985 dnl # were exported in 2.6.17 for use by modules which was consistent with
986 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
987 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
988 dnl # were dropped entirely leaving modules no way to directly iterate over
989 dnl # the zone list. Because we need access to the zone helpers we check
990 dnl # if the kernel contains the old or new implementation. Then we check
991 dnl # to see if the symbols we need for each version are available. If they
992 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
994 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
995 AC_MSG_CHECKING([whether symbol *_pgdat exist])
996 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
998 if test $rc -eq 0; then
1000 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1007 dnl # Proposed API change,
1008 dnl # This symbol is not available in stock kernels. You may build a
1009 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1010 dnl # these symbols for use. If your already rolling a custom kernel for
1011 dnl # your environment this is recommended.
1013 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1014 SPL_CHECK_SYMBOL_EXPORT(
1015 [first_online_pgdat],
1017 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1018 [first_online_pgdat() is available])],
1023 dnl # Proposed API change,
1024 dnl # This symbol is not available in stock kernels. You may build a
1025 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1026 dnl # these symbols for use. If your already rolling a custom kernel for
1027 dnl # your environment this is recommended.
1029 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1030 SPL_CHECK_SYMBOL_EXPORT(
1031 [next_online_pgdat],
1033 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1034 [next_online_pgdat() is available])],
1039 dnl # Proposed API change,
1040 dnl # This symbol is not available in stock kernels. You may build a
1041 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1042 dnl # these symbols for use. If your already rolling a custom kernel for
1043 dnl # your environment this is recommended.
1045 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1046 SPL_CHECK_SYMBOL_EXPORT(
1049 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1050 [next_zone() is available])],
1055 dnl # 2.6.17 API change,
1056 dnl # See SPL_AC_PGDAT_HELPERS for details.
1058 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1059 SPL_CHECK_SYMBOL_EXPORT(
1062 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1063 [pgdat_list is available])],
1068 dnl # 2.6.18 API change,
1069 dnl # First introduced global_page_state() support as an inline.
1071 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1072 AC_MSG_CHECKING([whether global_page_state() is available])
1073 SPL_LINUX_TRY_COMPILE([
1074 #include <linux/mm.h>
1076 unsigned long state;
1077 state = global_page_state(0);
1080 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1081 [global_page_state() is available])
1088 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1089 dnl # Public global zone stats now include a free page count. However
1090 dnl # the enumerated names of the counters have changed since this API
1091 dnl # was introduced. We need to deduce the corrent name to use. This
1092 dnl # replaces the priviate get_zone_counts() interface.
1094 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1095 dnl # is 2.6.30 as of when this was written.
1097 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1098 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1099 SPL_LINUX_TRY_COMPILE([
1100 #include <linux/mm.h>
1102 enum zone_stat_item zsi;
1103 zsi = NR_FREE_PAGES;
1106 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1107 [Page state NR_FREE_PAGES is available])
1114 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1115 dnl # Public global zone stats now include an inactive page count. However
1116 dnl # the enumerated names of the counters have changed since this API
1117 dnl # was introduced. We need to deduce the corrent name to use. This
1118 dnl # replaces the priviate get_zone_counts() interface.
1120 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1121 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1122 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1124 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1125 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1126 SPL_LINUX_TRY_COMPILE([
1127 #include <linux/mm.h>
1129 enum zone_stat_item zsi;
1133 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1134 [Page state NR_INACTIVE is available])
1139 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1140 SPL_LINUX_TRY_COMPILE([
1141 #include <linux/mm.h>
1143 enum zone_stat_item zsi;
1144 zsi = NR_INACTIVE_ANON;
1147 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1148 [Page state NR_INACTIVE_ANON is available])
1153 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1154 SPL_LINUX_TRY_COMPILE([
1155 #include <linux/mm.h>
1157 enum zone_stat_item zsi;
1158 zsi = NR_INACTIVE_FILE;
1161 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1162 [Page state NR_INACTIVE_FILE is available])
1169 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1170 dnl # Public global zone stats now include an active page count. However
1171 dnl # the enumerated names of the counters have changed since this API
1172 dnl # was introduced. We need to deduce the corrent name to use. This
1173 dnl # replaces the priviate get_zone_counts() interface.
1175 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1176 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1177 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1179 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1180 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1181 SPL_LINUX_TRY_COMPILE([
1182 #include <linux/mm.h>
1184 enum zone_stat_item zsi;
1188 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1189 [Page state NR_ACTIVE is available])
1194 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1195 SPL_LINUX_TRY_COMPILE([
1196 #include <linux/mm.h>
1198 enum zone_stat_item zsi;
1199 zsi = NR_ACTIVE_ANON;
1202 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1203 [Page state NR_ACTIVE_ANON is available])
1208 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1209 SPL_LINUX_TRY_COMPILE([
1210 #include <linux/mm.h>
1212 enum zone_stat_item zsi;
1213 zsi = NR_ACTIVE_FILE;
1216 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1217 [Page state NR_ACTIVE_FILE is available])
1224 dnl # Proposed API change for legacy kernels.
1225 dnl # This symbol is not available in older kernels. For kernels post
1226 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1227 dnl # page state information. This symbol is only used in legacy kernels
1228 dnl # any only as a last resort.
1230 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1231 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1232 SPL_LINUX_TRY_COMPILE([
1234 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1235 #error "global_page_state needs NR_FREE_PAGES"
1238 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1239 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1240 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1241 #error "global_page_state needs NR_ACTIVE*"
1244 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1245 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1246 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1247 #error "global_page_state needs NR_INACTIVE*"
1253 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1254 [get_zone_counts() is needed])
1256 SPL_CHECK_SYMBOL_EXPORT(
1259 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1260 [get_zone_counts() is available])],
1266 dnl # Symbol available in RHEL kernels not in stock kernels.
1268 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1269 SPL_CHECK_SYMBOL_EXPORT(
1272 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1273 [set_fs_pwd() is available])],
1278 dnl # 2.6.25 API change,
1279 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1281 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1282 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1283 SPL_LINUX_TRY_COMPILE([
1284 #include <linux/sched.h>
1285 #include <linux/fs_struct.h>
1287 set_fs_pwd(NULL, NULL);
1290 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1291 [set_fs_pwd() wants 2 args])
1298 dnl # SLES API change, never adopted in mainline,
1299 dnl # Third 'struct vfsmount *' argument removed.
1301 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1302 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1303 SPL_LINUX_TRY_COMPILE([
1304 #include <linux/fs.h>
1306 vfs_unlink(NULL, NULL);
1309 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1310 [vfs_unlink() wants 2 args])
1317 dnl # SLES API change, never adopted in mainline,
1318 dnl # Third and sixth 'struct vfsmount *' argument removed.
1320 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1321 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1322 SPL_LINUX_TRY_COMPILE([
1323 #include <linux/fs.h>
1325 vfs_rename(NULL, NULL, NULL, NULL);
1328 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1329 [vfs_rename() wants 4 args])
1336 dnl # 2.6.29 API change,
1337 dnl # check whether 'struct cred' exists
1339 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1340 AC_MSG_CHECKING([whether struct cred exists])
1341 SPL_LINUX_TRY_COMPILE([
1342 #include <linux/cred.h>
1348 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1355 dnl # Custom SPL patch may export this symbol.
1357 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1358 SPL_CHECK_SYMBOL_EXPORT(
1361 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1362 [groups_search() is available])],
1367 dnl # 2.6.x API change,
1368 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1370 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1371 SPL_CHECK_SYMBOL_EXPORT(
1372 [__put_task_struct],
1374 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1375 [__put_task_struct() is available])],
1380 dnl # 2.6.32 API change,
1381 dnl # Unused 'struct file *' removed from prototype.
1383 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1384 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1385 SPL_LINUX_TRY_COMPILE([
1386 #include <linux/sysctl.h>
1388 proc_dostring(NULL, 0, NULL, NULL, NULL);
1391 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1392 [proc_handler() wants 5 args])