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