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"
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
42 SPL_AC_5ARGS_DEVICE_CREATE
43 SPL_AC_CLASS_DEVICE_CREATE
44 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
45 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
52 SPL_AC_MONOTONIC_CLOCK
55 SPL_AC_MUTEX_LOCK_NESTED
58 SPL_AC_3ARGS_ON_EACH_CPU
59 SPL_AC_KALLSYMS_LOOKUP_NAME
60 SPL_AC_GET_VMALLOC_INFO
62 SPL_AC_FIRST_ONLINE_PGDAT
63 SPL_AC_NEXT_ONLINE_PGDAT
66 SPL_AC_GLOBAL_PAGE_STATE
67 SPL_AC_ZONE_STAT_ITEM_FREE
68 SPL_AC_ZONE_STAT_ITEM_INACTIVE
69 SPL_AC_ZONE_STAT_ITEM_ACTIVE
70 SPL_AC_GET_ZONE_COUNTS
73 SPL_AC_2ARGS_SET_FS_PWD
74 SPL_AC_2ARGS_VFS_UNLINK
75 SPL_AC_4ARGS_VFS_RENAME
78 SPL_AC_PUT_TASK_STRUCT
79 SPL_AC_5ARGS_PROC_HANDLER
83 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
84 modpost=$LINUX/scripts/Makefile.modpost
85 AC_MSG_CHECKING([kernel file name for module symbols])
86 if test -f "$modpost"; then
87 if grep -q Modules.symvers $modpost; then
88 LINUX_SYMBOLS=Modules.symvers
90 LINUX_SYMBOLS=Module.symvers
95 AC_MSG_RESULT($LINUX_SYMBOLS)
96 AC_SUBST(LINUX_SYMBOLS)
99 AC_DEFUN([SPL_AC_KERNEL], [
101 AS_HELP_STRING([--with-linux=PATH],
102 [Path to kernel source]),
103 [kernelsrc="$withval"])
105 AC_ARG_WITH([linux-obj],
106 AS_HELP_STRING([--with-linux-obj=PATH],
107 [Path to kernel build objects]),
108 [kernelbuild="$withval"])
110 AC_MSG_CHECKING([kernel source directory])
111 if test -z "$kernelsrc"; then
112 headersdir="/lib/modules/$(uname -r)/build"
113 if test -e "$headersdir"; then
114 sourcelink=$(readlink -f "$headersdir")
116 sourcelink=$(ls -1d /usr/src/kernels/* \
118 2>/dev/null | grep -v obj | tail -1)
121 if test -n "$sourcelink" && test -e ${sourcelink}; then
122 kernelsrc=`readlink -f ${sourcelink}`
124 AC_MSG_RESULT([Not found])
126 *** Please make sure the kernel devel package for your distribution
127 *** is installed then try again. If that fails you can specify the
128 *** location of the kernel source with the '--with-linux=PATH' option.])
131 if test "$kernelsrc" = "NONE"; then
136 AC_MSG_RESULT([$kernelsrc])
137 AC_MSG_CHECKING([kernel build directory])
138 if test -z "$kernelbuild"; then
139 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
140 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
141 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
142 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
143 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
144 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
146 kernelbuild=${kernelsrc}
149 AC_MSG_RESULT([$kernelbuild])
151 AC_MSG_CHECKING([kernel source version])
152 utsrelease1=$kernelbuild/include/linux/version.h
153 utsrelease2=$kernelbuild/include/linux/utsrelease.h
154 utsrelease3=$kernelbuild/include/generated/utsrelease.h
155 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
156 utsrelease=linux/version.h
157 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
158 utsrelease=linux/utsrelease.h
159 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
160 utsrelease=generated/utsrelease.h
163 if test "$utsrelease"; then
164 kernsrcver=`(echo "#include <$utsrelease>";
165 echo "kernsrcver=UTS_RELEASE") |
166 cpp -I $kernelbuild/include |
167 grep "^kernsrcver=" | cut -d \" -f 2`
169 if test -z "$kernsrcver"; then
170 AC_MSG_RESULT([Not found])
171 AC_MSG_ERROR([*** Cannot determine kernel version.])
174 AC_MSG_RESULT([Not found])
175 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
178 AC_MSG_RESULT([$kernsrcver])
181 LINUX_OBJ=${kernelbuild}
182 LINUX_VERSION=${kernsrcver}
186 AC_SUBST(LINUX_VERSION)
188 SPL_AC_MODULE_SYMVERS
192 dnl # Default SPL user configuration
194 AC_DEFUN([SPL_AC_CONFIG_USER], [
195 dnl # Explicitly check for gawk, we require it for the the usermode
196 dnl # helper. For some reason the standard awk command does not
197 dnl # behave correctly when invoked from the usermode helper.
198 AS_IF([test "x$AWK" != xgawk], [
200 *** Required util gawk missing. Please install the required
201 *** gawk package for your distribution and try again.])
205 AC_DEFUN([SPL_AC_LICENSE], [
206 AC_MSG_CHECKING([spl license])
208 AC_MSG_RESULT([$LICENSE])
209 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
213 AC_DEFUN([SPL_AC_CONFIG], [
215 AC_ARG_WITH([config],
216 AS_HELP_STRING([--with-config=CONFIG],
217 [Config file 'kernel|user|all|srpm']),
218 [SPL_CONFIG="$withval"])
220 AC_MSG_CHECKING([spl config])
221 AC_MSG_RESULT([$SPL_CONFIG]);
224 case "$SPL_CONFIG" in
225 kernel) SPL_AC_CONFIG_KERNEL ;;
226 user) SPL_AC_CONFIG_USER ;;
227 all) SPL_AC_CONFIG_KERNEL
228 SPL_AC_CONFIG_USER ;;
231 AC_MSG_RESULT([Error!])
232 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
233 user kernel|user|all|srpm]) ;;
236 AM_CONDITIONAL([CONFIG_USER],
237 [test "$SPL_CONFIG" = user] ||
238 [test "$SPL_CONFIG" = all])
239 AM_CONDITIONAL([CONFIG_KERNEL],
240 [test "$SPL_CONFIG" = kernel] ||
241 [test "$SPL_CONFIG" = all])
245 dnl # Enable if the SPL should be compiled with internal debugging enabled.
246 dnl # By default this support is disabled.
248 AC_DEFUN([SPL_AC_DEBUG], [
249 AC_MSG_CHECKING([whether debugging is enabled])
250 AC_ARG_ENABLE([debug],
251 [AS_HELP_STRING([--enable-debug],
252 [Enable generic debug support @<:@default=no@:>@])],
256 AS_IF([test "x$enable_debug" = xyes],
258 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
259 DEBUG_CFLAGS="-DDEBUG -Werror"
262 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
263 DEBUG_CFLAGS="-DNDEBUG"
266 AC_SUBST(DEBUG_CFLAGS)
267 AC_MSG_RESULT([$enable_debug])
271 dnl # Enabled by default it provides a minimal level of memory tracking.
272 dnl # A total count of bytes allocated is kept for each alloc and free.
273 dnl # Then at module unload time a report to the console will be printed
274 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
275 dnl # and provide an easy way to inspect the kmem based slab.
277 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
278 AC_ARG_ENABLE([debug-kmem],
279 [AS_HELP_STRING([--enable-debug-kmem],
280 [Enable basic kmem accounting @<:@default=yes@:>@])],
282 [enable_debug_kmem=yes])
284 AS_IF([test "x$enable_debug_kmem" = xyes],
285 [AC_DEFINE([DEBUG_KMEM], [1],
286 [Define to 1 to enable basic kmem accounting])
287 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
289 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
290 AC_MSG_RESULT([$enable_debug_kmem])
294 dnl # Disabled by default it provides detailed memory tracking. This
295 dnl # feature also requires --enable-debug-kmem to be set. When enabled
296 dnl # not only will total bytes be tracked but also the location of every
297 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
298 dnl # addresses and where they were allocated will be dumped to the console.
299 dnl # Enabling this feature has a significant impact on performance but it
300 dnl # makes finding memory leaks pretty straight forward.
302 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
303 AC_ARG_ENABLE([debug-kmem-tracking],
304 [AS_HELP_STRING([--enable-debug-kmem-tracking],
305 [Enable detailed kmem tracking @<:@default=no@:>@])],
307 [enable_debug_kmem_tracking=no])
309 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
310 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
311 [Define to 1 to enable detailed kmem tracking])
312 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
314 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
315 AC_MSG_RESULT([$enable_debug_kmem_tracking])
319 dnl # SPL_LINUX_CONFTEST
321 AC_DEFUN([SPL_LINUX_CONFTEST], [
322 cat confdefs.h - <<_ACEOF >conftest.c
328 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
330 m4_define([SPL_LANG_PROGRAM], [
335 dnl Do *not* indent the following line: there may be CPP directives.
336 dnl Don't move the `;' right after for the same reason.
344 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
346 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
347 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
348 rm -Rf build && mkdir -p build
349 echo "obj-m := conftest.o" >build/Makefile
351 [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])],
353 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
359 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
361 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
362 [SPL_LINUX_COMPILE_IFELSE(
363 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
365 [test -s build/conftest.o],
370 dnl # SPL_LINUX_CONFIG
372 AC_DEFUN([SPL_LINUX_CONFIG],
373 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
374 SPL_LINUX_TRY_COMPILE([
375 #ifndef AUTOCONF_INCLUDED
376 #include <linux/config.h>
380 #error CONFIG_$1 not #defined
392 dnl # SPL_CHECK_SYMBOL_EXPORT
393 dnl # check symbol exported or not
395 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
396 [AC_MSG_CHECKING([whether symbol $1 is exported])
397 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
398 $LINUX_OBJ/Module*.symvers 2>/dev/null
400 if test $rc -ne 0; then
403 grep -q -E "EXPORT_SYMBOL.*($1)" \
404 "$LINUX_OBJ/$file" 2>/dev/null
406 if test $rc -eq 0; then
411 if test $export -eq 0; then
425 dnl # SPL_CHECK_HEADER
426 dnl # check whether header exists and define HAVE_$2_HEADER
428 AC_DEFUN([SPL_CHECK_HEADER],
429 [AC_MSG_CHECKING([whether header $1 exists])
430 SPL_LINUX_TRY_COMPILE([
435 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
445 dnl # Use the atomic implemenation based on global spinlocks. This
446 dnl # should only be needed by 32-bit kernels which do not provide
447 dnl # the atomic64_* API. It may be optionally enabled as a fallback
448 dnl # if problems are observed with the direct mapping to the native
449 dnl # Linux atomic operations. You may not disable atomic spinlocks
450 dnl # if you kernel does not an atomic64_* API.
452 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
453 AC_ARG_ENABLE([atomic-spinlocks],
454 [AS_HELP_STRING([--enable-atomic-spinlocks],
455 [Atomic types use spinlocks @<:@default=check@:>@])],
457 [enable_atomic_spinlocks=check])
459 SPL_LINUX_TRY_COMPILE([
460 #include <asm/atomic.h>
465 AC_DEFINE(HAVE_ATOMIC64_T, 1,
466 [kernel defines atomic64_t])
471 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
472 AS_IF([test "x$have_atomic64_t" = xyes], [
473 enable_atomic_spinlocks=no
475 enable_atomic_spinlocks=yes
479 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
480 AC_DEFINE([ATOMIC_SPINLOCK], [1],
481 [Atomic types use spinlocks])
483 AS_IF([test "x$have_atomic64_t" = xno], [
485 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
489 AC_MSG_CHECKING([whether atomic types use spinlocks])
490 AC_MSG_RESULT([$enable_atomic_spinlocks])
492 AC_MSG_CHECKING([whether kernel defines atomic64_t])
493 AC_MSG_RESULT([$have_atomic64_t])
497 dnl # 2.6.24 API change,
498 dnl # check if atomic64_cmpxchg is defined
500 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
501 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
502 SPL_LINUX_TRY_COMPILE([
503 #include <asm/atomic.h>
505 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
508 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
509 [kernel defines atomic64_cmpxchg])
516 dnl # 2.6.24 API change,
517 dnl # check if atomic64_xchg is defined
519 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
520 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
521 SPL_LINUX_TRY_COMPILE([
522 #include <asm/atomic.h>
524 atomic64_xchg((atomic64_t *)NULL, 0);
527 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
528 [kernel defines atomic64_xchg])
535 dnl # 2.6.24 API change,
536 dnl # check if uintptr_t typedef is defined
538 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
539 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
540 SPL_LINUX_TRY_COMPILE([
541 #include <linux/types.h>
546 AC_DEFINE(HAVE_UINTPTR_T, 1,
547 [kernel defines uintptr_t])
554 dnl # 2.6.20 API change,
555 dnl # INIT_WORK use 2 args and not store data inside
557 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
558 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
559 SPL_LINUX_TRY_COMPILE([
560 #include <linux/workqueue.h>
562 struct work_struct work;
563 INIT_WORK(&work, NULL, NULL);
566 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
567 [INIT_WORK wants 3 args])
574 dnl # 2.6.21 API change,
575 dnl # 'register_sysctl_table' use only one argument instead of two
577 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
578 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
579 SPL_LINUX_TRY_COMPILE([
580 #include <linux/sysctl.h>
582 return register_sysctl_table(NULL,0);
585 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
586 [register_sysctl_table() wants 2 args])
593 dnl # 2.6.23 API change
594 dnl # Old set_shrinker API replaced with register_shrinker
596 AC_DEFUN([SPL_AC_SET_SHRINKER], [
597 AC_MSG_CHECKING([whether set_shrinker() available])
598 SPL_LINUX_TRY_COMPILE([
599 #include <linux/mm.h>
601 return set_shrinker(DEFAULT_SEEKS, NULL);
604 AC_DEFINE(HAVE_SET_SHRINKER, 1,
605 [set_shrinker() available])
612 dnl # 2.6.25 API change,
613 dnl # struct path entry added to struct nameidata
615 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
616 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
617 SPL_LINUX_TRY_COMPILE([
618 #include <linux/namei.h>
623 nd.path.dentry = NULL;
626 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
627 [struct path used in struct nameidata])
634 dnl # Custom SPL patch may export this system it is not required
636 AC_DEFUN([SPL_AC_TASK_CURR], [
637 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
638 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
643 dnl # 2.6.19 API change,
644 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
646 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
647 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
648 SPL_LINUX_TRY_COMPILE([
649 #include <linux/sysctl.h>
651 #ifndef CTL_UNNUMBERED
652 #error CTL_UNNUMBERED undefined
656 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
657 [unnumbered sysctl support exists])
664 dnl # 2.6.33 API change,
665 dnl # Removed .ctl_name from struct ctl_table.
667 AC_DEFUN([SPL_AC_CTL_NAME], [
668 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
669 SPL_LINUX_TRY_COMPILE([
670 #include <linux/sysctl.h>
672 struct ctl_table ctl;
676 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
683 dnl # 2.6.16 API change.
684 dnl # Check if 'fls64()' is available
686 AC_DEFUN([SPL_AC_FLS64],
687 [AC_MSG_CHECKING([whether fls64() is available])
688 SPL_LINUX_TRY_COMPILE([
689 #include <linux/bitops.h>
694 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
701 dnl # 2.6.18 API change, check whether device_create() is available.
702 dnl # Device_create() was introduced in 2.6.18 and depricated
703 dnl # class_device_create() which was fully removed in 2.6.26.
705 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
706 SPL_CHECK_SYMBOL_EXPORT(
708 [drivers/base/core.c],
709 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
710 [device_create() is available])],
715 dnl # 2.6.27 API change,
716 dnl # device_create() uses 5 args, new 'drvdata' argument.
718 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
719 AC_MSG_CHECKING([whether device_create() wants 5 args])
720 tmp_flags="$EXTRA_KCFLAGS"
721 EXTRA_KCFLAGS="-Werror"
722 SPL_LINUX_TRY_COMPILE([
723 #include <linux/device.h>
725 device_create(NULL, NULL, 0, NULL, "%d", 1);
728 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
729 [device_create wants 5 args])
733 EXTRA_KCFLAGS="$tmp_flags"
737 dnl # 2.6.13 API change, check whether class_device_create() is available.
738 dnl # Class_device_create() was introduced in 2.6.13 and depricated
739 dnl # class_simple_device_add() which was fully removed in 2.6.13.
741 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
742 SPL_CHECK_SYMBOL_EXPORT(
743 [class_device_create],
744 [drivers/base/class.c],
745 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
746 [class_device_create() is available])],
751 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
753 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
754 SPL_CHECK_SYMBOL_EXPORT(
755 [set_normalized_timespec],
757 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
758 [set_normalized_timespec() is available as export])],
763 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
764 dnl # previously it was available in time.h as an inline.
766 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
767 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
768 SPL_LINUX_TRY_COMPILE([
769 #include <linux/time.h>
770 void set_normalized_timespec(struct timespec *ts,
771 time_t sec, long nsec) { }
778 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
779 [set_normalized_timespec() is available as inline])
784 dnl # 2.6.18 API change,
785 dnl # timespec_sub() inline function available in linux/time.h
787 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
788 AC_MSG_CHECKING([whether timespec_sub() is available])
789 SPL_LINUX_TRY_COMPILE([
790 #include <linux/time.h>
792 struct timespec a, b, c = { 0 };
793 c = timespec_sub(a, b);
796 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
803 dnl # 2.6.19 API change,
804 dnl # check if init_utsname() is available in linux/utsname.h
806 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
807 AC_MSG_CHECKING([whether init_utsname() is available])
808 SPL_LINUX_TRY_COMPILE([
809 #include <linux/utsname.h>
811 struct new_utsname *a = init_utsname();
814 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
821 dnl # 2.6.26 API change,
822 dnl # definition of struct fdtable relocated to linux/fdtable.h
824 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
825 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
829 dnl # 2.6.14 API change,
830 dnl # check whether 'files_fdtable()' exists
832 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
833 AC_MSG_CHECKING([whether files_fdtable() is available])
834 SPL_LINUX_TRY_COMPILE([
835 #include <linux/sched.h>
836 #include <linux/file.h>
837 #ifdef HAVE_FDTABLE_HEADER
838 #include <linux/fdtable.h>
841 struct files_struct *files = current->files;
842 struct fdtable *fdt = files_fdtable(files);
845 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
852 dnl # 2.6.18 API change,
853 dnl # added linux/uaccess.h
855 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
856 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
860 dnl # 2.6.12 API change,
861 dnl # check whether 'kmalloc_node()' is available.
863 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
864 AC_MSG_CHECKING([whether kmalloc_node() is available])
865 SPL_LINUX_TRY_COMPILE([
866 #include <linux/slab.h>
868 void *a = kmalloc_node(1, GFP_KERNEL, 0);
871 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
878 dnl # 2.6.9 API change,
879 dnl # check whether 'monotonic_clock()' is available it may
880 dnl # be available for some archs but not others.
882 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
883 SPL_CHECK_SYMBOL_EXPORT(
886 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
887 [monotonic_clock() is available])],
892 dnl # 2.6.16 API change,
893 dnl # check whether 'struct inode' has i_mutex
895 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
896 AC_MSG_CHECKING([whether struct inode has i_mutex])
897 SPL_LINUX_TRY_COMPILE([
898 #include <linux/fs.h>
899 #include <linux/mutex.h>
902 mutex_init(&i.i_mutex);
905 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
912 dnl # 2.6.29 API change,
913 dnl # Adaptive mutexs introduced.
915 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
916 AC_MSG_CHECKING([whether struct mutex has owner])
917 SPL_LINUX_TRY_COMPILE([
918 #include <linux/mutex.h>
924 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
931 dnl # 2.6.18 API change,
932 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
933 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
934 dnl # if the mutex validator is disabled or otherwise unavailable.
936 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
937 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
938 SPL_LINUX_TRY_COMPILE([
939 #include <linux/mutex.h>
943 mutex_lock_nested(&mutex, 0);
946 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
947 [mutex_lock_nested() is available])
954 dnl # 2.6.22 API change,
955 dnl # First introduced 'div64_64()' in lib/div64.c
957 AC_DEFUN([SPL_AC_DIV64_64], [
958 SPL_CHECK_SYMBOL_EXPORT(
961 [AC_DEFINE(HAVE_DIV64_64, 1,
962 [div64_64() is available])],
967 dnl # 2.6.26 API change,
968 dnl # Renamed 'div64_64()' to 'div64_u64' in lib/div64.c
970 AC_DEFUN([SPL_AC_DIV64_U64], [
971 SPL_CHECK_SYMBOL_EXPORT(
974 [AC_DEFINE(HAVE_DIV64_U64, 1,
975 [div64_u64() is available])],
980 dnl # 2.6.27 API change,
981 dnl # on_each_cpu() uses 3 args, no 'retry' argument
983 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
984 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
985 SPL_LINUX_TRY_COMPILE([
986 #include <linux/smp.h>
988 on_each_cpu(NULL, NULL, 0);
991 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
992 [on_each_cpu wants 3 args])
999 dnl # 2.6.18 API change,
1000 dnl # kallsyms_lookup_name no longer exported
1002 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1003 SPL_CHECK_SYMBOL_EXPORT(
1004 [kallsyms_lookup_name],
1006 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1007 [kallsyms_lookup_name() is 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_GET_VMALLOC_INFO], [
1019 SPL_CHECK_SYMBOL_EXPORT(
1022 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1023 [get_vmalloc_info() is available])],
1028 dnl # 2.6.17 API change
1029 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1030 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1031 dnl # were exported in 2.6.17 for use by modules which was consistent with
1032 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1033 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1034 dnl # were dropped entirely leaving modules no way to directly iterate over
1035 dnl # the zone list. Because we need access to the zone helpers we check
1036 dnl # if the kernel contains the old or new implementation. Then we check
1037 dnl # to see if the symbols we need for each version are available. If they
1038 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1040 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1041 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1042 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1044 if test $rc -eq 0; then
1045 AC_MSG_RESULT([yes])
1046 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1053 dnl # Proposed API change,
1054 dnl # This symbol is not available in stock kernels. You may build a
1055 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1056 dnl # these symbols for use. If your already rolling a custom kernel for
1057 dnl # your environment this is recommended.
1059 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1060 SPL_CHECK_SYMBOL_EXPORT(
1061 [first_online_pgdat],
1063 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1064 [first_online_pgdat() is available])],
1069 dnl # Proposed API change,
1070 dnl # This symbol is not available in stock kernels. You may build a
1071 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1072 dnl # these symbols for use. If your already rolling a custom kernel for
1073 dnl # your environment this is recommended.
1075 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1076 SPL_CHECK_SYMBOL_EXPORT(
1077 [next_online_pgdat],
1079 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1080 [next_online_pgdat() is available])],
1085 dnl # Proposed API change,
1086 dnl # This symbol is not available in stock kernels. You may build a
1087 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1088 dnl # these symbols for use. If your already rolling a custom kernel for
1089 dnl # your environment this is recommended.
1091 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1092 SPL_CHECK_SYMBOL_EXPORT(
1095 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1096 [next_zone() is available])],
1101 dnl # 2.6.17 API change,
1102 dnl # See SPL_AC_PGDAT_HELPERS for details.
1104 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1105 SPL_CHECK_SYMBOL_EXPORT(
1108 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1109 [pgdat_list is available])],
1114 dnl # 2.6.18 API change,
1115 dnl # First introduced global_page_state() support as an inline.
1117 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1118 AC_MSG_CHECKING([whether global_page_state() is available])
1119 SPL_LINUX_TRY_COMPILE([
1120 #include <linux/mm.h>
1122 unsigned long state;
1123 state = global_page_state(0);
1126 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1127 [global_page_state() is available])
1134 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1135 dnl # Public global zone stats now include a free page count. However
1136 dnl # the enumerated names of the counters have changed since this API
1137 dnl # was introduced. We need to deduce the corrent name to use. This
1138 dnl # replaces the priviate get_zone_counts() interface.
1140 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1141 dnl # is 2.6.30 as of when this was written.
1143 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1144 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1145 SPL_LINUX_TRY_COMPILE([
1146 #include <linux/mm.h>
1148 enum zone_stat_item zsi;
1149 zsi = NR_FREE_PAGES;
1152 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1153 [Page state NR_FREE_PAGES is available])
1160 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1161 dnl # Public global zone stats now include an inactive page count. However
1162 dnl # the enumerated names of the counters have changed since this API
1163 dnl # was introduced. We need to deduce the corrent name to use. This
1164 dnl # replaces the priviate get_zone_counts() interface.
1166 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1167 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1168 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1170 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1171 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1172 SPL_LINUX_TRY_COMPILE([
1173 #include <linux/mm.h>
1175 enum zone_stat_item zsi;
1179 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1180 [Page state NR_INACTIVE is available])
1185 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1186 SPL_LINUX_TRY_COMPILE([
1187 #include <linux/mm.h>
1189 enum zone_stat_item zsi;
1190 zsi = NR_INACTIVE_ANON;
1193 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1194 [Page state NR_INACTIVE_ANON is available])
1199 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1200 SPL_LINUX_TRY_COMPILE([
1201 #include <linux/mm.h>
1203 enum zone_stat_item zsi;
1204 zsi = NR_INACTIVE_FILE;
1207 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1208 [Page state NR_INACTIVE_FILE is available])
1215 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1216 dnl # Public global zone stats now include an active page count. However
1217 dnl # the enumerated names of the counters have changed since this API
1218 dnl # was introduced. We need to deduce the corrent name to use. This
1219 dnl # replaces the priviate get_zone_counts() interface.
1221 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1222 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1223 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1225 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1226 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1227 SPL_LINUX_TRY_COMPILE([
1228 #include <linux/mm.h>
1230 enum zone_stat_item zsi;
1234 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1235 [Page state NR_ACTIVE is available])
1240 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1241 SPL_LINUX_TRY_COMPILE([
1242 #include <linux/mm.h>
1244 enum zone_stat_item zsi;
1245 zsi = NR_ACTIVE_ANON;
1248 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1249 [Page state NR_ACTIVE_ANON is available])
1254 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1255 SPL_LINUX_TRY_COMPILE([
1256 #include <linux/mm.h>
1258 enum zone_stat_item zsi;
1259 zsi = NR_ACTIVE_FILE;
1262 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1263 [Page state NR_ACTIVE_FILE is available])
1270 dnl # Proposed API change for legacy kernels.
1271 dnl # This symbol is not available in older kernels. For kernels post
1272 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1273 dnl # page state information. This symbol is only used in legacy kernels
1274 dnl # any only as a last resort.
1276 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1277 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1278 SPL_LINUX_TRY_COMPILE([
1280 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1281 #error "global_page_state needs NR_FREE_PAGES"
1284 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1285 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1286 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1287 #error "global_page_state needs NR_ACTIVE*"
1290 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1291 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1292 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1293 #error "global_page_state needs NR_INACTIVE*"
1299 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1300 [get_zone_counts() is needed])
1302 SPL_CHECK_SYMBOL_EXPORT(
1305 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1306 [get_zone_counts() is available])],
1312 dnl # 2.6.27 API change,
1313 dnl # The user_path_dir() replaces __user_walk()
1315 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1316 SPL_CHECK_SYMBOL_EXPORT(
1319 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1320 [user_path_dir() is available])],
1325 dnl # Symbol available in RHEL kernels not in stock kernels.
1327 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1328 SPL_CHECK_SYMBOL_EXPORT(
1331 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1332 [set_fs_pwd() is available])],
1337 dnl # 2.6.25 API change,
1338 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1340 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1341 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1342 SPL_LINUX_TRY_COMPILE([
1343 #include <linux/sched.h>
1344 #include <linux/fs_struct.h>
1346 set_fs_pwd(NULL, NULL);
1349 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1350 [set_fs_pwd() wants 2 args])
1357 dnl # SLES API change, never adopted in mainline,
1358 dnl # Third 'struct vfsmount *' argument removed.
1360 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1361 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1362 SPL_LINUX_TRY_COMPILE([
1363 #include <linux/fs.h>
1365 vfs_unlink(NULL, NULL);
1368 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1369 [vfs_unlink() wants 2 args])
1376 dnl # SLES API change, never adopted in mainline,
1377 dnl # Third and sixth 'struct vfsmount *' argument removed.
1379 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1380 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1381 SPL_LINUX_TRY_COMPILE([
1382 #include <linux/fs.h>
1384 vfs_rename(NULL, NULL, NULL, NULL);
1387 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1388 [vfs_rename() wants 4 args])
1395 dnl # 2.6.29 API change,
1396 dnl # check whether 'struct cred' exists
1398 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1399 AC_MSG_CHECKING([whether struct cred exists])
1400 SPL_LINUX_TRY_COMPILE([
1401 #include <linux/cred.h>
1407 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1414 dnl # Custom SPL patch may export this symbol.
1416 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1417 SPL_CHECK_SYMBOL_EXPORT(
1420 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1421 [groups_search() is available])],
1426 dnl # 2.6.x API change,
1427 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1429 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1430 SPL_CHECK_SYMBOL_EXPORT(
1431 [__put_task_struct],
1433 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1434 [__put_task_struct() is available])],
1439 dnl # 2.6.32 API change,
1440 dnl # Unused 'struct file *' removed from prototype.
1442 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1443 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1444 SPL_LINUX_TRY_COMPILE([
1445 #include <linux/sysctl.h>
1447 proc_dostring(NULL, 0, NULL, NULL, NULL);
1450 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1451 [proc_handler() wants 5 args])
1458 dnl # 2.6.x API change,
1459 dnl # kvasprintf() function added.
1461 AC_DEFUN([SPL_AC_KVASPRINTF], [
1462 SPL_CHECK_SYMBOL_EXPORT(
1465 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1466 [kvasprintf() is available])],