]> git.proxmox.com Git - mirror_spl-debian.git/blob - config/spl-build.m4
Support custom build directories
[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_KMEM
22 SPL_AC_DEBUG_KMEM_TRACKING
23 SPL_AC_ATOMIC_SPINLOCK
24 SPL_AC_TYPE_ATOMIC64_CMPXCHG
25 SPL_AC_TYPE_ATOMIC64_XCHG
26 SPL_AC_TYPE_UINTPTR_T
27 SPL_AC_3ARGS_INIT_WORK
28 SPL_AC_2ARGS_REGISTER_SYSCTL
29 SPL_AC_SET_SHRINKER
30 SPL_AC_PATH_IN_NAMEIDATA
31 SPL_AC_TASK_CURR
32 SPL_AC_CTL_UNNUMBERED
33 SPL_AC_CTL_NAME
34 SPL_AC_FLS64
35 SPL_AC_DEVICE_CREATE
36 SPL_AC_5ARGS_DEVICE_CREATE
37 SPL_AC_CLASS_DEVICE_CREATE
38 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
39 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
40 SPL_AC_TIMESPEC_SUB
41 SPL_AC_INIT_UTSNAME
42 SPL_AC_FDTABLE_HEADER
43 SPL_AC_FILES_FDTABLE
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_LOCK_NESTED
50 SPL_AC_3ARGS_ON_EACH_CPU
51 SPL_AC_KALLSYMS_LOOKUP_NAME
52 SPL_AC_GET_VMALLOC_INFO
53 SPL_AC_PGDAT_HELPERS
54 SPL_AC_FIRST_ONLINE_PGDAT
55 SPL_AC_NEXT_ONLINE_PGDAT
56 SPL_AC_NEXT_ZONE
57 SPL_AC_PGDAT_LIST
58 SPL_AC_GLOBAL_PAGE_STATE
59 SPL_AC_ZONE_STAT_ITEM_FREE
60 SPL_AC_ZONE_STAT_ITEM_INACTIVE
61 SPL_AC_ZONE_STAT_ITEM_ACTIVE
62 SPL_AC_GET_ZONE_COUNTS
63 SPL_AC_USER_PATH_DIR
64 SPL_AC_SET_FS_PWD
65 SPL_AC_2ARGS_SET_FS_PWD
66 SPL_AC_2ARGS_VFS_UNLINK
67 SPL_AC_4ARGS_VFS_RENAME
68 SPL_AC_CRED_STRUCT
69 SPL_AC_GROUPS_SEARCH
70 SPL_AC_PUT_TASK_STRUCT
71 SPL_AC_5ARGS_PROC_HANDLER
72 SPL_AC_KVASPRINTF
73 SPL_AC_3ARGS_FILE_FSYNC
74 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
75 ])
76
77 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
78 modpost=$LINUX/scripts/Makefile.modpost
79 AC_MSG_CHECKING([kernel file name for module symbols])
80 if test -f "$modpost"; then
81 if grep -q Modules.symvers $modpost; then
82 LINUX_SYMBOLS=Modules.symvers
83 else
84 LINUX_SYMBOLS=Module.symvers
85 fi
86 else
87 LINUX_SYMBOLS=NONE
88 fi
89 AC_MSG_RESULT($LINUX_SYMBOLS)
90 AC_SUBST(LINUX_SYMBOLS)
91 ])
92
93 AC_DEFUN([SPL_AC_KERNEL], [
94 AC_ARG_WITH([linux],
95 AS_HELP_STRING([--with-linux=PATH],
96 [Path to kernel source]),
97 [kernelsrc="$withval"])
98
99 AC_ARG_WITH([linux-obj],
100 AS_HELP_STRING([--with-linux-obj=PATH],
101 [Path to kernel build objects]),
102 [kernelbuild="$withval"])
103
104 AC_MSG_CHECKING([kernel source directory])
105 if test -z "$kernelsrc"; then
106 headersdir="/lib/modules/$(uname -r)/build"
107 if test -e "$headersdir"; then
108 sourcelink=$(readlink -f "$headersdir")
109 else
110 sourcelink=$(ls -1d /usr/src/kernels/* \
111 /usr/src/linux-* \
112 2>/dev/null | grep -v obj | tail -1)
113 fi
114
115 if test -n "$sourcelink" && test -e ${sourcelink}; then
116 kernelsrc=`readlink -f ${sourcelink}`
117 else
118 AC_MSG_RESULT([Not found])
119 AC_MSG_ERROR([
120 *** Please make sure the kernel devel package for your distribution
121 *** is installed then try again. If that fails you can specify the
122 *** location of the kernel source with the '--with-linux=PATH' option.])
123 fi
124 else
125 if test "$kernelsrc" = "NONE"; then
126 kernsrcver=NONE
127 fi
128 fi
129
130 AC_MSG_RESULT([$kernelsrc])
131 AC_MSG_CHECKING([kernel build directory])
132 if test -z "$kernelbuild"; then
133 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
134 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
135 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
136 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
137 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
138 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
139 else
140 kernelbuild=${kernelsrc}
141 fi
142 fi
143 AC_MSG_RESULT([$kernelbuild])
144
145 AC_MSG_CHECKING([kernel source version])
146 utsrelease1=$kernelbuild/include/linux/version.h
147 utsrelease2=$kernelbuild/include/linux/utsrelease.h
148 utsrelease3=$kernelbuild/include/generated/utsrelease.h
149 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
150 utsrelease=linux/version.h
151 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
152 utsrelease=linux/utsrelease.h
153 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
154 utsrelease=generated/utsrelease.h
155 fi
156
157 if test "$utsrelease"; then
158 kernsrcver=`(echo "#include <$utsrelease>";
159 echo "kernsrcver=UTS_RELEASE") |
160 cpp -I $kernelbuild/include |
161 grep "^kernsrcver=" | cut -d \" -f 2`
162
163 if test -z "$kernsrcver"; then
164 AC_MSG_RESULT([Not found])
165 AC_MSG_ERROR([*** Cannot determine kernel version.])
166 fi
167 else
168 AC_MSG_RESULT([Not found])
169 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
170 fi
171
172 AC_MSG_RESULT([$kernsrcver])
173
174 LINUX=${kernelsrc}
175 LINUX_OBJ=${kernelbuild}
176 LINUX_VERSION=${kernsrcver}
177
178 AC_SUBST(LINUX)
179 AC_SUBST(LINUX_OBJ)
180 AC_SUBST(LINUX_VERSION)
181
182 SPL_AC_MODULE_SYMVERS
183 ])
184
185 dnl #
186 dnl # Explicitly check for gawk, we require it for the the usermode
187 dnl # helper. For some reason the standard awk command does not
188 dnl # behave correctly when invoked from the usermode helper.
189 dnl #
190 AC_DEFUN([SPL_AC_GAWK], [
191 AS_IF([test "x$AWK" != xgawk], [
192 AC_MSG_ERROR([
193 *** Required util gawk missing. Please install the required
194 *** gawk package for your distribution and try again.])
195 ])
196 ])
197
198 dnl #
199 dnl # Default SPL user configuration
200 dnl #
201 AC_DEFUN([SPL_AC_CONFIG_USER], [
202 SPL_AC_GAWK
203 ])
204
205 dnl #
206 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
207 dnl # are missing it is non-fatal but you will not be able to build
208 dnl # RPM packages and will be warned if you try too.
209 dnl #
210 AC_DEFUN([SPL_AC_RPM], [
211 RPM=rpm
212 RPMBUILD=rpmbuild
213
214 AC_MSG_CHECKING([whether $RPM is available])
215 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
216 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
217 HAVE_RPM=yes
218 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
219 ],[
220 HAVE_RPM=no
221 AC_MSG_RESULT([$HAVE_RPM])
222 ])
223
224 AC_MSG_CHECKING([whether $RPMBUILD is available])
225 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
226 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
227 HAVE_RPMBUILD=yes
228 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
229 ],[
230 HAVE_RPMBUILD=no
231 AC_MSG_RESULT([$HAVE_RPMBUILD])
232 ])
233
234 AC_SUBST(HAVE_RPM)
235 AC_SUBST(RPM)
236 AC_SUBST(RPM_VERSION)
237
238 AC_SUBST(HAVE_RPMBUILD)
239 AC_SUBST(RPMBUILD)
240 AC_SUBST(RPMBUILD_VERSION)
241 ])
242
243 dnl #
244 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
245 dnl # tools are missing it is non-fatal but you will not be able to build
246 dnl # DEB packages and will be warned if you try too.
247 dnl #
248 AC_DEFUN([SPL_AC_DPKG], [
249 DPKG=dpkg
250 DPKGBUILD=dpkg-buildpackage
251
252 AC_MSG_CHECKING([whether $DPKG is available])
253 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
254 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
255 HAVE_DPKG=yes
256 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
257 ],[
258 HAVE_DPKG=no
259 AC_MSG_RESULT([$HAVE_DPKG])
260 ])
261
262 AC_MSG_CHECKING([whether $DPKGBUILD is available])
263 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
264 DPKGBUILD_VERSION=$(echo $tmp | \
265 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
266 HAVE_DPKGBUILD=yes
267 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
268 ],[
269 HAVE_DPKGBUILD=no
270 AC_MSG_RESULT([$HAVE_DPKGBUILD])
271 ])
272
273 AC_SUBST(HAVE_DPKG)
274 AC_SUBST(DPKG)
275 AC_SUBST(DPKG_VERSION)
276
277 AC_SUBST(HAVE_DPKGBUILD)
278 AC_SUBST(DPKGBUILD)
279 AC_SUBST(DPKGBUILD_VERSION)
280 ])
281
282 dnl #
283 dnl # Until native packaging for various different packing systems
284 dnl # can be added the least we can do is attempt to use alien to
285 dnl # convert the RPM packages to the needed package type. This is
286 dnl # a hack but so far it has worked reasonable well.
287 dnl #
288 AC_DEFUN([SPL_AC_ALIEN], [
289 ALIEN=alien
290
291 AC_MSG_CHECKING([whether $ALIEN is available])
292 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
293 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
294 HAVE_ALIEN=yes
295 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
296 ],[
297 HAVE_ALIEN=no
298 AC_MSG_RESULT([$HAVE_ALIEN])
299 ])
300
301 AC_SUBST(HAVE_ALIEN)
302 AC_SUBST(ALIEN)
303 AC_SUBST(ALIEN_VERSION)
304 ])
305
306 dnl #
307 dnl # Using the VENDOR tag from config.guess set the default
308 dnl # package type for 'make pkg': (rpm | deb | tgz)
309 dnl #
310 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
311 AC_MSG_CHECKING([linux distribution])
312 if test -f /etc/redhat-release ; then
313 VENDOR=redhat ;
314 elif test -f /etc/fedora-release ; then
315 VENDOR=fedora ;
316 elif test -f /etc/lsb-release ; then
317 VENDOR=ubuntu ;
318 elif test -f /etc/debian_version ; then
319 VENDOR=debian ;
320 elif test -f /etc/SuSE-release ; then
321 VENDOR=sles ;
322 elif test -f /etc/slackware-version ; then
323 VENDOR=slackware ;
324 elif test -f /etc/gentoo-release ; then
325 VENDOR=gentoo ;
326 else
327 VENDOR= ;
328 fi
329 AC_MSG_RESULT([$VENDOR])
330 AC_SUBST(VENDOR)
331
332 AC_MSG_CHECKING([default package type])
333 case "$VENDOR" in
334 fedora) DEFAULT_PACKAGE=rpm ;;
335 redhat) DEFAULT_PACKAGE=rpm ;;
336 sles) DEFAULT_PACKAGE=rpm ;;
337 ubuntu) DEFAULT_PACKAGE=deb ;;
338 debian) DEFAULT_PACKAGE=deb ;;
339 slackware) DEFAULT_PACKAGE=tgz ;;
340 *) DEFAULT_PACKAGE=rpm ;;
341 esac
342
343 AC_MSG_RESULT([$DEFAULT_PACKAGE])
344 AC_SUBST(DEFAULT_PACKAGE)
345 ])
346
347 dnl #
348 dnl # Default SPL user configuration
349 dnl #
350 AC_DEFUN([SPL_AC_PACKAGE], [
351 SPL_AC_RPM
352 SPL_AC_DPKG
353 SPL_AC_ALIEN
354 SPL_AC_DEFAULT_PACKAGE
355 ])
356
357 AC_DEFUN([SPL_AC_LICENSE], [
358 AC_MSG_CHECKING([spl license])
359 LICENSE=GPL
360 AC_MSG_RESULT([$LICENSE])
361 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
362 AC_SUBST(LICENSE)
363 ])
364
365 AC_DEFUN([SPL_AC_CONFIG], [
366 SPL_CONFIG=all
367 AC_ARG_WITH([config],
368 AS_HELP_STRING([--with-config=CONFIG],
369 [Config file 'kernel|user|all|srpm']),
370 [SPL_CONFIG="$withval"])
371
372 AC_MSG_CHECKING([spl config])
373 AC_MSG_RESULT([$SPL_CONFIG]);
374 AC_SUBST(SPL_CONFIG)
375
376 case "$SPL_CONFIG" in
377 kernel) SPL_AC_CONFIG_KERNEL ;;
378 user) SPL_AC_CONFIG_USER ;;
379 all) SPL_AC_CONFIG_KERNEL
380 SPL_AC_CONFIG_USER ;;
381 srpm) ;;
382 *)
383 AC_MSG_RESULT([Error!])
384 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
385 user kernel|user|all|srpm]) ;;
386 esac
387
388 AM_CONDITIONAL([CONFIG_USER],
389 [test "$SPL_CONFIG" = user] ||
390 [test "$SPL_CONFIG" = all])
391 AM_CONDITIONAL([CONFIG_KERNEL],
392 [test "$SPL_CONFIG" = kernel] ||
393 [test "$SPL_CONFIG" = all])
394 ])
395
396 dnl #
397 dnl # Enable if the SPL should be compiled with internal debugging enabled.
398 dnl # By default this support is disabled.
399 dnl #
400 AC_DEFUN([SPL_AC_DEBUG], [
401 AC_MSG_CHECKING([whether debugging is enabled])
402 AC_ARG_ENABLE([debug],
403 [AS_HELP_STRING([--enable-debug],
404 [Enable generic debug support @<:@default=no@:>@])],
405 [],
406 [enable_debug=no])
407
408 AS_IF([test "x$enable_debug" = xyes],
409 [
410 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
411 DEBUG_CFLAGS="-DDEBUG -Werror"
412 ],
413 [
414 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
415 DEBUG_CFLAGS="-DNDEBUG"
416 ])
417
418 AC_SUBST(DEBUG_CFLAGS)
419 AC_MSG_RESULT([$enable_debug])
420 ])
421
422 dnl #
423 dnl # Enabled by default it provides a minimal level of memory tracking.
424 dnl # A total count of bytes allocated is kept for each alloc and free.
425 dnl # Then at module unload time a report to the console will be printed
426 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
427 dnl # and provide an easy way to inspect the kmem based slab.
428 dnl #
429 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
430 AC_ARG_ENABLE([debug-kmem],
431 [AS_HELP_STRING([--enable-debug-kmem],
432 [Enable basic kmem accounting @<:@default=yes@:>@])],
433 [],
434 [enable_debug_kmem=yes])
435
436 AS_IF([test "x$enable_debug_kmem" = xyes],
437 [AC_DEFINE([DEBUG_KMEM], [1],
438 [Define to 1 to enable basic kmem accounting])
439 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
440
441 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
442 AC_MSG_RESULT([$enable_debug_kmem])
443 ])
444
445 dnl #
446 dnl # Disabled by default it provides detailed memory tracking. This
447 dnl # feature also requires --enable-debug-kmem to be set. When enabled
448 dnl # not only will total bytes be tracked but also the location of every
449 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
450 dnl # addresses and where they were allocated will be dumped to the console.
451 dnl # Enabling this feature has a significant impact on performance but it
452 dnl # makes finding memory leaks pretty straight forward.
453 dnl #
454 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
455 AC_ARG_ENABLE([debug-kmem-tracking],
456 [AS_HELP_STRING([--enable-debug-kmem-tracking],
457 [Enable detailed kmem tracking @<:@default=no@:>@])],
458 [],
459 [enable_debug_kmem_tracking=no])
460
461 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
462 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
463 [Define to 1 to enable detailed kmem tracking])
464 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
465
466 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
467 AC_MSG_RESULT([$enable_debug_kmem_tracking])
468 ])
469
470 dnl #
471 dnl # SPL_LINUX_CONFTEST
472 dnl #
473 AC_DEFUN([SPL_LINUX_CONFTEST], [
474 cat confdefs.h - <<_ACEOF >conftest.c
475 $1
476 _ACEOF
477 ])
478
479 dnl #
480 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
481 dnl #
482 m4_define([SPL_LANG_PROGRAM], [
483 $1
484 int
485 main (void)
486 {
487 dnl Do *not* indent the following line: there may be CPP directives.
488 dnl Don't move the `;' right after for the same reason.
489 $2
490 ;
491 return 0;
492 }
493 ])
494
495 dnl #
496 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
497 dnl #
498 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
499 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
500 rm -Rf build && mkdir -p build
501 echo "obj-m := conftest.o" >build/Makefile
502 AS_IF(
503 [AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
504 [$4],
505 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
506 )
507 rm -Rf build
508 ])
509
510 dnl #
511 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
512 dnl #
513 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
514 [SPL_LINUX_COMPILE_IFELSE(
515 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
516 [modules],
517 [test -s build/conftest.o],
518 [$3], [$4])
519 ])
520
521 dnl #
522 dnl # SPL_LINUX_CONFIG
523 dnl #
524 AC_DEFUN([SPL_LINUX_CONFIG],
525 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
526 SPL_LINUX_TRY_COMPILE([
527 #ifndef AUTOCONF_INCLUDED
528 #include <linux/config.h>
529 #endif
530 ],[
531 #ifndef CONFIG_$1
532 #error CONFIG_$1 not #defined
533 #endif
534 ],[
535 AC_MSG_RESULT([yes])
536 $2
537 ],[
538 AC_MSG_RESULT([no])
539 $3
540 ])
541 ])
542
543 dnl #
544 dnl # SPL_CHECK_SYMBOL_EXPORT
545 dnl # check symbol exported or not
546 dnl #
547 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
548 [AC_MSG_CHECKING([whether symbol $1 is exported])
549 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
550 $LINUX_OBJ/Module*.symvers 2>/dev/null
551 rc=$?
552 if test $rc -ne 0; then
553 export=0
554 for file in $2; do
555 grep -q -E "EXPORT_SYMBOL.*($1)" \
556 "$LINUX_OBJ/$file" 2>/dev/null
557 rc=$?
558 if test $rc -eq 0; then
559 export=1
560 break;
561 fi
562 done
563 if test $export -eq 0; then
564 AC_MSG_RESULT([no])
565 $4
566 else
567 AC_MSG_RESULT([yes])
568 $3
569 fi
570 else
571 AC_MSG_RESULT([yes])
572 $3
573 fi
574 ])
575
576 dnl #
577 dnl # SPL_CHECK_HEADER
578 dnl # check whether header exists and define HAVE_$2_HEADER
579 dnl #
580 AC_DEFUN([SPL_CHECK_HEADER],
581 [AC_MSG_CHECKING([whether header $1 exists])
582 SPL_LINUX_TRY_COMPILE([
583 #include <$1>
584 ],[
585 return 0;
586 ],[
587 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
588 AC_MSG_RESULT(yes)
589 $3
590 ],[
591 AC_MSG_RESULT(no)
592 $4
593 ])
594 ])
595
596 dnl #
597 dnl # Use the atomic implemenation based on global spinlocks. This
598 dnl # should only be needed by 32-bit kernels which do not provide
599 dnl # the atomic64_* API. It may be optionally enabled as a fallback
600 dnl # if problems are observed with the direct mapping to the native
601 dnl # Linux atomic operations. You may not disable atomic spinlocks
602 dnl # if you kernel does not an atomic64_* API.
603 dnl #
604 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
605 AC_ARG_ENABLE([atomic-spinlocks],
606 [AS_HELP_STRING([--enable-atomic-spinlocks],
607 [Atomic types use spinlocks @<:@default=check@:>@])],
608 [],
609 [enable_atomic_spinlocks=check])
610
611 SPL_LINUX_TRY_COMPILE([
612 #include <asm/atomic.h>
613 ],[
614 atomic64_t *ptr;
615 ],[
616 have_atomic64_t=yes
617 AC_DEFINE(HAVE_ATOMIC64_T, 1,
618 [kernel defines atomic64_t])
619 ],[
620 have_atomic64_t=no
621 ])
622
623 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
624 AS_IF([test "x$have_atomic64_t" = xyes], [
625 enable_atomic_spinlocks=no
626 ],[
627 enable_atomic_spinlocks=yes
628 ])
629 ])
630
631 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
632 AC_DEFINE([ATOMIC_SPINLOCK], [1],
633 [Atomic types use spinlocks])
634 ],[
635 AS_IF([test "x$have_atomic64_t" = xno], [
636 AC_MSG_FAILURE(
637 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
638 ])
639 ])
640
641 AC_MSG_CHECKING([whether atomic types use spinlocks])
642 AC_MSG_RESULT([$enable_atomic_spinlocks])
643
644 AC_MSG_CHECKING([whether kernel defines atomic64_t])
645 AC_MSG_RESULT([$have_atomic64_t])
646 ])
647
648 dnl #
649 dnl # 2.6.24 API change,
650 dnl # check if atomic64_cmpxchg is defined
651 dnl #
652 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
653 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
654 SPL_LINUX_TRY_COMPILE([
655 #include <asm/atomic.h>
656 #include <asm/system.h>
657 ],[
658 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
659 ],[
660 AC_MSG_RESULT([yes])
661 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
662 [kernel defines atomic64_cmpxchg])
663 ],[
664 AC_MSG_RESULT([no])
665 ])
666 ])
667
668 dnl #
669 dnl # 2.6.24 API change,
670 dnl # check if atomic64_xchg is defined
671 dnl #
672 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
673 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
674 SPL_LINUX_TRY_COMPILE([
675 #include <asm/atomic.h>
676 ],[
677 atomic64_xchg((atomic64_t *)NULL, 0);
678 ],[
679 AC_MSG_RESULT([yes])
680 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
681 [kernel defines atomic64_xchg])
682 ],[
683 AC_MSG_RESULT([no])
684 ])
685 ])
686
687 dnl #
688 dnl # 2.6.24 API change,
689 dnl # check if uintptr_t typedef is defined
690 dnl #
691 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
692 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
693 SPL_LINUX_TRY_COMPILE([
694 #include <linux/types.h>
695 ],[
696 uintptr_t *ptr;
697 ],[
698 AC_MSG_RESULT([yes])
699 AC_DEFINE(HAVE_UINTPTR_T, 1,
700 [kernel defines uintptr_t])
701 ],[
702 AC_MSG_RESULT([no])
703 ])
704 ])
705
706 dnl #
707 dnl # 2.6.20 API change,
708 dnl # INIT_WORK use 2 args and not store data inside
709 dnl #
710 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
711 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
712 SPL_LINUX_TRY_COMPILE([
713 #include <linux/workqueue.h>
714 ],[
715 struct work_struct work;
716 INIT_WORK(&work, NULL, NULL);
717 ],[
718 AC_MSG_RESULT(yes)
719 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
720 [INIT_WORK wants 3 args])
721 ],[
722 AC_MSG_RESULT(no)
723 ])
724 ])
725
726 dnl #
727 dnl # 2.6.21 API change,
728 dnl # 'register_sysctl_table' use only one argument instead of two
729 dnl #
730 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
731 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
732 SPL_LINUX_TRY_COMPILE([
733 #include <linux/sysctl.h>
734 ],[
735 return register_sysctl_table(NULL,0);
736 ],[
737 AC_MSG_RESULT(yes)
738 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
739 [register_sysctl_table() wants 2 args])
740 ],[
741 AC_MSG_RESULT(no)
742 ])
743 ])
744
745 dnl #
746 dnl # 2.6.23 API change
747 dnl # Old set_shrinker API replaced with register_shrinker
748 dnl #
749 AC_DEFUN([SPL_AC_SET_SHRINKER], [
750 AC_MSG_CHECKING([whether set_shrinker() available])
751 SPL_LINUX_TRY_COMPILE([
752 #include <linux/mm.h>
753 ],[
754 return set_shrinker(DEFAULT_SEEKS, NULL);
755 ],[
756 AC_MSG_RESULT([yes])
757 AC_DEFINE(HAVE_SET_SHRINKER, 1,
758 [set_shrinker() available])
759 ],[
760 AC_MSG_RESULT([no])
761 ])
762 ])
763
764 dnl #
765 dnl # 2.6.25 API change,
766 dnl # struct path entry added to struct nameidata
767 dnl #
768 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
769 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
770 SPL_LINUX_TRY_COMPILE([
771 #include <linux/namei.h>
772 ],[
773 struct nameidata nd;
774
775 nd.path.mnt = NULL;
776 nd.path.dentry = NULL;
777 ],[
778 AC_MSG_RESULT(yes)
779 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
780 [struct path used in struct nameidata])
781 ],[
782 AC_MSG_RESULT(no)
783 ])
784 ])
785
786 dnl #
787 dnl # Custom SPL patch may export this system it is not required
788 dnl #
789 AC_DEFUN([SPL_AC_TASK_CURR], [
790 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
791 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
792 [])
793 ])
794
795 dnl #
796 dnl # 2.6.19 API change,
797 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
798 dnl #
799 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
800 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
801 SPL_LINUX_TRY_COMPILE([
802 #include <linux/sysctl.h>
803 ],[
804 #ifndef CTL_UNNUMBERED
805 #error CTL_UNNUMBERED undefined
806 #endif
807 ],[
808 AC_MSG_RESULT(yes)
809 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
810 [unnumbered sysctl support exists])
811 ],[
812 AC_MSG_RESULT(no)
813 ])
814 ])
815
816 dnl #
817 dnl # 2.6.33 API change,
818 dnl # Removed .ctl_name from struct ctl_table.
819 dnl #
820 AC_DEFUN([SPL_AC_CTL_NAME], [
821 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
822 SPL_LINUX_TRY_COMPILE([
823 #include <linux/sysctl.h>
824 ],[
825 struct ctl_table ctl;
826 ctl.ctl_name = 0;
827 ],[
828 AC_MSG_RESULT(yes)
829 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
830 ],[
831 AC_MSG_RESULT(no)
832 ])
833 ])
834
835 dnl #
836 dnl # 2.6.16 API change.
837 dnl # Check if 'fls64()' is available
838 dnl #
839 AC_DEFUN([SPL_AC_FLS64],
840 [AC_MSG_CHECKING([whether fls64() is available])
841 SPL_LINUX_TRY_COMPILE([
842 #include <linux/bitops.h>
843 ],[
844 return fls64(0);
845 ],[
846 AC_MSG_RESULT(yes)
847 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
848 ],[
849 AC_MSG_RESULT(no)
850 ])
851 ])
852
853 dnl #
854 dnl # 2.6.18 API change, check whether device_create() is available.
855 dnl # Device_create() was introduced in 2.6.18 and depricated
856 dnl # class_device_create() which was fully removed in 2.6.26.
857 dnl #
858 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
859 SPL_CHECK_SYMBOL_EXPORT(
860 [device_create],
861 [drivers/base/core.c],
862 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
863 [device_create() is available])],
864 [])
865 ])
866
867 dnl #
868 dnl # 2.6.27 API change,
869 dnl # device_create() uses 5 args, new 'drvdata' argument.
870 dnl #
871 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
872 AC_MSG_CHECKING([whether device_create() wants 5 args])
873 tmp_flags="$EXTRA_KCFLAGS"
874 EXTRA_KCFLAGS="-Werror"
875 SPL_LINUX_TRY_COMPILE([
876 #include <linux/device.h>
877 ],[
878 device_create(NULL, NULL, 0, NULL, "%d", 1);
879 ],[
880 AC_MSG_RESULT(yes)
881 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
882 [device_create wants 5 args])
883 ],[
884 AC_MSG_RESULT(no)
885 ])
886 EXTRA_KCFLAGS="$tmp_flags"
887 ])
888
889 dnl #
890 dnl # 2.6.13 API change, check whether class_device_create() is available.
891 dnl # Class_device_create() was introduced in 2.6.13 and depricated
892 dnl # class_simple_device_add() which was fully removed in 2.6.13.
893 dnl #
894 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
895 SPL_CHECK_SYMBOL_EXPORT(
896 [class_device_create],
897 [drivers/base/class.c],
898 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
899 [class_device_create() is available])],
900 [])
901 ])
902
903 dnl #
904 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
905 dnl #
906 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
907 SPL_CHECK_SYMBOL_EXPORT(
908 [set_normalized_timespec],
909 [kernel/time.c],
910 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
911 [set_normalized_timespec() is available as export])],
912 [])
913 ])
914
915 dnl #
916 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
917 dnl # previously it was available in time.h as an inline.
918 dnl #
919 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
920 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
921 SPL_LINUX_TRY_COMPILE([
922 #include <linux/time.h>
923 void set_normalized_timespec(struct timespec *ts,
924 time_t sec, long nsec) { }
925 ],
926 [],
927 [
928 AC_MSG_RESULT(no)
929 ],[
930 AC_MSG_RESULT(yes)
931 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
932 [set_normalized_timespec() is available as inline])
933 ])
934 ])
935
936 dnl #
937 dnl # 2.6.18 API change,
938 dnl # timespec_sub() inline function available in linux/time.h
939 dnl #
940 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
941 AC_MSG_CHECKING([whether timespec_sub() is available])
942 SPL_LINUX_TRY_COMPILE([
943 #include <linux/time.h>
944 ],[
945 struct timespec a, b, c = { 0 };
946 c = timespec_sub(a, b);
947 ],[
948 AC_MSG_RESULT(yes)
949 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
950 ],[
951 AC_MSG_RESULT(no)
952 ])
953 ])
954
955 dnl #
956 dnl # 2.6.19 API change,
957 dnl # check if init_utsname() is available in linux/utsname.h
958 dnl #
959 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
960 AC_MSG_CHECKING([whether init_utsname() is available])
961 SPL_LINUX_TRY_COMPILE([
962 #include <linux/utsname.h>
963 ],[
964 struct new_utsname *a = init_utsname();
965 ],[
966 AC_MSG_RESULT(yes)
967 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
968 ],[
969 AC_MSG_RESULT(no)
970 ])
971 ])
972
973 dnl #
974 dnl # 2.6.26 API change,
975 dnl # definition of struct fdtable relocated to linux/fdtable.h
976 dnl #
977 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
978 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
979 ])
980
981 dnl #
982 dnl # 2.6.14 API change,
983 dnl # check whether 'files_fdtable()' exists
984 dnl #
985 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
986 AC_MSG_CHECKING([whether files_fdtable() is available])
987 SPL_LINUX_TRY_COMPILE([
988 #include <linux/sched.h>
989 #include <linux/file.h>
990 #ifdef HAVE_FDTABLE_HEADER
991 #include <linux/fdtable.h>
992 #endif
993 ],[
994 struct files_struct *files = current->files;
995 struct fdtable *fdt = files_fdtable(files);
996 ],[
997 AC_MSG_RESULT(yes)
998 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
999 ],[
1000 AC_MSG_RESULT(no)
1001 ])
1002 ])
1003
1004 dnl #
1005 dnl # 2.6.18 API change,
1006 dnl # added linux/uaccess.h
1007 dnl #
1008 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1009 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1010 ])
1011
1012 dnl #
1013 dnl # 2.6.12 API change,
1014 dnl # check whether 'kmalloc_node()' is available.
1015 dnl #
1016 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1017 AC_MSG_CHECKING([whether kmalloc_node() is available])
1018 SPL_LINUX_TRY_COMPILE([
1019 #include <linux/slab.h>
1020 ],[
1021 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1022 ],[
1023 AC_MSG_RESULT(yes)
1024 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1025 ],[
1026 AC_MSG_RESULT(no)
1027 ])
1028 ])
1029
1030 dnl #
1031 dnl # 2.6.9 API change,
1032 dnl # check whether 'monotonic_clock()' is available it may
1033 dnl # be available for some archs but not others.
1034 dnl #
1035 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1036 SPL_CHECK_SYMBOL_EXPORT(
1037 [monotonic_clock],
1038 [],
1039 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1040 [monotonic_clock() is available])],
1041 [])
1042 ])
1043
1044 dnl #
1045 dnl # 2.6.16 API change,
1046 dnl # check whether 'struct inode' has i_mutex
1047 dnl #
1048 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1049 AC_MSG_CHECKING([whether struct inode has i_mutex])
1050 SPL_LINUX_TRY_COMPILE([
1051 #include <linux/fs.h>
1052 #include <linux/mutex.h>
1053 ],[
1054 struct inode i;
1055 mutex_init(&i.i_mutex);
1056 ],[
1057 AC_MSG_RESULT(yes)
1058 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1059 ],[
1060 AC_MSG_RESULT(no)
1061 ])
1062 ])
1063
1064 dnl #
1065 dnl # 2.6.29 API change,
1066 dnl # Adaptive mutexs introduced.
1067 dnl #
1068 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1069 AC_MSG_CHECKING([whether struct mutex has owner])
1070 SPL_LINUX_TRY_COMPILE([
1071 #include <linux/mutex.h>
1072 ],[
1073 struct mutex mtx;
1074 mtx.owner = NULL;
1075 ],[
1076 AC_MSG_RESULT(yes)
1077 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1078 ],[
1079 AC_MSG_RESULT(no)
1080 ])
1081 ])
1082
1083 dnl #
1084 dnl # 2.6.18 API change,
1085 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1086 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1087 dnl # if the mutex validator is disabled or otherwise unavailable.
1088 dnl #
1089 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1090 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1091 SPL_LINUX_TRY_COMPILE([
1092 #include <linux/mutex.h>
1093 ],[
1094 struct mutex mutex;
1095 mutex_init(&mutex);
1096 mutex_lock_nested(&mutex, 0);
1097 ],[
1098 AC_MSG_RESULT(yes)
1099 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1100 [mutex_lock_nested() is available])
1101 ],[
1102 AC_MSG_RESULT(no)
1103 ])
1104 ])
1105
1106 dnl #
1107 dnl # 2.6.27 API change,
1108 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1109 dnl #
1110 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1111 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1112 SPL_LINUX_TRY_COMPILE([
1113 #include <linux/smp.h>
1114 ],[
1115 on_each_cpu(NULL, NULL, 0);
1116 ],[
1117 AC_MSG_RESULT(yes)
1118 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1119 [on_each_cpu wants 3 args])
1120 ],[
1121 AC_MSG_RESULT(no)
1122 ])
1123 ])
1124
1125 dnl #
1126 dnl # 2.6.18 API change,
1127 dnl # kallsyms_lookup_name no longer exported
1128 dnl #
1129 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1130 SPL_CHECK_SYMBOL_EXPORT(
1131 [kallsyms_lookup_name],
1132 [],
1133 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1134 [kallsyms_lookup_name() is available])],
1135 [])
1136 ])
1137
1138 dnl #
1139 dnl # Proposed API change,
1140 dnl # This symbol is not available in stock kernels. You may build a
1141 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1142 dnl # these symbols for use. If your already rolling a custom kernel for
1143 dnl # your environment this is recommended.
1144 dnl #
1145 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1146 SPL_CHECK_SYMBOL_EXPORT(
1147 [get_vmalloc_info],
1148 [],
1149 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1150 [get_vmalloc_info() is available])],
1151 [])
1152 ])
1153
1154 dnl #
1155 dnl # 2.6.17 API change
1156 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1157 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1158 dnl # were exported in 2.6.17 for use by modules which was consistent with
1159 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1160 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1161 dnl # were dropped entirely leaving modules no way to directly iterate over
1162 dnl # the zone list. Because we need access to the zone helpers we check
1163 dnl # if the kernel contains the old or new implementation. Then we check
1164 dnl # to see if the symbols we need for each version are available. If they
1165 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1166 dnl #
1167 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1168 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1169 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1170 rc=$?
1171 if test $rc -eq 0; then
1172 AC_MSG_RESULT([yes])
1173 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1174 else
1175 AC_MSG_RESULT([no])
1176 fi
1177 ])
1178
1179 dnl #
1180 dnl # Proposed API change,
1181 dnl # This symbol is not available in stock kernels. You may build a
1182 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1183 dnl # these symbols for use. If your already rolling a custom kernel for
1184 dnl # your environment this is recommended.
1185 dnl #
1186 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1187 SPL_CHECK_SYMBOL_EXPORT(
1188 [first_online_pgdat],
1189 [],
1190 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1191 [first_online_pgdat() is available])],
1192 [])
1193 ])
1194
1195 dnl #
1196 dnl # Proposed API change,
1197 dnl # This symbol is not available in stock kernels. You may build a
1198 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1199 dnl # these symbols for use. If your already rolling a custom kernel for
1200 dnl # your environment this is recommended.
1201 dnl #
1202 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1203 SPL_CHECK_SYMBOL_EXPORT(
1204 [next_online_pgdat],
1205 [],
1206 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1207 [next_online_pgdat() is available])],
1208 [])
1209 ])
1210
1211 dnl #
1212 dnl # Proposed API change,
1213 dnl # This symbol is not available in stock kernels. You may build a
1214 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1215 dnl # these symbols for use. If your already rolling a custom kernel for
1216 dnl # your environment this is recommended.
1217 dnl #
1218 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1219 SPL_CHECK_SYMBOL_EXPORT(
1220 [next_zone],
1221 [],
1222 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1223 [next_zone() is available])],
1224 [])
1225 ])
1226
1227 dnl #
1228 dnl # 2.6.17 API change,
1229 dnl # See SPL_AC_PGDAT_HELPERS for details.
1230 dnl #
1231 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1232 SPL_CHECK_SYMBOL_EXPORT(
1233 [pgdat_list],
1234 [],
1235 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1236 [pgdat_list is available])],
1237 [])
1238 ])
1239
1240 dnl #
1241 dnl # 2.6.18 API change,
1242 dnl # First introduced global_page_state() support as an inline.
1243 dnl #
1244 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1245 AC_MSG_CHECKING([whether global_page_state() is available])
1246 SPL_LINUX_TRY_COMPILE([
1247 #include <linux/mm.h>
1248 ],[
1249 unsigned long state;
1250 state = global_page_state(0);
1251 ],[
1252 AC_MSG_RESULT(yes)
1253 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1254 [global_page_state() is available])
1255 ],[
1256 AC_MSG_RESULT(no)
1257 ])
1258 ])
1259
1260 dnl #
1261 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1262 dnl # Public global zone stats now include a free page count. However
1263 dnl # the enumerated names of the counters have changed since this API
1264 dnl # was introduced. We need to deduce the corrent name to use. This
1265 dnl # replaces the priviate get_zone_counts() interface.
1266 dnl #
1267 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1268 dnl # is 2.6.30 as of when this was written.
1269 dnl #
1270 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1271 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1272 SPL_LINUX_TRY_COMPILE([
1273 #include <linux/mm.h>
1274 ],[
1275 enum zone_stat_item zsi;
1276 zsi = NR_FREE_PAGES;
1277 ],[
1278 AC_MSG_RESULT(yes)
1279 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1280 [Page state NR_FREE_PAGES is available])
1281 ],[
1282 AC_MSG_RESULT(no)
1283 ])
1284 ])
1285
1286 dnl #
1287 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1288 dnl # Public global zone stats now include an inactive page count. However
1289 dnl # the enumerated names of the counters have changed since this API
1290 dnl # was introduced. We need to deduce the corrent name to use. This
1291 dnl # replaces the priviate get_zone_counts() interface.
1292 dnl #
1293 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1294 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1295 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1296 dnl #
1297 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1298 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1299 SPL_LINUX_TRY_COMPILE([
1300 #include <linux/mm.h>
1301 ],[
1302 enum zone_stat_item zsi;
1303 zsi = NR_INACTIVE;
1304 ],[
1305 AC_MSG_RESULT(yes)
1306 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1307 [Page state NR_INACTIVE is available])
1308 ],[
1309 AC_MSG_RESULT(no)
1310 ])
1311
1312 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1313 SPL_LINUX_TRY_COMPILE([
1314 #include <linux/mm.h>
1315 ],[
1316 enum zone_stat_item zsi;
1317 zsi = NR_INACTIVE_ANON;
1318 ],[
1319 AC_MSG_RESULT(yes)
1320 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1321 [Page state NR_INACTIVE_ANON is available])
1322 ],[
1323 AC_MSG_RESULT(no)
1324 ])
1325
1326 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1327 SPL_LINUX_TRY_COMPILE([
1328 #include <linux/mm.h>
1329 ],[
1330 enum zone_stat_item zsi;
1331 zsi = NR_INACTIVE_FILE;
1332 ],[
1333 AC_MSG_RESULT(yes)
1334 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1335 [Page state NR_INACTIVE_FILE is available])
1336 ],[
1337 AC_MSG_RESULT(no)
1338 ])
1339 ])
1340
1341 dnl #
1342 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1343 dnl # Public global zone stats now include an active page count. However
1344 dnl # the enumerated names of the counters have changed since this API
1345 dnl # was introduced. We need to deduce the corrent name to use. This
1346 dnl # replaces the priviate get_zone_counts() interface.
1347 dnl #
1348 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1349 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1350 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1351 dnl #
1352 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1353 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1354 SPL_LINUX_TRY_COMPILE([
1355 #include <linux/mm.h>
1356 ],[
1357 enum zone_stat_item zsi;
1358 zsi = NR_ACTIVE;
1359 ],[
1360 AC_MSG_RESULT(yes)
1361 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1362 [Page state NR_ACTIVE is available])
1363 ],[
1364 AC_MSG_RESULT(no)
1365 ])
1366
1367 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1368 SPL_LINUX_TRY_COMPILE([
1369 #include <linux/mm.h>
1370 ],[
1371 enum zone_stat_item zsi;
1372 zsi = NR_ACTIVE_ANON;
1373 ],[
1374 AC_MSG_RESULT(yes)
1375 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1376 [Page state NR_ACTIVE_ANON is available])
1377 ],[
1378 AC_MSG_RESULT(no)
1379 ])
1380
1381 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1382 SPL_LINUX_TRY_COMPILE([
1383 #include <linux/mm.h>
1384 ],[
1385 enum zone_stat_item zsi;
1386 zsi = NR_ACTIVE_FILE;
1387 ],[
1388 AC_MSG_RESULT(yes)
1389 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1390 [Page state NR_ACTIVE_FILE is available])
1391 ],[
1392 AC_MSG_RESULT(no)
1393 ])
1394 ])
1395
1396 dnl #
1397 dnl # Proposed API change for legacy kernels.
1398 dnl # This symbol is not available in older kernels. For kernels post
1399 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1400 dnl # page state information. This symbol is only used in legacy kernels
1401 dnl # any only as a last resort.
1402 dnl
1403 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1404 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1405 SPL_LINUX_TRY_COMPILE([
1406 ],[
1407 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1408 #error "global_page_state needs NR_FREE_PAGES"
1409 #endif
1410
1411 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1412 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1413 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1414 #error "global_page_state needs NR_ACTIVE*"
1415 #endif
1416
1417 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1418 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1419 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1420 #error "global_page_state needs NR_INACTIVE*"
1421 #endif
1422 ],[
1423 AC_MSG_RESULT(no)
1424 ],[
1425 AC_MSG_RESULT(yes)
1426 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1427 [get_zone_counts() is needed])
1428
1429 SPL_CHECK_SYMBOL_EXPORT(
1430 [get_zone_counts],
1431 [],
1432 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1433 [get_zone_counts() is available])],
1434 [])
1435 ])
1436 ])
1437
1438 dnl #
1439 dnl # 2.6.27 API change,
1440 dnl # The user_path_dir() replaces __user_walk()
1441 dnl #
1442 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1443 SPL_CHECK_SYMBOL_EXPORT(
1444 [user_path_at],
1445 [],
1446 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1447 [user_path_dir() is available])],
1448 [])
1449 ])
1450
1451 dnl #
1452 dnl # Symbol available in RHEL kernels not in stock kernels.
1453 dnl #
1454 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1455 SPL_CHECK_SYMBOL_EXPORT(
1456 [set_fs_pwd],
1457 [],
1458 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1459 [set_fs_pwd() is available])],
1460 [])
1461 ])
1462
1463 dnl #
1464 dnl # 2.6.25 API change,
1465 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1466 dnl #
1467 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1468 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1469 SPL_LINUX_TRY_COMPILE([
1470 #include <linux/sched.h>
1471 #include <linux/fs_struct.h>
1472 ],[
1473 set_fs_pwd(NULL, NULL);
1474 ],[
1475 AC_MSG_RESULT(yes)
1476 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1477 [set_fs_pwd() wants 2 args])
1478 ],[
1479 AC_MSG_RESULT(no)
1480 ])
1481 ])
1482
1483 dnl #
1484 dnl # SLES API change, never adopted in mainline,
1485 dnl # Third 'struct vfsmount *' argument removed.
1486 dnl #
1487 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1488 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1489 SPL_LINUX_TRY_COMPILE([
1490 #include <linux/fs.h>
1491 ],[
1492 vfs_unlink(NULL, NULL);
1493 ],[
1494 AC_MSG_RESULT(yes)
1495 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1496 [vfs_unlink() wants 2 args])
1497 ],[
1498 AC_MSG_RESULT(no)
1499 ])
1500 ])
1501
1502 dnl #
1503 dnl # SLES API change, never adopted in mainline,
1504 dnl # Third and sixth 'struct vfsmount *' argument removed.
1505 dnl #
1506 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1507 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1508 SPL_LINUX_TRY_COMPILE([
1509 #include <linux/fs.h>
1510 ],[
1511 vfs_rename(NULL, NULL, NULL, NULL);
1512 ],[
1513 AC_MSG_RESULT(yes)
1514 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1515 [vfs_rename() wants 4 args])
1516 ],[
1517 AC_MSG_RESULT(no)
1518 ])
1519 ])
1520
1521 dnl #
1522 dnl # 2.6.29 API change,
1523 dnl # check whether 'struct cred' exists
1524 dnl #
1525 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1526 AC_MSG_CHECKING([whether struct cred exists])
1527 SPL_LINUX_TRY_COMPILE([
1528 #include <linux/cred.h>
1529 ],[
1530 struct cred *cr;
1531 cr = NULL;
1532 ],[
1533 AC_MSG_RESULT(yes)
1534 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1535 ],[
1536 AC_MSG_RESULT(no)
1537 ])
1538 ])
1539
1540 dnl #
1541 dnl # Custom SPL patch may export this symbol.
1542 dnl #
1543 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1544 SPL_CHECK_SYMBOL_EXPORT(
1545 [groups_search],
1546 [],
1547 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1548 [groups_search() is available])],
1549 [])
1550 ])
1551
1552 dnl #
1553 dnl # 2.6.x API change,
1554 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1555 dnl #
1556 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1557 SPL_CHECK_SYMBOL_EXPORT(
1558 [__put_task_struct],
1559 [],
1560 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1561 [__put_task_struct() is available])],
1562 [])
1563 ])
1564
1565 dnl #
1566 dnl # 2.6.32 API change,
1567 dnl # Unused 'struct file *' removed from prototype.
1568 dnl #
1569 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1570 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1571 SPL_LINUX_TRY_COMPILE([
1572 #include <linux/sysctl.h>
1573 ],[
1574 proc_dostring(NULL, 0, NULL, NULL, NULL);
1575 ],[
1576 AC_MSG_RESULT(yes)
1577 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1578 [proc_handler() wants 5 args])
1579 ],[
1580 AC_MSG_RESULT(no)
1581 ])
1582 ])
1583
1584 dnl #
1585 dnl # 2.6.x API change,
1586 dnl # kvasprintf() function added.
1587 dnl #
1588 AC_DEFUN([SPL_AC_KVASPRINTF], [
1589 SPL_CHECK_SYMBOL_EXPORT(
1590 [kvasprintf],
1591 [],
1592 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1593 [kvasprintf() is available])],
1594 [])
1595 ])
1596
1597 dnl #
1598 dnl # 2.6.35 API change,
1599 dnl # Unused 'struct dentry *' removed from prototype.
1600 dnl #
1601 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1602 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1603 SPL_LINUX_TRY_COMPILE([
1604 #include <linux/buffer_head.h>
1605 ],[
1606 file_fsync(NULL, NULL, 0);
1607 ],[
1608 AC_MSG_RESULT(yes)
1609 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1610 [file_fsync() wants 3 args])
1611 ],[
1612 AC_MSG_RESULT(no)
1613 ])
1614 ])
1615
1616 dnl #
1617 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1618 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1619 dnl # condition. The fixed version is exported as a symbol. The race
1620 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1621 dnl # call that version while holding sem->wait_lock.
1622 dnl #
1623 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1624 SPL_CHECK_SYMBOL_EXPORT(
1625 [rwsem_is_locked],
1626 [lib/rwsem-spinlock.c],
1627 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1628 [rwsem_is_locked() acquires sem->wait_lock])],
1629 [])
1630 ])