]> git.proxmox.com Git - mirror_spl.git/blame - config/spl-build.m4
Linux 2.6.36 compat, wrap RLIM64_INFINITY
[mirror_spl.git] / config / spl-build.m4
CommitLineData
716154c5
BB
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###############################################################################
8
86933a6e
BB
9AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
10 SPL_AC_KERNEL
11
86933a6e
BB
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
14 fi
86933a6e 15 AC_SUBST(KERNELMAKE_PARAMS)
a7958f7e
BB
16
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
86933a6e
BB
18 AC_SUBST(KERNELCPPFLAGS)
19
20 SPL_AC_DEBUG
21 SPL_AC_DEBUG_KMEM
055ffd98 22 SPL_AC_DEBUG_KMEM_TRACKING
5e9b5d83 23 SPL_AC_ATOMIC_SPINLOCK
302b88e6
BB
24 SPL_AC_TYPE_ATOMIC64_CMPXCHG
25 SPL_AC_TYPE_ATOMIC64_XCHG
d04c8a56 26 SPL_AC_TYPE_UINTPTR_T
86933a6e
BB
27 SPL_AC_3ARGS_INIT_WORK
28 SPL_AC_2ARGS_REGISTER_SYSCTL
29 SPL_AC_SET_SHRINKER
23aa63cb 30 SPL_AC_3ARGS_SHRINKER_CALLBACK
86933a6e
BB
31 SPL_AC_PATH_IN_NAMEIDATA
32 SPL_AC_TASK_CURR
33 SPL_AC_CTL_UNNUMBERED
79a3bf13 34 SPL_AC_CTL_NAME
86933a6e
BB
35 SPL_AC_FLS64
36 SPL_AC_DEVICE_CREATE
37 SPL_AC_5ARGS_DEVICE_CREATE
38 SPL_AC_CLASS_DEVICE_CREATE
39 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
40 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
41 SPL_AC_TIMESPEC_SUB
42 SPL_AC_INIT_UTSNAME
43 SPL_AC_FDTABLE_HEADER
44 SPL_AC_FILES_FDTABLE
45 SPL_AC_UACCESS_HEADER
46 SPL_AC_KMALLOC_NODE
47 SPL_AC_MONOTONIC_CLOCK
48 SPL_AC_INODE_I_MUTEX
4d54fdee 49 SPL_AC_MUTEX_OWNER
86933a6e 50 SPL_AC_MUTEX_LOCK_NESTED
86933a6e
BB
51 SPL_AC_3ARGS_ON_EACH_CPU
52 SPL_AC_KALLSYMS_LOOKUP_NAME
53 SPL_AC_GET_VMALLOC_INFO
54 SPL_AC_PGDAT_HELPERS
55 SPL_AC_FIRST_ONLINE_PGDAT
56 SPL_AC_NEXT_ONLINE_PGDAT
57 SPL_AC_NEXT_ZONE
58 SPL_AC_PGDAT_LIST
86933a6e 59 SPL_AC_GLOBAL_PAGE_STATE
6ae7fef5
BB
60 SPL_AC_ZONE_STAT_ITEM_FREE
61 SPL_AC_ZONE_STAT_ITEM_INACTIVE
62 SPL_AC_ZONE_STAT_ITEM_ACTIVE
63 SPL_AC_GET_ZONE_COUNTS
7119bf70 64 SPL_AC_USER_PATH_DIR
51a727e9
BB
65 SPL_AC_SET_FS_PWD
66 SPL_AC_2ARGS_SET_FS_PWD
86933a6e
BB
67 SPL_AC_2ARGS_VFS_UNLINK
68 SPL_AC_4ARGS_VFS_RENAME
ec7d53e9
BB
69 SPL_AC_CRED_STRUCT
70 SPL_AC_GROUPS_SEARCH
e811949a 71 SPL_AC_PUT_TASK_STRUCT
3977f837 72 SPL_AC_5ARGS_PROC_HANDLER
b868e22f 73 SPL_AC_KVASPRINTF
f0ff89fc 74 SPL_AC_3ARGS_FILE_FSYNC
46aa7b39 75 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
86933a6e
BB
76])
77
78AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
bb339d06 79 modpost=$LINUX/scripts/Makefile.modpost
86933a6e 80 AC_MSG_CHECKING([kernel file name for module symbols])
bb339d06
BB
81 if test -f "$modpost"; then
82 if grep -q Modules.symvers $modpost; then
83 LINUX_SYMBOLS=Modules.symvers
84 else
85 LINUX_SYMBOLS=Module.symvers
86 fi
86933a6e 87 else
bb339d06 88 LINUX_SYMBOLS=NONE
86933a6e
BB
89 fi
90 AC_MSG_RESULT($LINUX_SYMBOLS)
91 AC_SUBST(LINUX_SYMBOLS)
92])
93
57d86234 94AC_DEFUN([SPL_AC_KERNEL], [
57d86234 95 AC_ARG_WITH([linux],
96 AS_HELP_STRING([--with-linux=PATH],
97 [Path to kernel source]),
39a3d2a4 98 [kernelsrc="$withval"])
57d86234 99
100 AC_ARG_WITH([linux-obj],
101 AS_HELP_STRING([--with-linux-obj=PATH],
102 [Path to kernel build objects]),
103 [kernelbuild="$withval"])
104
105 AC_MSG_CHECKING([kernel source directory])
106 if test -z "$kernelsrc"; then
534c4e38
BM
107 headersdir="/lib/modules/$(uname -r)/build"
108 if test -e "$headersdir"; then
109 sourcelink=$(readlink -f "$headersdir")
110 else
111 sourcelink=$(ls -1d /usr/src/kernels/* \
112 /usr/src/linux-* \
113 2>/dev/null | grep -v obj | tail -1)
114 fi
57d86234 115
8fd4e3af 116 if test -n "$sourcelink" && test -e ${sourcelink}; then
d4326403 117 kernelsrc=`readlink -f ${sourcelink}`
d4326403 118 else
57d86234 119 AC_MSG_RESULT([Not found])
120 AC_MSG_ERROR([
8fd4e3af
BB
121 *** Please make sure the kernel devel package for your distribution
122 *** is installed then try again. If that fails you can specify the
123 *** location of the kernel source with the '--with-linux=PATH' option.])
57d86234 124 fi
c5f70460
BB
125 else
126 if test "$kernelsrc" = "NONE"; then
127 kernsrcver=NONE
128 fi
57d86234 129 fi
130
131 AC_MSG_RESULT([$kernelsrc])
132 AC_MSG_CHECKING([kernel build directory])
39a3d2a4 133 if test -z "$kernelbuild"; then
e2d28a37
BB
134 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
135 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
136 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
137 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
138 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
139 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
39a3d2a4
BB
140 else
141 kernelbuild=${kernelsrc}
142 fi
bf338d8d 143 fi
57d86234 144 AC_MSG_RESULT([$kernelbuild])
145
146 AC_MSG_CHECKING([kernel source version])
fd921c2e
BB
147 utsrelease1=$kernelbuild/include/linux/version.h
148 utsrelease2=$kernelbuild/include/linux/utsrelease.h
149 utsrelease3=$kernelbuild/include/generated/utsrelease.h
150 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
151 utsrelease=linux/version.h
152 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
153 utsrelease=linux/utsrelease.h
154 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
155 utsrelease=generated/utsrelease.h
156 fi
57d86234 157
fd921c2e
BB
158 if test "$utsrelease"; then
159 kernsrcver=`(echo "#include <$utsrelease>";
57d86234 160 echo "kernsrcver=UTS_RELEASE") |
d4326403 161 cpp -I $kernelbuild/include |
57d86234 162 grep "^kernsrcver=" | cut -d \" -f 2`
57d86234 163
fd921c2e
BB
164 if test -z "$kernsrcver"; then
165 AC_MSG_RESULT([Not found])
166 AC_MSG_ERROR([*** Cannot determine kernel version.])
167 fi
168 else
57d86234 169 AC_MSG_RESULT([Not found])
fd921c2e 170 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
57d86234 171 fi
172
173 AC_MSG_RESULT([$kernsrcver])
174
57d86234 175 LINUX=${kernelsrc}
176 LINUX_OBJ=${kernelbuild}
c5f70460
BB
177 LINUX_VERSION=${kernsrcver}
178
57d86234 179 AC_SUBST(LINUX)
180 AC_SUBST(LINUX_OBJ)
c5f70460 181 AC_SUBST(LINUX_VERSION)
57d86234 182
86933a6e 183 SPL_AC_MODULE_SYMVERS
2e0e7e69
BB
184])
185
86933a6e 186dnl #
287b2fb1
BB
187dnl # Explicitly check for gawk, we require it for the the usermode
188dnl # helper. For some reason the standard awk command does not
189dnl # behave correctly when invoked from the usermode helper.
86933a6e 190dnl #
287b2fb1 191AC_DEFUN([SPL_AC_GAWK], [
18142514
BB
192 AS_IF([test "x$AWK" != xgawk], [
193 AC_MSG_ERROR([
194 *** Required util gawk missing. Please install the required
195 *** gawk package for your distribution and try again.])
196 ])
197])
86933a6e 198
287b2fb1
BB
199dnl #
200dnl # Default SPL user configuration
201dnl #
202AC_DEFUN([SPL_AC_CONFIG_USER], [
203 SPL_AC_GAWK
204])
205
206dnl #
207dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
208dnl # are missing it is non-fatal but you will not be able to build
209dnl # RPM packages and will be warned if you try too.
210dnl #
211AC_DEFUN([SPL_AC_RPM], [
212 RPM=rpm
213 RPMBUILD=rpmbuild
214
215 AC_MSG_CHECKING([whether $RPM is available])
216 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
217 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
218 HAVE_RPM=yes
219 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
220 ],[
221 HAVE_RPM=no
222 AC_MSG_RESULT([$HAVE_RPM])
223 ])
224
225 AC_MSG_CHECKING([whether $RPMBUILD is available])
226 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
227 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
228 HAVE_RPMBUILD=yes
229 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
230 ],[
231 HAVE_RPMBUILD=no
232 AC_MSG_RESULT([$HAVE_RPMBUILD])
233 ])
234
235 AC_SUBST(HAVE_RPM)
236 AC_SUBST(RPM)
237 AC_SUBST(RPM_VERSION)
238
239 AC_SUBST(HAVE_RPMBUILD)
240 AC_SUBST(RPMBUILD)
241 AC_SUBST(RPMBUILD_VERSION)
242])
243
244dnl #
245dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
246dnl # tools are missing it is non-fatal but you will not be able to build
247dnl # DEB packages and will be warned if you try too.
248dnl #
249AC_DEFUN([SPL_AC_DPKG], [
250 DPKG=dpkg
251 DPKGBUILD=dpkg-buildpackage
252
253 AC_MSG_CHECKING([whether $DPKG is available])
254 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
255 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
256 HAVE_DPKG=yes
257 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
258 ],[
259 HAVE_DPKG=no
260 AC_MSG_RESULT([$HAVE_DPKG])
261 ])
262
263 AC_MSG_CHECKING([whether $DPKGBUILD is available])
264 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
265 DPKGBUILD_VERSION=$(echo $tmp | \
266 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
267 HAVE_DPKGBUILD=yes
268 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
269 ],[
270 HAVE_DPKGBUILD=no
271 AC_MSG_RESULT([$HAVE_DPKGBUILD])
272 ])
273
274 AC_SUBST(HAVE_DPKG)
275 AC_SUBST(DPKG)
276 AC_SUBST(DPKG_VERSION)
277
278 AC_SUBST(HAVE_DPKGBUILD)
279 AC_SUBST(DPKGBUILD)
280 AC_SUBST(DPKGBUILD_VERSION)
281])
282
283dnl #
284dnl # Until native packaging for various different packing systems
285dnl # can be added the least we can do is attempt to use alien to
286dnl # convert the RPM packages to the needed package type. This is
287dnl # a hack but so far it has worked reasonable well.
288dnl #
289AC_DEFUN([SPL_AC_ALIEN], [
290 ALIEN=alien
291
292 AC_MSG_CHECKING([whether $ALIEN is available])
293 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
294 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
295 HAVE_ALIEN=yes
296 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
297 ],[
298 HAVE_ALIEN=no
299 AC_MSG_RESULT([$HAVE_ALIEN])
300 ])
301
302 AC_SUBST(HAVE_ALIEN)
303 AC_SUBST(ALIEN)
304 AC_SUBST(ALIEN_VERSION)
305])
306
307dnl #
308dnl # Using the VENDOR tag from config.guess set the default
309dnl # package type for 'make pkg': (rpm | deb | tgz)
310dnl #
311AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
73fc084e
BB
312 AC_MSG_CHECKING([linux distribution])
313 if test -f /etc/redhat-release ; then
314 VENDOR=redhat ;
315 elif test -f /etc/fedora-release ; then
316 VENDOR=fedora ;
317 elif test -f /etc/lsb-release ; then
318 VENDOR=ubuntu ;
319 elif test -f /etc/debian_version ; then
320 VENDOR=debian ;
321 elif test -f /etc/SuSE-release ; then
322 VENDOR=sles ;
323 elif test -f /etc/slackware-version ; then
324 VENDOR=slackware ;
325 elif test -f /etc/gentoo-release ; then
326 VENDOR=gentoo ;
327 else
328 VENDOR= ;
329 fi
330 AC_MSG_RESULT([$VENDOR])
331 AC_SUBST(VENDOR)
287b2fb1
BB
332
333 AC_MSG_CHECKING([default package type])
334 case "$VENDOR" in
335 fedora) DEFAULT_PACKAGE=rpm ;;
336 redhat) DEFAULT_PACKAGE=rpm ;;
337 sles) DEFAULT_PACKAGE=rpm ;;
338 ubuntu) DEFAULT_PACKAGE=deb ;;
339 debian) DEFAULT_PACKAGE=deb ;;
340 slackware) DEFAULT_PACKAGE=tgz ;;
341 *) DEFAULT_PACKAGE=rpm ;;
342 esac
343
344 AC_MSG_RESULT([$DEFAULT_PACKAGE])
345 AC_SUBST(DEFAULT_PACKAGE)
346])
347
348dnl #
349dnl # Default SPL user configuration
350dnl #
351AC_DEFUN([SPL_AC_PACKAGE], [
352 SPL_AC_RPM
353 SPL_AC_DPKG
354 SPL_AC_ALIEN
355 SPL_AC_DEFAULT_PACKAGE
356])
357
6a1c3d41 358AC_DEFUN([SPL_AC_LICENSE], [
86933a6e
BB
359 AC_MSG_CHECKING([spl license])
360 LICENSE=GPL
361 AC_MSG_RESULT([$LICENSE])
6a1c3d41 362 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
86933a6e
BB
363 AC_SUBST(LICENSE)
364])
365
366AC_DEFUN([SPL_AC_CONFIG], [
367 SPL_CONFIG=all
368 AC_ARG_WITH([config],
369 AS_HELP_STRING([--with-config=CONFIG],
c1541dfe 370 [Config file 'kernel|user|all|srpm']),
86933a6e
BB
371 [SPL_CONFIG="$withval"])
372
373 AC_MSG_CHECKING([spl config])
374 AC_MSG_RESULT([$SPL_CONFIG]);
375 AC_SUBST(SPL_CONFIG)
376
377 case "$SPL_CONFIG" in
378 kernel) SPL_AC_CONFIG_KERNEL ;;
379 user) SPL_AC_CONFIG_USER ;;
380 all) SPL_AC_CONFIG_KERNEL
381 SPL_AC_CONFIG_USER ;;
c1541dfe 382 srpm) ;;
86933a6e
BB
383 *)
384 AC_MSG_RESULT([Error!])
385 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
c1541dfe 386 user kernel|user|all|srpm]) ;;
86933a6e
BB
387 esac
388
389 AM_CONDITIONAL([CONFIG_USER],
390 [test "$SPL_CONFIG" = user] ||
391 [test "$SPL_CONFIG" = all])
392 AM_CONDITIONAL([CONFIG_KERNEL],
393 [test "$SPL_CONFIG" = kernel] ||
394 [test "$SPL_CONFIG" = all])
6a1c3d41 395])
396
055ffd98
BB
397dnl #
398dnl # Enable if the SPL should be compiled with internal debugging enabled.
399dnl # By default this support is disabled.
400dnl #
57d86234 401AC_DEFUN([SPL_AC_DEBUG], [
c950d148 402 AC_MSG_CHECKING([whether debugging is enabled])
055ffd98
BB
403 AC_ARG_ENABLE([debug],
404 [AS_HELP_STRING([--enable-debug],
405 [Enable generic debug support @<:@default=no@:>@])],
406 [],
407 [enable_debug=no])
408
409 AS_IF([test "x$enable_debug" = xyes],
c950d148 410 [
c950d148
BB
411 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
412 DEBUG_CFLAGS="-DDEBUG -Werror"
413 ],
414 [
c950d148
BB
415 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
416 DEBUG_CFLAGS="-DNDEBUG"
417 ])
055ffd98 418
c950d148 419 AC_SUBST(DEBUG_CFLAGS)
055ffd98 420 AC_MSG_RESULT([$enable_debug])
57d86234 421])
422
055ffd98
BB
423dnl #
424dnl # Enabled by default it provides a minimal level of memory tracking.
425dnl # A total count of bytes allocated is kept for each alloc and free.
426dnl # Then at module unload time a report to the console will be printed
427dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
428dnl # and provide an easy way to inspect the kmem based slab.
429dnl #
57d86234 430AC_DEFUN([SPL_AC_DEBUG_KMEM], [
055ffd98
BB
431 AC_ARG_ENABLE([debug-kmem],
432 [AS_HELP_STRING([--enable-debug-kmem],
433 [Enable basic kmem accounting @<:@default=yes@:>@])],
434 [],
435 [enable_debug_kmem=yes])
57d86234 436
055ffd98
BB
437 AS_IF([test "x$enable_debug_kmem" = xyes],
438 [AC_DEFINE([DEBUG_KMEM], [1],
439 [Define to 1 to enable basic kmem accounting])
440 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
441
442 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
443 AC_MSG_RESULT([$enable_debug_kmem])
57d86234 444])
445
055ffd98
BB
446dnl #
447dnl # Disabled by default it provides detailed memory tracking. This
448dnl # feature also requires --enable-debug-kmem to be set. When enabled
449dnl # not only will total bytes be tracked but also the location of every
450dnl # alloc and free. When the SPL module is unloaded a list of all leaked
451dnl # addresses and where they were allocated will be dumped to the console.
452dnl # Enabling this feature has a significant impact on performance but it
453dnl # makes finding memory leaks pretty straight forward.
454dnl #
455AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
456 AC_ARG_ENABLE([debug-kmem-tracking],
457 [AS_HELP_STRING([--enable-debug-kmem-tracking],
458 [Enable detailed kmem tracking @<:@default=no@:>@])],
459 [],
460 [enable_debug_kmem_tracking=no])
461
462 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
463 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
464 [Define to 1 to enable detailed kmem tracking])
465 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
466
467 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
468 AC_MSG_RESULT([$enable_debug_kmem_tracking])
57d86234 469])
470
471dnl #
472dnl # SPL_LINUX_CONFTEST
473dnl #
474AC_DEFUN([SPL_LINUX_CONFTEST], [
dbe561d8 475cat confdefs.h - <<_ACEOF >conftest.c
57d86234 476$1
477_ACEOF
478])
479
480dnl #
481dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
482dnl #
483m4_define([SPL_LANG_PROGRAM], [
484$1
485int
486main (void)
487{
488dnl Do *not* indent the following line: there may be CPP directives.
489dnl Don't move the `;' right after for the same reason.
490$2
491 ;
492 return 0;
493}
494])
495
496dnl #
497dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
498dnl #
499AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
c5f70460
BB
500 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
501 rm -Rf build && mkdir -p build
502 echo "obj-m := conftest.o" >build/Makefile
503 AS_IF(
3d0cb2d3 504 [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])],
c5f70460
BB
505 [$4],
506 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
507 )
508 rm -Rf build
57d86234 509])
510
511dnl #
512dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
513dnl #
514AC_DEFUN([SPL_LINUX_TRY_COMPILE],
515 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 516 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
517 [modules],
518 [test -s build/conftest.o],
519 [$3], [$4])
57d86234 520])
521
522dnl #
523dnl # SPL_LINUX_CONFIG
524dnl #
525AC_DEFUN([SPL_LINUX_CONFIG],
526 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
527 SPL_LINUX_TRY_COMPILE([
528 #ifndef AUTOCONF_INCLUDED
529 #include <linux/config.h>
530 #endif
531 ],[
532 #ifndef CONFIG_$1
533 #error CONFIG_$1 not #defined
534 #endif
535 ],[
536 AC_MSG_RESULT([yes])
537 $2
538 ],[
539 AC_MSG_RESULT([no])
540 $3
541 ])
542])
543
544dnl #
545dnl # SPL_CHECK_SYMBOL_EXPORT
546dnl # check symbol exported or not
547dnl #
548AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
549 [AC_MSG_CHECKING([whether symbol $1 is exported])
2e0e7e69
BB
550 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
551 $LINUX_OBJ/Module*.symvers 2>/dev/null
57d86234 552 rc=$?
553 if test $rc -ne 0; then
554 export=0
555 for file in $2; do
2e0e7e69
BB
556 grep -q -E "EXPORT_SYMBOL.*($1)" \
557 "$LINUX_OBJ/$file" 2>/dev/null
57d86234 558 rc=$?
559 if test $rc -eq 0; then
560 export=1
561 break;
562 fi
563 done
564 if test $export -eq 0; then
565 AC_MSG_RESULT([no])
566 $4
567 else
568 AC_MSG_RESULT([yes])
569 $3
570 fi
571 else
572 AC_MSG_RESULT([yes])
573 $3
574 fi
575])
576
86de8532 577dnl #
578dnl # SPL_CHECK_HEADER
579dnl # check whether header exists and define HAVE_$2_HEADER
580dnl #
581AC_DEFUN([SPL_CHECK_HEADER],
582 [AC_MSG_CHECKING([whether header $1 exists])
583 SPL_LINUX_TRY_COMPILE([
d50bd9e2 584 #include <$1>
86de8532 585 ],[
586 return 0;
587 ],[
588 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
589 AC_MSG_RESULT(yes)
590 $3
591 ],[
592 AC_MSG_RESULT(no)
593 $4
594 ])
595])
6a6cafbe 596
57d86234 597dnl #
d04c8a56
BB
598dnl # Use the atomic implemenation based on global spinlocks. This
599dnl # should only be needed by 32-bit kernels which do not provide
600dnl # the atomic64_* API. It may be optionally enabled as a fallback
601dnl # if problems are observed with the direct mapping to the native
602dnl # Linux atomic operations. You may not disable atomic spinlocks
603dnl # if you kernel does not an atomic64_* API.
57d86234 604dnl #
d04c8a56
BB
605AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
606 AC_ARG_ENABLE([atomic-spinlocks],
607 [AS_HELP_STRING([--enable-atomic-spinlocks],
608 [Atomic types use spinlocks @<:@default=check@:>@])],
609 [],
610 [enable_atomic_spinlocks=check])
57d86234 611
a0f6da3d 612 SPL_LINUX_TRY_COMPILE([
613 #include <asm/atomic.h>
614 ],[
615 atomic64_t *ptr;
616 ],[
d04c8a56 617 have_atomic64_t=yes
a0f6da3d 618 AC_DEFINE(HAVE_ATOMIC64_T, 1,
d04c8a56 619 [kernel defines atomic64_t])
a0f6da3d 620 ],[
d04c8a56
BB
621 have_atomic64_t=no
622 ])
623
624 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
625 AS_IF([test "x$have_atomic64_t" = xyes], [
626 enable_atomic_spinlocks=no
627 ],[
628 enable_atomic_spinlocks=yes
629 ])
a0f6da3d 630 ])
d04c8a56
BB
631
632 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
633 AC_DEFINE([ATOMIC_SPINLOCK], [1],
634 [Atomic types use spinlocks])
635 ],[
636 AS_IF([test "x$have_atomic64_t" = xno], [
637 AC_MSG_FAILURE(
638 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
639 ])
640 ])
641
642 AC_MSG_CHECKING([whether atomic types use spinlocks])
643 AC_MSG_RESULT([$enable_atomic_spinlocks])
644
645 AC_MSG_CHECKING([whether kernel defines atomic64_t])
646 AC_MSG_RESULT([$have_atomic64_t])
a0f6da3d 647])
648
302b88e6
BB
649dnl #
650dnl # 2.6.24 API change,
651dnl # check if atomic64_cmpxchg is defined
652dnl #
653AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
654 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
655 SPL_LINUX_TRY_COMPILE([
656 #include <asm/atomic.h>
5ec44a37 657 #include <asm/system.h>
302b88e6
BB
658 ],[
659 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
660 ],[
661 AC_MSG_RESULT([yes])
662 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
663 [kernel defines atomic64_cmpxchg])
664 ],[
665 AC_MSG_RESULT([no])
666 ])
667])
668
669dnl #
670dnl # 2.6.24 API change,
671dnl # check if atomic64_xchg is defined
672dnl #
673AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
674 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
675 SPL_LINUX_TRY_COMPILE([
676 #include <asm/atomic.h>
677 ],[
678 atomic64_xchg((atomic64_t *)NULL, 0);
679 ],[
680 AC_MSG_RESULT([yes])
681 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
682 [kernel defines atomic64_xchg])
683 ],[
684 AC_MSG_RESULT([no])
685 ])
686])
687
d04c8a56
BB
688dnl #
689dnl # 2.6.24 API change,
690dnl # check if uintptr_t typedef is defined
691dnl #
692AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
693 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
694 SPL_LINUX_TRY_COMPILE([
695 #include <linux/types.h>
696 ],[
697 uintptr_t *ptr;
698 ],[
699 AC_MSG_RESULT([yes])
700 AC_DEFINE(HAVE_UINTPTR_T, 1,
701 [kernel defines uintptr_t])
702 ],[
703 AC_MSG_RESULT([no])
704 ])
705])
706
57d86234 707dnl #
3d061e9d 708dnl # 2.6.20 API change,
57d86234 709dnl # INIT_WORK use 2 args and not store data inside
710dnl #
711AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
712 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
713 SPL_LINUX_TRY_COMPILE([
d50bd9e2 714 #include <linux/workqueue.h>
57d86234 715 ],[
d50bd9e2 716 struct work_struct work;
717 INIT_WORK(&work, NULL, NULL);
57d86234 718 ],[
d50bd9e2 719 AC_MSG_RESULT(yes)
720 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
721 [INIT_WORK wants 3 args])
57d86234 722 ],[
d50bd9e2 723 AC_MSG_RESULT(no)
57d86234 724 ])
725])
726
727dnl #
3d061e9d 728dnl # 2.6.21 API change,
57d86234 729dnl # 'register_sysctl_table' use only one argument instead of two
730dnl #
731AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
732 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
733 SPL_LINUX_TRY_COMPILE([
d50bd9e2 734 #include <linux/sysctl.h>
57d86234 735 ],[
d50bd9e2 736 return register_sysctl_table(NULL,0);
57d86234 737 ],[
d50bd9e2 738 AC_MSG_RESULT(yes)
739 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
740 [register_sysctl_table() wants 2 args])
57d86234 741 ],[
d50bd9e2 742 AC_MSG_RESULT(no)
57d86234 743 ])
744])
745
57d86234 746dnl #
3d061e9d 747dnl # 2.6.23 API change
57d86234 748dnl # Old set_shrinker API replaced with register_shrinker
749dnl #
750AC_DEFUN([SPL_AC_SET_SHRINKER], [
751 AC_MSG_CHECKING([whether set_shrinker() available])
752 SPL_LINUX_TRY_COMPILE([
753 #include <linux/mm.h>
754 ],[
755 return set_shrinker(DEFAULT_SEEKS, NULL);
756 ],[
757 AC_MSG_RESULT([yes])
758 AC_DEFINE(HAVE_SET_SHRINKER, 1,
759 [set_shrinker() available])
760 ],[
761 AC_MSG_RESULT([no])
762 ])
763])
764
23aa63cb
BB
765dnl #
766dnl # 2.6.35 API change,
767dnl # Add context to shrinker callback
768dnl #
769AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
770 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
771 tmp_flags="$EXTRA_KCFLAGS"
772 EXTRA_KCFLAGS="-Werror"
773 SPL_LINUX_TRY_COMPILE([
774 #include <linux/mm.h>
775
776 int shrinker_cb(struct shrinker *, int, unsigned int);
777 ],[
778 struct shrinker cache_shrinker = {
779 .shrink = shrinker_cb,
780 .seeks = DEFAULT_SEEKS,
781 };
782 register_shrinker(&cache_shrinker);
783 ],[
784 AC_MSG_RESULT(yes)
785 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
786 [shrinker callback wants 3 args])
787 ],[
788 AC_MSG_RESULT(no)
789 ])
790 EXTRA_KCFLAGS="$tmp_flags"
791])
792
57d86234 793dnl #
3d061e9d 794dnl # 2.6.25 API change,
57d86234 795dnl # struct path entry added to struct nameidata
796dnl #
797AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
798 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
799 SPL_LINUX_TRY_COMPILE([
d50bd9e2 800 #include <linux/namei.h>
57d86234 801 ],[
d50bd9e2 802 struct nameidata nd;
57d86234 803
804 nd.path.mnt = NULL;
805 nd.path.dentry = NULL;
806 ],[
d50bd9e2 807 AC_MSG_RESULT(yes)
808 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
809 [struct path used in struct nameidata])
57d86234 810 ],[
d50bd9e2 811 AC_MSG_RESULT(no)
57d86234 812 ])
813])
814
815dnl #
816dnl # Custom SPL patch may export this system it is not required
817dnl #
818AC_DEFUN([SPL_AC_TASK_CURR], [
819 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
820 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
821 [])
822])
823
824dnl #
3d061e9d 825dnl # 2.6.19 API change,
57d86234 826dnl # Use CTL_UNNUMBERED when binary sysctl is not required
827dnl #
828AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
829 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
830 SPL_LINUX_TRY_COMPILE([
d50bd9e2 831 #include <linux/sysctl.h>
57d86234 832 ],[
833 #ifndef CTL_UNNUMBERED
834 #error CTL_UNNUMBERED undefined
835 #endif
836 ],[
d50bd9e2 837 AC_MSG_RESULT(yes)
838 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
839 [unnumbered sysctl support exists])
57d86234 840 ],[
d50bd9e2 841 AC_MSG_RESULT(no)
57d86234 842 ])
843])
877a32e9 844
79a3bf13
BB
845dnl #
846dnl # 2.6.33 API change,
847dnl # Removed .ctl_name from struct ctl_table.
848dnl #
849AC_DEFUN([SPL_AC_CTL_NAME], [
850 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
851 SPL_LINUX_TRY_COMPILE([
852 #include <linux/sysctl.h>
853 ],[
854 struct ctl_table ctl;
855 ctl.ctl_name = 0;
856 ],[
857 AC_MSG_RESULT(yes)
858 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
859 ],[
860 AC_MSG_RESULT(no)
861 ])
862])
863
877a32e9 864dnl #
865dnl # 2.6.16 API change.
866dnl # Check if 'fls64()' is available
867dnl #
868AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 869 [AC_MSG_CHECKING([whether fls64() is available])
870 SPL_LINUX_TRY_COMPILE([
871 #include <linux/bitops.h>
872 ],[
873 return fls64(0);
874 ],[
875 AC_MSG_RESULT(yes)
876 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
877 ],[
878 AC_MSG_RESULT(no)
879 ])
877a32e9 880])
46c685d0 881
882dnl #
883dnl # 2.6.18 API change, check whether device_create() is available.
884dnl # Device_create() was introduced in 2.6.18 and depricated
885dnl # class_device_create() which was fully removed in 2.6.26.
886dnl #
887AC_DEFUN([SPL_AC_DEVICE_CREATE], [
888 SPL_CHECK_SYMBOL_EXPORT(
889 [device_create],
890 [drivers/base/core.c],
891 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
892 [device_create() is available])],
6a6cafbe 893 [])
46c685d0 894])
895
8123ac4f
BB
896dnl #
897dnl # 2.6.27 API change,
898dnl # device_create() uses 5 args, new 'drvdata' argument.
899dnl #
900AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
901 AC_MSG_CHECKING([whether device_create() wants 5 args])
902 tmp_flags="$EXTRA_KCFLAGS"
903 EXTRA_KCFLAGS="-Werror"
904 SPL_LINUX_TRY_COMPILE([
905 #include <linux/device.h>
906 ],[
907 device_create(NULL, NULL, 0, NULL, "%d", 1);
908 ],[
909 AC_MSG_RESULT(yes)
910 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
911 [device_create wants 5 args])
912 ],[
913 AC_MSG_RESULT(no)
914 ])
915 EXTRA_KCFLAGS="$tmp_flags"
916])
917
46c685d0 918dnl #
919dnl # 2.6.13 API change, check whether class_device_create() is available.
920dnl # Class_device_create() was introduced in 2.6.13 and depricated
921dnl # class_simple_device_add() which was fully removed in 2.6.13.
922dnl #
923AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
924 SPL_CHECK_SYMBOL_EXPORT(
925 [class_device_create],
926 [drivers/base/class.c],
927 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
928 [class_device_create() is available])],
6a6cafbe 929 [])
46c685d0 930])
6a6cafbe 931
6a6cafbe 932dnl #
933dnl # 2.6.26 API change, set_normalized_timespec() is exported.
934dnl #
935AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
936 SPL_CHECK_SYMBOL_EXPORT(
937 [set_normalized_timespec],
938 [kernel/time.c],
939 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
940 [set_normalized_timespec() is available as export])],
941 [])
942])
943
944dnl #
945dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
946dnl # previously it was available in time.h as an inline.
947dnl #
86de8532 948AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
949 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 950 SPL_LINUX_TRY_COMPILE([
951 #include <linux/time.h>
6a6cafbe 952 void set_normalized_timespec(struct timespec *ts,
25557fd8 953 time_t sec, long nsec) { }
954 ],
955 [],
956 [
6a6cafbe 957 AC_MSG_RESULT(no)
958 ],[
959 AC_MSG_RESULT(yes)
960 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
961 [set_normalized_timespec() is available as inline])
962 ])
963])
964
965dnl #
966dnl # 2.6.18 API change,
967dnl # timespec_sub() inline function available in linux/time.h
968dnl #
86de8532 969AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
970 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 971 SPL_LINUX_TRY_COMPILE([
972 #include <linux/time.h>
973 ],[
974 struct timespec a, b, c = { 0 };
975 c = timespec_sub(a, b);
976 ],[
977 AC_MSG_RESULT(yes)
978 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
979 ],[
980 AC_MSG_RESULT(no)
981 ])
982])
983
86de8532 984dnl #
3d061e9d 985dnl # 2.6.19 API change,
986dnl # check if init_utsname() is available in linux/utsname.h
987dnl #
988AC_DEFUN([SPL_AC_INIT_UTSNAME], [
989 AC_MSG_CHECKING([whether init_utsname() is available])
990 SPL_LINUX_TRY_COMPILE([
991 #include <linux/utsname.h>
992 ],[
993 struct new_utsname *a = init_utsname();
994 ],[
995 AC_MSG_RESULT(yes)
996 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
997 ],[
998 AC_MSG_RESULT(no)
999 ])
1000])
1001
1002dnl #
1003dnl # 2.6.26 API change,
1004dnl # definition of struct fdtable relocated to linux/fdtable.h
86de8532 1005dnl #
1006AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1007 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1008])
322640b7 1009
1010dnl #
3d061e9d 1011dnl # 2.6.14 API change,
1012dnl # check whether 'files_fdtable()' exists
1013dnl #
1014AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1015 AC_MSG_CHECKING([whether files_fdtable() is available])
1016 SPL_LINUX_TRY_COMPILE([
1017 #include <linux/sched.h>
1018 #include <linux/file.h>
1019 #ifdef HAVE_FDTABLE_HEADER
1020 #include <linux/fdtable.h>
1021 #endif
1022 ],[
1023 struct files_struct *files = current->files;
1024 struct fdtable *fdt = files_fdtable(files);
1025 ],[
1026 AC_MSG_RESULT(yes)
1027 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1028 ],[
1029 AC_MSG_RESULT(no)
1030 ])
1031])
1032
1033dnl #
1034dnl # 2.6.18 API change,
1035dnl # added linux/uaccess.h
322640b7 1036dnl #
1037AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1038 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1039])
3d061e9d 1040
1041dnl #
1042dnl # 2.6.12 API change,
1043dnl # check whether 'kmalloc_node()' is available.
1044dnl #
1045AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1046 AC_MSG_CHECKING([whether kmalloc_node() is available])
1047 SPL_LINUX_TRY_COMPILE([
1048 #include <linux/slab.h>
1049 ],[
1050 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1051 ],[
1052 AC_MSG_RESULT(yes)
1053 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1054 ],[
1055 AC_MSG_RESULT(no)
1056 ])
1057])
1058
1059dnl #
1060dnl # 2.6.9 API change,
1061dnl # check whether 'monotonic_clock()' is available it may
1062dnl # be available for some archs but not others.
1063dnl #
1064AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1065 SPL_CHECK_SYMBOL_EXPORT(
1066 [monotonic_clock],
1067 [],
1068 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1069 [monotonic_clock() is available])],
1070 [])
1071])
1072
1073dnl #
1074dnl # 2.6.16 API change,
1075dnl # check whether 'struct inode' has i_mutex
1076dnl #
1077AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1078 AC_MSG_CHECKING([whether struct inode has i_mutex])
1079 SPL_LINUX_TRY_COMPILE([
1080 #include <linux/fs.h>
1081 #include <linux/mutex.h>
1082 ],[
1083 struct inode i;
1084 mutex_init(&i.i_mutex);
1085 ],[
1086 AC_MSG_RESULT(yes)
1087 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1088 ],[
1089 AC_MSG_RESULT(no)
1090 ])
1091])
b61a6e8b 1092
4d54fdee
BB
1093dnl #
1094dnl # 2.6.29 API change,
1095dnl # Adaptive mutexs introduced.
1096dnl #
1097AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1098 AC_MSG_CHECKING([whether struct mutex has owner])
1099 SPL_LINUX_TRY_COMPILE([
1100 #include <linux/mutex.h>
1101 ],[
1102 struct mutex mtx;
1103 mtx.owner = NULL;
1104 ],[
1105 AC_MSG_RESULT(yes)
1106 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1107 ],[
1108 AC_MSG_RESULT(no)
1109 ])
1110])
1111
6c9433c1
BB
1112dnl #
1113dnl # 2.6.18 API change,
1114dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1115dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1116dnl # if the mutex validator is disabled or otherwise unavailable.
1117dnl #
1118AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1119 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1120 SPL_LINUX_TRY_COMPILE([
1121 #include <linux/mutex.h>
1122 ],[
1123 struct mutex mutex;
1124 mutex_init(&mutex);
1125 mutex_lock_nested(&mutex, 0);
1126 ],[
1127 AC_MSG_RESULT(yes)
1128 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1129 [mutex_lock_nested() is available])
1130 ],[
1131 AC_MSG_RESULT(no)
1132 ])
1133])
1134
31a033ec
BB
1135dnl #
1136dnl # 2.6.27 API change,
1137dnl # on_each_cpu() uses 3 args, no 'retry' argument
1138dnl #
1139AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1140 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1141 SPL_LINUX_TRY_COMPILE([
1142 #include <linux/smp.h>
1143 ],[
1144 on_each_cpu(NULL, NULL, 0);
1145 ],[
1146 AC_MSG_RESULT(yes)
1147 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1148 [on_each_cpu wants 3 args])
1149 ],[
1150 AC_MSG_RESULT(no)
1151 ])
1152])
36b313da
BB
1153
1154dnl #
d1ff2312
BB
1155dnl # 2.6.18 API change,
1156dnl # kallsyms_lookup_name no longer exported
1157dnl #
1158AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1159 SPL_CHECK_SYMBOL_EXPORT(
1160 [kallsyms_lookup_name],
1161 [],
1162 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1163 [kallsyms_lookup_name() is available])],
1164 [])
1165])
1166
1167dnl #
e11d6c5f
BB
1168dnl # Proposed API change,
1169dnl # This symbol is not available in stock kernels. You may build a
1170dnl # custom kernel with the *-spl-export-symbols.patch which will export
1171dnl # these symbols for use. If your already rolling a custom kernel for
1172dnl # your environment this is recommended.
d1ff2312
BB
1173dnl #
1174AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1175 SPL_CHECK_SYMBOL_EXPORT(
1176 [get_vmalloc_info],
1177 [],
1178 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1179 [get_vmalloc_info() is available])],
1180 [])
1181])
1182
5232d256
BB
1183dnl #
1184dnl # 2.6.17 API change
1185dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1186dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1187dnl # were exported in 2.6.17 for use by modules which was consistent with
1188dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1189dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1190dnl # were dropped entirely leaving modules no way to directly iterate over
1191dnl # the zone list. Because we need access to the zone helpers we check
1192dnl # if the kernel contains the old or new implementation. Then we check
1193dnl # to see if the symbols we need for each version are available. If they
1194dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1195dnl #
1196AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1197 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1198 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1199 rc=$?
1200 if test $rc -eq 0; then
1201 AC_MSG_RESULT([yes])
1202 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1203 else
1204 AC_MSG_RESULT([no])
1205 fi
1206])
1207
d1ff2312 1208dnl #
e11d6c5f
BB
1209dnl # Proposed API change,
1210dnl # This symbol is not available in stock kernels. You may build a
1211dnl # custom kernel with the *-spl-export-symbols.patch which will export
1212dnl # these symbols for use. If your already rolling a custom kernel for
1213dnl # your environment this is recommended.
36b313da
BB
1214dnl #
1215AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1216 SPL_CHECK_SYMBOL_EXPORT(
1217 [first_online_pgdat],
1218 [],
1219 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1220 [first_online_pgdat() is available])],
1221 [])
1222])
1223
1224dnl #
e11d6c5f
BB
1225dnl # Proposed API change,
1226dnl # This symbol is not available in stock kernels. You may build a
1227dnl # custom kernel with the *-spl-export-symbols.patch which will export
1228dnl # these symbols for use. If your already rolling a custom kernel for
1229dnl # your environment this is recommended.
36b313da
BB
1230dnl #
1231AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1232 SPL_CHECK_SYMBOL_EXPORT(
1233 [next_online_pgdat],
1234 [],
1235 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1236 [next_online_pgdat() is available])],
1237 [])
1238])
1239
1240dnl #
e11d6c5f
BB
1241dnl # Proposed API change,
1242dnl # This symbol is not available in stock kernels. You may build a
1243dnl # custom kernel with the *-spl-export-symbols.patch which will export
1244dnl # these symbols for use. If your already rolling a custom kernel for
1245dnl # your environment this is recommended.
36b313da
BB
1246dnl #
1247AC_DEFUN([SPL_AC_NEXT_ZONE], [
1248 SPL_CHECK_SYMBOL_EXPORT(
1249 [next_zone],
1250 [],
1251 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1252 [next_zone() is available])],
1253 [])
1254])
4ab13d3b 1255
5232d256
BB
1256dnl #
1257dnl # 2.6.17 API change,
1258dnl # See SPL_AC_PGDAT_HELPERS for details.
1259dnl #
1260AC_DEFUN([SPL_AC_PGDAT_LIST], [
1261 SPL_CHECK_SYMBOL_EXPORT(
1262 [pgdat_list],
1263 [],
1264 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1265 [pgdat_list is available])],
1266 [])
1267])
1268
96dded38
BB
1269dnl #
1270dnl # 2.6.18 API change,
1271dnl # First introduced global_page_state() support as an inline.
1272dnl #
1273AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1274 AC_MSG_CHECKING([whether global_page_state() is available])
1275 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1276 #include <linux/mm.h>
96dded38
BB
1277 ],[
1278 unsigned long state;
6ae7fef5 1279 state = global_page_state(0);
96dded38
BB
1280 ],[
1281 AC_MSG_RESULT(yes)
1282 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1283 [global_page_state() is available])
1284 ],[
1285 AC_MSG_RESULT(no)
1286 ])
1287])
1288
e11d6c5f 1289dnl #
6ae7fef5
BB
1290dnl # 2.6.21 API change (plus subsequent naming convention changes),
1291dnl # Public global zone stats now include a free page count. However
1292dnl # the enumerated names of the counters have changed since this API
1293dnl # was introduced. We need to deduce the corrent name to use. This
1294dnl # replaces the priviate get_zone_counts() interface.
1295dnl #
1296dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1297dnl # is 2.6.30 as of when this was written.
e11d6c5f 1298dnl #
6ae7fef5
BB
1299AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1300 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
e11d6c5f 1301 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1302 #include <linux/mm.h>
e11d6c5f 1303 ],[
6ae7fef5
BB
1304 enum zone_stat_item zsi;
1305 zsi = NR_FREE_PAGES;
e11d6c5f
BB
1306 ],[
1307 AC_MSG_RESULT(yes)
6ae7fef5
BB
1308 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1309 [Page state NR_FREE_PAGES is available])
e11d6c5f
BB
1310 ],[
1311 AC_MSG_RESULT(no)
1312 ])
1313])
a093c6a4 1314
6ae7fef5
BB
1315dnl #
1316dnl # 2.6.21 API change (plus subsequent naming convention changes),
1317dnl # Public global zone stats now include an inactive page count. However
1318dnl # the enumerated names of the counters have changed since this API
1319dnl # was introduced. We need to deduce the corrent name to use. This
1320dnl # replaces the priviate get_zone_counts() interface.
1321dnl #
1322dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1323dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1324dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1325dnl #
1326AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1327 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1328 SPL_LINUX_TRY_COMPILE([
1329 #include <linux/mm.h>
1330 ],[
1331 enum zone_stat_item zsi;
1332 zsi = NR_INACTIVE;
1333 ],[
1334 AC_MSG_RESULT(yes)
1335 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1336 [Page state NR_INACTIVE is available])
1337 ],[
1338 AC_MSG_RESULT(no)
1339 ])
1340
1341 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1342 SPL_LINUX_TRY_COMPILE([
1343 #include <linux/mm.h>
1344 ],[
1345 enum zone_stat_item zsi;
1346 zsi = NR_INACTIVE_ANON;
1347 ],[
1348 AC_MSG_RESULT(yes)
1349 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1350 [Page state NR_INACTIVE_ANON is available])
1351 ],[
1352 AC_MSG_RESULT(no)
1353 ])
1354
1355 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1356 SPL_LINUX_TRY_COMPILE([
1357 #include <linux/mm.h>
1358 ],[
1359 enum zone_stat_item zsi;
1360 zsi = NR_INACTIVE_FILE;
1361 ],[
1362 AC_MSG_RESULT(yes)
1363 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1364 [Page state NR_INACTIVE_FILE is available])
1365 ],[
1366 AC_MSG_RESULT(no)
1367 ])
1368])
1369
1370dnl #
1371dnl # 2.6.21 API change (plus subsequent naming convention changes),
1372dnl # Public global zone stats now include an active page count. However
1373dnl # the enumerated names of the counters have changed since this API
1374dnl # was introduced. We need to deduce the corrent name to use. This
1375dnl # replaces the priviate get_zone_counts() interface.
1376dnl #
1377dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1378dnl # anonymous and file active pages. As of 2.6.28 it was split in
1379dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1380dnl #
1381AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1382 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1383 SPL_LINUX_TRY_COMPILE([
1384 #include <linux/mm.h>
1385 ],[
1386 enum zone_stat_item zsi;
1387 zsi = NR_ACTIVE;
1388 ],[
1389 AC_MSG_RESULT(yes)
1390 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1391 [Page state NR_ACTIVE is available])
1392 ],[
1393 AC_MSG_RESULT(no)
1394 ])
1395
1396 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1397 SPL_LINUX_TRY_COMPILE([
1398 #include <linux/mm.h>
1399 ],[
1400 enum zone_stat_item zsi;
1401 zsi = NR_ACTIVE_ANON;
1402 ],[
1403 AC_MSG_RESULT(yes)
1404 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1405 [Page state NR_ACTIVE_ANON is available])
1406 ],[
1407 AC_MSG_RESULT(no)
1408 ])
1409
1410 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1411 SPL_LINUX_TRY_COMPILE([
1412 #include <linux/mm.h>
1413 ],[
1414 enum zone_stat_item zsi;
1415 zsi = NR_ACTIVE_FILE;
1416 ],[
1417 AC_MSG_RESULT(yes)
1418 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1419 [Page state NR_ACTIVE_FILE is available])
1420 ],[
1421 AC_MSG_RESULT(no)
1422 ])
1423])
1424
1425dnl #
1426dnl # Proposed API change for legacy kernels.
1427dnl # This symbol is not available in older kernels. For kernels post
1428dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1429dnl # page state information. This symbol is only used in legacy kernels
1430dnl # any only as a last resort.
1431dnl
1432AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1433 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1434 SPL_LINUX_TRY_COMPILE([
1435 ],[
1436 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1437 #error "global_page_state needs NR_FREE_PAGES"
1438 #endif
1439
1440 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1441 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1442 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1443 #error "global_page_state needs NR_ACTIVE*"
1444 #endif
1445
1446 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1447 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1448 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1449 #error "global_page_state needs NR_INACTIVE*"
1450 #endif
1451 ],[
1452 AC_MSG_RESULT(no)
1453 ],[
1454 AC_MSG_RESULT(yes)
1455 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1456 [get_zone_counts() is needed])
1457
1458 SPL_CHECK_SYMBOL_EXPORT(
1459 [get_zone_counts],
1460 [],
1461 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1462 [get_zone_counts() is available])],
1463 [])
1464 ])
1465])
1466
7119bf70
BB
1467dnl #
1468dnl # 2.6.27 API change,
1469dnl # The user_path_dir() replaces __user_walk()
1470dnl #
1471AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1472 SPL_CHECK_SYMBOL_EXPORT(
1473 [user_path_at],
1474 [],
1475 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1476 [user_path_dir() is available])],
1477 [])
1478])
1479
51a727e9
BB
1480dnl #
1481dnl # Symbol available in RHEL kernels not in stock kernels.
1482dnl #
1483AC_DEFUN([SPL_AC_SET_FS_PWD], [
1484 SPL_CHECK_SYMBOL_EXPORT(
1485 [set_fs_pwd],
1486 [],
1487 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1488 [set_fs_pwd() is available])],
1489 [])
1490])
1491
1492dnl #
1493dnl # 2.6.25 API change,
1494dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1495dnl #
1496AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1497 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1498 SPL_LINUX_TRY_COMPILE([
1499 #include <linux/sched.h>
baf2979e 1500 #include <linux/fs_struct.h>
51a727e9
BB
1501 ],[
1502 set_fs_pwd(NULL, NULL);
1503 ],[
1504 AC_MSG_RESULT(yes)
1505 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1506 [set_fs_pwd() wants 2 args])
1507 ],[
1508 AC_MSG_RESULT(no)
1509 ])
1510])
1511
a093c6a4
BB
1512dnl #
1513dnl # SLES API change, never adopted in mainline,
1514dnl # Third 'struct vfsmount *' argument removed.
1515dnl #
1516AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1517 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1518 SPL_LINUX_TRY_COMPILE([
1519 #include <linux/fs.h>
1520 ],[
1521 vfs_unlink(NULL, NULL);
1522 ],[
1523 AC_MSG_RESULT(yes)
1524 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1525 [vfs_unlink() wants 2 args])
1526 ],[
1527 AC_MSG_RESULT(no)
1528 ])
1529])
1530
1531dnl #
1532dnl # SLES API change, never adopted in mainline,
1533dnl # Third and sixth 'struct vfsmount *' argument removed.
1534dnl #
1535AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1536 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1537 SPL_LINUX_TRY_COMPILE([
1538 #include <linux/fs.h>
1539 ],[
1540 vfs_rename(NULL, NULL, NULL, NULL);
1541 ],[
1542 AC_MSG_RESULT(yes)
1543 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1544 [vfs_rename() wants 4 args])
1545 ],[
1546 AC_MSG_RESULT(no)
1547 ])
1548])
ec7d53e9
BB
1549
1550dnl #
1551dnl # 2.6.29 API change,
1552dnl # check whether 'struct cred' exists
1553dnl #
1554AC_DEFUN([SPL_AC_CRED_STRUCT], [
1555 AC_MSG_CHECKING([whether struct cred exists])
1556 SPL_LINUX_TRY_COMPILE([
1557 #include <linux/cred.h>
1558 ],[
1559 struct cred *cr;
1560 cr = NULL;
1561 ],[
1562 AC_MSG_RESULT(yes)
1563 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1564 ],[
1565 AC_MSG_RESULT(no)
1566 ])
1567])
1568
1569dnl #
e811949a 1570dnl # Custom SPL patch may export this symbol.
ec7d53e9
BB
1571dnl #
1572AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1573 SPL_CHECK_SYMBOL_EXPORT(
1574 [groups_search],
1575 [],
1576 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1577 [groups_search() is available])],
1578 [])
1579])
e811949a
BB
1580
1581dnl #
1582dnl # 2.6.x API change,
1583dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1584dnl #
1585AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1586 SPL_CHECK_SYMBOL_EXPORT(
1587 [__put_task_struct],
1588 [],
1589 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1590 [__put_task_struct() is available])],
1591 [])
1592])
3977f837
BB
1593
1594dnl #
1595dnl # 2.6.32 API change,
1596dnl # Unused 'struct file *' removed from prototype.
1597dnl #
1598AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1599 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1600 SPL_LINUX_TRY_COMPILE([
1601 #include <linux/sysctl.h>
1602 ],[
1603 proc_dostring(NULL, 0, NULL, NULL, NULL);
1604 ],[
1605 AC_MSG_RESULT(yes)
1606 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1607 [proc_handler() wants 5 args])
1608 ],[
1609 AC_MSG_RESULT(no)
1610 ])
1611])
b868e22f
BB
1612
1613dnl #
1614dnl # 2.6.x API change,
1615dnl # kvasprintf() function added.
1616dnl #
1617AC_DEFUN([SPL_AC_KVASPRINTF], [
1618 SPL_CHECK_SYMBOL_EXPORT(
1619 [kvasprintf],
1620 [],
1621 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1622 [kvasprintf() is available])],
1623 [])
1624])
f0ff89fc
BB
1625
1626dnl #
1627dnl # 2.6.35 API change,
1628dnl # Unused 'struct dentry *' removed from prototype.
1629dnl #
1630AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1631 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1632 SPL_LINUX_TRY_COMPILE([
1633 #include <linux/buffer_head.h>
1634 ],[
1635 file_fsync(NULL, NULL, 0);
1636 ],[
1637 AC_MSG_RESULT(yes)
1638 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1639 [file_fsync() wants 3 args])
1640 ],[
1641 AC_MSG_RESULT(no)
1642 ])
1643])
46aa7b39
NB
1644
1645dnl #
1646dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1647dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1648dnl # condition. The fixed version is exported as a symbol. The race
1649dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1650dnl # call that version while holding sem->wait_lock.
1651dnl #
1652AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1653 SPL_CHECK_SYMBOL_EXPORT(
1654 [rwsem_is_locked],
1655 [lib/rwsem-spinlock.c],
1656 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1657 [rwsem_is_locked() acquires sem->wait_lock])],
1658 [])
1659])