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