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