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