]> git.proxmox.com Git - mirror_spl.git/blob - config/spl-build.m4
Add Debian and Slackware style packaging via alien
[mirror_spl.git] / config / spl-build.m4
1 ###############################################################################
2 # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 # Copyright (C) 2007 The Regents of the University of California.
4 # Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5 ###############################################################################
6 # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration.
7 ###############################################################################
8
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
10 SPL_AC_KERNEL
11
12 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
13 dnl # compiler options are added by the kernel build system.
14 abs_srcdir=`readlink -f ${srcdir}`
15 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
16 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir}/include"
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -include ${abs_srcdir}/spl_config.h"
18
19 if test "${LINUX_OBJ}" != "${LINUX}"; then
20 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
21 fi
22
23 AC_SUBST(KERNELMAKE_PARAMS)
24 AC_SUBST(KERNELCPPFLAGS)
25
26 SPL_AC_DEBUG
27 SPL_AC_DEBUG_KMEM
28 SPL_AC_DEBUG_KMEM_TRACKING
29 SPL_AC_ATOMIC_SPINLOCK
30 SPL_AC_TYPE_ATOMIC64_CMPXCHG
31 SPL_AC_TYPE_ATOMIC64_XCHG
32 SPL_AC_TYPE_UINTPTR_T
33 SPL_AC_3ARGS_INIT_WORK
34 SPL_AC_2ARGS_REGISTER_SYSCTL
35 SPL_AC_SET_SHRINKER
36 SPL_AC_PATH_IN_NAMEIDATA
37 SPL_AC_TASK_CURR
38 SPL_AC_CTL_UNNUMBERED
39 SPL_AC_CTL_NAME
40 SPL_AC_FLS64
41 SPL_AC_DEVICE_CREATE
42 SPL_AC_5ARGS_DEVICE_CREATE
43 SPL_AC_CLASS_DEVICE_CREATE
44 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
45 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
46 SPL_AC_TIMESPEC_SUB
47 SPL_AC_INIT_UTSNAME
48 SPL_AC_FDTABLE_HEADER
49 SPL_AC_FILES_FDTABLE
50 SPL_AC_UACCESS_HEADER
51 SPL_AC_KMALLOC_NODE
52 SPL_AC_MONOTONIC_CLOCK
53 SPL_AC_INODE_I_MUTEX
54 SPL_AC_MUTEX_OWNER
55 SPL_AC_MUTEX_LOCK_NESTED
56 SPL_AC_3ARGS_ON_EACH_CPU
57 SPL_AC_KALLSYMS_LOOKUP_NAME
58 SPL_AC_GET_VMALLOC_INFO
59 SPL_AC_PGDAT_HELPERS
60 SPL_AC_FIRST_ONLINE_PGDAT
61 SPL_AC_NEXT_ONLINE_PGDAT
62 SPL_AC_NEXT_ZONE
63 SPL_AC_PGDAT_LIST
64 SPL_AC_GLOBAL_PAGE_STATE
65 SPL_AC_ZONE_STAT_ITEM_FREE
66 SPL_AC_ZONE_STAT_ITEM_INACTIVE
67 SPL_AC_ZONE_STAT_ITEM_ACTIVE
68 SPL_AC_GET_ZONE_COUNTS
69 SPL_AC_USER_PATH_DIR
70 SPL_AC_SET_FS_PWD
71 SPL_AC_2ARGS_SET_FS_PWD
72 SPL_AC_2ARGS_VFS_UNLINK
73 SPL_AC_4ARGS_VFS_RENAME
74 SPL_AC_CRED_STRUCT
75 SPL_AC_GROUPS_SEARCH
76 SPL_AC_PUT_TASK_STRUCT
77 SPL_AC_5ARGS_PROC_HANDLER
78 SPL_AC_KVASPRINTF
79 SPL_AC_3ARGS_FILE_FSYNC
80 ])
81
82 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
83 modpost=$LINUX/scripts/Makefile.modpost
84 AC_MSG_CHECKING([kernel file name for module symbols])
85 if test -f "$modpost"; then
86 if grep -q Modules.symvers $modpost; then
87 LINUX_SYMBOLS=Modules.symvers
88 else
89 LINUX_SYMBOLS=Module.symvers
90 fi
91 else
92 LINUX_SYMBOLS=NONE
93 fi
94 AC_MSG_RESULT($LINUX_SYMBOLS)
95 AC_SUBST(LINUX_SYMBOLS)
96 ])
97
98 AC_DEFUN([SPL_AC_KERNEL], [
99 AC_ARG_WITH([linux],
100 AS_HELP_STRING([--with-linux=PATH],
101 [Path to kernel source]),
102 [kernelsrc="$withval"])
103
104 AC_ARG_WITH([linux-obj],
105 AS_HELP_STRING([--with-linux-obj=PATH],
106 [Path to kernel build objects]),
107 [kernelbuild="$withval"])
108
109 AC_MSG_CHECKING([kernel source directory])
110 if test -z "$kernelsrc"; then
111 headersdir="/lib/modules/$(uname -r)/build"
112 if test -e "$headersdir"; then
113 sourcelink=$(readlink -f "$headersdir")
114 else
115 sourcelink=$(ls -1d /usr/src/kernels/* \
116 /usr/src/linux-* \
117 2>/dev/null | grep -v obj | tail -1)
118 fi
119
120 if test -n "$sourcelink" && test -e ${sourcelink}; then
121 kernelsrc=`readlink -f ${sourcelink}`
122 else
123 AC_MSG_RESULT([Not found])
124 AC_MSG_ERROR([
125 *** Please make sure the kernel devel package for your distribution
126 *** is installed then try again. If that fails you can specify the
127 *** location of the kernel source with the '--with-linux=PATH' option.])
128 fi
129 else
130 if test "$kernelsrc" = "NONE"; then
131 kernsrcver=NONE
132 fi
133 fi
134
135 AC_MSG_RESULT([$kernelsrc])
136 AC_MSG_CHECKING([kernel build directory])
137 if test -z "$kernelbuild"; then
138 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
139 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
140 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
141 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
142 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
143 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
144 else
145 kernelbuild=${kernelsrc}
146 fi
147 fi
148 AC_MSG_RESULT([$kernelbuild])
149
150 AC_MSG_CHECKING([kernel source version])
151 utsrelease1=$kernelbuild/include/linux/version.h
152 utsrelease2=$kernelbuild/include/linux/utsrelease.h
153 utsrelease3=$kernelbuild/include/generated/utsrelease.h
154 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
155 utsrelease=linux/version.h
156 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
157 utsrelease=linux/utsrelease.h
158 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
159 utsrelease=generated/utsrelease.h
160 fi
161
162 if test "$utsrelease"; then
163 kernsrcver=`(echo "#include <$utsrelease>";
164 echo "kernsrcver=UTS_RELEASE") |
165 cpp -I $kernelbuild/include |
166 grep "^kernsrcver=" | cut -d \" -f 2`
167
168 if test -z "$kernsrcver"; then
169 AC_MSG_RESULT([Not found])
170 AC_MSG_ERROR([*** Cannot determine kernel version.])
171 fi
172 else
173 AC_MSG_RESULT([Not found])
174 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
175 fi
176
177 AC_MSG_RESULT([$kernsrcver])
178
179 LINUX=${kernelsrc}
180 LINUX_OBJ=${kernelbuild}
181 LINUX_VERSION=${kernsrcver}
182
183 AC_SUBST(LINUX)
184 AC_SUBST(LINUX_OBJ)
185 AC_SUBST(LINUX_VERSION)
186
187 SPL_AC_MODULE_SYMVERS
188 ])
189
190 dnl #
191 dnl # Explicitly check for gawk, we require it for the the usermode
192 dnl # helper. For some reason the standard awk command does not
193 dnl # behave correctly when invoked from the usermode helper.
194 dnl #
195 AC_DEFUN([SPL_AC_GAWK], [
196 AS_IF([test "x$AWK" != xgawk], [
197 AC_MSG_ERROR([
198 *** Required util gawk missing. Please install the required
199 *** gawk package for your distribution and try again.])
200 ])
201 ])
202
203 dnl #
204 dnl # Default SPL user configuration
205 dnl #
206 AC_DEFUN([SPL_AC_CONFIG_USER], [
207 SPL_AC_GAWK
208 ])
209
210 dnl #
211 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
212 dnl # are missing it is non-fatal but you will not be able to build
213 dnl # RPM packages and will be warned if you try too.
214 dnl #
215 AC_DEFUN([SPL_AC_RPM], [
216 RPM=rpm
217 RPMBUILD=rpmbuild
218
219 AC_MSG_CHECKING([whether $RPM is available])
220 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
221 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
222 HAVE_RPM=yes
223 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
224 ],[
225 HAVE_RPM=no
226 AC_MSG_RESULT([$HAVE_RPM])
227 ])
228
229 AC_MSG_CHECKING([whether $RPMBUILD is available])
230 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
231 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
232 HAVE_RPMBUILD=yes
233 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
234 ],[
235 HAVE_RPMBUILD=no
236 AC_MSG_RESULT([$HAVE_RPMBUILD])
237 ])
238
239 AC_SUBST(HAVE_RPM)
240 AC_SUBST(RPM)
241 AC_SUBST(RPM_VERSION)
242
243 AC_SUBST(HAVE_RPMBUILD)
244 AC_SUBST(RPMBUILD)
245 AC_SUBST(RPMBUILD_VERSION)
246 ])
247
248 dnl #
249 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
250 dnl # tools are missing it is non-fatal but you will not be able to build
251 dnl # DEB packages and will be warned if you try too.
252 dnl #
253 AC_DEFUN([SPL_AC_DPKG], [
254 DPKG=dpkg
255 DPKGBUILD=dpkg-buildpackage
256
257 AC_MSG_CHECKING([whether $DPKG is available])
258 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
259 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
260 HAVE_DPKG=yes
261 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
262 ],[
263 HAVE_DPKG=no
264 AC_MSG_RESULT([$HAVE_DPKG])
265 ])
266
267 AC_MSG_CHECKING([whether $DPKGBUILD is available])
268 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
269 DPKGBUILD_VERSION=$(echo $tmp | \
270 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
271 HAVE_DPKGBUILD=yes
272 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
273 ],[
274 HAVE_DPKGBUILD=no
275 AC_MSG_RESULT([$HAVE_DPKGBUILD])
276 ])
277
278 AC_SUBST(HAVE_DPKG)
279 AC_SUBST(DPKG)
280 AC_SUBST(DPKG_VERSION)
281
282 AC_SUBST(HAVE_DPKGBUILD)
283 AC_SUBST(DPKGBUILD)
284 AC_SUBST(DPKGBUILD_VERSION)
285 ])
286
287 dnl #
288 dnl # Until native packaging for various different packing systems
289 dnl # can be added the least we can do is attempt to use alien to
290 dnl # convert the RPM packages to the needed package type. This is
291 dnl # a hack but so far it has worked reasonable well.
292 dnl #
293 AC_DEFUN([SPL_AC_ALIEN], [
294 ALIEN=alien
295
296 AC_MSG_CHECKING([whether $ALIEN is available])
297 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
298 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
299 HAVE_ALIEN=yes
300 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
301 ],[
302 HAVE_ALIEN=no
303 AC_MSG_RESULT([$HAVE_ALIEN])
304 ])
305
306 AC_SUBST(HAVE_ALIEN)
307 AC_SUBST(ALIEN)
308 AC_SUBST(ALIEN_VERSION)
309 ])
310
311 dnl #
312 dnl # Using the VENDOR tag from config.guess set the default
313 dnl # package type for 'make pkg': (rpm | deb | tgz)
314 dnl #
315 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
316 VENDOR=$(echo $ac_build_alias | cut -f2 -d'-')
317
318 AC_MSG_CHECKING([default package type])
319 case "$VENDOR" in
320 fedora) DEFAULT_PACKAGE=rpm ;;
321 redhat) DEFAULT_PACKAGE=rpm ;;
322 sles) DEFAULT_PACKAGE=rpm ;;
323 ubuntu) DEFAULT_PACKAGE=deb ;;
324 debian) DEFAULT_PACKAGE=deb ;;
325 slackware) DEFAULT_PACKAGE=tgz ;;
326 *) DEFAULT_PACKAGE=rpm ;;
327 esac
328
329 AC_MSG_RESULT([$DEFAULT_PACKAGE])
330 AC_SUBST(DEFAULT_PACKAGE)
331 ])
332
333 dnl #
334 dnl # Default SPL user configuration
335 dnl #
336 AC_DEFUN([SPL_AC_PACKAGE], [
337 SPL_AC_RPM
338 SPL_AC_DPKG
339 SPL_AC_ALIEN
340 SPL_AC_DEFAULT_PACKAGE
341 ])
342
343 AC_DEFUN([SPL_AC_LICENSE], [
344 AC_MSG_CHECKING([spl license])
345 LICENSE=GPL
346 AC_MSG_RESULT([$LICENSE])
347 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
348 AC_SUBST(LICENSE)
349 ])
350
351 AC_DEFUN([SPL_AC_CONFIG], [
352 SPL_CONFIG=all
353 AC_ARG_WITH([config],
354 AS_HELP_STRING([--with-config=CONFIG],
355 [Config file 'kernel|user|all|srpm']),
356 [SPL_CONFIG="$withval"])
357
358 AC_MSG_CHECKING([spl config])
359 AC_MSG_RESULT([$SPL_CONFIG]);
360 AC_SUBST(SPL_CONFIG)
361
362 case "$SPL_CONFIG" in
363 kernel) SPL_AC_CONFIG_KERNEL ;;
364 user) SPL_AC_CONFIG_USER ;;
365 all) SPL_AC_CONFIG_KERNEL
366 SPL_AC_CONFIG_USER ;;
367 srpm) ;;
368 *)
369 AC_MSG_RESULT([Error!])
370 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
371 user kernel|user|all|srpm]) ;;
372 esac
373
374 AM_CONDITIONAL([CONFIG_USER],
375 [test "$SPL_CONFIG" = user] ||
376 [test "$SPL_CONFIG" = all])
377 AM_CONDITIONAL([CONFIG_KERNEL],
378 [test "$SPL_CONFIG" = kernel] ||
379 [test "$SPL_CONFIG" = all])
380 ])
381
382 dnl #
383 dnl # Enable if the SPL should be compiled with internal debugging enabled.
384 dnl # By default this support is disabled.
385 dnl #
386 AC_DEFUN([SPL_AC_DEBUG], [
387 AC_MSG_CHECKING([whether debugging is enabled])
388 AC_ARG_ENABLE([debug],
389 [AS_HELP_STRING([--enable-debug],
390 [Enable generic debug support @<:@default=no@:>@])],
391 [],
392 [enable_debug=no])
393
394 AS_IF([test "x$enable_debug" = xyes],
395 [
396 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
397 DEBUG_CFLAGS="-DDEBUG -Werror"
398 ],
399 [
400 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
401 DEBUG_CFLAGS="-DNDEBUG"
402 ])
403
404 AC_SUBST(DEBUG_CFLAGS)
405 AC_MSG_RESULT([$enable_debug])
406 ])
407
408 dnl #
409 dnl # Enabled by default it provides a minimal level of memory tracking.
410 dnl # A total count of bytes allocated is kept for each alloc and free.
411 dnl # Then at module unload time a report to the console will be printed
412 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
413 dnl # and provide an easy way to inspect the kmem based slab.
414 dnl #
415 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
416 AC_ARG_ENABLE([debug-kmem],
417 [AS_HELP_STRING([--enable-debug-kmem],
418 [Enable basic kmem accounting @<:@default=yes@:>@])],
419 [],
420 [enable_debug_kmem=yes])
421
422 AS_IF([test "x$enable_debug_kmem" = xyes],
423 [AC_DEFINE([DEBUG_KMEM], [1],
424 [Define to 1 to enable basic kmem accounting])
425 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
426
427 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
428 AC_MSG_RESULT([$enable_debug_kmem])
429 ])
430
431 dnl #
432 dnl # Disabled by default it provides detailed memory tracking. This
433 dnl # feature also requires --enable-debug-kmem to be set. When enabled
434 dnl # not only will total bytes be tracked but also the location of every
435 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
436 dnl # addresses and where they were allocated will be dumped to the console.
437 dnl # Enabling this feature has a significant impact on performance but it
438 dnl # makes finding memory leaks pretty straight forward.
439 dnl #
440 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
441 AC_ARG_ENABLE([debug-kmem-tracking],
442 [AS_HELP_STRING([--enable-debug-kmem-tracking],
443 [Enable detailed kmem tracking @<:@default=no@:>@])],
444 [],
445 [enable_debug_kmem_tracking=no])
446
447 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
448 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
449 [Define to 1 to enable detailed kmem tracking])
450 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
451
452 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
453 AC_MSG_RESULT([$enable_debug_kmem_tracking])
454 ])
455
456 dnl #
457 dnl # SPL_LINUX_CONFTEST
458 dnl #
459 AC_DEFUN([SPL_LINUX_CONFTEST], [
460 cat confdefs.h - <<_ACEOF >conftest.c
461 $1
462 _ACEOF
463 ])
464
465 dnl #
466 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
467 dnl #
468 m4_define([SPL_LANG_PROGRAM], [
469 $1
470 int
471 main (void)
472 {
473 dnl Do *not* indent the following line: there may be CPP directives.
474 dnl Don't move the `;' right after for the same reason.
475 $2
476 ;
477 return 0;
478 }
479 ])
480
481 dnl #
482 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
483 dnl #
484 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
485 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
486 rm -Rf build && mkdir -p build
487 echo "obj-m := conftest.o" >build/Makefile
488 AS_IF(
489 [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])],
490 [$4],
491 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
492 )
493 rm -Rf build
494 ])
495
496 dnl #
497 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
498 dnl #
499 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
500 [SPL_LINUX_COMPILE_IFELSE(
501 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
502 [modules],
503 [test -s build/conftest.o],
504 [$3], [$4])
505 ])
506
507 dnl #
508 dnl # SPL_LINUX_CONFIG
509 dnl #
510 AC_DEFUN([SPL_LINUX_CONFIG],
511 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
512 SPL_LINUX_TRY_COMPILE([
513 #ifndef AUTOCONF_INCLUDED
514 #include <linux/config.h>
515 #endif
516 ],[
517 #ifndef CONFIG_$1
518 #error CONFIG_$1 not #defined
519 #endif
520 ],[
521 AC_MSG_RESULT([yes])
522 $2
523 ],[
524 AC_MSG_RESULT([no])
525 $3
526 ])
527 ])
528
529 dnl #
530 dnl # SPL_CHECK_SYMBOL_EXPORT
531 dnl # check symbol exported or not
532 dnl #
533 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
534 [AC_MSG_CHECKING([whether symbol $1 is exported])
535 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
536 $LINUX_OBJ/Module*.symvers 2>/dev/null
537 rc=$?
538 if test $rc -ne 0; then
539 export=0
540 for file in $2; do
541 grep -q -E "EXPORT_SYMBOL.*($1)" \
542 "$LINUX_OBJ/$file" 2>/dev/null
543 rc=$?
544 if test $rc -eq 0; then
545 export=1
546 break;
547 fi
548 done
549 if test $export -eq 0; then
550 AC_MSG_RESULT([no])
551 $4
552 else
553 AC_MSG_RESULT([yes])
554 $3
555 fi
556 else
557 AC_MSG_RESULT([yes])
558 $3
559 fi
560 ])
561
562 dnl #
563 dnl # SPL_CHECK_HEADER
564 dnl # check whether header exists and define HAVE_$2_HEADER
565 dnl #
566 AC_DEFUN([SPL_CHECK_HEADER],
567 [AC_MSG_CHECKING([whether header $1 exists])
568 SPL_LINUX_TRY_COMPILE([
569 #include <$1>
570 ],[
571 return 0;
572 ],[
573 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
574 AC_MSG_RESULT(yes)
575 $3
576 ],[
577 AC_MSG_RESULT(no)
578 $4
579 ])
580 ])
581
582 dnl #
583 dnl # Use the atomic implemenation based on global spinlocks. This
584 dnl # should only be needed by 32-bit kernels which do not provide
585 dnl # the atomic64_* API. It may be optionally enabled as a fallback
586 dnl # if problems are observed with the direct mapping to the native
587 dnl # Linux atomic operations. You may not disable atomic spinlocks
588 dnl # if you kernel does not an atomic64_* API.
589 dnl #
590 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
591 AC_ARG_ENABLE([atomic-spinlocks],
592 [AS_HELP_STRING([--enable-atomic-spinlocks],
593 [Atomic types use spinlocks @<:@default=check@:>@])],
594 [],
595 [enable_atomic_spinlocks=check])
596
597 SPL_LINUX_TRY_COMPILE([
598 #include <asm/atomic.h>
599 ],[
600 atomic64_t *ptr;
601 ],[
602 have_atomic64_t=yes
603 AC_DEFINE(HAVE_ATOMIC64_T, 1,
604 [kernel defines atomic64_t])
605 ],[
606 have_atomic64_t=no
607 ])
608
609 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
610 AS_IF([test "x$have_atomic64_t" = xyes], [
611 enable_atomic_spinlocks=no
612 ],[
613 enable_atomic_spinlocks=yes
614 ])
615 ])
616
617 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
618 AC_DEFINE([ATOMIC_SPINLOCK], [1],
619 [Atomic types use spinlocks])
620 ],[
621 AS_IF([test "x$have_atomic64_t" = xno], [
622 AC_MSG_FAILURE(
623 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
624 ])
625 ])
626
627 AC_MSG_CHECKING([whether atomic types use spinlocks])
628 AC_MSG_RESULT([$enable_atomic_spinlocks])
629
630 AC_MSG_CHECKING([whether kernel defines atomic64_t])
631 AC_MSG_RESULT([$have_atomic64_t])
632 ])
633
634 dnl #
635 dnl # 2.6.24 API change,
636 dnl # check if atomic64_cmpxchg is defined
637 dnl #
638 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
639 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
640 SPL_LINUX_TRY_COMPILE([
641 #include <asm/atomic.h>
642 ],[
643 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
644 ],[
645 AC_MSG_RESULT([yes])
646 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
647 [kernel defines atomic64_cmpxchg])
648 ],[
649 AC_MSG_RESULT([no])
650 ])
651 ])
652
653 dnl #
654 dnl # 2.6.24 API change,
655 dnl # check if atomic64_xchg is defined
656 dnl #
657 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
658 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
659 SPL_LINUX_TRY_COMPILE([
660 #include <asm/atomic.h>
661 ],[
662 atomic64_xchg((atomic64_t *)NULL, 0);
663 ],[
664 AC_MSG_RESULT([yes])
665 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
666 [kernel defines atomic64_xchg])
667 ],[
668 AC_MSG_RESULT([no])
669 ])
670 ])
671
672 dnl #
673 dnl # 2.6.24 API change,
674 dnl # check if uintptr_t typedef is defined
675 dnl #
676 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
677 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
678 SPL_LINUX_TRY_COMPILE([
679 #include <linux/types.h>
680 ],[
681 uintptr_t *ptr;
682 ],[
683 AC_MSG_RESULT([yes])
684 AC_DEFINE(HAVE_UINTPTR_T, 1,
685 [kernel defines uintptr_t])
686 ],[
687 AC_MSG_RESULT([no])
688 ])
689 ])
690
691 dnl #
692 dnl # 2.6.20 API change,
693 dnl # INIT_WORK use 2 args and not store data inside
694 dnl #
695 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
696 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
697 SPL_LINUX_TRY_COMPILE([
698 #include <linux/workqueue.h>
699 ],[
700 struct work_struct work;
701 INIT_WORK(&work, NULL, NULL);
702 ],[
703 AC_MSG_RESULT(yes)
704 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
705 [INIT_WORK wants 3 args])
706 ],[
707 AC_MSG_RESULT(no)
708 ])
709 ])
710
711 dnl #
712 dnl # 2.6.21 API change,
713 dnl # 'register_sysctl_table' use only one argument instead of two
714 dnl #
715 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
716 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
717 SPL_LINUX_TRY_COMPILE([
718 #include <linux/sysctl.h>
719 ],[
720 return register_sysctl_table(NULL,0);
721 ],[
722 AC_MSG_RESULT(yes)
723 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
724 [register_sysctl_table() wants 2 args])
725 ],[
726 AC_MSG_RESULT(no)
727 ])
728 ])
729
730 dnl #
731 dnl # 2.6.23 API change
732 dnl # Old set_shrinker API replaced with register_shrinker
733 dnl #
734 AC_DEFUN([SPL_AC_SET_SHRINKER], [
735 AC_MSG_CHECKING([whether set_shrinker() available])
736 SPL_LINUX_TRY_COMPILE([
737 #include <linux/mm.h>
738 ],[
739 return set_shrinker(DEFAULT_SEEKS, NULL);
740 ],[
741 AC_MSG_RESULT([yes])
742 AC_DEFINE(HAVE_SET_SHRINKER, 1,
743 [set_shrinker() available])
744 ],[
745 AC_MSG_RESULT([no])
746 ])
747 ])
748
749 dnl #
750 dnl # 2.6.25 API change,
751 dnl # struct path entry added to struct nameidata
752 dnl #
753 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
754 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
755 SPL_LINUX_TRY_COMPILE([
756 #include <linux/namei.h>
757 ],[
758 struct nameidata nd;
759
760 nd.path.mnt = NULL;
761 nd.path.dentry = NULL;
762 ],[
763 AC_MSG_RESULT(yes)
764 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
765 [struct path used in struct nameidata])
766 ],[
767 AC_MSG_RESULT(no)
768 ])
769 ])
770
771 dnl #
772 dnl # Custom SPL patch may export this system it is not required
773 dnl #
774 AC_DEFUN([SPL_AC_TASK_CURR], [
775 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
776 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
777 [])
778 ])
779
780 dnl #
781 dnl # 2.6.19 API change,
782 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
783 dnl #
784 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
785 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
786 SPL_LINUX_TRY_COMPILE([
787 #include <linux/sysctl.h>
788 ],[
789 #ifndef CTL_UNNUMBERED
790 #error CTL_UNNUMBERED undefined
791 #endif
792 ],[
793 AC_MSG_RESULT(yes)
794 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
795 [unnumbered sysctl support exists])
796 ],[
797 AC_MSG_RESULT(no)
798 ])
799 ])
800
801 dnl #
802 dnl # 2.6.33 API change,
803 dnl # Removed .ctl_name from struct ctl_table.
804 dnl #
805 AC_DEFUN([SPL_AC_CTL_NAME], [
806 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
807 SPL_LINUX_TRY_COMPILE([
808 #include <linux/sysctl.h>
809 ],[
810 struct ctl_table ctl;
811 ctl.ctl_name = 0;
812 ],[
813 AC_MSG_RESULT(yes)
814 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
815 ],[
816 AC_MSG_RESULT(no)
817 ])
818 ])
819
820 dnl #
821 dnl # 2.6.16 API change.
822 dnl # Check if 'fls64()' is available
823 dnl #
824 AC_DEFUN([SPL_AC_FLS64],
825 [AC_MSG_CHECKING([whether fls64() is available])
826 SPL_LINUX_TRY_COMPILE([
827 #include <linux/bitops.h>
828 ],[
829 return fls64(0);
830 ],[
831 AC_MSG_RESULT(yes)
832 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
833 ],[
834 AC_MSG_RESULT(no)
835 ])
836 ])
837
838 dnl #
839 dnl # 2.6.18 API change, check whether device_create() is available.
840 dnl # Device_create() was introduced in 2.6.18 and depricated
841 dnl # class_device_create() which was fully removed in 2.6.26.
842 dnl #
843 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
844 SPL_CHECK_SYMBOL_EXPORT(
845 [device_create],
846 [drivers/base/core.c],
847 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
848 [device_create() is available])],
849 [])
850 ])
851
852 dnl #
853 dnl # 2.6.27 API change,
854 dnl # device_create() uses 5 args, new 'drvdata' argument.
855 dnl #
856 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
857 AC_MSG_CHECKING([whether device_create() wants 5 args])
858 tmp_flags="$EXTRA_KCFLAGS"
859 EXTRA_KCFLAGS="-Werror"
860 SPL_LINUX_TRY_COMPILE([
861 #include <linux/device.h>
862 ],[
863 device_create(NULL, NULL, 0, NULL, "%d", 1);
864 ],[
865 AC_MSG_RESULT(yes)
866 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
867 [device_create wants 5 args])
868 ],[
869 AC_MSG_RESULT(no)
870 ])
871 EXTRA_KCFLAGS="$tmp_flags"
872 ])
873
874 dnl #
875 dnl # 2.6.13 API change, check whether class_device_create() is available.
876 dnl # Class_device_create() was introduced in 2.6.13 and depricated
877 dnl # class_simple_device_add() which was fully removed in 2.6.13.
878 dnl #
879 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
880 SPL_CHECK_SYMBOL_EXPORT(
881 [class_device_create],
882 [drivers/base/class.c],
883 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
884 [class_device_create() is available])],
885 [])
886 ])
887
888 dnl #
889 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
890 dnl #
891 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
892 SPL_CHECK_SYMBOL_EXPORT(
893 [set_normalized_timespec],
894 [kernel/time.c],
895 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
896 [set_normalized_timespec() is available as export])],
897 [])
898 ])
899
900 dnl #
901 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
902 dnl # previously it was available in time.h as an inline.
903 dnl #
904 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
905 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
906 SPL_LINUX_TRY_COMPILE([
907 #include <linux/time.h>
908 void set_normalized_timespec(struct timespec *ts,
909 time_t sec, long nsec) { }
910 ],
911 [],
912 [
913 AC_MSG_RESULT(no)
914 ],[
915 AC_MSG_RESULT(yes)
916 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
917 [set_normalized_timespec() is available as inline])
918 ])
919 ])
920
921 dnl #
922 dnl # 2.6.18 API change,
923 dnl # timespec_sub() inline function available in linux/time.h
924 dnl #
925 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
926 AC_MSG_CHECKING([whether timespec_sub() is available])
927 SPL_LINUX_TRY_COMPILE([
928 #include <linux/time.h>
929 ],[
930 struct timespec a, b, c = { 0 };
931 c = timespec_sub(a, b);
932 ],[
933 AC_MSG_RESULT(yes)
934 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
935 ],[
936 AC_MSG_RESULT(no)
937 ])
938 ])
939
940 dnl #
941 dnl # 2.6.19 API change,
942 dnl # check if init_utsname() is available in linux/utsname.h
943 dnl #
944 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
945 AC_MSG_CHECKING([whether init_utsname() is available])
946 SPL_LINUX_TRY_COMPILE([
947 #include <linux/utsname.h>
948 ],[
949 struct new_utsname *a = init_utsname();
950 ],[
951 AC_MSG_RESULT(yes)
952 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
953 ],[
954 AC_MSG_RESULT(no)
955 ])
956 ])
957
958 dnl #
959 dnl # 2.6.26 API change,
960 dnl # definition of struct fdtable relocated to linux/fdtable.h
961 dnl #
962 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
963 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
964 ])
965
966 dnl #
967 dnl # 2.6.14 API change,
968 dnl # check whether 'files_fdtable()' exists
969 dnl #
970 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
971 AC_MSG_CHECKING([whether files_fdtable() is available])
972 SPL_LINUX_TRY_COMPILE([
973 #include <linux/sched.h>
974 #include <linux/file.h>
975 #ifdef HAVE_FDTABLE_HEADER
976 #include <linux/fdtable.h>
977 #endif
978 ],[
979 struct files_struct *files = current->files;
980 struct fdtable *fdt = files_fdtable(files);
981 ],[
982 AC_MSG_RESULT(yes)
983 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
984 ],[
985 AC_MSG_RESULT(no)
986 ])
987 ])
988
989 dnl #
990 dnl # 2.6.18 API change,
991 dnl # added linux/uaccess.h
992 dnl #
993 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
994 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
995 ])
996
997 dnl #
998 dnl # 2.6.12 API change,
999 dnl # check whether 'kmalloc_node()' is available.
1000 dnl #
1001 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1002 AC_MSG_CHECKING([whether kmalloc_node() is available])
1003 SPL_LINUX_TRY_COMPILE([
1004 #include <linux/slab.h>
1005 ],[
1006 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1007 ],[
1008 AC_MSG_RESULT(yes)
1009 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1010 ],[
1011 AC_MSG_RESULT(no)
1012 ])
1013 ])
1014
1015 dnl #
1016 dnl # 2.6.9 API change,
1017 dnl # check whether 'monotonic_clock()' is available it may
1018 dnl # be available for some archs but not others.
1019 dnl #
1020 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1021 SPL_CHECK_SYMBOL_EXPORT(
1022 [monotonic_clock],
1023 [],
1024 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1025 [monotonic_clock() is available])],
1026 [])
1027 ])
1028
1029 dnl #
1030 dnl # 2.6.16 API change,
1031 dnl # check whether 'struct inode' has i_mutex
1032 dnl #
1033 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1034 AC_MSG_CHECKING([whether struct inode has i_mutex])
1035 SPL_LINUX_TRY_COMPILE([
1036 #include <linux/fs.h>
1037 #include <linux/mutex.h>
1038 ],[
1039 struct inode i;
1040 mutex_init(&i.i_mutex);
1041 ],[
1042 AC_MSG_RESULT(yes)
1043 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1044 ],[
1045 AC_MSG_RESULT(no)
1046 ])
1047 ])
1048
1049 dnl #
1050 dnl # 2.6.29 API change,
1051 dnl # Adaptive mutexs introduced.
1052 dnl #
1053 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1054 AC_MSG_CHECKING([whether struct mutex has owner])
1055 SPL_LINUX_TRY_COMPILE([
1056 #include <linux/mutex.h>
1057 ],[
1058 struct mutex mtx;
1059 mtx.owner = NULL;
1060 ],[
1061 AC_MSG_RESULT(yes)
1062 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1063 ],[
1064 AC_MSG_RESULT(no)
1065 ])
1066 ])
1067
1068 dnl #
1069 dnl # 2.6.18 API change,
1070 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1071 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1072 dnl # if the mutex validator is disabled or otherwise unavailable.
1073 dnl #
1074 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1075 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1076 SPL_LINUX_TRY_COMPILE([
1077 #include <linux/mutex.h>
1078 ],[
1079 struct mutex mutex;
1080 mutex_init(&mutex);
1081 mutex_lock_nested(&mutex, 0);
1082 ],[
1083 AC_MSG_RESULT(yes)
1084 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1085 [mutex_lock_nested() is available])
1086 ],[
1087 AC_MSG_RESULT(no)
1088 ])
1089 ])
1090
1091 dnl #
1092 dnl # 2.6.27 API change,
1093 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1094 dnl #
1095 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1096 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1097 SPL_LINUX_TRY_COMPILE([
1098 #include <linux/smp.h>
1099 ],[
1100 on_each_cpu(NULL, NULL, 0);
1101 ],[
1102 AC_MSG_RESULT(yes)
1103 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1104 [on_each_cpu wants 3 args])
1105 ],[
1106 AC_MSG_RESULT(no)
1107 ])
1108 ])
1109
1110 dnl #
1111 dnl # 2.6.18 API change,
1112 dnl # kallsyms_lookup_name no longer exported
1113 dnl #
1114 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1115 SPL_CHECK_SYMBOL_EXPORT(
1116 [kallsyms_lookup_name],
1117 [],
1118 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1119 [kallsyms_lookup_name() is available])],
1120 [])
1121 ])
1122
1123 dnl #
1124 dnl # Proposed API change,
1125 dnl # This symbol is not available in stock kernels. You may build a
1126 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1127 dnl # these symbols for use. If your already rolling a custom kernel for
1128 dnl # your environment this is recommended.
1129 dnl #
1130 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1131 SPL_CHECK_SYMBOL_EXPORT(
1132 [get_vmalloc_info],
1133 [],
1134 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1135 [get_vmalloc_info() is available])],
1136 [])
1137 ])
1138
1139 dnl #
1140 dnl # 2.6.17 API change
1141 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1142 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1143 dnl # were exported in 2.6.17 for use by modules which was consistent with
1144 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1145 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1146 dnl # were dropped entirely leaving modules no way to directly iterate over
1147 dnl # the zone list. Because we need access to the zone helpers we check
1148 dnl # if the kernel contains the old or new implementation. Then we check
1149 dnl # to see if the symbols we need for each version are available. If they
1150 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1151 dnl #
1152 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1153 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1154 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1155 rc=$?
1156 if test $rc -eq 0; then
1157 AC_MSG_RESULT([yes])
1158 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1159 else
1160 AC_MSG_RESULT([no])
1161 fi
1162 ])
1163
1164 dnl #
1165 dnl # Proposed API change,
1166 dnl # This symbol is not available in stock kernels. You may build a
1167 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1168 dnl # these symbols for use. If your already rolling a custom kernel for
1169 dnl # your environment this is recommended.
1170 dnl #
1171 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1172 SPL_CHECK_SYMBOL_EXPORT(
1173 [first_online_pgdat],
1174 [],
1175 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1176 [first_online_pgdat() is available])],
1177 [])
1178 ])
1179
1180 dnl #
1181 dnl # Proposed API change,
1182 dnl # This symbol is not available in stock kernels. You may build a
1183 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1184 dnl # these symbols for use. If your already rolling a custom kernel for
1185 dnl # your environment this is recommended.
1186 dnl #
1187 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1188 SPL_CHECK_SYMBOL_EXPORT(
1189 [next_online_pgdat],
1190 [],
1191 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1192 [next_online_pgdat() is available])],
1193 [])
1194 ])
1195
1196 dnl #
1197 dnl # Proposed API change,
1198 dnl # This symbol is not available in stock kernels. You may build a
1199 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1200 dnl # these symbols for use. If your already rolling a custom kernel for
1201 dnl # your environment this is recommended.
1202 dnl #
1203 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1204 SPL_CHECK_SYMBOL_EXPORT(
1205 [next_zone],
1206 [],
1207 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1208 [next_zone() is available])],
1209 [])
1210 ])
1211
1212 dnl #
1213 dnl # 2.6.17 API change,
1214 dnl # See SPL_AC_PGDAT_HELPERS for details.
1215 dnl #
1216 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1217 SPL_CHECK_SYMBOL_EXPORT(
1218 [pgdat_list],
1219 [],
1220 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1221 [pgdat_list is available])],
1222 [])
1223 ])
1224
1225 dnl #
1226 dnl # 2.6.18 API change,
1227 dnl # First introduced global_page_state() support as an inline.
1228 dnl #
1229 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1230 AC_MSG_CHECKING([whether global_page_state() is available])
1231 SPL_LINUX_TRY_COMPILE([
1232 #include <linux/mm.h>
1233 ],[
1234 unsigned long state;
1235 state = global_page_state(0);
1236 ],[
1237 AC_MSG_RESULT(yes)
1238 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1239 [global_page_state() is available])
1240 ],[
1241 AC_MSG_RESULT(no)
1242 ])
1243 ])
1244
1245 dnl #
1246 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1247 dnl # Public global zone stats now include a free page count. However
1248 dnl # the enumerated names of the counters have changed since this API
1249 dnl # was introduced. We need to deduce the corrent name to use. This
1250 dnl # replaces the priviate get_zone_counts() interface.
1251 dnl #
1252 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1253 dnl # is 2.6.30 as of when this was written.
1254 dnl #
1255 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1256 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1257 SPL_LINUX_TRY_COMPILE([
1258 #include <linux/mm.h>
1259 ],[
1260 enum zone_stat_item zsi;
1261 zsi = NR_FREE_PAGES;
1262 ],[
1263 AC_MSG_RESULT(yes)
1264 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1265 [Page state NR_FREE_PAGES is available])
1266 ],[
1267 AC_MSG_RESULT(no)
1268 ])
1269 ])
1270
1271 dnl #
1272 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1273 dnl # Public global zone stats now include an inactive page count. However
1274 dnl # the enumerated names of the counters have changed since this API
1275 dnl # was introduced. We need to deduce the corrent name to use. This
1276 dnl # replaces the priviate get_zone_counts() interface.
1277 dnl #
1278 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1279 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1280 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1281 dnl #
1282 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1283 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1284 SPL_LINUX_TRY_COMPILE([
1285 #include <linux/mm.h>
1286 ],[
1287 enum zone_stat_item zsi;
1288 zsi = NR_INACTIVE;
1289 ],[
1290 AC_MSG_RESULT(yes)
1291 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1292 [Page state NR_INACTIVE is available])
1293 ],[
1294 AC_MSG_RESULT(no)
1295 ])
1296
1297 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1298 SPL_LINUX_TRY_COMPILE([
1299 #include <linux/mm.h>
1300 ],[
1301 enum zone_stat_item zsi;
1302 zsi = NR_INACTIVE_ANON;
1303 ],[
1304 AC_MSG_RESULT(yes)
1305 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1306 [Page state NR_INACTIVE_ANON is available])
1307 ],[
1308 AC_MSG_RESULT(no)
1309 ])
1310
1311 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1312 SPL_LINUX_TRY_COMPILE([
1313 #include <linux/mm.h>
1314 ],[
1315 enum zone_stat_item zsi;
1316 zsi = NR_INACTIVE_FILE;
1317 ],[
1318 AC_MSG_RESULT(yes)
1319 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1320 [Page state NR_INACTIVE_FILE is available])
1321 ],[
1322 AC_MSG_RESULT(no)
1323 ])
1324 ])
1325
1326 dnl #
1327 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1328 dnl # Public global zone stats now include an active page count. However
1329 dnl # the enumerated names of the counters have changed since this API
1330 dnl # was introduced. We need to deduce the corrent name to use. This
1331 dnl # replaces the priviate get_zone_counts() interface.
1332 dnl #
1333 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1334 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1335 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1336 dnl #
1337 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1338 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1339 SPL_LINUX_TRY_COMPILE([
1340 #include <linux/mm.h>
1341 ],[
1342 enum zone_stat_item zsi;
1343 zsi = NR_ACTIVE;
1344 ],[
1345 AC_MSG_RESULT(yes)
1346 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1347 [Page state NR_ACTIVE is available])
1348 ],[
1349 AC_MSG_RESULT(no)
1350 ])
1351
1352 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1353 SPL_LINUX_TRY_COMPILE([
1354 #include <linux/mm.h>
1355 ],[
1356 enum zone_stat_item zsi;
1357 zsi = NR_ACTIVE_ANON;
1358 ],[
1359 AC_MSG_RESULT(yes)
1360 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1361 [Page state NR_ACTIVE_ANON is available])
1362 ],[
1363 AC_MSG_RESULT(no)
1364 ])
1365
1366 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1367 SPL_LINUX_TRY_COMPILE([
1368 #include <linux/mm.h>
1369 ],[
1370 enum zone_stat_item zsi;
1371 zsi = NR_ACTIVE_FILE;
1372 ],[
1373 AC_MSG_RESULT(yes)
1374 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1375 [Page state NR_ACTIVE_FILE is available])
1376 ],[
1377 AC_MSG_RESULT(no)
1378 ])
1379 ])
1380
1381 dnl #
1382 dnl # Proposed API change for legacy kernels.
1383 dnl # This symbol is not available in older kernels. For kernels post
1384 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1385 dnl # page state information. This symbol is only used in legacy kernels
1386 dnl # any only as a last resort.
1387 dnl
1388 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1389 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1390 SPL_LINUX_TRY_COMPILE([
1391 ],[
1392 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1393 #error "global_page_state needs NR_FREE_PAGES"
1394 #endif
1395
1396 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1397 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1398 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1399 #error "global_page_state needs NR_ACTIVE*"
1400 #endif
1401
1402 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1403 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1404 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1405 #error "global_page_state needs NR_INACTIVE*"
1406 #endif
1407 ],[
1408 AC_MSG_RESULT(no)
1409 ],[
1410 AC_MSG_RESULT(yes)
1411 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1412 [get_zone_counts() is needed])
1413
1414 SPL_CHECK_SYMBOL_EXPORT(
1415 [get_zone_counts],
1416 [],
1417 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1418 [get_zone_counts() is available])],
1419 [])
1420 ])
1421 ])
1422
1423 dnl #
1424 dnl # 2.6.27 API change,
1425 dnl # The user_path_dir() replaces __user_walk()
1426 dnl #
1427 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1428 SPL_CHECK_SYMBOL_EXPORT(
1429 [user_path_at],
1430 [],
1431 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1432 [user_path_dir() is available])],
1433 [])
1434 ])
1435
1436 dnl #
1437 dnl # Symbol available in RHEL kernels not in stock kernels.
1438 dnl #
1439 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1440 SPL_CHECK_SYMBOL_EXPORT(
1441 [set_fs_pwd],
1442 [],
1443 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1444 [set_fs_pwd() is available])],
1445 [])
1446 ])
1447
1448 dnl #
1449 dnl # 2.6.25 API change,
1450 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1451 dnl #
1452 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1453 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1454 SPL_LINUX_TRY_COMPILE([
1455 #include <linux/sched.h>
1456 #include <linux/fs_struct.h>
1457 ],[
1458 set_fs_pwd(NULL, NULL);
1459 ],[
1460 AC_MSG_RESULT(yes)
1461 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1462 [set_fs_pwd() wants 2 args])
1463 ],[
1464 AC_MSG_RESULT(no)
1465 ])
1466 ])
1467
1468 dnl #
1469 dnl # SLES API change, never adopted in mainline,
1470 dnl # Third 'struct vfsmount *' argument removed.
1471 dnl #
1472 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1473 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1474 SPL_LINUX_TRY_COMPILE([
1475 #include <linux/fs.h>
1476 ],[
1477 vfs_unlink(NULL, NULL);
1478 ],[
1479 AC_MSG_RESULT(yes)
1480 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1481 [vfs_unlink() wants 2 args])
1482 ],[
1483 AC_MSG_RESULT(no)
1484 ])
1485 ])
1486
1487 dnl #
1488 dnl # SLES API change, never adopted in mainline,
1489 dnl # Third and sixth 'struct vfsmount *' argument removed.
1490 dnl #
1491 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1492 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1493 SPL_LINUX_TRY_COMPILE([
1494 #include <linux/fs.h>
1495 ],[
1496 vfs_rename(NULL, NULL, NULL, NULL);
1497 ],[
1498 AC_MSG_RESULT(yes)
1499 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1500 [vfs_rename() wants 4 args])
1501 ],[
1502 AC_MSG_RESULT(no)
1503 ])
1504 ])
1505
1506 dnl #
1507 dnl # 2.6.29 API change,
1508 dnl # check whether 'struct cred' exists
1509 dnl #
1510 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1511 AC_MSG_CHECKING([whether struct cred exists])
1512 SPL_LINUX_TRY_COMPILE([
1513 #include <linux/cred.h>
1514 ],[
1515 struct cred *cr;
1516 cr = NULL;
1517 ],[
1518 AC_MSG_RESULT(yes)
1519 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1520 ],[
1521 AC_MSG_RESULT(no)
1522 ])
1523 ])
1524
1525 dnl #
1526 dnl # Custom SPL patch may export this symbol.
1527 dnl #
1528 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1529 SPL_CHECK_SYMBOL_EXPORT(
1530 [groups_search],
1531 [],
1532 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1533 [groups_search() is available])],
1534 [])
1535 ])
1536
1537 dnl #
1538 dnl # 2.6.x API change,
1539 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1540 dnl #
1541 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1542 SPL_CHECK_SYMBOL_EXPORT(
1543 [__put_task_struct],
1544 [],
1545 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1546 [__put_task_struct() is available])],
1547 [])
1548 ])
1549
1550 dnl #
1551 dnl # 2.6.32 API change,
1552 dnl # Unused 'struct file *' removed from prototype.
1553 dnl #
1554 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1555 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1556 SPL_LINUX_TRY_COMPILE([
1557 #include <linux/sysctl.h>
1558 ],[
1559 proc_dostring(NULL, 0, NULL, NULL, NULL);
1560 ],[
1561 AC_MSG_RESULT(yes)
1562 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1563 [proc_handler() wants 5 args])
1564 ],[
1565 AC_MSG_RESULT(no)
1566 ])
1567 ])
1568
1569 dnl #
1570 dnl # 2.6.x API change,
1571 dnl # kvasprintf() function added.
1572 dnl #
1573 AC_DEFUN([SPL_AC_KVASPRINTF], [
1574 SPL_CHECK_SYMBOL_EXPORT(
1575 [kvasprintf],
1576 [],
1577 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1578 [kvasprintf() is available])],
1579 [])
1580 ])
1581
1582 dnl #
1583 dnl # 2.6.35 API change,
1584 dnl # Unused 'struct dentry *' removed from prototype.
1585 dnl #
1586 AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1587 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1588 SPL_LINUX_TRY_COMPILE([
1589 #include <linux/buffer_head.h>
1590 ],[
1591 file_fsync(NULL, NULL, 0);
1592 ],[
1593 AC_MSG_RESULT(yes)
1594 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1595 [file_fsync() wants 3 args])
1596 ],[
1597 AC_MSG_RESULT(no)
1598 ])
1599 ])