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