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