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