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