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