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