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