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