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