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