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