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