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