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