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