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