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