]> git.proxmox.com Git - mirror_spl-debian.git/blob - config/spl-build.m4
Imported Upstream version 0.6.5.4
[mirror_spl-debian.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 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
14 fi
15 AC_SUBST(KERNELMAKE_PARAMS)
16
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
19
20 SPL_AC_DEBUG
21 SPL_AC_DEBUG_KMEM
22 SPL_AC_DEBUG_KMEM_TRACKING
23 SPL_AC_TEST_MODULE
24 SPL_AC_ATOMIC_SPINLOCK
25 SPL_AC_SHRINKER_CALLBACK
26 SPL_AC_CTL_NAME
27 SPL_AC_PDE_DATA
28 SPL_AC_SET_FS_PWD_WITH_CONST
29 SPL_AC_2ARGS_VFS_UNLINK
30 SPL_AC_4ARGS_VFS_RENAME
31 SPL_AC_2ARGS_VFS_FSYNC
32 SPL_AC_INODE_TRUNCATE_RANGE
33 SPL_AC_FS_STRUCT_SPINLOCK
34 SPL_AC_KUIDGID_T
35 SPL_AC_PUT_TASK_STRUCT
36 SPL_AC_KERNEL_FALLOCATE
37 SPL_AC_CONFIG_ZLIB_INFLATE
38 SPL_AC_CONFIG_ZLIB_DEFLATE
39 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
40 SPL_AC_SHRINK_CONTROL_STRUCT
41 SPL_AC_RWSEM_SPINLOCK_IS_RAW
42 SPL_AC_SCHED_RT_HEADER
43 SPL_AC_2ARGS_VFS_GETATTR
44 SPL_AC_USLEEP_RANGE
45 SPL_AC_KMEM_CACHE_ALLOCFLAGS
46 SPL_AC_WAIT_ON_BIT
47 ])
48
49 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
50 modpost=$LINUX/scripts/Makefile.modpost
51 AC_MSG_CHECKING([kernel file name for module symbols])
52 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
53 if grep -q Modules.symvers $modpost; then
54 LINUX_SYMBOLS=Modules.symvers
55 else
56 LINUX_SYMBOLS=Module.symvers
57 fi
58
59 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
60 AC_MSG_ERROR([
61 *** Please make sure the kernel devel package for your distribution
62 *** is installed. If you are building with a custom kernel, make sure the
63 *** kernel is configured, built, and the '--with-linux=PATH' configure
64 *** option refers to the location of the kernel source.])
65 fi
66 else
67 LINUX_SYMBOLS=NONE
68 fi
69 AC_MSG_RESULT($LINUX_SYMBOLS)
70 AC_SUBST(LINUX_SYMBOLS)
71 ])
72
73 AC_DEFUN([SPL_AC_KERNEL], [
74 AC_ARG_WITH([linux],
75 AS_HELP_STRING([--with-linux=PATH],
76 [Path to kernel source]),
77 [kernelsrc="$withval"])
78
79 AC_ARG_WITH([linux-obj],
80 AS_HELP_STRING([--with-linux-obj=PATH],
81 [Path to kernel build objects]),
82 [kernelbuild="$withval"])
83
84 AC_MSG_CHECKING([kernel source directory])
85 if test -z "$kernelsrc"; then
86 if test -e "/lib/modules/$(uname -r)/source"; then
87 headersdir="/lib/modules/$(uname -r)/source"
88 sourcelink=$(readlink -f "$headersdir")
89 elif test -e "/lib/modules/$(uname -r)/build"; then
90 headersdir="/lib/modules/$(uname -r)/build"
91 sourcelink=$(readlink -f "$headersdir")
92 else
93 sourcelink=$(ls -1d /usr/src/kernels/* \
94 /usr/src/linux-* \
95 2>/dev/null | grep -v obj | tail -1)
96 fi
97
98 if test -n "$sourcelink" && test -e ${sourcelink}; then
99 kernelsrc=`readlink -f ${sourcelink}`
100 else
101 kernelsrc="[Not found]"
102 fi
103 else
104 if test "$kernelsrc" = "NONE"; then
105 kernsrcver=NONE
106 fi
107 fi
108
109 AC_MSG_RESULT([$kernelsrc])
110 if test ! -d "$kernelsrc"; then
111 AC_MSG_ERROR([
112 *** Please make sure the kernel devel package for your distribution
113 *** is installed and then try again. If that fails, you can specify the
114 *** location of the kernel source with the '--with-linux=PATH' option.])
115 fi
116
117 AC_MSG_CHECKING([kernel build directory])
118 if test -z "$kernelbuild"; then
119 if test -e "/lib/modules/$(uname -r)/build"; then
120 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
121 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
122 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
123 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
124 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
125 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
126 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
127 else
128 kernelbuild=${kernelsrc}
129 fi
130 fi
131 AC_MSG_RESULT([$kernelbuild])
132
133 AC_MSG_CHECKING([kernel source version])
134 utsrelease1=$kernelbuild/include/linux/version.h
135 utsrelease2=$kernelbuild/include/linux/utsrelease.h
136 utsrelease3=$kernelbuild/include/generated/utsrelease.h
137 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
138 utsrelease=linux/version.h
139 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
140 utsrelease=linux/utsrelease.h
141 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
142 utsrelease=generated/utsrelease.h
143 fi
144
145 if test "$utsrelease"; then
146 kernsrcver=`(echo "#include <$utsrelease>";
147 echo "kernsrcver=UTS_RELEASE") |
148 cpp -I $kernelbuild/include |
149 grep "^kernsrcver=" | cut -d \" -f 2`
150
151 if test -z "$kernsrcver"; then
152 AC_MSG_RESULT([Not found])
153 AC_MSG_ERROR([*** Cannot determine kernel version.])
154 fi
155 else
156 AC_MSG_RESULT([Not found])
157 if test "x$enable_linux_builtin" != xyes; then
158 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
159 else
160 AC_MSG_ERROR([
161 *** Cannot find UTS_RELEASE definition.
162 *** Please run 'make prepare' inside the kernel source tree.])
163 fi
164 fi
165
166 AC_MSG_RESULT([$kernsrcver])
167
168 LINUX=${kernelsrc}
169 LINUX_OBJ=${kernelbuild}
170 LINUX_VERSION=${kernsrcver}
171
172 AC_SUBST(LINUX)
173 AC_SUBST(LINUX_OBJ)
174 AC_SUBST(LINUX_VERSION)
175
176 SPL_AC_MODULE_SYMVERS
177 ])
178
179 dnl #
180 dnl # Default SPL user configuration
181 dnl #
182 AC_DEFUN([SPL_AC_CONFIG_USER], [])
183
184 dnl #
185 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
186 dnl # are missing, it is non-fatal, but you will not be able to build
187 dnl # RPM packages and will be warned if you try too.
188 dnl #
189 dnl # By default, the generic spec file will be used because it requires
190 dnl # minimal dependencies. Distribution specific spec files can be
191 dnl # placed under the 'rpm/<distribution>' directory and enabled using
192 dnl # the --with-spec=<distribution> configure option.
193 dnl #
194 AC_DEFUN([SPL_AC_RPM], [
195 RPM=rpm
196 RPMBUILD=rpmbuild
197
198 AC_MSG_CHECKING([whether $RPM is available])
199 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
200 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
201 HAVE_RPM=yes
202 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
203 ],[
204 HAVE_RPM=no
205 AC_MSG_RESULT([$HAVE_RPM])
206 ])
207
208 AC_MSG_CHECKING([whether $RPMBUILD is available])
209 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
210 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
211 HAVE_RPMBUILD=yes
212 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
213 ],[
214 HAVE_RPMBUILD=no
215 AC_MSG_RESULT([$HAVE_RPMBUILD])
216 ])
217
218 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
219 RPM_DEFINE_UTIL=
220 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
221 RPM_DEFINE_DKMS=
222
223 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
224 SRPM_DEFINE_UTIL=
225 SRPM_DEFINE_KMOD=
226 SRPM_DEFINE_DKMS=
227
228 RPM_SPEC_DIR="rpm/generic"
229 AC_ARG_WITH([spec],
230 AS_HELP_STRING([--with-spec=SPEC],
231 [Spec files 'generic|redhat']),
232 [RPM_SPEC_DIR="rpm/$withval"])
233
234 AC_MSG_CHECKING([whether spec files are available])
235 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
236
237 AC_SUBST(HAVE_RPM)
238 AC_SUBST(RPM)
239 AC_SUBST(RPM_VERSION)
240
241 AC_SUBST(HAVE_RPMBUILD)
242 AC_SUBST(RPMBUILD)
243 AC_SUBST(RPMBUILD_VERSION)
244
245 AC_SUBST(RPM_SPEC_DIR)
246 AC_SUBST(RPM_DEFINE_UTIL)
247 AC_SUBST(RPM_DEFINE_KMOD)
248 AC_SUBST(RPM_DEFINE_DKMS)
249 AC_SUBST(RPM_DEFINE_COMMON)
250 AC_SUBST(SRPM_DEFINE_UTIL)
251 AC_SUBST(SRPM_DEFINE_KMOD)
252 AC_SUBST(SRPM_DEFINE_DKMS)
253 AC_SUBST(SRPM_DEFINE_COMMON)
254 ])
255
256 dnl #
257 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
258 dnl # tools are missing it is non-fatal but you will not be able to build
259 dnl # DEB packages and will be warned if you try too.
260 dnl #
261 AC_DEFUN([SPL_AC_DPKG], [
262 DPKG=dpkg
263 DPKGBUILD=dpkg-buildpackage
264
265 AC_MSG_CHECKING([whether $DPKG is available])
266 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
267 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
268 HAVE_DPKG=yes
269 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
270 ],[
271 HAVE_DPKG=no
272 AC_MSG_RESULT([$HAVE_DPKG])
273 ])
274
275 AC_MSG_CHECKING([whether $DPKGBUILD is available])
276 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
277 DPKGBUILD_VERSION=$(echo $tmp | \
278 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
279 HAVE_DPKGBUILD=yes
280 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
281 ],[
282 HAVE_DPKGBUILD=no
283 AC_MSG_RESULT([$HAVE_DPKGBUILD])
284 ])
285
286 AC_SUBST(HAVE_DPKG)
287 AC_SUBST(DPKG)
288 AC_SUBST(DPKG_VERSION)
289
290 AC_SUBST(HAVE_DPKGBUILD)
291 AC_SUBST(DPKGBUILD)
292 AC_SUBST(DPKGBUILD_VERSION)
293 ])
294
295 dnl #
296 dnl # Until native packaging for various different packing systems
297 dnl # can be added the least we can do is attempt to use alien to
298 dnl # convert the RPM packages to the needed package type. This is
299 dnl # a hack but so far it has worked reasonable well.
300 dnl #
301 AC_DEFUN([SPL_AC_ALIEN], [
302 ALIEN=alien
303
304 AC_MSG_CHECKING([whether $ALIEN is available])
305 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
306 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
307 HAVE_ALIEN=yes
308 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
309 ],[
310 HAVE_ALIEN=no
311 AC_MSG_RESULT([$HAVE_ALIEN])
312 ])
313
314 AC_SUBST(HAVE_ALIEN)
315 AC_SUBST(ALIEN)
316 AC_SUBST(ALIEN_VERSION)
317 ])
318
319 dnl #
320 dnl # Using the VENDOR tag from config.guess set the default
321 dnl # package type for 'make pkg': (rpm | deb | tgz)
322 dnl #
323 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
324 AC_MSG_CHECKING([linux distribution])
325 if test -f /etc/toss-release ; then
326 VENDOR=toss ;
327 elif test -f /etc/fedora-release ; then
328 VENDOR=fedora ;
329 elif test -f /etc/redhat-release ; then
330 VENDOR=redhat ;
331 elif test -f /etc/gentoo-release ; then
332 VENDOR=gentoo ;
333 elif test -f /etc/arch-release ; then
334 VENDOR=arch ;
335 elif test -f /etc/SuSE-release ; then
336 VENDOR=sles ;
337 elif test -f /etc/slackware-version ; then
338 VENDOR=slackware ;
339 elif test -f /etc/lunar.release ; then
340 VENDOR=lunar ;
341 elif test -f /etc/lsb-release ; then
342 VENDOR=ubuntu ;
343 elif test -f /etc/debian_version ; then
344 VENDOR=debian ;
345 else
346 VENDOR= ;
347 fi
348 AC_MSG_RESULT([$VENDOR])
349 AC_SUBST(VENDOR)
350
351 AC_MSG_CHECKING([default package type])
352 case "$VENDOR" in
353 toss) DEFAULT_PACKAGE=rpm ;;
354 redhat) DEFAULT_PACKAGE=rpm ;;
355 fedora) DEFAULT_PACKAGE=rpm ;;
356 gentoo) DEFAULT_PACKAGE=tgz ;;
357 arch) DEFAULT_PACKAGE=tgz ;;
358 sles) DEFAULT_PACKAGE=rpm ;;
359 slackware) DEFAULT_PACKAGE=tgz ;;
360 lunar) DEFAULT_PACKAGE=tgz ;;
361 ubuntu) DEFAULT_PACKAGE=deb ;;
362 debian) DEFAULT_PACKAGE=deb ;;
363 *) DEFAULT_PACKAGE=rpm ;;
364 esac
365
366 AC_MSG_RESULT([$DEFAULT_PACKAGE])
367 AC_SUBST(DEFAULT_PACKAGE)
368 ])
369
370 dnl #
371 dnl # Default SPL user configuration
372 dnl #
373 AC_DEFUN([SPL_AC_PACKAGE], [
374 SPL_AC_DEFAULT_PACKAGE
375 SPL_AC_RPM
376 SPL_AC_DPKG
377 SPL_AC_ALIEN
378 ])
379
380 AC_DEFUN([SPL_AC_LICENSE], [
381 AC_MSG_CHECKING([spl author])
382 AC_MSG_RESULT([$SPL_META_AUTHOR])
383
384 AC_MSG_CHECKING([spl license])
385 AC_MSG_RESULT([$SPL_META_LICENSE])
386 ])
387
388 AC_DEFUN([SPL_AC_CONFIG], [
389 SPL_CONFIG=all
390 AC_ARG_WITH([config],
391 AS_HELP_STRING([--with-config=CONFIG],
392 [Config file 'kernel|user|all|srpm']),
393 [SPL_CONFIG="$withval"])
394 AC_ARG_ENABLE([linux-builtin],
395 [AC_HELP_STRING([--enable-linux-builtin],
396 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
397 [],
398 [enable_linux_builtin=no])
399
400 AC_MSG_CHECKING([spl config])
401 AC_MSG_RESULT([$SPL_CONFIG]);
402 AC_SUBST(SPL_CONFIG)
403
404 case "$SPL_CONFIG" in
405 kernel) SPL_AC_CONFIG_KERNEL ;;
406 user) SPL_AC_CONFIG_USER ;;
407 all) SPL_AC_CONFIG_KERNEL
408 SPL_AC_CONFIG_USER ;;
409 srpm) ;;
410 *)
411 AC_MSG_RESULT([Error!])
412 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
413 user kernel|user|all|srpm]) ;;
414 esac
415
416 AM_CONDITIONAL([CONFIG_USER],
417 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
418 AM_CONDITIONAL([CONFIG_KERNEL],
419 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
420 [test "x$enable_linux_builtin" != xyes ])
421 ])
422
423 dnl #
424 dnl # Enable if the SPL should be compiled with internal debugging enabled.
425 dnl # By default this support is disabled.
426 dnl #
427 AC_DEFUN([SPL_AC_DEBUG], [
428 AC_MSG_CHECKING([whether debugging is enabled])
429 AC_ARG_ENABLE([debug],
430 [AS_HELP_STRING([--enable-debug],
431 [Enable generic debug support @<:@default=no@:>@])],
432 [],
433 [enable_debug=no])
434
435 AS_IF([test "x$enable_debug" = xyes],
436 [
437 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
438 DEBUG_CFLAGS="-DDEBUG -Werror"
439 DEBUG_SPL="_with_debug"
440 ], [
441 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
442 DEBUG_CFLAGS="-DNDEBUG"
443 DEBUG_SPL="_without_debug"
444 ])
445
446 AC_SUBST(DEBUG_CFLAGS)
447 AC_SUBST(DEBUG_SPL)
448 AC_MSG_RESULT([$enable_debug])
449 ])
450
451 dnl #
452 dnl # Enabled by default it provides a minimal level of memory tracking.
453 dnl # A total count of bytes allocated is kept for each alloc and free.
454 dnl # Then at module unload time a report to the console will be printed
455 dnl # if memory was leaked.
456 dnl #
457 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
458 AC_ARG_ENABLE([debug-kmem],
459 [AS_HELP_STRING([--enable-debug-kmem],
460 [Enable basic kmem accounting @<:@default=no@:>@])],
461 [],
462 [enable_debug_kmem=no])
463
464 AS_IF([test "x$enable_debug_kmem" = xyes],
465 [
466 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
467 DEBUG_KMEM="_with_debug_kmem"
468 AC_DEFINE([DEBUG_KMEM], [1],
469 [Define to 1 to enable basic kmem accounting])
470 ], [
471 DEBUG_KMEM="_without_debug_kmem"
472 ])
473
474 AC_SUBST(DEBUG_KMEM)
475 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
476 AC_MSG_RESULT([$enable_debug_kmem])
477 ])
478
479 dnl #
480 dnl # Disabled by default it provides detailed memory tracking. This
481 dnl # feature also requires --enable-debug-kmem to be set. When enabled
482 dnl # not only will total bytes be tracked but also the location of every
483 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
484 dnl # addresses and where they were allocated will be dumped to the console.
485 dnl # Enabling this feature has a significant impact on performance but it
486 dnl # makes finding memory leaks pretty straight forward.
487 dnl #
488 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
489 AC_ARG_ENABLE([debug-kmem-tracking],
490 [AS_HELP_STRING([--enable-debug-kmem-tracking],
491 [Enable detailed kmem tracking @<:@default=no@:>@])],
492 [],
493 [enable_debug_kmem_tracking=no])
494
495 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
496 [
497 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
498 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
499 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
500 [Define to 1 to enable detailed kmem tracking])
501 ], [
502 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
503 ])
504
505 AC_SUBST(DEBUG_KMEM_TRACKING)
506 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
507 AC_MSG_RESULT([$enable_debug_kmem_tracking])
508 ])
509
510 dnl #
511 dnl # SPL_LINUX_CONFTEST
512 dnl #
513 AC_DEFUN([SPL_LINUX_CONFTEST], [
514 cat confdefs.h - <<_ACEOF >conftest.c
515 $1
516 _ACEOF
517 ])
518
519 dnl #
520 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
521 dnl #
522 m4_define([SPL_LANG_PROGRAM], [
523 $1
524 int
525 main (void)
526 {
527 dnl Do *not* indent the following line: there may be CPP directives.
528 dnl Don't move the `;' right after for the same reason.
529 $2
530 ;
531 return 0;
532 }
533 ])
534
535 dnl #
536 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
537 dnl #
538 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
539 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
540 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
541 echo "obj-m := conftest.o" >build/Makefile
542 modpost_flag=''
543 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
544 AS_IF(
545 [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 $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
546 [$4],
547 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
548 )
549 rm -Rf build
550 ])
551
552 dnl #
553 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
554 dnl #
555 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
556 [SPL_LINUX_COMPILE_IFELSE(
557 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
558 [modules],
559 [test -s build/conftest.o],
560 [$3], [$4])
561 ])
562
563 dnl #
564 dnl # SPL_CHECK_SYMBOL_EXPORT
565 dnl # check symbol exported or not
566 dnl #
567 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
568 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
569 $LINUX_OBJ/Module*.symvers 2>/dev/null
570 rc=$?
571 if test $rc -ne 0; then
572 export=0
573 for file in $2; do
574 grep -q -E "EXPORT_SYMBOL.*($1)" \
575 "$LINUX_OBJ/$file" 2>/dev/null
576 rc=$?
577 if test $rc -eq 0; then
578 export=1
579 break;
580 fi
581 done
582 if test $export -eq 0; then :
583 $4
584 else :
585 $3
586 fi
587 else :
588 $3
589 fi
590 ])
591
592 dnl #
593 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
594 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
595 dnl # is called if not compiling for builtin
596 dnl #
597 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
598 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
599 if test $rc -ne 0; then :
600 $6
601 else
602 if test "x$enable_linux_builtin" != xyes; then
603 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
604 fi
605 if test $rc -ne 0; then :
606 $6
607 else :
608 $5
609 fi
610 fi
611 ])
612
613 dnl #
614 dnl # SPL_CHECK_SYMBOL_HEADER
615 dnl # check if a symbol prototype is defined in listed headers.
616 dnl #
617 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
618 AC_MSG_CHECKING([whether symbol $1 exists in header])
619 header=0
620 for file in $3; do
621 grep -q "$2" "$LINUX/$file" 2>/dev/null
622 rc=$?
623 if test $rc -eq 0; then
624 header=1
625 break;
626 fi
627 done
628 if test $header -eq 0; then
629 AC_MSG_RESULT([no])
630 $5
631 else
632 AC_MSG_RESULT([yes])
633 $4
634 fi
635 ])
636
637 dnl #
638 dnl # SPL_CHECK_HEADER
639 dnl # check whether header exists and define HAVE_$2_HEADER
640 dnl #
641 AC_DEFUN([SPL_CHECK_HEADER],
642 [AC_MSG_CHECKING([whether header $1 exists])
643 SPL_LINUX_TRY_COMPILE([
644 #include <$1>
645 ],[
646 return 0;
647 ],[
648 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
649 AC_MSG_RESULT(yes)
650 $3
651 ],[
652 AC_MSG_RESULT(no)
653 $4
654 ])
655 ])
656
657 dnl #
658 dnl # Basic toolchain sanity check. Verify that kernel modules can
659 dnl # be built and which symbols can be used.
660 dnl #
661 AC_DEFUN([SPL_AC_TEST_MODULE],
662 [AC_MSG_CHECKING([whether modules can be built])
663 SPL_LINUX_TRY_COMPILE([],[],[
664 AC_MSG_RESULT([yes])
665 ],[
666 AC_MSG_RESULT([no])
667 if test "x$enable_linux_builtin" != xyes; then
668 AC_MSG_ERROR([*** Unable to build an empty module.])
669 else
670 AC_MSG_ERROR([
671 *** Unable to build an empty module.
672 *** Please run 'make scripts' inside the kernel source tree.])
673 fi
674 ])
675
676 AS_IF([test "x$cross_compiling" != xyes], [
677 AC_RUN_IFELSE([
678 AC_LANG_PROGRAM([
679 #include "$LINUX/include/linux/license.h"
680 ], [
681 return !license_is_gpl_compatible(
682 "$SPL_META_LICENSE");
683 ])
684 ], [
685 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
686 [Define to 1 if GPL-only symbols can be used])
687 ], [
688 ])
689 ])
690 ])
691
692 dnl #
693 dnl # Use the atomic implemenation based on global spinlocks. This
694 dnl # should only be needed by 32-bit kernels which do not provide
695 dnl # the atomic64_* API. It may be optionally enabled as a fallback
696 dnl # if problems are observed with the direct mapping to the native
697 dnl # Linux atomic operations. You may not disable atomic spinlocks
698 dnl # if you kernel does not an atomic64_* API.
699 dnl #
700 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
701 AC_ARG_ENABLE([atomic-spinlocks],
702 [AS_HELP_STRING([--enable-atomic-spinlocks],
703 [Atomic types use spinlocks @<:@default=check@:>@])],
704 [],
705 [enable_atomic_spinlocks=check])
706
707 SPL_LINUX_TRY_COMPILE([
708 #include <linux/fs.h>
709 ],[
710 atomic64_t *ptr __attribute__ ((unused));
711 ],[
712 have_atomic64_t=yes
713 AC_DEFINE(HAVE_ATOMIC64_T, 1,
714 [kernel defines atomic64_t])
715 ],[
716 have_atomic64_t=no
717 ])
718
719 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
720 AS_IF([test "x$have_atomic64_t" = xyes], [
721 enable_atomic_spinlocks=no
722 ],[
723 enable_atomic_spinlocks=yes
724 ])
725 ])
726
727 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
728 AC_DEFINE([ATOMIC_SPINLOCK], [1],
729 [Atomic types use spinlocks])
730 ],[
731 AS_IF([test "x$have_atomic64_t" = xno], [
732 AC_MSG_FAILURE(
733 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
734 ])
735 ])
736
737 AC_MSG_CHECKING([whether atomic types use spinlocks])
738 AC_MSG_RESULT([$enable_atomic_spinlocks])
739
740 AC_MSG_CHECKING([whether kernel defines atomic64_t])
741 AC_MSG_RESULT([$have_atomic64_t])
742 ])
743
744 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
745 tmp_flags="$EXTRA_KCFLAGS"
746 EXTRA_KCFLAGS="-Werror"
747 dnl #
748 dnl # 2.6.23 to 2.6.34 API change
749 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
750 dnl #
751 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
752 SPL_LINUX_TRY_COMPILE([
753 #include <linux/mm.h>
754
755 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
756 ],[
757 struct shrinker cache_shrinker = {
758 .shrink = shrinker_cb,
759 .seeks = DEFAULT_SEEKS,
760 };
761 register_shrinker(&cache_shrinker);
762 ],[
763 AC_MSG_RESULT(yes)
764 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
765 [old shrinker callback wants 2 args])
766 ],[
767 AC_MSG_RESULT(no)
768 dnl #
769 dnl # 2.6.35 - 2.6.39 API change
770 dnl # ->shrink(struct shrinker *,
771 dnl # int nr_to_scan, gfp_t gfp_mask)
772 dnl #
773 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
774 SPL_LINUX_TRY_COMPILE([
775 #include <linux/mm.h>
776
777 int shrinker_cb(struct shrinker *, int nr_to_scan,
778 gfp_t gfp_mask);
779 ],[
780 struct shrinker cache_shrinker = {
781 .shrink = shrinker_cb,
782 .seeks = DEFAULT_SEEKS,
783 };
784 register_shrinker(&cache_shrinker);
785 ],[
786 AC_MSG_RESULT(yes)
787 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
788 [old shrinker callback wants 3 args])
789 ],[
790 AC_MSG_RESULT(no)
791 dnl #
792 dnl # 3.0 - 3.11 API change
793 dnl # ->shrink(struct shrinker *,
794 dnl # struct shrink_control *sc)
795 dnl #
796 AC_MSG_CHECKING(
797 [whether new 2-argument shrinker exists])
798 SPL_LINUX_TRY_COMPILE([
799 #include <linux/mm.h>
800
801 int shrinker_cb(struct shrinker *,
802 struct shrink_control *sc);
803 ],[
804 struct shrinker cache_shrinker = {
805 .shrink = shrinker_cb,
806 .seeks = DEFAULT_SEEKS,
807 };
808 register_shrinker(&cache_shrinker);
809 ],[
810 AC_MSG_RESULT(yes)
811 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
812 [new shrinker callback wants 2 args])
813 ],[
814 AC_MSG_RESULT(no)
815 dnl #
816 dnl # 3.12 API change,
817 dnl # ->shrink() is logically split in to
818 dnl # ->count_objects() and ->scan_objects()
819 dnl #
820 AC_MSG_CHECKING(
821 [whether ->count_objects callback exists])
822 SPL_LINUX_TRY_COMPILE([
823 #include <linux/mm.h>
824
825 unsigned long shrinker_cb(
826 struct shrinker *,
827 struct shrink_control *sc);
828 ],[
829 struct shrinker cache_shrinker = {
830 .count_objects = shrinker_cb,
831 .scan_objects = shrinker_cb,
832 .seeks = DEFAULT_SEEKS,
833 };
834 register_shrinker(&cache_shrinker);
835 ],[
836 AC_MSG_RESULT(yes)
837 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
838 1, [->count_objects exists])
839 ],[
840 AC_MSG_ERROR(error)
841 ])
842 ])
843 ])
844 ])
845 EXTRA_KCFLAGS="$tmp_flags"
846 ])
847
848 dnl #
849 dnl # 2.6.33 API change,
850 dnl # Removed .ctl_name from struct ctl_table.
851 dnl #
852 AC_DEFUN([SPL_AC_CTL_NAME], [
853 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
854 SPL_LINUX_TRY_COMPILE([
855 #include <linux/sysctl.h>
856 ],[
857 struct ctl_table ctl __attribute__ ((unused));
858 ctl.ctl_name = 0;
859 ],[
860 AC_MSG_RESULT(yes)
861 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
862 ],[
863 AC_MSG_RESULT(no)
864 ])
865 ])
866
867 dnl #
868 dnl # 3.10 API change,
869 dnl # PDE is replaced by PDE_DATA
870 dnl #
871 AC_DEFUN([SPL_AC_PDE_DATA], [
872 AC_MSG_CHECKING([whether PDE_DATA() is available])
873 SPL_LINUX_TRY_COMPILE_SYMBOL([
874 #include <linux/proc_fs.h>
875 ], [
876 PDE_DATA(NULL);
877 ], [PDE_DATA], [], [
878 AC_MSG_RESULT(yes)
879 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
880 ],[
881 AC_MSG_RESULT(no)
882 ])
883 ])
884
885 dnl #
886 dnl # 3.9 API change
887 dnl # set_fs_pwd takes const struct path *
888 dnl #
889 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
890 tmp_flags="$EXTRA_KCFLAGS"
891 EXTRA_KCFLAGS="-Werror"
892 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
893 SPL_LINUX_TRY_COMPILE([
894 #include <linux/spinlock.h>
895 #include <linux/fs_struct.h>
896 #include <linux/path.h>
897 void (*const set_fs_pwd_func)
898 (struct fs_struct *, const struct path *)
899 = set_fs_pwd;
900 ],[
901 return 0;
902 ],[
903 AC_MSG_RESULT(yes)
904 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
905 [set_fs_pwd() needs const path *])
906 ],[
907 SPL_LINUX_TRY_COMPILE([
908 #include <linux/spinlock.h>
909 #include <linux/fs_struct.h>
910 #include <linux/path.h>
911 void (*const set_fs_pwd_func)
912 (struct fs_struct *, struct path *)
913 = set_fs_pwd;
914 ],[
915 return 0;
916 ],[
917 AC_MSG_RESULT(no)
918 ],[
919 AC_MSG_ERROR(unknown)
920 ])
921 ])
922 EXTRA_KCFLAGS="$tmp_flags"
923 ])
924
925 dnl #
926 dnl # 3.13 API change
927 dnl # vfs_unlink() updated to take a third delegated_inode argument.
928 dnl #
929 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
930 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
931 SPL_LINUX_TRY_COMPILE([
932 #include <linux/fs.h>
933 ],[
934 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
935 ],[
936 AC_MSG_RESULT(yes)
937 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
938 [vfs_unlink() wants 2 args])
939 ],[
940 AC_MSG_RESULT(no)
941 dnl #
942 dnl # Linux 3.13 API change
943 dnl # Added delegated inode
944 dnl #
945 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
946 SPL_LINUX_TRY_COMPILE([
947 #include <linux/fs.h>
948 ],[
949 vfs_unlink((struct inode *) NULL,
950 (struct dentry *) NULL,
951 (struct inode **) NULL);
952 ],[
953 AC_MSG_RESULT(yes)
954 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
955 [vfs_unlink() wants 3 args])
956 ],[
957 AC_MSG_ERROR(no)
958 ])
959
960 ])
961 ])
962
963 dnl #
964 dnl # 3.13 and 3.15 API changes
965 dnl # Added delegated inode and flags argument.
966 dnl #
967 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
968 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
969 SPL_LINUX_TRY_COMPILE([
970 #include <linux/fs.h>
971 ],[
972 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
973 (struct inode *) NULL, (struct dentry *) NULL);
974 ],[
975 AC_MSG_RESULT(yes)
976 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
977 [vfs_rename() wants 4 args])
978 ],[
979 AC_MSG_RESULT(no)
980 dnl #
981 dnl # Linux 3.13 API change
982 dnl # Added delegated inode
983 dnl #
984 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
985 SPL_LINUX_TRY_COMPILE([
986 #include <linux/fs.h>
987 ],[
988 vfs_rename((struct inode *) NULL,
989 (struct dentry *) NULL,
990 (struct inode *) NULL,
991 (struct dentry *) NULL,
992 (struct inode **) NULL);
993 ],[
994 AC_MSG_RESULT(yes)
995 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
996 [vfs_rename() wants 5 args])
997 ],[
998 AC_MSG_RESULT(no)
999 dnl #
1000 dnl # Linux 3.15 API change
1001 dnl # Added flags
1002 dnl #
1003 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1004 SPL_LINUX_TRY_COMPILE([
1005 #include <linux/fs.h>
1006 ],[
1007 vfs_rename((struct inode *) NULL,
1008 (struct dentry *) NULL,
1009 (struct inode *) NULL,
1010 (struct dentry *) NULL,
1011 (struct inode **) NULL,
1012 (unsigned int) 0);
1013 ],[
1014 AC_MSG_RESULT(yes)
1015 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1016 [vfs_rename() wants 6 args])
1017 ],[
1018 AC_MSG_ERROR(no)
1019 ])
1020 ])
1021 ])
1022 ])
1023
1024 dnl #
1025 dnl # 2.6.36 API change,
1026 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1027 dnl # a spinlock_t to improve the fastpath performance.
1028 dnl #
1029 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1030 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1031 tmp_flags="$EXTRA_KCFLAGS"
1032 EXTRA_KCFLAGS="-Werror"
1033 SPL_LINUX_TRY_COMPILE([
1034 #include <linux/sched.h>
1035 #include <linux/fs_struct.h>
1036 ],[
1037 static struct fs_struct fs;
1038 spin_lock_init(&fs.lock);
1039 ],[
1040 AC_MSG_RESULT(yes)
1041 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1042 [struct fs_struct uses spinlock_t])
1043 ],[
1044 AC_MSG_RESULT(no)
1045 ])
1046 EXTRA_KCFLAGS="$tmp_flags"
1047 ])
1048
1049 dnl #
1050 dnl # User namespaces, use kuid_t in place of uid_t
1051 dnl # where available. Not strictly a user namespaces thing
1052 dnl # but it should prevent surprises
1053 dnl #
1054 AC_DEFUN([SPL_AC_KUIDGID_T], [
1055 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1056 SPL_LINUX_TRY_COMPILE([
1057 #include <linux/uidgid.h>
1058 ], [
1059 kuid_t userid = KUIDT_INIT(0);
1060 kgid_t groupid = KGIDT_INIT(0);
1061 ],[
1062 SPL_LINUX_TRY_COMPILE([
1063 #include <linux/uidgid.h>
1064 ], [
1065 kuid_t userid = 0;
1066 kgid_t groupid = 0;
1067 ],[
1068 AC_MSG_RESULT(yes; optional)
1069 ],[
1070 AC_MSG_RESULT(yes; mandatory)
1071 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1072 ])
1073 ],[
1074 AC_MSG_RESULT(no)
1075 ])
1076 ])
1077
1078 dnl #
1079 dnl # 2.6.39 API change,
1080 dnl # __put_task_struct() was exported by the mainline kernel.
1081 dnl #
1082 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1083 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1084 SPL_LINUX_TRY_COMPILE_SYMBOL([
1085 #include <linux/sched.h>
1086 ], [
1087 __put_task_struct(NULL);
1088 ], [__put_task_struct], [], [
1089 AC_MSG_RESULT(yes)
1090 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1091 [__put_task_struct() is available])
1092 ], [
1093 AC_MSG_RESULT(no)
1094 ])
1095 ])
1096
1097 dnl #
1098 dnl # 2.6.35 API change,
1099 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1100 dnl #
1101 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1102 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1103 SPL_LINUX_TRY_COMPILE([
1104 #include <linux/fs.h>
1105 ],[
1106 vfs_fsync(NULL, 0);
1107 ],[
1108 AC_MSG_RESULT(yes)
1109 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1110 ],[
1111 AC_MSG_RESULT(no)
1112 ])
1113 ])
1114
1115 dnl #
1116 dnl # 3.5 API change,
1117 dnl # inode_operations.truncate_range removed
1118 dnl #
1119 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
1120 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
1121 SPL_LINUX_TRY_COMPILE([
1122 #include <linux/fs.h>
1123 ],[
1124 struct inode_operations ops;
1125 ops.truncate_range = NULL;
1126 ],[
1127 AC_MSG_RESULT(yes)
1128 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
1129 [truncate_range() inode operation is available])
1130 ],[
1131 AC_MSG_RESULT(no)
1132 ])
1133 ])
1134
1135 dnl #
1136 dnl # Linux 2.6.38 - 3.x API
1137 dnl #
1138 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
1139 AC_MSG_CHECKING([whether fops->fallocate() exists])
1140 SPL_LINUX_TRY_COMPILE([
1141 #include <linux/fs.h>
1142 ],[
1143 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1144 struct file_operations fops __attribute__ ((unused)) = {
1145 .fallocate = fallocate,
1146 };
1147 ],[
1148 AC_MSG_RESULT(yes)
1149 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1150 ],[
1151 AC_MSG_RESULT(no)
1152 ])
1153 ])
1154
1155 dnl #
1156 dnl # Linux 2.6.x - 2.6.37 API
1157 dnl #
1158 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
1159 AC_MSG_CHECKING([whether iops->fallocate() exists])
1160 SPL_LINUX_TRY_COMPILE([
1161 #include <linux/fs.h>
1162 ],[
1163 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
1164 struct inode_operations fops __attribute__ ((unused)) = {
1165 .fallocate = fallocate,
1166 };
1167 ],[
1168 AC_MSG_RESULT(yes)
1169 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
1170 ],[
1171 AC_MSG_RESULT(no)
1172 ])
1173 ])
1174
1175 dnl #
1176 dnl # PaX Linux 2.6.38 - 3.x API
1177 dnl #
1178 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
1179 AC_MSG_CHECKING([whether fops->fallocate() exists])
1180 SPL_LINUX_TRY_COMPILE([
1181 #include <linux/fs.h>
1182 ],[
1183 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
1184 struct file_operations_no_const fops __attribute__ ((unused)) = {
1185 .fallocate = fallocate,
1186 };
1187 ],[
1188 AC_MSG_RESULT(yes)
1189 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
1190 ],[
1191 AC_MSG_RESULT(no)
1192 ])
1193 ])
1194
1195 dnl #
1196 dnl # The fallocate callback was moved from the inode_operations
1197 dnl # structure to the file_operations structure.
1198 dnl #
1199 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
1200 SPL_AC_KERNEL_FILE_FALLOCATE
1201 SPL_AC_KERNEL_INODE_FALLOCATE
1202 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
1203 ])
1204
1205 dnl #
1206 dnl # zlib inflate compat,
1207 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
1208 dnl #
1209 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
1210 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
1211 SPL_LINUX_TRY_COMPILE([
1212 #if !defined(CONFIG_ZLIB_INFLATE) && \
1213 !defined(CONFIG_ZLIB_INFLATE_MODULE)
1214 #error CONFIG_ZLIB_INFLATE not defined
1215 #endif
1216 ],[ ],[
1217 AC_MSG_RESULT([yes])
1218 ],[
1219 AC_MSG_RESULT([no])
1220 AC_MSG_ERROR([
1221 *** This kernel does not include the required zlib inflate support.
1222 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
1223 ])
1224 ])
1225
1226 dnl #
1227 dnl # zlib deflate compat,
1228 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
1229 dnl #
1230 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
1231 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
1232 SPL_LINUX_TRY_COMPILE([
1233 #if !defined(CONFIG_ZLIB_DEFLATE) && \
1234 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
1235 #error CONFIG_ZLIB_DEFLATE not defined
1236 #endif
1237 ],[ ],[
1238 AC_MSG_RESULT([yes])
1239 ],[
1240 AC_MSG_RESULT([no])
1241 AC_MSG_ERROR([
1242 *** This kernel does not include the required zlib deflate support.
1243 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
1244 ])
1245 ])
1246
1247 dnl #
1248 dnl # 2.6.39 API compat,
1249 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
1250 dnl # This was done to avoid always having to allocate the maximum size
1251 dnl # workspace (268K). The caller can now specific the windowBits and
1252 dnl # memLevel compression parameters to get a smaller workspace.
1253 dnl #
1254 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
1255 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
1256 SPL_LINUX_TRY_COMPILE([
1257 #include <linux/zlib.h>
1258 ],[
1259 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
1260 ],[
1261 AC_MSG_RESULT(yes)
1262 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
1263 [zlib_deflate_workspacesize() wants 2 args])
1264 ],[
1265 AC_MSG_RESULT(no)
1266 ])
1267 ])
1268
1269 dnl #
1270 dnl # 2.6.39 API change,
1271 dnl # Shrinker adjust to use common shrink_control structure.
1272 dnl #
1273 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
1274 AC_MSG_CHECKING([whether struct shrink_control exists])
1275 SPL_LINUX_TRY_COMPILE([
1276 #include <linux/mm.h>
1277 ],[
1278 struct shrink_control sc __attribute__ ((unused));
1279
1280 sc.nr_to_scan = 0;
1281 sc.gfp_mask = GFP_KERNEL;
1282 ],[
1283 AC_MSG_RESULT(yes)
1284 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
1285 [struct shrink_control exists])
1286 ],[
1287 AC_MSG_RESULT(no)
1288 ])
1289 ])
1290
1291 dnl #
1292 dnl # 3.1 API Change
1293 dnl #
1294 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
1295 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
1296 dnl #
1297 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
1298 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
1299 tmp_flags="$EXTRA_KCFLAGS"
1300 EXTRA_KCFLAGS="-Werror"
1301 SPL_LINUX_TRY_COMPILE([
1302 #include <linux/rwsem.h>
1303 ],[
1304 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
1305 raw_spinlock_t dummy_lock __attribute__ ((unused));
1306 dummy_semaphore.wait_lock = dummy_lock;
1307 ],[
1308 AC_MSG_RESULT(yes)
1309 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
1310 [struct rw_semaphore member wait_lock is raw_spinlock_t])
1311 ],[
1312 AC_MSG_RESULT(no)
1313 ])
1314 EXTRA_KCFLAGS="$tmp_flags"
1315 ])
1316
1317 dnl #
1318 dnl # 3.9 API change,
1319 dnl # Moved things from linux/sched.h to linux/sched/rt.h
1320 dnl #
1321 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
1322 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
1323 SPL_LINUX_TRY_COMPILE([
1324 #include <linux/sched.h>
1325 #include <linux/sched/rt.h>
1326 ],[
1327 return 0;
1328 ],[
1329 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
1330 AC_MSG_RESULT(yes)
1331 ],[
1332 AC_MSG_RESULT(no)
1333 ])
1334 ])
1335
1336 dnl #
1337 dnl # 3.9 API change,
1338 dnl # vfs_getattr() uses 2 args
1339 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
1340 dnl #
1341 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
1342 AC_MSG_CHECKING([whether vfs_getattr() wants])
1343 SPL_LINUX_TRY_COMPILE([
1344 #include <linux/fs.h>
1345 ],[
1346 vfs_getattr((struct path *) NULL,
1347 (struct kstat *)NULL);
1348 ],[
1349 AC_MSG_RESULT(2 args)
1350 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
1351 [vfs_getattr wants 2 args])
1352 ],[
1353 SPL_LINUX_TRY_COMPILE([
1354 #include <linux/fs.h>
1355 ],[
1356 vfs_getattr((struct vfsmount *)NULL,
1357 (struct dentry *)NULL,
1358 (struct kstat *)NULL);
1359 ],[
1360 AC_MSG_RESULT(3 args)
1361 ],[
1362 AC_MSG_ERROR(unknown)
1363 ])
1364 ])
1365 ])
1366
1367 dnl #
1368 dnl # 2.6.36 API compatibility.
1369 dnl # Added usleep_range timer.
1370 dnl # usleep_range is a finer precision implementation of msleep
1371 dnl # designed to be a drop-in replacement for udelay where a precise
1372 dnl # sleep / busy-wait is unnecessary.
1373 dnl #
1374 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
1375 AC_MSG_CHECKING([whether usleep_range() is available])
1376 SPL_LINUX_TRY_COMPILE([
1377 #include <linux/delay.h>
1378 ],[
1379 usleep_range(0, 0);
1380 ],[
1381 AC_MSG_RESULT(yes)
1382 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
1383 [usleep_range is available])
1384 ],[
1385 AC_MSG_RESULT(no)
1386 ])
1387 ])
1388
1389 dnl #
1390 dnl # 2.6.35 API change,
1391 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
1392 dnl # private allocation flags which are applied when allocating a new slab
1393 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
1394 dnl # non-default flags.
1395 dnl #
1396 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
1397 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
1398 SPL_LINUX_TRY_COMPILE([
1399 #include <linux/slab.h>
1400 ],[
1401 struct kmem_cache cachep __attribute__ ((unused));
1402 cachep.allocflags = GFP_KERNEL;
1403 ],[
1404 AC_MSG_RESULT(yes)
1405 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
1406 [struct kmem_cache has allocflags])
1407 ],[
1408 AC_MSG_RESULT(no)
1409
1410 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
1411 SPL_LINUX_TRY_COMPILE([
1412 #include <linux/slab.h>
1413 ],[
1414 struct kmem_cache cachep __attribute__ ((unused));
1415 cachep.gfpflags = GFP_KERNEL;
1416 ],[
1417 AC_MSG_RESULT(yes)
1418 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
1419 [struct kmem_cache has gfpflags])
1420 ],[
1421 AC_MSG_RESULT(no)
1422 ])
1423 ])
1424 ])
1425
1426 dnl #
1427 dnl # 3.17 API change,
1428 dnl # wait_on_bit() no longer requires an action argument. The former
1429 dnl # "wait_on_bit" interface required an 'action' function to be provided
1430 dnl # which does the actual waiting. There were over 20 such functions in the
1431 dnl # kernel, many of them identical, though most cases can be satisfied by one
1432 dnl # of just two functions: one which uses io_schedule() and one which just
1433 dnl # uses schedule(). This API change was made to consolidate all of those
1434 dnl # redundant wait functions.
1435 dnl #
1436 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
1437 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
1438 SPL_LINUX_TRY_COMPILE([
1439 #include <linux/wait.h>
1440 ],[
1441 int (*action)(void *) = NULL;
1442 wait_on_bit(NULL, 0, action, 0);
1443 ],[
1444 AC_MSG_RESULT(yes)
1445 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
1446 ],[
1447 AC_MSG_RESULT(no)
1448 ])
1449 ])