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