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