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