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