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