1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
12 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
13 dnl # compiler options are added by the kernel build system.
14 abs_srcdir=`readlink -f ${srcdir}`
15 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes -Werror"
16 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir}/include"
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -include ${abs_srcdir}/spl_config.h"
19 if test "${LINUX_OBJ}" != "${LINUX}"; then
20 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
23 AC_SUBST(KERNELMAKE_PARAMS)
24 AC_SUBST(KERNELCPPFLAGS)
28 SPL_AC_DEBUG_KMEM_TRACKING
29 SPL_AC_ATOMIC_SPINLOCK
30 SPL_AC_TYPE_ATOMIC64_CMPXCHG
31 SPL_AC_TYPE_ATOMIC64_XCHG
33 SPL_AC_3ARGS_INIT_WORK
34 SPL_AC_2ARGS_REGISTER_SYSCTL
36 SPL_AC_PATH_IN_NAMEIDATA
41 SPL_AC_5ARGS_DEVICE_CREATE
42 SPL_AC_CLASS_DEVICE_CREATE
43 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
44 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
51 SPL_AC_MONOTONIC_CLOCK
54 SPL_AC_MUTEX_LOCK_NESTED
57 SPL_AC_3ARGS_ON_EACH_CPU
58 SPL_AC_KALLSYMS_LOOKUP_NAME
59 SPL_AC_GET_VMALLOC_INFO
61 SPL_AC_FIRST_ONLINE_PGDAT
62 SPL_AC_NEXT_ONLINE_PGDAT
65 SPL_AC_GLOBAL_PAGE_STATE
66 SPL_AC_ZONE_STAT_ITEM_FREE
67 SPL_AC_ZONE_STAT_ITEM_INACTIVE
68 SPL_AC_ZONE_STAT_ITEM_ACTIVE
69 SPL_AC_GET_ZONE_COUNTS
71 SPL_AC_2ARGS_SET_FS_PWD
72 SPL_AC_2ARGS_VFS_UNLINK
73 SPL_AC_4ARGS_VFS_RENAME
76 SPL_AC_PUT_TASK_STRUCT
77 SPL_AC_5ARGS_PROC_HANDLER
80 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
81 modpost=$LINUX/scripts/Makefile.modpost
82 AC_MSG_CHECKING([kernel file name for module symbols])
83 if test -f "$modpost"; then
84 if grep -q Modules.symvers $modpost; then
85 LINUX_SYMBOLS=Modules.symvers
87 LINUX_SYMBOLS=Module.symvers
92 AC_MSG_RESULT($LINUX_SYMBOLS)
93 AC_SUBST(LINUX_SYMBOLS)
96 AC_DEFUN([SPL_AC_KERNEL], [
98 AS_HELP_STRING([--with-linux=PATH],
99 [Path to kernel source]),
100 [kernelsrc="$withval"])
102 AC_ARG_WITH([linux-obj],
103 AS_HELP_STRING([--with-linux-obj=PATH],
104 [Path to kernel build objects]),
105 [kernelbuild="$withval"])
107 AC_MSG_CHECKING([kernel source directory])
108 if test -z "$kernelsrc"; then
109 headersdir="/lib/modules/$(uname -r)/build"
110 if test -e "$headersdir"; then
111 sourcelink=$(readlink -f "$headersdir")
113 sourcelink=$(ls -1d /usr/src/kernels/* \
115 2>/dev/null | grep -v obj | tail -1)
118 if test -e ${sourcelink}; then
119 kernelsrc=`readlink -f ${sourcelink}`
121 AC_MSG_RESULT([Not found])
123 *** Please specify the location of the kernel source
124 *** with the '--with-linux=PATH' option])
127 if test "$kernelsrc" = "NONE"; then
132 AC_MSG_RESULT([$kernelsrc])
133 AC_MSG_CHECKING([kernel build directory])
134 if test -z "$kernelbuild"; then
135 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
136 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
137 elif test -d ${kernelsrc}-obj/`arch`/default; then
138 kernelbuild=${kernelsrc}-obj/`arch`/default
139 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
140 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
142 kernelbuild=${kernelsrc}
145 AC_MSG_RESULT([$kernelbuild])
147 AC_MSG_CHECKING([kernel source version])
148 if test -r $kernelbuild/include/linux/version.h &&
149 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
151 kernsrcver=`(echo "#include <linux/version.h>";
152 echo "kernsrcver=UTS_RELEASE") |
153 cpp -I $kernelbuild/include |
154 grep "^kernsrcver=" | cut -d \" -f 2`
156 elif test -r $kernelbuild/include/linux/utsrelease.h &&
157 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
159 kernsrcver=`(echo "#include <linux/utsrelease.h>";
160 echo "kernsrcver=UTS_RELEASE") |
161 cpp -I $kernelbuild/include |
162 grep "^kernsrcver=" | cut -d \" -f 2`
165 if test -z "$kernsrcver"; then
166 AC_MSG_RESULT([Not found])
168 *** Cannot determine the version of the linux kernel source.
169 *** Please prepare the kernel before running this script])
172 AC_MSG_RESULT([$kernsrcver])
175 LINUX_OBJ=${kernelbuild}
176 LINUX_VERSION=${kernsrcver}
180 AC_SUBST(LINUX_VERSION)
182 SPL_AC_MODULE_SYMVERS
186 dnl # Default SPL user configuration
188 AC_DEFUN([SPL_AC_CONFIG_USER], [])
190 AC_DEFUN([SPL_AC_LICENSE], [
191 AC_MSG_CHECKING([spl license])
193 AC_MSG_RESULT([$LICENSE])
194 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
198 AC_DEFUN([SPL_AC_CONFIG], [
200 AC_ARG_WITH([config],
201 AS_HELP_STRING([--with-config=CONFIG],
202 [Config file 'kernel|user|all|srpm']),
203 [SPL_CONFIG="$withval"])
205 AC_MSG_CHECKING([spl config])
206 AC_MSG_RESULT([$SPL_CONFIG]);
209 case "$SPL_CONFIG" in
210 kernel) SPL_AC_CONFIG_KERNEL ;;
211 user) SPL_AC_CONFIG_USER ;;
212 all) SPL_AC_CONFIG_KERNEL
213 SPL_AC_CONFIG_USER ;;
216 AC_MSG_RESULT([Error!])
217 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
218 user kernel|user|all|srpm]) ;;
221 AM_CONDITIONAL([CONFIG_USER],
222 [test "$SPL_CONFIG" = user] ||
223 [test "$SPL_CONFIG" = all])
224 AM_CONDITIONAL([CONFIG_KERNEL],
225 [test "$SPL_CONFIG" = kernel] ||
226 [test "$SPL_CONFIG" = all])
230 dnl # Enable if the SPL should be compiled with internal debugging enabled.
231 dnl # By default this support is disabled.
233 AC_DEFUN([SPL_AC_DEBUG], [
234 AC_ARG_ENABLE([debug],
235 [AS_HELP_STRING([--enable-debug],
236 [Enable generic debug support @<:@default=no@:>@])],
240 AS_IF([test "x$enable_debug" = xyes],
241 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"],
242 [KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"])
244 AC_MSG_CHECKING([whether debugging is enabled])
245 AC_MSG_RESULT([$enable_debug])
249 dnl # Enabled by default it provides a minimal level of memory tracking.
250 dnl # A total count of bytes allocated is kept for each alloc and free.
251 dnl # Then at module unload time a report to the console will be printed
252 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
253 dnl # and provide an easy way to inspect the kmem based slab.
255 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
256 AC_ARG_ENABLE([debug-kmem],
257 [AS_HELP_STRING([--enable-debug-kmem],
258 [Enable basic kmem accounting @<:@default=yes@:>@])],
260 [enable_debug_kmem=yes])
262 AS_IF([test "x$enable_debug_kmem" = xyes],
263 [AC_DEFINE([DEBUG_KMEM], [1],
264 [Define to 1 to enable basic kmem accounting])
265 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
267 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
268 AC_MSG_RESULT([$enable_debug_kmem])
272 dnl # Disabled by default it provides detailed memory tracking. This
273 dnl # feature also requires --enable-debug-kmem to be set. When enabled
274 dnl # not only will total bytes be tracked but also the location of every
275 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
276 dnl # addresses and where they were allocated will be dumped to the console.
277 dnl # Enabling this feature has a significant impact on performance but it
278 dnl # makes finding memory leaks pretty straight forward.
280 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
281 AC_ARG_ENABLE([debug-kmem-tracking],
282 [AS_HELP_STRING([--enable-debug-kmem-tracking],
283 [Enable detailed kmem tracking @<:@default=no@:>@])],
285 [enable_debug_kmem_tracking=no])
287 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
288 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
289 [Define to 1 to enable detailed kmem tracking])
290 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
292 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
293 AC_MSG_RESULT([$enable_debug_kmem_tracking])
297 dnl # SPL_LINUX_CONFTEST
299 AC_DEFUN([SPL_LINUX_CONFTEST], [
300 cat >conftest.c <<_ACEOF
306 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
308 m4_define([SPL_LANG_PROGRAM], [
313 dnl Do *not* indent the following line: there may be CPP directives.
314 dnl Don't move the `;' right after for the same reason.
322 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
324 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
325 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
326 rm -Rf build && mkdir -p build
327 echo "obj-m := conftest.o" >build/Makefile
329 [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])],
331 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
337 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
339 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
340 [SPL_LINUX_COMPILE_IFELSE(
341 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
343 [test -s build/conftest.o],
348 dnl # SPL_LINUX_CONFIG
350 AC_DEFUN([SPL_LINUX_CONFIG],
351 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
352 SPL_LINUX_TRY_COMPILE([
353 #ifndef AUTOCONF_INCLUDED
354 #include <linux/config.h>
358 #error CONFIG_$1 not #defined
370 dnl # SPL_CHECK_SYMBOL_EXPORT
371 dnl # check symbol exported or not
373 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
374 [AC_MSG_CHECKING([whether symbol $1 is exported])
375 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
376 $LINUX_OBJ/Module*.symvers 2>/dev/null
378 if test $rc -ne 0; then
381 grep -q -E "EXPORT_SYMBOL.*($1)" \
382 "$LINUX_OBJ/$file" 2>/dev/null
384 if test $rc -eq 0; then
389 if test $export -eq 0; then
403 dnl # SPL_CHECK_HEADER
404 dnl # check whether header exists and define HAVE_$2_HEADER
406 AC_DEFUN([SPL_CHECK_HEADER],
407 [AC_MSG_CHECKING([whether header $1 exists])
408 SPL_LINUX_TRY_COMPILE([
413 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
423 dnl # Use the atomic implemenation based on global spinlocks. This
424 dnl # should only be needed by 32-bit kernels which do not provide
425 dnl # the atomic64_* API. It may be optionally enabled as a fallback
426 dnl # if problems are observed with the direct mapping to the native
427 dnl # Linux atomic operations. You may not disable atomic spinlocks
428 dnl # if you kernel does not an atomic64_* API.
430 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
431 AC_ARG_ENABLE([atomic-spinlocks],
432 [AS_HELP_STRING([--enable-atomic-spinlocks],
433 [Atomic types use spinlocks @<:@default=check@:>@])],
435 [enable_atomic_spinlocks=check])
437 SPL_LINUX_TRY_COMPILE([
438 #include <asm/atomic.h>
443 AC_DEFINE(HAVE_ATOMIC64_T, 1,
444 [kernel defines atomic64_t])
449 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
450 AS_IF([test "x$have_atomic64_t" = xyes], [
451 enable_atomic_spinlocks=no
453 enable_atomic_spinlocks=yes
457 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
458 AC_DEFINE([ATOMIC_SPINLOCK], [1],
459 [Atomic types use spinlocks])
461 AS_IF([test "x$have_atomic64_t" = xno], [
463 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
467 AC_MSG_CHECKING([whether atomic types use spinlocks])
468 AC_MSG_RESULT([$enable_atomic_spinlocks])
470 AC_MSG_CHECKING([whether kernel defines atomic64_t])
471 AC_MSG_RESULT([$have_atomic64_t])
475 dnl # 2.6.24 API change,
476 dnl # check if atomic64_cmpxchg is defined
478 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
479 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
480 SPL_LINUX_TRY_COMPILE([
481 #include <asm/atomic.h>
483 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
486 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
487 [kernel defines atomic64_cmpxchg])
494 dnl # 2.6.24 API change,
495 dnl # check if atomic64_xchg is defined
497 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
498 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
499 SPL_LINUX_TRY_COMPILE([
500 #include <asm/atomic.h>
502 atomic64_xchg((atomic64_t *)NULL, 0);
505 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
506 [kernel defines atomic64_xchg])
513 dnl # 2.6.24 API change,
514 dnl # check if uintptr_t typedef is defined
516 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
517 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
518 SPL_LINUX_TRY_COMPILE([
519 #include <linux/types.h>
524 AC_DEFINE(HAVE_UINTPTR_T, 1,
525 [kernel defines uintptr_t])
532 dnl # 2.6.20 API change,
533 dnl # INIT_WORK use 2 args and not store data inside
535 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
536 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
537 SPL_LINUX_TRY_COMPILE([
538 #include <linux/workqueue.h>
540 struct work_struct work;
541 INIT_WORK(&work, NULL, NULL);
544 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
545 [INIT_WORK wants 3 args])
552 dnl # 2.6.21 API change,
553 dnl # 'register_sysctl_table' use only one argument instead of two
555 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
556 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
557 SPL_LINUX_TRY_COMPILE([
558 #include <linux/sysctl.h>
560 return register_sysctl_table(NULL,0);
563 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
564 [register_sysctl_table() wants 2 args])
571 dnl # 2.6.23 API change
572 dnl # Old set_shrinker API replaced with register_shrinker
574 AC_DEFUN([SPL_AC_SET_SHRINKER], [
575 AC_MSG_CHECKING([whether set_shrinker() available])
576 SPL_LINUX_TRY_COMPILE([
577 #include <linux/mm.h>
579 return set_shrinker(DEFAULT_SEEKS, NULL);
582 AC_DEFINE(HAVE_SET_SHRINKER, 1,
583 [set_shrinker() available])
590 dnl # 2.6.25 API change,
591 dnl # struct path entry added to struct nameidata
593 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
594 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
595 SPL_LINUX_TRY_COMPILE([
596 #include <linux/namei.h>
601 nd.path.dentry = NULL;
604 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
605 [struct path used in struct nameidata])
612 dnl # Custom SPL patch may export this system it is not required
614 AC_DEFUN([SPL_AC_TASK_CURR], [
615 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
616 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
621 dnl # 2.6.19 API change,
622 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
624 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
625 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
626 SPL_LINUX_TRY_COMPILE([
627 #include <linux/sysctl.h>
629 #ifndef CTL_UNNUMBERED
630 #error CTL_UNNUMBERED undefined
634 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
635 [unnumbered sysctl support exists])
642 dnl # 2.6.16 API change.
643 dnl # Check if 'fls64()' is available
645 AC_DEFUN([SPL_AC_FLS64],
646 [AC_MSG_CHECKING([whether fls64() is available])
647 SPL_LINUX_TRY_COMPILE([
648 #include <linux/bitops.h>
653 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
660 dnl # 2.6.18 API change, check whether device_create() is available.
661 dnl # Device_create() was introduced in 2.6.18 and depricated
662 dnl # class_device_create() which was fully removed in 2.6.26.
664 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
665 SPL_CHECK_SYMBOL_EXPORT(
667 [drivers/base/core.c],
668 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
669 [device_create() is available])],
674 dnl # 2.6.27 API change,
675 dnl # device_create() uses 5 args, new 'drvdata' argument.
677 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
678 AC_MSG_CHECKING([whether device_create() wants 5 args])
679 tmp_flags="$EXTRA_KCFLAGS"
680 EXTRA_KCFLAGS="-Werror"
681 SPL_LINUX_TRY_COMPILE([
682 #include <linux/device.h>
684 device_create(NULL, NULL, 0, NULL, "%d", 1);
687 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
688 [device_create wants 5 args])
692 EXTRA_KCFLAGS="$tmp_flags"
696 dnl # 2.6.13 API change, check whether class_device_create() is available.
697 dnl # Class_device_create() was introduced in 2.6.13 and depricated
698 dnl # class_simple_device_add() which was fully removed in 2.6.13.
700 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
701 SPL_CHECK_SYMBOL_EXPORT(
702 [class_device_create],
703 [drivers/base/class.c],
704 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
705 [class_device_create() is available])],
710 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
712 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
713 SPL_CHECK_SYMBOL_EXPORT(
714 [set_normalized_timespec],
716 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
717 [set_normalized_timespec() is available as export])],
722 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
723 dnl # previously it was available in time.h as an inline.
725 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
726 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
727 SPL_LINUX_TRY_COMPILE([
728 #include <linux/time.h>
729 void set_normalized_timespec(struct timespec *ts,
730 time_t sec, long nsec) { }
737 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
738 [set_normalized_timespec() is available as inline])
743 dnl # 2.6.18 API change,
744 dnl # timespec_sub() inline function available in linux/time.h
746 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
747 AC_MSG_CHECKING([whether timespec_sub() is available])
748 SPL_LINUX_TRY_COMPILE([
749 #include <linux/time.h>
751 struct timespec a, b, c = { 0 };
752 c = timespec_sub(a, b);
755 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
762 dnl # 2.6.19 API change,
763 dnl # check if init_utsname() is available in linux/utsname.h
765 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
766 AC_MSG_CHECKING([whether init_utsname() is available])
767 SPL_LINUX_TRY_COMPILE([
768 #include <linux/utsname.h>
770 struct new_utsname *a = init_utsname();
773 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
780 dnl # 2.6.26 API change,
781 dnl # definition of struct fdtable relocated to linux/fdtable.h
783 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
784 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
788 dnl # 2.6.14 API change,
789 dnl # check whether 'files_fdtable()' exists
791 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
792 AC_MSG_CHECKING([whether files_fdtable() is available])
793 SPL_LINUX_TRY_COMPILE([
794 #include <linux/sched.h>
795 #include <linux/file.h>
796 #ifdef HAVE_FDTABLE_HEADER
797 #include <linux/fdtable.h>
800 struct files_struct *files = current->files;
801 struct fdtable *fdt = files_fdtable(files);
804 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
811 dnl # 2.6.18 API change,
812 dnl # added linux/uaccess.h
814 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
815 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
819 dnl # 2.6.12 API change,
820 dnl # check whether 'kmalloc_node()' is available.
822 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
823 AC_MSG_CHECKING([whether kmalloc_node() is available])
824 SPL_LINUX_TRY_COMPILE([
825 #include <linux/slab.h>
827 void *a = kmalloc_node(1, GFP_KERNEL, 0);
830 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
837 dnl # 2.6.9 API change,
838 dnl # check whether 'monotonic_clock()' is available it may
839 dnl # be available for some archs but not others.
841 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
842 SPL_CHECK_SYMBOL_EXPORT(
845 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
846 [monotonic_clock() is available])],
851 dnl # 2.6.16 API change,
852 dnl # check whether 'struct inode' has i_mutex
854 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
855 AC_MSG_CHECKING([whether struct inode has i_mutex])
856 SPL_LINUX_TRY_COMPILE([
857 #include <linux/fs.h>
858 #include <linux/mutex.h>
861 mutex_init(&i.i_mutex);
864 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
871 dnl # 2.6.29 API change,
872 dnl # Adaptive mutexs introduced.
874 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
875 AC_MSG_CHECKING([whether struct mutex has owner])
876 SPL_LINUX_TRY_COMPILE([
877 #include <linux/mutex.h>
883 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
890 dnl # 2.6.18 API change,
891 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
892 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
893 dnl # if the mutex validator is disabled or otherwise unavailable.
895 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
896 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
897 SPL_LINUX_TRY_COMPILE([
898 #include <linux/mutex.h>
902 mutex_lock_nested(&mutex, 0);
905 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
906 [mutex_lock_nested() is available])
913 dnl # 2.6.22 API change,
914 dnl # First introduced 'div64_64()' in lib/div64.c
916 AC_DEFUN([SPL_AC_DIV64_64], [
917 SPL_CHECK_SYMBOL_EXPORT(
920 [AC_DEFINE(HAVE_DIV64_64, 1,
921 [div64_64() is available])],
926 dnl # 2.6.26 API change,
927 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
929 AC_DEFUN([SPL_AC_DIV64_U64], [
930 SPL_CHECK_SYMBOL_EXPORT(
933 [AC_DEFINE(HAVE_DIV64_U64, 1,
934 [div64_u64() is available])],
939 dnl # 2.6.27 API change,
940 dnl # on_each_cpu() uses 3 args, no 'retry' argument
942 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
943 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
944 SPL_LINUX_TRY_COMPILE([
945 #include <linux/smp.h>
947 on_each_cpu(NULL, NULL, 0);
950 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
951 [on_each_cpu wants 3 args])
958 dnl # 2.6.18 API change,
959 dnl # kallsyms_lookup_name no longer exported
961 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
962 SPL_CHECK_SYMBOL_EXPORT(
963 [kallsyms_lookup_name],
965 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
966 [kallsyms_lookup_name() is available])],
971 dnl # Proposed API change,
972 dnl # This symbol is not available in stock kernels. You may build a
973 dnl # custom kernel with the *-spl-export-symbols.patch which will export
974 dnl # these symbols for use. If your already rolling a custom kernel for
975 dnl # your environment this is recommended.
977 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
978 SPL_CHECK_SYMBOL_EXPORT(
981 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
982 [get_vmalloc_info() is available])],
987 dnl # 2.6.17 API change
988 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
989 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
990 dnl # were exported in 2.6.17 for use by modules which was consistent with
991 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
992 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
993 dnl # were dropped entirely leaving modules no way to directly iterate over
994 dnl # the zone list. Because we need access to the zone helpers we check
995 dnl # if the kernel contains the old or new implementation. Then we check
996 dnl # to see if the symbols we need for each version are available. If they
997 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
999 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1000 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1001 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1003 if test $rc -eq 0; then
1004 AC_MSG_RESULT([yes])
1005 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1012 dnl # Proposed API change,
1013 dnl # This symbol is not available in stock kernels. You may build a
1014 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1015 dnl # these symbols for use. If your already rolling a custom kernel for
1016 dnl # your environment this is recommended.
1018 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1019 SPL_CHECK_SYMBOL_EXPORT(
1020 [first_online_pgdat],
1022 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1023 [first_online_pgdat() is available])],
1028 dnl # Proposed API change,
1029 dnl # This symbol is not available in stock kernels. You may build a
1030 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1031 dnl # these symbols for use. If your already rolling a custom kernel for
1032 dnl # your environment this is recommended.
1034 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1035 SPL_CHECK_SYMBOL_EXPORT(
1036 [next_online_pgdat],
1038 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1039 [next_online_pgdat() is available])],
1044 dnl # Proposed API change,
1045 dnl # This symbol is not available in stock kernels. You may build a
1046 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1047 dnl # these symbols for use. If your already rolling a custom kernel for
1048 dnl # your environment this is recommended.
1050 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1051 SPL_CHECK_SYMBOL_EXPORT(
1054 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1055 [next_zone() is available])],
1060 dnl # 2.6.17 API change,
1061 dnl # See SPL_AC_PGDAT_HELPERS for details.
1063 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1064 SPL_CHECK_SYMBOL_EXPORT(
1067 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1068 [pgdat_list is available])],
1073 dnl # 2.6.18 API change,
1074 dnl # First introduced global_page_state() support as an inline.
1076 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1077 AC_MSG_CHECKING([whether global_page_state() is available])
1078 SPL_LINUX_TRY_COMPILE([
1079 #include <linux/mm.h>
1081 unsigned long state;
1082 state = global_page_state(0);
1085 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1086 [global_page_state() is available])
1093 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1094 dnl # Public global zone stats now include a free page count. However
1095 dnl # the enumerated names of the counters have changed since this API
1096 dnl # was introduced. We need to deduce the corrent name to use. This
1097 dnl # replaces the priviate get_zone_counts() interface.
1099 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1100 dnl # is 2.6.30 as of when this was written.
1102 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1103 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1104 SPL_LINUX_TRY_COMPILE([
1105 #include <linux/mm.h>
1107 enum zone_stat_item zsi;
1108 zsi = NR_FREE_PAGES;
1111 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1112 [Page state NR_FREE_PAGES is available])
1119 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1120 dnl # Public global zone stats now include an inactive page count. However
1121 dnl # the enumerated names of the counters have changed since this API
1122 dnl # was introduced. We need to deduce the corrent name to use. This
1123 dnl # replaces the priviate get_zone_counts() interface.
1125 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1126 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1127 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1129 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1130 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1131 SPL_LINUX_TRY_COMPILE([
1132 #include <linux/mm.h>
1134 enum zone_stat_item zsi;
1138 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1139 [Page state NR_INACTIVE is available])
1144 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1145 SPL_LINUX_TRY_COMPILE([
1146 #include <linux/mm.h>
1148 enum zone_stat_item zsi;
1149 zsi = NR_INACTIVE_ANON;
1152 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1153 [Page state NR_INACTIVE_ANON is available])
1158 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1159 SPL_LINUX_TRY_COMPILE([
1160 #include <linux/mm.h>
1162 enum zone_stat_item zsi;
1163 zsi = NR_INACTIVE_FILE;
1166 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1167 [Page state NR_INACTIVE_FILE is available])
1174 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1175 dnl # Public global zone stats now include an active page count. However
1176 dnl # the enumerated names of the counters have changed since this API
1177 dnl # was introduced. We need to deduce the corrent name to use. This
1178 dnl # replaces the priviate get_zone_counts() interface.
1180 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1181 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1182 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1184 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1185 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1186 SPL_LINUX_TRY_COMPILE([
1187 #include <linux/mm.h>
1189 enum zone_stat_item zsi;
1193 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1194 [Page state NR_ACTIVE is available])
1199 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1200 SPL_LINUX_TRY_COMPILE([
1201 #include <linux/mm.h>
1203 enum zone_stat_item zsi;
1204 zsi = NR_ACTIVE_ANON;
1207 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1208 [Page state NR_ACTIVE_ANON is available])
1213 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1214 SPL_LINUX_TRY_COMPILE([
1215 #include <linux/mm.h>
1217 enum zone_stat_item zsi;
1218 zsi = NR_ACTIVE_FILE;
1221 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1222 [Page state NR_ACTIVE_FILE is available])
1229 dnl # Proposed API change for legacy kernels.
1230 dnl # This symbol is not available in older kernels. For kernels post
1231 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1232 dnl # page state information. This symbol is only used in legacy kernels
1233 dnl # any only as a last resort.
1235 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1236 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1237 SPL_LINUX_TRY_COMPILE([
1239 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1240 #error "global_page_state needs NR_FREE_PAGES"
1243 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1244 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1245 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1246 #error "global_page_state needs NR_ACTIVE*"
1249 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1250 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1251 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1252 #error "global_page_state needs NR_INACTIVE*"
1258 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1259 [get_zone_counts() is needed])
1261 SPL_CHECK_SYMBOL_EXPORT(
1264 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1265 [get_zone_counts() is available])],
1271 dnl # Symbol available in RHEL kernels not in stock kernels.
1273 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1274 SPL_CHECK_SYMBOL_EXPORT(
1277 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1278 [set_fs_pwd() is available])],
1283 dnl # 2.6.25 API change,
1284 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1286 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1287 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1288 SPL_LINUX_TRY_COMPILE([
1289 #include <linux/sched.h>
1290 #include <linux/fs_struct.h>
1292 set_fs_pwd(NULL, NULL);
1295 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1296 [set_fs_pwd() wants 2 args])
1303 dnl # SLES API change, never adopted in mainline,
1304 dnl # Third 'struct vfsmount *' argument removed.
1306 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1307 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1308 SPL_LINUX_TRY_COMPILE([
1309 #include <linux/fs.h>
1311 vfs_unlink(NULL, NULL);
1314 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1315 [vfs_unlink() wants 2 args])
1322 dnl # SLES API change, never adopted in mainline,
1323 dnl # Third and sixth 'struct vfsmount *' argument removed.
1325 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1326 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1327 SPL_LINUX_TRY_COMPILE([
1328 #include <linux/fs.h>
1330 vfs_rename(NULL, NULL, NULL, NULL);
1333 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1334 [vfs_rename() wants 4 args])
1341 dnl # 2.6.29 API change,
1342 dnl # check whether 'struct cred' exists
1344 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1345 AC_MSG_CHECKING([whether struct cred exists])
1346 SPL_LINUX_TRY_COMPILE([
1347 #include <linux/cred.h>
1353 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1360 dnl # Custom SPL patch may export this symbol.
1362 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1363 SPL_CHECK_SYMBOL_EXPORT(
1366 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1367 [groups_search() is available])],
1372 dnl # 2.6.x API change,
1373 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1375 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1376 SPL_CHECK_SYMBOL_EXPORT(
1377 [__put_task_struct],
1379 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1380 [__put_task_struct() is available])],
1385 dnl # 2.6.32 API change,
1386 dnl # Unused 'struct file *' removed from prototype.
1388 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1389 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1390 SPL_LINUX_TRY_COMPILE([
1391 #include <linux/sysctl.h>
1393 proc_dostring(NULL, 0, NULL, NULL, NULL);
1396 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1397 [proc_handler() wants 5 args])