]> git.proxmox.com Git - mirror_spl-debian.git/blame - config/spl-build.m4
Remove get/put_task_struct as they are not available for SLES11
[mirror_spl-debian.git] / config / spl-build.m4
CommitLineData
86933a6e
BB
1dnl #
2dnl # Default SPL kernel configuration
3dnl #
4AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
5 SPL_AC_KERNEL
6
7 dnl # Kernel build make options
8 dnl # KERNELMAKE_PARAMS="V=1" # Enable verbose module build
9 KERNELMAKE_PARAMS="V=1"
10
11 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
12 dnl # compiler options are added by the kernel build system.
13 abs_srcdir=`readlink -f ${srcdir}`
14 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes -Werror"
15 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir} -I${abs_srcdir}/include"
16
17 if test "${LINUX_OBJ}" != "${LINUX}"; then
18 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
19 fi
20
21 AC_SUBST(KERNELMAKE_PARAMS)
22 AC_SUBST(KERNELCPPFLAGS)
23
24 SPL_AC_DEBUG
25 SPL_AC_DEBUG_KMEM
26 SPL_AC_DEBUG_MUTEX
27 SPL_AC_DEBUG_KSTAT
28 SPL_AC_DEBUG_CALLB
29 SPL_AC_TYPE_UINTPTR_T
30 SPL_AC_TYPE_ATOMIC64_T
31 SPL_AC_3ARGS_INIT_WORK
32 SPL_AC_2ARGS_REGISTER_SYSCTL
33 SPL_AC_SET_SHRINKER
34 SPL_AC_PATH_IN_NAMEIDATA
35 SPL_AC_TASK_CURR
36 SPL_AC_CTL_UNNUMBERED
37 SPL_AC_FLS64
38 SPL_AC_DEVICE_CREATE
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
43 SPL_AC_TIMESPEC_SUB
44 SPL_AC_INIT_UTSNAME
45 SPL_AC_FDTABLE_HEADER
46 SPL_AC_FILES_FDTABLE
47 SPL_AC_UACCESS_HEADER
48 SPL_AC_KMALLOC_NODE
49 SPL_AC_MONOTONIC_CLOCK
50 SPL_AC_INODE_I_MUTEX
51 SPL_AC_MUTEX_LOCK_NESTED
52 SPL_AC_DIV64_64
53 SPL_AC_DIV64_U64
54 SPL_AC_3ARGS_ON_EACH_CPU
55 SPL_AC_KALLSYMS_LOOKUP_NAME
56 SPL_AC_GET_VMALLOC_INFO
57 SPL_AC_PGDAT_HELPERS
58 SPL_AC_FIRST_ONLINE_PGDAT
59 SPL_AC_NEXT_ONLINE_PGDAT
60 SPL_AC_NEXT_ZONE
61 SPL_AC_PGDAT_LIST
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
ec7d53e9
BB
67 SPL_AC_CRED_STRUCT
68 SPL_AC_GROUPS_SEARCH
86933a6e
BB
69])
70
71AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
bb339d06 72 modpost=$LINUX/scripts/Makefile.modpost
86933a6e 73 AC_MSG_CHECKING([kernel file name for module symbols])
bb339d06
BB
74 if test -f "$modpost"; then
75 if grep -q Modules.symvers $modpost; then
76 LINUX_SYMBOLS=Modules.symvers
77 else
78 LINUX_SYMBOLS=Module.symvers
79 fi
86933a6e 80 else
bb339d06 81 LINUX_SYMBOLS=NONE
86933a6e
BB
82 fi
83 AC_MSG_RESULT($LINUX_SYMBOLS)
84 AC_SUBST(LINUX_SYMBOLS)
85])
86
57d86234 87AC_DEFUN([SPL_AC_KERNEL], [
57d86234 88 AC_ARG_WITH([linux],
89 AS_HELP_STRING([--with-linux=PATH],
90 [Path to kernel source]),
39a3d2a4 91 [kernelsrc="$withval"])
57d86234 92
93 AC_ARG_WITH([linux-obj],
94 AS_HELP_STRING([--with-linux-obj=PATH],
95 [Path to kernel build objects]),
96 [kernelbuild="$withval"])
97
98 AC_MSG_CHECKING([kernel source directory])
99 if test -z "$kernelsrc"; then
bf338d8d
BB
100 sourcelink=`ls -1d /usr/src/kernels/* /usr/src/linux-* \
101 2>/dev/null | grep -v obj | tail -1`
57d86234 102
d4326403
BB
103 if test -e ${sourcelink}; then
104 kernelsrc=`readlink -f ${sourcelink}`
d4326403 105 else
57d86234 106 AC_MSG_RESULT([Not found])
107 AC_MSG_ERROR([
108 *** Please specify the location of the kernel source
6a1c3d41 109 *** with the '--with-linux=PATH' option])
57d86234 110 fi
c5f70460
BB
111 else
112 if test "$kernelsrc" = "NONE"; then
113 kernsrcver=NONE
114 fi
57d86234 115 fi
116
117 AC_MSG_RESULT([$kernelsrc])
118 AC_MSG_CHECKING([kernel build directory])
39a3d2a4 119 if test -z "$kernelbuild"; then
749e5eb1 120 if test -d ${kernelsrc}-obj/`arch`/`arch`; then
39a3d2a4 121 kernelbuild=${kernelsrc}-obj/`arch`/`arch`
749e5eb1
BB
122 elif test -d ${kernelsrc}-obj/`arch`/default; then
123 kernelbuild=${kernelsrc}-obj/`arch`/default
39a3d2a4
BB
124 elif test -d `dirname ${kernelsrc}`/build-`arch`; then
125 kernelbuild=`dirname ${kernelsrc}`/build-`arch`
126 else
127 kernelbuild=${kernelsrc}
128 fi
bf338d8d 129 fi
57d86234 130 AC_MSG_RESULT([$kernelbuild])
131
132 AC_MSG_CHECKING([kernel source version])
133 if test -r $kernelbuild/include/linux/version.h &&
134 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
135
136 kernsrcver=`(echo "#include <linux/version.h>";
137 echo "kernsrcver=UTS_RELEASE") |
d4326403 138 cpp -I $kernelbuild/include |
57d86234 139 grep "^kernsrcver=" | cut -d \" -f 2`
140
141 elif test -r $kernelbuild/include/linux/utsrelease.h &&
142 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
143
144 kernsrcver=`(echo "#include <linux/utsrelease.h>";
145 echo "kernsrcver=UTS_RELEASE") |
d4326403 146 cpp -I $kernelbuild/include |
57d86234 147 grep "^kernsrcver=" | cut -d \" -f 2`
148 fi
149
150 if test -z "$kernsrcver"; then
151 AC_MSG_RESULT([Not found])
152 AC_MSG_ERROR([
153 *** Cannot determine the version of the linux kernel source.
154 *** Please prepare the kernel before running this script])
155 fi
156
157 AC_MSG_RESULT([$kernsrcver])
158
57d86234 159 LINUX=${kernelsrc}
160 LINUX_OBJ=${kernelbuild}
c5f70460
BB
161 LINUX_VERSION=${kernsrcver}
162
57d86234 163 AC_SUBST(LINUX)
164 AC_SUBST(LINUX_OBJ)
c5f70460 165 AC_SUBST(LINUX_VERSION)
57d86234 166
86933a6e 167 SPL_AC_MODULE_SYMVERS
2e0e7e69
BB
168])
169
86933a6e
BB
170dnl #
171dnl # Default SPL user configuration
172dnl #
173AC_DEFUN([SPL_AC_CONFIG_USER], [])
174
6a1c3d41 175AC_DEFUN([SPL_AC_LICENSE], [
86933a6e
BB
176 AC_MSG_CHECKING([spl license])
177 LICENSE=GPL
178 AC_MSG_RESULT([$LICENSE])
6a1c3d41 179 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
86933a6e
BB
180 AC_SUBST(LICENSE)
181])
182
183AC_DEFUN([SPL_AC_CONFIG], [
184 SPL_CONFIG=all
185 AC_ARG_WITH([config],
186 AS_HELP_STRING([--with-config=CONFIG],
187 [Config file 'kernel|user|all']),
188 [SPL_CONFIG="$withval"])
189
190 AC_MSG_CHECKING([spl config])
191 AC_MSG_RESULT([$SPL_CONFIG]);
192 AC_SUBST(SPL_CONFIG)
193
194 case "$SPL_CONFIG" in
195 kernel) SPL_AC_CONFIG_KERNEL ;;
196 user) SPL_AC_CONFIG_USER ;;
197 all) SPL_AC_CONFIG_KERNEL
198 SPL_AC_CONFIG_USER ;;
199 *)
200 AC_MSG_RESULT([Error!])
201 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
202 user kernel|user|all]) ;;
203 esac
204
205 AM_CONDITIONAL([CONFIG_USER],
206 [test "$SPL_CONFIG" = user] ||
207 [test "$SPL_CONFIG" = all])
208 AM_CONDITIONAL([CONFIG_KERNEL],
209 [test "$SPL_CONFIG" = kernel] ||
210 [test "$SPL_CONFIG" = all])
6a1c3d41 211])
212
57d86234 213AC_DEFUN([SPL_AC_DEBUG], [
214 AC_MSG_CHECKING([whether debugging is enabled])
215 AC_ARG_ENABLE( [debug],
216 AS_HELP_STRING([--enable-debug],
217 [Enable generic debug support (default off)]),
218 [ case "$enableval" in
219 yes) spl_ac_debug=yes ;;
475cdc78 220 no) spl_ac_debug=no ;;
57d86234 221 *) AC_MSG_RESULT([Error!])
222 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
223 esac ]
224 )
225 if test "$spl_ac_debug" = yes; then
475cdc78 226 AC_MSG_RESULT([yes])
57d86234 227 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
228 else
475cdc78 229 AC_MSG_RESULT([no])
475cdc78 230 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
57d86234 231 fi
57d86234 232])
233
234AC_DEFUN([SPL_AC_DEBUG_KMEM], [
235 AC_MSG_CHECKING([whether kmem debugging is enabled])
236 AC_ARG_ENABLE( [debug-kmem],
237 AS_HELP_STRING([--enable-debug-kmem],
238 [Enable kmem debug support (default off)]),
239 [ case "$enableval" in
475cdc78 240 yes) spl_ac_debug_kmem=yes ;;
241 no) spl_ac_debug_kmem=no ;;
57d86234 242 *) AC_MSG_RESULT([Error!])
243 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
244 esac ]
245 )
475cdc78 246 if test "$spl_ac_debug_kmem" = yes; then
247 AC_MSG_RESULT([yes])
57d86234 248 AC_DEFINE([DEBUG_KMEM], [1],
249 [Define to 1 to enable kmem debugging])
475cdc78 250 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
251 else
252 AC_MSG_RESULT([no])
57d86234 253 fi
57d86234 254])
255
256AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
257 AC_MSG_CHECKING([whether mutex debugging is enabled])
258 AC_ARG_ENABLE( [debug-mutex],
259 AS_HELP_STRING([--enable-debug-mutex],
260 [Enable mutex debug support (default off)]),
261 [ case "$enableval" in
475cdc78 262 yes) spl_ac_debug_mutex=yes ;;
263 no) spl_ac_debug_mutex=no ;;
57d86234 264 *) AC_MSG_RESULT([Error!])
265 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
266 esac ]
267 )
475cdc78 268 if test "$spl_ac_debug_mutex" = yes; then
269 AC_MSG_RESULT([yes])
57d86234 270 AC_DEFINE([DEBUG_MUTEX], [1],
271 [Define to 1 to enable mutex debugging])
475cdc78 272 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
273 else
274 AC_MSG_RESULT([no])
57d86234 275 fi
57d86234 276])
277
278AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
279 AC_MSG_CHECKING([whether kstat debugging is enabled])
280 AC_ARG_ENABLE( [debug-kstat],
281 AS_HELP_STRING([--enable-debug-kstat],
282 [Enable kstat debug support (default off)]),
283 [ case "$enableval" in
475cdc78 284 yes) spl_ac_debug_kstat=yes ;;
285 no) spl_ac_debug_kstat=no ;;
57d86234 286 *) AC_MSG_RESULT([Error!])
287 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
288 esac ]
289 )
475cdc78 290 if test "$spl_ac_debug_kstat" = yes; then
291 AC_MSG_RESULT([yes])
57d86234 292 AC_DEFINE([DEBUG_KSTAT], [1],
293 [Define to 1 to enable kstat debugging])
475cdc78 294 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
295 else
296 AC_MSG_RESULT([no])
57d86234 297 fi
57d86234 298])
299
300AC_DEFUN([SPL_AC_DEBUG_CALLB], [
301 AC_MSG_CHECKING([whether callb debugging is enabled])
302 AC_ARG_ENABLE( [debug-callb],
303 AS_HELP_STRING([--enable-debug-callb],
304 [Enable callb debug support (default off)]),
305 [ case "$enableval" in
475cdc78 306 yes) spl_ac_debug_callb=yes ;;
307 no) spl_ac_debug_callb=no ;;
57d86234 308 *) AC_MSG_RESULT([Error!])
309 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
310 esac ]
311 )
475cdc78 312 if test "$spl_ac_debug_callb" = yes; then
313 AC_MSG_RESULT([yes])
57d86234 314 AC_DEFINE([DEBUG_CALLB], [1],
315 [Define to 1 to enable callb debugging])
475cdc78 316 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
317 else
318 AC_MSG_RESULT([no])
57d86234 319 fi
57d86234 320])
321
322dnl #
323dnl # SPL_LINUX_CONFTEST
324dnl #
325AC_DEFUN([SPL_LINUX_CONFTEST], [
326cat >conftest.c <<_ACEOF
327$1
328_ACEOF
329])
330
331dnl #
332dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
333dnl #
334m4_define([SPL_LANG_PROGRAM], [
335$1
336int
337main (void)
338{
339dnl Do *not* indent the following line: there may be CPP directives.
340dnl Don't move the `;' right after for the same reason.
341$2
342 ;
343 return 0;
344}
345])
346
347dnl #
348dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
349dnl #
350AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
c5f70460
BB
351 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
352 rm -Rf build && mkdir -p build
353 echo "obj-m := conftest.o" >build/Makefile
354 AS_IF(
3d0cb2d3 355 [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
356 [$4],
357 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
358 )
359 rm -Rf build
57d86234 360])
361
362dnl #
363dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
364dnl #
365AC_DEFUN([SPL_LINUX_TRY_COMPILE],
366 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 367 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
368 [modules],
369 [test -s build/conftest.o],
370 [$3], [$4])
57d86234 371])
372
373dnl #
374dnl # SPL_LINUX_CONFIG
375dnl #
376AC_DEFUN([SPL_LINUX_CONFIG],
377 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
378 SPL_LINUX_TRY_COMPILE([
379 #ifndef AUTOCONF_INCLUDED
380 #include <linux/config.h>
381 #endif
382 ],[
383 #ifndef CONFIG_$1
384 #error CONFIG_$1 not #defined
385 #endif
386 ],[
387 AC_MSG_RESULT([yes])
388 $2
389 ],[
390 AC_MSG_RESULT([no])
391 $3
392 ])
393])
394
395dnl #
396dnl # SPL_CHECK_SYMBOL_EXPORT
397dnl # check symbol exported or not
398dnl #
399AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
400 [AC_MSG_CHECKING([whether symbol $1 is exported])
2e0e7e69
BB
401 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
402 $LINUX_OBJ/Module*.symvers 2>/dev/null
57d86234 403 rc=$?
404 if test $rc -ne 0; then
405 export=0
406 for file in $2; do
2e0e7e69
BB
407 grep -q -E "EXPORT_SYMBOL.*($1)" \
408 "$LINUX_OBJ/$file" 2>/dev/null
57d86234 409 rc=$?
410 if test $rc -eq 0; then
411 export=1
412 break;
413 fi
414 done
415 if test $export -eq 0; then
416 AC_MSG_RESULT([no])
417 $4
418 else
419 AC_MSG_RESULT([yes])
420 $3
421 fi
422 else
423 AC_MSG_RESULT([yes])
424 $3
425 fi
426])
427
86de8532 428dnl #
429dnl # SPL_CHECK_HEADER
430dnl # check whether header exists and define HAVE_$2_HEADER
431dnl #
432AC_DEFUN([SPL_CHECK_HEADER],
433 [AC_MSG_CHECKING([whether header $1 exists])
434 SPL_LINUX_TRY_COMPILE([
d50bd9e2 435 #include <$1>
86de8532 436 ],[
437 return 0;
438 ],[
439 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
440 AC_MSG_RESULT(yes)
441 $3
442 ],[
443 AC_MSG_RESULT(no)
444 $4
445 ])
446])
6a6cafbe 447
57d86234 448dnl #
3d061e9d 449dnl # 2.6.24 API change,
57d86234 450dnl # check if uintptr_t typedef is defined
451dnl #
452AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
453 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
454 SPL_LINUX_TRY_COMPILE([
d50bd9e2 455 #include <linux/types.h>
57d86234 456 ],[
d50bd9e2 457 uintptr_t *ptr;
57d86234 458 ],[
d50bd9e2 459 AC_MSG_RESULT([yes])
460 AC_DEFINE(HAVE_UINTPTR_T, 1,
57d86234 461 [kernel defines uintptr_t])
462 ],[
d50bd9e2 463 AC_MSG_RESULT([no])
57d86234 464 ])
465])
466
a0f6da3d 467dnl #
468dnl # 2.6.x API change,
469dnl # check if atomic64_t typedef is defined
470dnl #
471AC_DEFUN([SPL_AC_TYPE_ATOMIC64_T],
472 [AC_MSG_CHECKING([whether kernel defines atomic64_t])
473 SPL_LINUX_TRY_COMPILE([
474 #include <asm/atomic.h>
475 ],[
476 atomic64_t *ptr;
477 ],[
478 AC_MSG_RESULT([yes])
479 AC_DEFINE(HAVE_ATOMIC64_T, 1,
480 [kernel defines atomic64_t])
481 ],[
482 AC_MSG_RESULT([no])
483 ])
484])
485
57d86234 486dnl #
3d061e9d 487dnl # 2.6.20 API change,
57d86234 488dnl # INIT_WORK use 2 args and not store data inside
489dnl #
490AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
491 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
492 SPL_LINUX_TRY_COMPILE([
d50bd9e2 493 #include <linux/workqueue.h>
57d86234 494 ],[
d50bd9e2 495 struct work_struct work;
496 INIT_WORK(&work, NULL, NULL);
57d86234 497 ],[
d50bd9e2 498 AC_MSG_RESULT(yes)
499 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
500 [INIT_WORK wants 3 args])
57d86234 501 ],[
d50bd9e2 502 AC_MSG_RESULT(no)
57d86234 503 ])
504])
505
506dnl #
3d061e9d 507dnl # 2.6.21 API change,
57d86234 508dnl # 'register_sysctl_table' use only one argument instead of two
509dnl #
510AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
511 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
512 SPL_LINUX_TRY_COMPILE([
d50bd9e2 513 #include <linux/sysctl.h>
57d86234 514 ],[
d50bd9e2 515 return register_sysctl_table(NULL,0);
57d86234 516 ],[
d50bd9e2 517 AC_MSG_RESULT(yes)
518 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
519 [register_sysctl_table() wants 2 args])
57d86234 520 ],[
d50bd9e2 521 AC_MSG_RESULT(no)
57d86234 522 ])
523])
524
57d86234 525dnl #
3d061e9d 526dnl # 2.6.23 API change
57d86234 527dnl # Old set_shrinker API replaced with register_shrinker
528dnl #
529AC_DEFUN([SPL_AC_SET_SHRINKER], [
530 AC_MSG_CHECKING([whether set_shrinker() available])
531 SPL_LINUX_TRY_COMPILE([
532 #include <linux/mm.h>
533 ],[
534 return set_shrinker(DEFAULT_SEEKS, NULL);
535 ],[
536 AC_MSG_RESULT([yes])
537 AC_DEFINE(HAVE_SET_SHRINKER, 1,
538 [set_shrinker() available])
539 ],[
540 AC_MSG_RESULT([no])
541 ])
542])
543
544dnl #
3d061e9d 545dnl # 2.6.25 API change,
57d86234 546dnl # struct path entry added to struct nameidata
547dnl #
548AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
549 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
550 SPL_LINUX_TRY_COMPILE([
d50bd9e2 551 #include <linux/namei.h>
57d86234 552 ],[
d50bd9e2 553 struct nameidata nd;
57d86234 554
555 nd.path.mnt = NULL;
556 nd.path.dentry = NULL;
557 ],[
d50bd9e2 558 AC_MSG_RESULT(yes)
559 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
560 [struct path used in struct nameidata])
57d86234 561 ],[
d50bd9e2 562 AC_MSG_RESULT(no)
57d86234 563 ])
564])
565
566dnl #
567dnl # Custom SPL patch may export this system it is not required
568dnl #
569AC_DEFUN([SPL_AC_TASK_CURR], [
570 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
571 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
572 [])
573])
574
575dnl #
3d061e9d 576dnl # 2.6.19 API change,
57d86234 577dnl # Use CTL_UNNUMBERED when binary sysctl is not required
578dnl #
579AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
580 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
581 SPL_LINUX_TRY_COMPILE([
d50bd9e2 582 #include <linux/sysctl.h>
57d86234 583 ],[
584 #ifndef CTL_UNNUMBERED
585 #error CTL_UNNUMBERED undefined
586 #endif
587 ],[
d50bd9e2 588 AC_MSG_RESULT(yes)
589 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
590 [unnumbered sysctl support exists])
57d86234 591 ],[
d50bd9e2 592 AC_MSG_RESULT(no)
57d86234 593 ])
594])
877a32e9 595
596dnl #
597dnl # 2.6.16 API change.
598dnl # Check if 'fls64()' is available
599dnl #
600AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 601 [AC_MSG_CHECKING([whether fls64() is available])
602 SPL_LINUX_TRY_COMPILE([
603 #include <linux/bitops.h>
604 ],[
605 return fls64(0);
606 ],[
607 AC_MSG_RESULT(yes)
608 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
609 ],[
610 AC_MSG_RESULT(no)
611 ])
877a32e9 612])
46c685d0 613
614dnl #
615dnl # 2.6.18 API change, check whether device_create() is available.
616dnl # Device_create() was introduced in 2.6.18 and depricated
617dnl # class_device_create() which was fully removed in 2.6.26.
618dnl #
619AC_DEFUN([SPL_AC_DEVICE_CREATE], [
620 SPL_CHECK_SYMBOL_EXPORT(
621 [device_create],
622 [drivers/base/core.c],
623 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
624 [device_create() is available])],
6a6cafbe 625 [])
46c685d0 626])
627
8123ac4f
BB
628dnl #
629dnl # 2.6.27 API change,
630dnl # device_create() uses 5 args, new 'drvdata' argument.
631dnl #
632AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
633 AC_MSG_CHECKING([whether device_create() wants 5 args])
634 tmp_flags="$EXTRA_KCFLAGS"
635 EXTRA_KCFLAGS="-Werror"
636 SPL_LINUX_TRY_COMPILE([
637 #include <linux/device.h>
638 ],[
639 device_create(NULL, NULL, 0, NULL, "%d", 1);
640 ],[
641 AC_MSG_RESULT(yes)
642 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
643 [device_create wants 5 args])
644 ],[
645 AC_MSG_RESULT(no)
646 ])
647 EXTRA_KCFLAGS="$tmp_flags"
648])
649
46c685d0 650dnl #
651dnl # 2.6.13 API change, check whether class_device_create() is available.
652dnl # Class_device_create() was introduced in 2.6.13 and depricated
653dnl # class_simple_device_add() which was fully removed in 2.6.13.
654dnl #
655AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
656 SPL_CHECK_SYMBOL_EXPORT(
657 [class_device_create],
658 [drivers/base/class.c],
659 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
660 [class_device_create() is available])],
6a6cafbe 661 [])
46c685d0 662])
6a6cafbe 663
6a6cafbe 664dnl #
665dnl # 2.6.26 API change, set_normalized_timespec() is exported.
666dnl #
667AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
668 SPL_CHECK_SYMBOL_EXPORT(
669 [set_normalized_timespec],
670 [kernel/time.c],
671 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
672 [set_normalized_timespec() is available as export])],
673 [])
674])
675
676dnl #
677dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
678dnl # previously it was available in time.h as an inline.
679dnl #
86de8532 680AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
681 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 682 SPL_LINUX_TRY_COMPILE([
683 #include <linux/time.h>
6a6cafbe 684 void set_normalized_timespec(struct timespec *ts,
25557fd8 685 time_t sec, long nsec) { }
686 ],
687 [],
688 [
6a6cafbe 689 AC_MSG_RESULT(no)
690 ],[
691 AC_MSG_RESULT(yes)
692 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
693 [set_normalized_timespec() is available as inline])
694 ])
695])
696
697dnl #
698dnl # 2.6.18 API change,
699dnl # timespec_sub() inline function available in linux/time.h
700dnl #
86de8532 701AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
702 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 703 SPL_LINUX_TRY_COMPILE([
704 #include <linux/time.h>
705 ],[
706 struct timespec a, b, c = { 0 };
707 c = timespec_sub(a, b);
708 ],[
709 AC_MSG_RESULT(yes)
710 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
711 ],[
712 AC_MSG_RESULT(no)
713 ])
714])
715
86de8532 716dnl #
3d061e9d 717dnl # 2.6.19 API change,
718dnl # check if init_utsname() is available in linux/utsname.h
719dnl #
720AC_DEFUN([SPL_AC_INIT_UTSNAME], [
721 AC_MSG_CHECKING([whether init_utsname() is available])
722 SPL_LINUX_TRY_COMPILE([
723 #include <linux/utsname.h>
724 ],[
725 struct new_utsname *a = init_utsname();
726 ],[
727 AC_MSG_RESULT(yes)
728 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
729 ],[
730 AC_MSG_RESULT(no)
731 ])
732])
733
734dnl #
735dnl # 2.6.26 API change,
736dnl # definition of struct fdtable relocated to linux/fdtable.h
86de8532 737dnl #
738AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
739 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
740])
322640b7 741
742dnl #
3d061e9d 743dnl # 2.6.14 API change,
744dnl # check whether 'files_fdtable()' exists
745dnl #
746AC_DEFUN([SPL_AC_FILES_FDTABLE], [
747 AC_MSG_CHECKING([whether files_fdtable() is available])
748 SPL_LINUX_TRY_COMPILE([
749 #include <linux/sched.h>
750 #include <linux/file.h>
751 #ifdef HAVE_FDTABLE_HEADER
752 #include <linux/fdtable.h>
753 #endif
754 ],[
755 struct files_struct *files = current->files;
756 struct fdtable *fdt = files_fdtable(files);
757 ],[
758 AC_MSG_RESULT(yes)
759 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
760 ],[
761 AC_MSG_RESULT(no)
762 ])
763])
764
765dnl #
766dnl # 2.6.18 API change,
767dnl # added linux/uaccess.h
322640b7 768dnl #
769AC_DEFUN([SPL_AC_UACCESS_HEADER], [
770 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
771])
3d061e9d 772
773dnl #
774dnl # 2.6.12 API change,
775dnl # check whether 'kmalloc_node()' is available.
776dnl #
777AC_DEFUN([SPL_AC_KMALLOC_NODE], [
778 AC_MSG_CHECKING([whether kmalloc_node() is available])
779 SPL_LINUX_TRY_COMPILE([
780 #include <linux/slab.h>
781 ],[
782 void *a = kmalloc_node(1, GFP_KERNEL, 0);
783 ],[
784 AC_MSG_RESULT(yes)
785 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
786 ],[
787 AC_MSG_RESULT(no)
788 ])
789])
790
791dnl #
792dnl # 2.6.9 API change,
793dnl # check whether 'monotonic_clock()' is available it may
794dnl # be available for some archs but not others.
795dnl #
796AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
797 SPL_CHECK_SYMBOL_EXPORT(
798 [monotonic_clock],
799 [],
800 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
801 [monotonic_clock() is available])],
802 [])
803])
804
805dnl #
806dnl # 2.6.16 API change,
807dnl # check whether 'struct inode' has i_mutex
808dnl #
809AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
810 AC_MSG_CHECKING([whether struct inode has i_mutex])
811 SPL_LINUX_TRY_COMPILE([
812 #include <linux/fs.h>
813 #include <linux/mutex.h>
814 ],[
815 struct inode i;
816 mutex_init(&i.i_mutex);
817 ],[
818 AC_MSG_RESULT(yes)
819 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
820 ],[
821 AC_MSG_RESULT(no)
822 ])
823])
b61a6e8b 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
4ab13d3b 1008dnl #
e11d6c5f
BB
1009dnl # Proposed API change,
1010dnl # This symbol is not available in stock kernels. You may build a
1011dnl # custom kernel with the *-spl-export-symbols.patch which will export
1012dnl # these symbols for use. If your already rolling a custom kernel for
1013dnl # your environment this is recommended.
4ab13d3b
BB
1014dnl #
1015AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1016 SPL_CHECK_SYMBOL_EXPORT(
1017 [get_zone_counts],
1018 [],
1019 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1020 [get_zone_counts() is available])],
1021 [])
1022])
e11d6c5f 1023
96dded38
BB
1024dnl #
1025dnl # 2.6.18 API change,
1026dnl # First introduced global_page_state() support as an inline.
1027dnl #
1028AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1029 AC_MSG_CHECKING([whether global_page_state() is available])
1030 SPL_LINUX_TRY_COMPILE([
1031 #include <linux/vmstat.h>
1032 ],[
1033 unsigned long state;
1034 state = global_page_state(NR_FREE_PAGES);
1035 ],[
1036 AC_MSG_RESULT(yes)
1037 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1038 [global_page_state() is available])
1039 ],[
1040 AC_MSG_RESULT(no)
1041 ])
1042])
1043
e11d6c5f
BB
1044dnl #
1045dnl # 2.6.21 API change,
1046dnl # Public global zone stats now include free/inactive/active page
1047dnl # counts. This replaced the priviate get_zone_counts() interface.
1048dnl #
1049AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FIA], [
1050 AC_MSG_CHECKING([whether free/inactive/active page state is available])
1051 SPL_LINUX_TRY_COMPILE([
1052 #include <linux/mmzone.h>
1053 ],[
1054 enum zone_stat_item i1, i2, i3;
1055 i1 = NR_FREE_PAGES;
1056 i2 = NR_INACTIVE;
1057 i3 = NR_ACTIVE;
1058 ],[
1059 AC_MSG_RESULT(yes)
1060 AC_DEFINE(HAVE_ZONE_STAT_ITEM_FIA, 1,
1061 [free/inactive/active page state is available])
1062 ],[
1063 AC_MSG_RESULT(no)
1064 ])
1065])
a093c6a4
BB
1066
1067dnl #
1068dnl # SLES API change, never adopted in mainline,
1069dnl # Third 'struct vfsmount *' argument removed.
1070dnl #
1071AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1072 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1073 SPL_LINUX_TRY_COMPILE([
1074 #include <linux/fs.h>
1075 ],[
1076 vfs_unlink(NULL, NULL);
1077 ],[
1078 AC_MSG_RESULT(yes)
1079 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1080 [vfs_unlink() wants 2 args])
1081 ],[
1082 AC_MSG_RESULT(no)
1083 ])
1084])
1085
1086dnl #
1087dnl # SLES API change, never adopted in mainline,
1088dnl # Third and sixth 'struct vfsmount *' argument removed.
1089dnl #
1090AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1091 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1092 SPL_LINUX_TRY_COMPILE([
1093 #include <linux/fs.h>
1094 ],[
1095 vfs_rename(NULL, NULL, NULL, NULL);
1096 ],[
1097 AC_MSG_RESULT(yes)
1098 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1099 [vfs_rename() wants 4 args])
1100 ],[
1101 AC_MSG_RESULT(no)
1102 ])
1103])
ec7d53e9
BB
1104
1105dnl #
1106dnl # 2.6.29 API change,
1107dnl # check whether 'struct cred' exists
1108dnl #
1109AC_DEFUN([SPL_AC_CRED_STRUCT], [
1110 AC_MSG_CHECKING([whether struct cred exists])
1111 SPL_LINUX_TRY_COMPILE([
1112 #include <linux/cred.h>
1113 ],[
1114 struct cred *cr;
1115 cr = NULL;
1116 ],[
1117 AC_MSG_RESULT(yes)
1118 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1119 ],[
1120 AC_MSG_RESULT(no)
1121 ])
1122])
1123
1124dnl #
1125dnl # Custom SPL patch may export this symbol
1126dnl #
1127AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1128 SPL_CHECK_SYMBOL_EXPORT(
1129 [groups_search],
1130 [],
1131 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1132 [groups_search() is available])],
1133 [])
1134])