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