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)
26 SPL_AC_DEBUG_KMEM_TRACKING
27 SPL_AC_ATOMIC_SPINLOCK
28 SPL_AC_TYPE_ATOMIC64_CMPXCHG
29 SPL_AC_TYPE_ATOMIC64_XCHG
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|srpm']),
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 ;;
207 AC_MSG_RESULT([Error!])
208 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
209 user kernel|user|all|srpm]) ;;
212 AM_CONDITIONAL([CONFIG_USER],
213 [test "$SPL_CONFIG" = user] ||
214 [test "$SPL_CONFIG" = all])
215 AM_CONDITIONAL([CONFIG_KERNEL],
216 [test "$SPL_CONFIG" = kernel] ||
217 [test "$SPL_CONFIG" = all])
221 dnl # Enable if the SPL should be compiled with internal debugging enabled.
222 dnl # By default this support is disabled.
224 AC_DEFUN([SPL_AC_DEBUG], [
225 AC_ARG_ENABLE([debug],
226 [AS_HELP_STRING([--enable-debug],
227 [Enable generic debug support @<:@default=no@:>@])],
231 AS_IF([test "x$enable_debug" = xyes],
232 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"],
233 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"])
235 AC_MSG_CHECKING([whether debugging is enabled])
236 AC_MSG_RESULT([$enable_debug])
240 dnl # Enabled by default it provides a minimal level of memory tracking.
241 dnl # A total count of bytes allocated is kept for each alloc and free.
242 dnl # Then at module unload time a report to the console will be printed
243 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
244 dnl # and provide an easy way to inspect the kmem based slab.
246 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
247 AC_ARG_ENABLE([debug-kmem],
248 [AS_HELP_STRING([--enable-debug-kmem],
249 [Enable basic kmem accounting @<:@default=yes@:>@])],
251 [enable_debug_kmem=yes])
253 AS_IF([test "x$enable_debug_kmem" = xyes],
254 [AC_DEFINE([DEBUG_KMEM], [1],
255 [Define to 1 to enable basic kmem accounting])
256 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
258 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
259 AC_MSG_RESULT([$enable_debug_kmem])
263 dnl # Disabled by default it provides detailed memory tracking. This
264 dnl # feature also requires --enable-debug-kmem to be set. When enabled
265 dnl # not only will total bytes be tracked but also the location of every
266 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
267 dnl # addresses and where they were allocated will be dumped to the console.
268 dnl # Enabling this feature has a significant impact on performance but it
269 dnl # makes finding memory leaks pretty straight forward.
271 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
272 AC_ARG_ENABLE([debug-kmem-tracking],
273 [AS_HELP_STRING([--enable-debug-kmem-tracking],
274 [Enable detailed kmem tracking @<:@default=no@:>@])],
276 [enable_debug_kmem_tracking=no])
278 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
279 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
280 [Define to 1 to enable detailed kmem tracking])
281 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
283 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
284 AC_MSG_RESULT([$enable_debug_kmem_tracking])
288 dnl # SPL_LINUX_CONFTEST
290 AC_DEFUN([SPL_LINUX_CONFTEST], [
291 cat >conftest.c <<_ACEOF
297 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
299 m4_define([SPL_LANG_PROGRAM], [
304 dnl Do *not* indent the following line: there may be CPP directives.
305 dnl Don't move the `;' right after for the same reason.
313 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
315 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
316 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
317 rm -Rf build && mkdir -p build
318 echo "obj-m := conftest.o" >build/Makefile
320 [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])],
322 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
328 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
330 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
331 [SPL_LINUX_COMPILE_IFELSE(
332 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
334 [test -s build/conftest.o],
339 dnl # SPL_LINUX_CONFIG
341 AC_DEFUN([SPL_LINUX_CONFIG],
342 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
343 SPL_LINUX_TRY_COMPILE([
344 #ifndef AUTOCONF_INCLUDED
345 #include <linux/config.h>
349 #error CONFIG_$1 not #defined
361 dnl # SPL_CHECK_SYMBOL_EXPORT
362 dnl # check symbol exported or not
364 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
365 [AC_MSG_CHECKING([whether symbol $1 is exported])
366 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
367 $LINUX_OBJ/Module*.symvers 2>/dev/null
369 if test $rc -ne 0; then
372 grep -q -E "EXPORT_SYMBOL.*($1)" \
373 "$LINUX_OBJ/$file" 2>/dev/null
375 if test $rc -eq 0; then
380 if test $export -eq 0; then
394 dnl # SPL_CHECK_HEADER
395 dnl # check whether header exists and define HAVE_$2_HEADER
397 AC_DEFUN([SPL_CHECK_HEADER],
398 [AC_MSG_CHECKING([whether header $1 exists])
399 SPL_LINUX_TRY_COMPILE([
404 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
414 dnl # Use the atomic implemenation based on global spinlocks. This
415 dnl # should only be needed by 32-bit kernels which do not provide
416 dnl # the atomic64_* API. It may be optionally enabled as a fallback
417 dnl # if problems are observed with the direct mapping to the native
418 dnl # Linux atomic operations. You may not disable atomic spinlocks
419 dnl # if you kernel does not an atomic64_* API.
421 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
422 AC_ARG_ENABLE([atomic-spinlocks],
423 [AS_HELP_STRING([--enable-atomic-spinlocks],
424 [Atomic types use spinlocks @<:@default=check@:>@])],
426 [enable_atomic_spinlocks=check])
428 SPL_LINUX_TRY_COMPILE([
429 #include <asm/atomic.h>
434 AC_DEFINE(HAVE_ATOMIC64_T, 1,
435 [kernel defines atomic64_t])
440 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
441 AS_IF([test "x$have_atomic64_t" = xyes], [
442 enable_atomic_spinlocks=no
444 enable_atomic_spinlocks=yes
448 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
449 AC_DEFINE([ATOMIC_SPINLOCK], [1],
450 [Atomic types use spinlocks])
452 AS_IF([test "x$have_atomic64_t" = xno], [
454 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
458 AC_MSG_CHECKING([whether atomic types use spinlocks])
459 AC_MSG_RESULT([$enable_atomic_spinlocks])
461 AC_MSG_CHECKING([whether kernel defines atomic64_t])
462 AC_MSG_RESULT([$have_atomic64_t])
466 dnl # 2.6.24 API change,
467 dnl # check if atomic64_cmpxchg is defined
469 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
470 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
471 SPL_LINUX_TRY_COMPILE([
472 #include <asm/atomic.h>
474 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
477 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
478 [kernel defines atomic64_cmpxchg])
485 dnl # 2.6.24 API change,
486 dnl # check if atomic64_xchg is defined
488 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
489 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
490 SPL_LINUX_TRY_COMPILE([
491 #include <asm/atomic.h>
493 atomic64_xchg((atomic64_t *)NULL, 0);
496 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
497 [kernel defines atomic64_xchg])
504 dnl # 2.6.24 API change,
505 dnl # check if uintptr_t typedef is defined
507 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
508 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
509 SPL_LINUX_TRY_COMPILE([
510 #include <linux/types.h>
515 AC_DEFINE(HAVE_UINTPTR_T, 1,
516 [kernel defines uintptr_t])
523 dnl # 2.6.20 API change,
524 dnl # INIT_WORK use 2 args and not store data inside
526 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
527 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
528 SPL_LINUX_TRY_COMPILE([
529 #include <linux/workqueue.h>
531 struct work_struct work;
532 INIT_WORK(&work, NULL, NULL);
535 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
536 [INIT_WORK wants 3 args])
543 dnl # 2.6.21 API change,
544 dnl # 'register_sysctl_table' use only one argument instead of two
546 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
547 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
548 SPL_LINUX_TRY_COMPILE([
549 #include <linux/sysctl.h>
551 return register_sysctl_table(NULL,0);
554 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
555 [register_sysctl_table() wants 2 args])
562 dnl # 2.6.23 API change
563 dnl # Old set_shrinker API replaced with register_shrinker
565 AC_DEFUN([SPL_AC_SET_SHRINKER], [
566 AC_MSG_CHECKING([whether set_shrinker() available])
567 SPL_LINUX_TRY_COMPILE([
568 #include <linux/mm.h>
570 return set_shrinker(DEFAULT_SEEKS, NULL);
573 AC_DEFINE(HAVE_SET_SHRINKER, 1,
574 [set_shrinker() available])
581 dnl # 2.6.25 API change,
582 dnl # struct path entry added to struct nameidata
584 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
585 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
586 SPL_LINUX_TRY_COMPILE([
587 #include <linux/namei.h>
592 nd.path.dentry = NULL;
595 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
596 [struct path used in struct nameidata])
603 dnl # Custom SPL patch may export this system it is not required
605 AC_DEFUN([SPL_AC_TASK_CURR], [
606 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
607 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
612 dnl # 2.6.19 API change,
613 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
615 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
616 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
617 SPL_LINUX_TRY_COMPILE([
618 #include <linux/sysctl.h>
620 #ifndef CTL_UNNUMBERED
621 #error CTL_UNNUMBERED undefined
625 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
626 [unnumbered sysctl support exists])
633 dnl # 2.6.16 API change.
634 dnl # Check if 'fls64()' is available
636 AC_DEFUN([SPL_AC_FLS64],
637 [AC_MSG_CHECKING([whether fls64() is available])
638 SPL_LINUX_TRY_COMPILE([
639 #include <linux/bitops.h>
644 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
651 dnl # 2.6.18 API change, check whether device_create() is available.
652 dnl # Device_create() was introduced in 2.6.18 and depricated
653 dnl # class_device_create() which was fully removed in 2.6.26.
655 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
656 SPL_CHECK_SYMBOL_EXPORT(
658 [drivers/base/core.c],
659 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
660 [device_create() is available])],
665 dnl # 2.6.27 API change,
666 dnl # device_create() uses 5 args, new 'drvdata' argument.
668 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
669 AC_MSG_CHECKING([whether device_create() wants 5 args])
670 tmp_flags="$EXTRA_KCFLAGS"
671 EXTRA_KCFLAGS="-Werror"
672 SPL_LINUX_TRY_COMPILE([
673 #include <linux/device.h>
675 device_create(NULL, NULL, 0, NULL, "%d", 1);
678 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
679 [device_create wants 5 args])
683 EXTRA_KCFLAGS="$tmp_flags"
687 dnl # 2.6.13 API change, check whether class_device_create() is available.
688 dnl # Class_device_create() was introduced in 2.6.13 and depricated
689 dnl # class_simple_device_add() which was fully removed in 2.6.13.
691 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
692 SPL_CHECK_SYMBOL_EXPORT(
693 [class_device_create],
694 [drivers/base/class.c],
695 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
696 [class_device_create() is available])],
701 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
703 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
704 SPL_CHECK_SYMBOL_EXPORT(
705 [set_normalized_timespec],
707 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
708 [set_normalized_timespec() is available as export])],
713 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
714 dnl # previously it was available in time.h as an inline.
716 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
717 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
718 SPL_LINUX_TRY_COMPILE([
719 #include <linux/time.h>
720 void set_normalized_timespec(struct timespec *ts,
721 time_t sec, long nsec) { }
728 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
729 [set_normalized_timespec() is available as inline])
734 dnl # 2.6.18 API change,
735 dnl # timespec_sub() inline function available in linux/time.h
737 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
738 AC_MSG_CHECKING([whether timespec_sub() is available])
739 SPL_LINUX_TRY_COMPILE([
740 #include <linux/time.h>
742 struct timespec a, b, c = { 0 };
743 c = timespec_sub(a, b);
746 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
753 dnl # 2.6.19 API change,
754 dnl # check if init_utsname() is available in linux/utsname.h
756 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
757 AC_MSG_CHECKING([whether init_utsname() is available])
758 SPL_LINUX_TRY_COMPILE([
759 #include <linux/utsname.h>
761 struct new_utsname *a = init_utsname();
764 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
771 dnl # 2.6.26 API change,
772 dnl # definition of struct fdtable relocated to linux/fdtable.h
774 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
775 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
779 dnl # 2.6.14 API change,
780 dnl # check whether 'files_fdtable()' exists
782 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
783 AC_MSG_CHECKING([whether files_fdtable() is available])
784 SPL_LINUX_TRY_COMPILE([
785 #include <linux/sched.h>
786 #include <linux/file.h>
787 #ifdef HAVE_FDTABLE_HEADER
788 #include <linux/fdtable.h>
791 struct files_struct *files = current->files;
792 struct fdtable *fdt = files_fdtable(files);
795 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
802 dnl # 2.6.18 API change,
803 dnl # added linux/uaccess.h
805 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
806 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
810 dnl # 2.6.12 API change,
811 dnl # check whether 'kmalloc_node()' is available.
813 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
814 AC_MSG_CHECKING([whether kmalloc_node() is available])
815 SPL_LINUX_TRY_COMPILE([
816 #include <linux/slab.h>
818 void *a = kmalloc_node(1, GFP_KERNEL, 0);
821 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
828 dnl # 2.6.9 API change,
829 dnl # check whether 'monotonic_clock()' is available it may
830 dnl # be available for some archs but not others.
832 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
833 SPL_CHECK_SYMBOL_EXPORT(
836 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
837 [monotonic_clock() is available])],
842 dnl # 2.6.16 API change,
843 dnl # check whether 'struct inode' has i_mutex
845 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
846 AC_MSG_CHECKING([whether struct inode has i_mutex])
847 SPL_LINUX_TRY_COMPILE([
848 #include <linux/fs.h>
849 #include <linux/mutex.h>
852 mutex_init(&i.i_mutex);
855 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
862 dnl # 2.6.29 API change,
863 dnl # Adaptive mutexs introduced.
865 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
866 AC_MSG_CHECKING([whether struct mutex has owner])
867 SPL_LINUX_TRY_COMPILE([
868 #include <linux/mutex.h>
874 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
881 dnl # 2.6.18 API change,
882 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
883 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
884 dnl # if the mutex validator is disabled or otherwise unavailable.
886 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
887 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
888 SPL_LINUX_TRY_COMPILE([
889 #include <linux/mutex.h>
893 mutex_lock_nested(&mutex, 0);
896 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
897 [mutex_lock_nested() is available])
904 dnl # 2.6.22 API change,
905 dnl # First introduced 'div64_64()' in lib/div64.c
907 AC_DEFUN([SPL_AC_DIV64_64], [
908 SPL_CHECK_SYMBOL_EXPORT(
911 [AC_DEFINE(HAVE_DIV64_64, 1,
912 [div64_64() is available])],
917 dnl # 2.6.26 API change,
918 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
920 AC_DEFUN([SPL_AC_DIV64_U64], [
921 SPL_CHECK_SYMBOL_EXPORT(
924 [AC_DEFINE(HAVE_DIV64_U64, 1,
925 [div64_u64() is available])],
930 dnl # 2.6.27 API change,
931 dnl # on_each_cpu() uses 3 args, no 'retry' argument
933 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
934 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
935 SPL_LINUX_TRY_COMPILE([
936 #include <linux/smp.h>
938 on_each_cpu(NULL, NULL, 0);
941 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
942 [on_each_cpu wants 3 args])
949 dnl # 2.6.18 API change,
950 dnl # kallsyms_lookup_name no longer exported
952 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
953 SPL_CHECK_SYMBOL_EXPORT(
954 [kallsyms_lookup_name],
956 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
957 [kallsyms_lookup_name() is available])],
962 dnl # Proposed API change,
963 dnl # This symbol is not available in stock kernels. You may build a
964 dnl # custom kernel with the *-spl-export-symbols.patch which will export
965 dnl # these symbols for use. If your already rolling a custom kernel for
966 dnl # your environment this is recommended.
968 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
969 SPL_CHECK_SYMBOL_EXPORT(
972 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
973 [get_vmalloc_info() is available])],
978 dnl # 2.6.17 API change
979 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
980 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
981 dnl # were exported in 2.6.17 for use by modules which was consistent with
982 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
983 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
984 dnl # were dropped entirely leaving modules no way to directly iterate over
985 dnl # the zone list. Because we need access to the zone helpers we check
986 dnl # if the kernel contains the old or new implementation. Then we check
987 dnl # to see if the symbols we need for each version are available. If they
988 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
990 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
991 AC_MSG_CHECKING([whether symbol *_pgdat exist])
992 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
994 if test $rc -eq 0; then
996 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1003 dnl # Proposed API change,
1004 dnl # This symbol is not available in stock kernels. You may build a
1005 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1006 dnl # these symbols for use. If your already rolling a custom kernel for
1007 dnl # your environment this is recommended.
1009 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1010 SPL_CHECK_SYMBOL_EXPORT(
1011 [first_online_pgdat],
1013 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1014 [first_online_pgdat() is available])],
1019 dnl # Proposed API change,
1020 dnl # This symbol is not available in stock kernels. You may build a
1021 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1022 dnl # these symbols for use. If your already rolling a custom kernel for
1023 dnl # your environment this is recommended.
1025 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1026 SPL_CHECK_SYMBOL_EXPORT(
1027 [next_online_pgdat],
1029 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1030 [next_online_pgdat() is available])],
1035 dnl # Proposed API change,
1036 dnl # This symbol is not available in stock kernels. You may build a
1037 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1038 dnl # these symbols for use. If your already rolling a custom kernel for
1039 dnl # your environment this is recommended.
1041 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1042 SPL_CHECK_SYMBOL_EXPORT(
1045 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1046 [next_zone() is available])],
1051 dnl # 2.6.17 API change,
1052 dnl # See SPL_AC_PGDAT_HELPERS for details.
1054 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1055 SPL_CHECK_SYMBOL_EXPORT(
1058 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1059 [pgdat_list is available])],
1064 dnl # 2.6.18 API change,
1065 dnl # First introduced global_page_state() support as an inline.
1067 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1068 AC_MSG_CHECKING([whether global_page_state() is available])
1069 SPL_LINUX_TRY_COMPILE([
1070 #include <linux/mm.h>
1072 unsigned long state;
1073 state = global_page_state(0);
1076 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1077 [global_page_state() is available])
1084 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1085 dnl # Public global zone stats now include a free page count. However
1086 dnl # the enumerated names of the counters have changed since this API
1087 dnl # was introduced. We need to deduce the corrent name to use. This
1088 dnl # replaces the priviate get_zone_counts() interface.
1090 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1091 dnl # is 2.6.30 as of when this was written.
1093 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1094 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1095 SPL_LINUX_TRY_COMPILE([
1096 #include <linux/mm.h>
1098 enum zone_stat_item zsi;
1099 zsi = NR_FREE_PAGES;
1102 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1103 [Page state NR_FREE_PAGES is available])
1110 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1111 dnl # Public global zone stats now include an inactive page count. However
1112 dnl # the enumerated names of the counters have changed since this API
1113 dnl # was introduced. We need to deduce the corrent name to use. This
1114 dnl # replaces the priviate get_zone_counts() interface.
1116 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1117 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1118 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1120 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1121 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1122 SPL_LINUX_TRY_COMPILE([
1123 #include <linux/mm.h>
1125 enum zone_stat_item zsi;
1129 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1130 [Page state NR_INACTIVE is available])
1135 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1136 SPL_LINUX_TRY_COMPILE([
1137 #include <linux/mm.h>
1139 enum zone_stat_item zsi;
1140 zsi = NR_INACTIVE_ANON;
1143 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1144 [Page state NR_INACTIVE_ANON is available])
1149 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1150 SPL_LINUX_TRY_COMPILE([
1151 #include <linux/mm.h>
1153 enum zone_stat_item zsi;
1154 zsi = NR_INACTIVE_FILE;
1157 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1158 [Page state NR_INACTIVE_FILE is available])
1165 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1166 dnl # Public global zone stats now include an active page count. However
1167 dnl # the enumerated names of the counters have changed since this API
1168 dnl # was introduced. We need to deduce the corrent name to use. This
1169 dnl # replaces the priviate get_zone_counts() interface.
1171 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1172 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1173 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1175 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1176 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1177 SPL_LINUX_TRY_COMPILE([
1178 #include <linux/mm.h>
1180 enum zone_stat_item zsi;
1184 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1185 [Page state NR_ACTIVE is available])
1190 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1191 SPL_LINUX_TRY_COMPILE([
1192 #include <linux/mm.h>
1194 enum zone_stat_item zsi;
1195 zsi = NR_ACTIVE_ANON;
1198 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1199 [Page state NR_ACTIVE_ANON is available])
1204 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1205 SPL_LINUX_TRY_COMPILE([
1206 #include <linux/mm.h>
1208 enum zone_stat_item zsi;
1209 zsi = NR_ACTIVE_FILE;
1212 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1213 [Page state NR_ACTIVE_FILE is available])
1220 dnl # Proposed API change for legacy kernels.
1221 dnl # This symbol is not available in older kernels. For kernels post
1222 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1223 dnl # page state information. This symbol is only used in legacy kernels
1224 dnl # any only as a last resort.
1226 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1227 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1228 SPL_LINUX_TRY_COMPILE([
1230 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1231 #error "global_page_state needs NR_FREE_PAGES"
1234 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1235 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1236 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1237 #error "global_page_state needs NR_ACTIVE*"
1240 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1241 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1242 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1243 #error "global_page_state needs NR_INACTIVE*"
1249 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1250 [get_zone_counts() is needed])
1252 SPL_CHECK_SYMBOL_EXPORT(
1255 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1256 [get_zone_counts() is available])],
1262 dnl # Symbol available in RHEL kernels not in stock kernels.
1264 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1265 SPL_CHECK_SYMBOL_EXPORT(
1268 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1269 [set_fs_pwd() is available])],
1274 dnl # 2.6.25 API change,
1275 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1277 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1278 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1279 SPL_LINUX_TRY_COMPILE([
1280 #include <linux/sched.h>
1281 #include <linux/fs_struct.h>
1283 set_fs_pwd(NULL, NULL);
1286 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1287 [set_fs_pwd() wants 2 args])
1294 dnl # SLES API change, never adopted in mainline,
1295 dnl # Third 'struct vfsmount *' argument removed.
1297 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1298 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1299 SPL_LINUX_TRY_COMPILE([
1300 #include <linux/fs.h>
1302 vfs_unlink(NULL, NULL);
1305 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1306 [vfs_unlink() wants 2 args])
1313 dnl # SLES API change, never adopted in mainline,
1314 dnl # Third and sixth 'struct vfsmount *' argument removed.
1316 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1317 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1318 SPL_LINUX_TRY_COMPILE([
1319 #include <linux/fs.h>
1321 vfs_rename(NULL, NULL, NULL, NULL);
1324 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1325 [vfs_rename() wants 4 args])
1332 dnl # 2.6.29 API change,
1333 dnl # check whether 'struct cred' exists
1335 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1336 AC_MSG_CHECKING([whether struct cred exists])
1337 SPL_LINUX_TRY_COMPILE([
1338 #include <linux/cred.h>
1344 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1351 dnl # Custom SPL patch may export this symbol.
1353 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1354 SPL_CHECK_SYMBOL_EXPORT(
1357 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1358 [groups_search() is available])],
1363 dnl # 2.6.x API change,
1364 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1366 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1367 SPL_CHECK_SYMBOL_EXPORT(
1368 [__put_task_struct],
1370 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1371 [__put_task_struct() is available])],