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