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