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