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