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