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