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