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