]> git.proxmox.com Git - mirror_spl.git/blame - config/spl-build.m4
atomic_*_*_nv() functions need to return the new value atomically.
[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
30 SPL_AC_PATH_IN_NAMEIDATA
31 SPL_AC_TASK_CURR
32 SPL_AC_CTL_UNNUMBERED
79a3bf13 33 SPL_AC_CTL_NAME
86933a6e
BB
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
4d54fdee 48 SPL_AC_MUTEX_OWNER
86933a6e 49 SPL_AC_MUTEX_LOCK_NESTED
86933a6e
BB
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
86933a6e 58 SPL_AC_GLOBAL_PAGE_STATE
6ae7fef5
BB
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
7119bf70 63 SPL_AC_USER_PATH_DIR
51a727e9
BB
64 SPL_AC_SET_FS_PWD
65 SPL_AC_2ARGS_SET_FS_PWD
86933a6e
BB
66 SPL_AC_2ARGS_VFS_UNLINK
67 SPL_AC_4ARGS_VFS_RENAME
ec7d53e9
BB
68 SPL_AC_CRED_STRUCT
69 SPL_AC_GROUPS_SEARCH
e811949a 70 SPL_AC_PUT_TASK_STRUCT
3977f837 71 SPL_AC_5ARGS_PROC_HANDLER
b868e22f 72 SPL_AC_KVASPRINTF
f0ff89fc 73 SPL_AC_3ARGS_FILE_FSYNC
46aa7b39 74 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
86933a6e
BB
75])
76
77AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
bb339d06 78 modpost=$LINUX/scripts/Makefile.modpost
86933a6e 79 AC_MSG_CHECKING([kernel file name for module symbols])
bb339d06
BB
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
86933a6e 86 else
bb339d06 87 LINUX_SYMBOLS=NONE
86933a6e
BB
88 fi
89 AC_MSG_RESULT($LINUX_SYMBOLS)
90 AC_SUBST(LINUX_SYMBOLS)
91])
92
57d86234 93AC_DEFUN([SPL_AC_KERNEL], [
57d86234 94 AC_ARG_WITH([linux],
95 AS_HELP_STRING([--with-linux=PATH],
96 [Path to kernel source]),
39a3d2a4 97 [kernelsrc="$withval"])
57d86234 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
534c4e38
BM
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
57d86234 114
8fd4e3af 115 if test -n "$sourcelink" && test -e ${sourcelink}; then
d4326403 116 kernelsrc=`readlink -f ${sourcelink}`
d4326403 117 else
57d86234 118 AC_MSG_RESULT([Not found])
119 AC_MSG_ERROR([
8fd4e3af
BB
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.])
57d86234 123 fi
c5f70460
BB
124 else
125 if test "$kernelsrc" = "NONE"; then
126 kernsrcver=NONE
127 fi
57d86234 128 fi
129
130 AC_MSG_RESULT([$kernelsrc])
131 AC_MSG_CHECKING([kernel build directory])
39a3d2a4 132 if test -z "$kernelbuild"; then
e2d28a37
BB
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}
39a3d2a4
BB
139 else
140 kernelbuild=${kernelsrc}
141 fi
bf338d8d 142 fi
57d86234 143 AC_MSG_RESULT([$kernelbuild])
144
145 AC_MSG_CHECKING([kernel source version])
fd921c2e
BB
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
57d86234 156
fd921c2e
BB
157 if test "$utsrelease"; then
158 kernsrcver=`(echo "#include <$utsrelease>";
57d86234 159 echo "kernsrcver=UTS_RELEASE") |
d4326403 160 cpp -I $kernelbuild/include |
57d86234 161 grep "^kernsrcver=" | cut -d \" -f 2`
57d86234 162
fd921c2e
BB
163 if test -z "$kernsrcver"; then
164 AC_MSG_RESULT([Not found])
165 AC_MSG_ERROR([*** Cannot determine kernel version.])
166 fi
167 else
57d86234 168 AC_MSG_RESULT([Not found])
fd921c2e 169 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
57d86234 170 fi
171
172 AC_MSG_RESULT([$kernsrcver])
173
57d86234 174 LINUX=${kernelsrc}
175 LINUX_OBJ=${kernelbuild}
c5f70460
BB
176 LINUX_VERSION=${kernsrcver}
177
57d86234 178 AC_SUBST(LINUX)
179 AC_SUBST(LINUX_OBJ)
c5f70460 180 AC_SUBST(LINUX_VERSION)
57d86234 181
86933a6e 182 SPL_AC_MODULE_SYMVERS
2e0e7e69
BB
183])
184
86933a6e 185dnl #
287b2fb1
BB
186dnl # Explicitly check for gawk, we require it for the the usermode
187dnl # helper. For some reason the standard awk command does not
188dnl # behave correctly when invoked from the usermode helper.
86933a6e 189dnl #
287b2fb1 190AC_DEFUN([SPL_AC_GAWK], [
18142514
BB
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])
86933a6e 197
287b2fb1
BB
198dnl #
199dnl # Default SPL user configuration
200dnl #
201AC_DEFUN([SPL_AC_CONFIG_USER], [
202 SPL_AC_GAWK
203])
204
205dnl #
206dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
207dnl # are missing it is non-fatal but you will not be able to build
208dnl # RPM packages and will be warned if you try too.
209dnl #
210AC_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
243dnl #
244dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
245dnl # tools are missing it is non-fatal but you will not be able to build
246dnl # DEB packages and will be warned if you try too.
247dnl #
248AC_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
282dnl #
283dnl # Until native packaging for various different packing systems
284dnl # can be added the least we can do is attempt to use alien to
285dnl # convert the RPM packages to the needed package type. This is
286dnl # a hack but so far it has worked reasonable well.
287dnl #
288AC_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
306dnl #
307dnl # Using the VENDOR tag from config.guess set the default
308dnl # package type for 'make pkg': (rpm | deb | tgz)
309dnl #
310AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
73fc084e
BB
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)
287b2fb1
BB
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
347dnl #
348dnl # Default SPL user configuration
349dnl #
350AC_DEFUN([SPL_AC_PACKAGE], [
351 SPL_AC_RPM
352 SPL_AC_DPKG
353 SPL_AC_ALIEN
354 SPL_AC_DEFAULT_PACKAGE
355])
356
6a1c3d41 357AC_DEFUN([SPL_AC_LICENSE], [
86933a6e
BB
358 AC_MSG_CHECKING([spl license])
359 LICENSE=GPL
360 AC_MSG_RESULT([$LICENSE])
6a1c3d41 361 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
86933a6e
BB
362 AC_SUBST(LICENSE)
363])
364
365AC_DEFUN([SPL_AC_CONFIG], [
366 SPL_CONFIG=all
367 AC_ARG_WITH([config],
368 AS_HELP_STRING([--with-config=CONFIG],
c1541dfe 369 [Config file 'kernel|user|all|srpm']),
86933a6e
BB
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 ;;
c1541dfe 381 srpm) ;;
86933a6e
BB
382 *)
383 AC_MSG_RESULT([Error!])
384 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
c1541dfe 385 user kernel|user|all|srpm]) ;;
86933a6e
BB
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])
6a1c3d41 394])
395
055ffd98
BB
396dnl #
397dnl # Enable if the SPL should be compiled with internal debugging enabled.
398dnl # By default this support is disabled.
399dnl #
57d86234 400AC_DEFUN([SPL_AC_DEBUG], [
c950d148 401 AC_MSG_CHECKING([whether debugging is enabled])
055ffd98
BB
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],
c950d148 409 [
c950d148
BB
410 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
411 DEBUG_CFLAGS="-DDEBUG -Werror"
412 ],
413 [
c950d148
BB
414 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
415 DEBUG_CFLAGS="-DNDEBUG"
416 ])
055ffd98 417
c950d148 418 AC_SUBST(DEBUG_CFLAGS)
055ffd98 419 AC_MSG_RESULT([$enable_debug])
57d86234 420])
421
055ffd98
BB
422dnl #
423dnl # Enabled by default it provides a minimal level of memory tracking.
424dnl # A total count of bytes allocated is kept for each alloc and free.
425dnl # Then at module unload time a report to the console will be printed
426dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
427dnl # and provide an easy way to inspect the kmem based slab.
428dnl #
57d86234 429AC_DEFUN([SPL_AC_DEBUG_KMEM], [
055ffd98
BB
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])
57d86234 435
055ffd98
BB
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])
57d86234 443])
444
055ffd98
BB
445dnl #
446dnl # Disabled by default it provides detailed memory tracking. This
447dnl # feature also requires --enable-debug-kmem to be set. When enabled
448dnl # not only will total bytes be tracked but also the location of every
449dnl # alloc and free. When the SPL module is unloaded a list of all leaked
450dnl # addresses and where they were allocated will be dumped to the console.
451dnl # Enabling this feature has a significant impact on performance but it
452dnl # makes finding memory leaks pretty straight forward.
453dnl #
454AC_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])
57d86234 468])
469
470dnl #
471dnl # SPL_LINUX_CONFTEST
472dnl #
473AC_DEFUN([SPL_LINUX_CONFTEST], [
dbe561d8 474cat confdefs.h - <<_ACEOF >conftest.c
57d86234 475$1
476_ACEOF
477])
478
479dnl #
480dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
481dnl #
482m4_define([SPL_LANG_PROGRAM], [
483$1
484int
485main (void)
486{
487dnl Do *not* indent the following line: there may be CPP directives.
488dnl Don't move the `;' right after for the same reason.
489$2
490 ;
491 return 0;
492}
493])
494
495dnl #
496dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
497dnl #
498AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
c5f70460
BB
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(
3d0cb2d3 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])],
c5f70460
BB
504 [$4],
505 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
506 )
507 rm -Rf build
57d86234 508])
509
510dnl #
511dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
512dnl #
513AC_DEFUN([SPL_LINUX_TRY_COMPILE],
514 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 515 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
516 [modules],
517 [test -s build/conftest.o],
518 [$3], [$4])
57d86234 519])
520
521dnl #
522dnl # SPL_LINUX_CONFIG
523dnl #
524AC_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
543dnl #
544dnl # SPL_CHECK_SYMBOL_EXPORT
545dnl # check symbol exported or not
546dnl #
547AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
548 [AC_MSG_CHECKING([whether symbol $1 is exported])
2e0e7e69
BB
549 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
550 $LINUX_OBJ/Module*.symvers 2>/dev/null
57d86234 551 rc=$?
552 if test $rc -ne 0; then
553 export=0
554 for file in $2; do
2e0e7e69
BB
555 grep -q -E "EXPORT_SYMBOL.*($1)" \
556 "$LINUX_OBJ/$file" 2>/dev/null
57d86234 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
86de8532 576dnl #
577dnl # SPL_CHECK_HEADER
578dnl # check whether header exists and define HAVE_$2_HEADER
579dnl #
580AC_DEFUN([SPL_CHECK_HEADER],
581 [AC_MSG_CHECKING([whether header $1 exists])
582 SPL_LINUX_TRY_COMPILE([
d50bd9e2 583 #include <$1>
86de8532 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])
6a6cafbe 595
57d86234 596dnl #
d04c8a56
BB
597dnl # Use the atomic implemenation based on global spinlocks. This
598dnl # should only be needed by 32-bit kernels which do not provide
599dnl # the atomic64_* API. It may be optionally enabled as a fallback
600dnl # if problems are observed with the direct mapping to the native
601dnl # Linux atomic operations. You may not disable atomic spinlocks
602dnl # if you kernel does not an atomic64_* API.
57d86234 603dnl #
d04c8a56
BB
604AC_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])
57d86234 610
a0f6da3d 611 SPL_LINUX_TRY_COMPILE([
612 #include <asm/atomic.h>
613 ],[
614 atomic64_t *ptr;
615 ],[
d04c8a56 616 have_atomic64_t=yes
a0f6da3d 617 AC_DEFINE(HAVE_ATOMIC64_T, 1,
d04c8a56 618 [kernel defines atomic64_t])
a0f6da3d 619 ],[
d04c8a56
BB
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 ])
a0f6da3d 629 ])
d04c8a56
BB
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])
a0f6da3d 646])
647
302b88e6
BB
648dnl #
649dnl # 2.6.24 API change,
650dnl # check if atomic64_cmpxchg is defined
651dnl #
652AC_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>
5ec44a37 656 #include <asm/system.h>
302b88e6
BB
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
668dnl #
669dnl # 2.6.24 API change,
670dnl # check if atomic64_xchg is defined
671dnl #
672AC_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
d04c8a56
BB
687dnl #
688dnl # 2.6.24 API change,
689dnl # check if uintptr_t typedef is defined
690dnl #
691AC_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
57d86234 706dnl #
3d061e9d 707dnl # 2.6.20 API change,
57d86234 708dnl # INIT_WORK use 2 args and not store data inside
709dnl #
710AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
711 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
712 SPL_LINUX_TRY_COMPILE([
d50bd9e2 713 #include <linux/workqueue.h>
57d86234 714 ],[
d50bd9e2 715 struct work_struct work;
716 INIT_WORK(&work, NULL, NULL);
57d86234 717 ],[
d50bd9e2 718 AC_MSG_RESULT(yes)
719 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
720 [INIT_WORK wants 3 args])
57d86234 721 ],[
d50bd9e2 722 AC_MSG_RESULT(no)
57d86234 723 ])
724])
725
726dnl #
3d061e9d 727dnl # 2.6.21 API change,
57d86234 728dnl # 'register_sysctl_table' use only one argument instead of two
729dnl #
730AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
731 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
732 SPL_LINUX_TRY_COMPILE([
d50bd9e2 733 #include <linux/sysctl.h>
57d86234 734 ],[
d50bd9e2 735 return register_sysctl_table(NULL,0);
57d86234 736 ],[
d50bd9e2 737 AC_MSG_RESULT(yes)
738 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
739 [register_sysctl_table() wants 2 args])
57d86234 740 ],[
d50bd9e2 741 AC_MSG_RESULT(no)
57d86234 742 ])
743])
744
57d86234 745dnl #
3d061e9d 746dnl # 2.6.23 API change
57d86234 747dnl # Old set_shrinker API replaced with register_shrinker
748dnl #
749AC_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
764dnl #
3d061e9d 765dnl # 2.6.25 API change,
57d86234 766dnl # struct path entry added to struct nameidata
767dnl #
768AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
769 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
770 SPL_LINUX_TRY_COMPILE([
d50bd9e2 771 #include <linux/namei.h>
57d86234 772 ],[
d50bd9e2 773 struct nameidata nd;
57d86234 774
775 nd.path.mnt = NULL;
776 nd.path.dentry = NULL;
777 ],[
d50bd9e2 778 AC_MSG_RESULT(yes)
779 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
780 [struct path used in struct nameidata])
57d86234 781 ],[
d50bd9e2 782 AC_MSG_RESULT(no)
57d86234 783 ])
784])
785
786dnl #
787dnl # Custom SPL patch may export this system it is not required
788dnl #
789AC_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
795dnl #
3d061e9d 796dnl # 2.6.19 API change,
57d86234 797dnl # Use CTL_UNNUMBERED when binary sysctl is not required
798dnl #
799AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
800 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
801 SPL_LINUX_TRY_COMPILE([
d50bd9e2 802 #include <linux/sysctl.h>
57d86234 803 ],[
804 #ifndef CTL_UNNUMBERED
805 #error CTL_UNNUMBERED undefined
806 #endif
807 ],[
d50bd9e2 808 AC_MSG_RESULT(yes)
809 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
810 [unnumbered sysctl support exists])
57d86234 811 ],[
d50bd9e2 812 AC_MSG_RESULT(no)
57d86234 813 ])
814])
877a32e9 815
79a3bf13
BB
816dnl #
817dnl # 2.6.33 API change,
818dnl # Removed .ctl_name from struct ctl_table.
819dnl #
820AC_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
877a32e9 835dnl #
836dnl # 2.6.16 API change.
837dnl # Check if 'fls64()' is available
838dnl #
839AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 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 ])
877a32e9 851])
46c685d0 852
853dnl #
854dnl # 2.6.18 API change, check whether device_create() is available.
855dnl # Device_create() was introduced in 2.6.18 and depricated
856dnl # class_device_create() which was fully removed in 2.6.26.
857dnl #
858AC_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])],
6a6cafbe 864 [])
46c685d0 865])
866
8123ac4f
BB
867dnl #
868dnl # 2.6.27 API change,
869dnl # device_create() uses 5 args, new 'drvdata' argument.
870dnl #
871AC_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
46c685d0 889dnl #
890dnl # 2.6.13 API change, check whether class_device_create() is available.
891dnl # Class_device_create() was introduced in 2.6.13 and depricated
892dnl # class_simple_device_add() which was fully removed in 2.6.13.
893dnl #
894AC_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])],
6a6cafbe 900 [])
46c685d0 901])
6a6cafbe 902
6a6cafbe 903dnl #
904dnl # 2.6.26 API change, set_normalized_timespec() is exported.
905dnl #
906AC_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
915dnl #
916dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
917dnl # previously it was available in time.h as an inline.
918dnl #
86de8532 919AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
920 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 921 SPL_LINUX_TRY_COMPILE([
922 #include <linux/time.h>
6a6cafbe 923 void set_normalized_timespec(struct timespec *ts,
25557fd8 924 time_t sec, long nsec) { }
925 ],
926 [],
927 [
6a6cafbe 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
936dnl #
937dnl # 2.6.18 API change,
938dnl # timespec_sub() inline function available in linux/time.h
939dnl #
86de8532 940AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
941 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 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
86de8532 955dnl #
3d061e9d 956dnl # 2.6.19 API change,
957dnl # check if init_utsname() is available in linux/utsname.h
958dnl #
959AC_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
973dnl #
974dnl # 2.6.26 API change,
975dnl # definition of struct fdtable relocated to linux/fdtable.h
86de8532 976dnl #
977AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
978 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
979])
322640b7 980
981dnl #
3d061e9d 982dnl # 2.6.14 API change,
983dnl # check whether 'files_fdtable()' exists
984dnl #
985AC_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
1004dnl #
1005dnl # 2.6.18 API change,
1006dnl # added linux/uaccess.h
322640b7 1007dnl #
1008AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1009 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1010])
3d061e9d 1011
1012dnl #
1013dnl # 2.6.12 API change,
1014dnl # check whether 'kmalloc_node()' is available.
1015dnl #
1016AC_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
1030dnl #
1031dnl # 2.6.9 API change,
1032dnl # check whether 'monotonic_clock()' is available it may
1033dnl # be available for some archs but not others.
1034dnl #
1035AC_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
1044dnl #
1045dnl # 2.6.16 API change,
1046dnl # check whether 'struct inode' has i_mutex
1047dnl #
1048AC_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])
b61a6e8b 1063
4d54fdee
BB
1064dnl #
1065dnl # 2.6.29 API change,
1066dnl # Adaptive mutexs introduced.
1067dnl #
1068AC_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
6c9433c1
BB
1083dnl #
1084dnl # 2.6.18 API change,
1085dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1086dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1087dnl # if the mutex validator is disabled or otherwise unavailable.
1088dnl #
1089AC_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
31a033ec
BB
1106dnl #
1107dnl # 2.6.27 API change,
1108dnl # on_each_cpu() uses 3 args, no 'retry' argument
1109dnl #
1110AC_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])
36b313da
BB
1124
1125dnl #
d1ff2312
BB
1126dnl # 2.6.18 API change,
1127dnl # kallsyms_lookup_name no longer exported
1128dnl #
1129AC_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
1138dnl #
e11d6c5f
BB
1139dnl # Proposed API change,
1140dnl # This symbol is not available in stock kernels. You may build a
1141dnl # custom kernel with the *-spl-export-symbols.patch which will export
1142dnl # these symbols for use. If your already rolling a custom kernel for
1143dnl # your environment this is recommended.
d1ff2312
BB
1144dnl #
1145AC_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
5232d256
BB
1154dnl #
1155dnl # 2.6.17 API change
1156dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1157dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1158dnl # were exported in 2.6.17 for use by modules which was consistent with
1159dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1160dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1161dnl # were dropped entirely leaving modules no way to directly iterate over
1162dnl # the zone list. Because we need access to the zone helpers we check
1163dnl # if the kernel contains the old or new implementation. Then we check
1164dnl # to see if the symbols we need for each version are available. If they
1165dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1166dnl #
1167AC_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
d1ff2312 1179dnl #
e11d6c5f
BB
1180dnl # Proposed API change,
1181dnl # This symbol is not available in stock kernels. You may build a
1182dnl # custom kernel with the *-spl-export-symbols.patch which will export
1183dnl # these symbols for use. If your already rolling a custom kernel for
1184dnl # your environment this is recommended.
36b313da
BB
1185dnl #
1186AC_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
1195dnl #
e11d6c5f
BB
1196dnl # Proposed API change,
1197dnl # This symbol is not available in stock kernels. You may build a
1198dnl # custom kernel with the *-spl-export-symbols.patch which will export
1199dnl # these symbols for use. If your already rolling a custom kernel for
1200dnl # your environment this is recommended.
36b313da
BB
1201dnl #
1202AC_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
1211dnl #
e11d6c5f
BB
1212dnl # Proposed API change,
1213dnl # This symbol is not available in stock kernels. You may build a
1214dnl # custom kernel with the *-spl-export-symbols.patch which will export
1215dnl # these symbols for use. If your already rolling a custom kernel for
1216dnl # your environment this is recommended.
36b313da
BB
1217dnl #
1218AC_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])
4ab13d3b 1226
5232d256
BB
1227dnl #
1228dnl # 2.6.17 API change,
1229dnl # See SPL_AC_PGDAT_HELPERS for details.
1230dnl #
1231AC_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
96dded38
BB
1240dnl #
1241dnl # 2.6.18 API change,
1242dnl # First introduced global_page_state() support as an inline.
1243dnl #
1244AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1245 AC_MSG_CHECKING([whether global_page_state() is available])
1246 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1247 #include <linux/mm.h>
96dded38
BB
1248 ],[
1249 unsigned long state;
6ae7fef5 1250 state = global_page_state(0);
96dded38
BB
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
e11d6c5f 1260dnl #
6ae7fef5
BB
1261dnl # 2.6.21 API change (plus subsequent naming convention changes),
1262dnl # Public global zone stats now include a free page count. However
1263dnl # the enumerated names of the counters have changed since this API
1264dnl # was introduced. We need to deduce the corrent name to use. This
1265dnl # replaces the priviate get_zone_counts() interface.
1266dnl #
1267dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1268dnl # is 2.6.30 as of when this was written.
e11d6c5f 1269dnl #
6ae7fef5
BB
1270AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1271 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
e11d6c5f 1272 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1273 #include <linux/mm.h>
e11d6c5f 1274 ],[
6ae7fef5
BB
1275 enum zone_stat_item zsi;
1276 zsi = NR_FREE_PAGES;
e11d6c5f
BB
1277 ],[
1278 AC_MSG_RESULT(yes)
6ae7fef5
BB
1279 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1280 [Page state NR_FREE_PAGES is available])
e11d6c5f
BB
1281 ],[
1282 AC_MSG_RESULT(no)
1283 ])
1284])
a093c6a4 1285
6ae7fef5
BB
1286dnl #
1287dnl # 2.6.21 API change (plus subsequent naming convention changes),
1288dnl # Public global zone stats now include an inactive page count. However
1289dnl # the enumerated names of the counters have changed since this API
1290dnl # was introduced. We need to deduce the corrent name to use. This
1291dnl # replaces the priviate get_zone_counts() interface.
1292dnl #
1293dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1294dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1295dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1296dnl #
1297AC_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
1341dnl #
1342dnl # 2.6.21 API change (plus subsequent naming convention changes),
1343dnl # Public global zone stats now include an active page count. However
1344dnl # the enumerated names of the counters have changed since this API
1345dnl # was introduced. We need to deduce the corrent name to use. This
1346dnl # replaces the priviate get_zone_counts() interface.
1347dnl #
1348dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1349dnl # anonymous and file active pages. As of 2.6.28 it was split in
1350dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1351dnl #
1352AC_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
1396dnl #
1397dnl # Proposed API change for legacy kernels.
1398dnl # This symbol is not available in older kernels. For kernels post
1399dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1400dnl # page state information. This symbol is only used in legacy kernels
1401dnl # any only as a last resort.
1402dnl
1403AC_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
7119bf70
BB
1438dnl #
1439dnl # 2.6.27 API change,
1440dnl # The user_path_dir() replaces __user_walk()
1441dnl #
1442AC_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
51a727e9
BB
1451dnl #
1452dnl # Symbol available in RHEL kernels not in stock kernels.
1453dnl #
1454AC_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
1463dnl #
1464dnl # 2.6.25 API change,
1465dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1466dnl #
1467AC_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>
baf2979e 1471 #include <linux/fs_struct.h>
51a727e9
BB
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
a093c6a4
BB
1483dnl #
1484dnl # SLES API change, never adopted in mainline,
1485dnl # Third 'struct vfsmount *' argument removed.
1486dnl #
1487AC_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
1502dnl #
1503dnl # SLES API change, never adopted in mainline,
1504dnl # Third and sixth 'struct vfsmount *' argument removed.
1505dnl #
1506AC_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])
ec7d53e9
BB
1520
1521dnl #
1522dnl # 2.6.29 API change,
1523dnl # check whether 'struct cred' exists
1524dnl #
1525AC_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
1540dnl #
e811949a 1541dnl # Custom SPL patch may export this symbol.
ec7d53e9
BB
1542dnl #
1543AC_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])
e811949a
BB
1551
1552dnl #
1553dnl # 2.6.x API change,
1554dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1555dnl #
1556AC_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])
3977f837
BB
1564
1565dnl #
1566dnl # 2.6.32 API change,
1567dnl # Unused 'struct file *' removed from prototype.
1568dnl #
1569AC_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])
b868e22f
BB
1583
1584dnl #
1585dnl # 2.6.x API change,
1586dnl # kvasprintf() function added.
1587dnl #
1588AC_DEFUN([SPL_AC_KVASPRINTF], [
1589 SPL_CHECK_SYMBOL_EXPORT(
1590 [kvasprintf],
1591 [],
1592 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1593 [kvasprintf() is available])],
1594 [])
1595])
f0ff89fc
BB
1596
1597dnl #
1598dnl # 2.6.35 API change,
1599dnl # Unused 'struct dentry *' removed from prototype.
1600dnl #
1601AC_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])
46aa7b39
NB
1615
1616dnl #
1617dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1618dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1619dnl # condition. The fixed version is exported as a symbol. The race
1620dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1621dnl # call that version while holding sem->wait_lock.
1622dnl #
1623AC_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])