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