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