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