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