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