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