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