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