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