]> git.proxmox.com Git - mirror_spl.git/blob - config/spl-build.m4
Remove utsname() wrapper
[mirror_spl.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_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_TYPE_UINTPTR_T
29 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_SHRINKER_CALLBACK
31 SPL_AC_CTL_UNNUMBERED
32 SPL_AC_CTL_NAME
33 SPL_AC_VMALLOC_INFO
34 SPL_AC_PDE_DATA
35 SPL_AC_FLS64
36 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
37 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
38 SPL_AC_TIMESPEC_SUB
39 SPL_AC_UACCESS_HEADER
40 SPL_AC_KMALLOC_NODE
41 SPL_AC_MONOTONIC_CLOCK
42 SPL_AC_INODE_I_MUTEX
43 SPL_AC_MUTEX_OWNER
44 SPL_AC_MUTEX_OWNER_TASK_STRUCT
45 SPL_AC_MUTEX_LOCK_NESTED
46 SPL_AC_3ARGS_ON_EACH_CPU
47 SPL_AC_KALLSYMS_LOOKUP_NAME
48 SPL_AC_GET_VMALLOC_INFO
49 SPL_AC_PGDAT_HELPERS
50 SPL_AC_FIRST_ONLINE_PGDAT
51 SPL_AC_NEXT_ONLINE_PGDAT
52 SPL_AC_NEXT_ZONE
53 SPL_AC_PGDAT_LIST
54 SPL_AC_GLOBAL_PAGE_STATE
55 SPL_AC_ZONE_STAT_ITEM_FREE
56 SPL_AC_ZONE_STAT_ITEM_INACTIVE
57 SPL_AC_ZONE_STAT_ITEM_ACTIVE
58 SPL_AC_GET_ZONE_COUNTS
59 SPL_AC_USER_PATH_DIR
60 SPL_AC_SET_FS_PWD
61 SPL_AC_SET_FS_PWD_WITH_CONST
62 SPL_AC_2ARGS_VFS_UNLINK
63 SPL_AC_4ARGS_VFS_RENAME
64 SPL_AC_VFS_FSYNC
65 SPL_AC_2ARGS_VFS_FSYNC
66 SPL_AC_INODE_TRUNCATE_RANGE
67 SPL_AC_FS_STRUCT_SPINLOCK
68 SPL_AC_CRED_STRUCT
69 SPL_AC_KUIDGID_T
70 SPL_AC_GROUPS_SEARCH
71 SPL_AC_PUT_TASK_STRUCT
72 SPL_AC_5ARGS_PROC_HANDLER
73 SPL_AC_KVASPRINTF
74 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
75 SPL_AC_KERNEL_FALLOCATE
76 SPL_AC_SHRINK_DCACHE_MEMORY
77 SPL_AC_SHRINK_ICACHE_MEMORY
78 SPL_AC_KERN_PATH
79 SPL_AC_CONFIG_KALLSYMS
80 SPL_AC_CONFIG_ZLIB_INFLATE
81 SPL_AC_CONFIG_ZLIB_DEFLATE
82 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
83 SPL_AC_SHRINK_CONTROL_STRUCT
84 SPL_AC_RWSEM_SPINLOCK_IS_RAW
85 SPL_AC_SCHED_RT_HEADER
86 SPL_AC_2ARGS_VFS_GETATTR
87 SPL_AC_USLEEP_RANGE
88 SPL_AC_KMEM_CACHE_ALLOCFLAGS
89 SPL_AC_WAIT_ON_BIT
90 ])
91
92 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
93 modpost=$LINUX/scripts/Makefile.modpost
94 AC_MSG_CHECKING([kernel file name for module symbols])
95 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
96 if grep -q Modules.symvers $modpost; then
97 LINUX_SYMBOLS=Modules.symvers
98 else
99 LINUX_SYMBOLS=Module.symvers
100 fi
101
102 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
103 AC_MSG_ERROR([
104 *** Please make sure the kernel devel package for your distribution
105 *** is installed. If you are building with a custom kernel, make sure the
106 *** kernel is configured, built, and the '--with-linux=PATH' configure
107 *** option refers to the location of the kernel source.])
108 fi
109 else
110 LINUX_SYMBOLS=NONE
111 fi
112 AC_MSG_RESULT($LINUX_SYMBOLS)
113 AC_SUBST(LINUX_SYMBOLS)
114 ])
115
116 AC_DEFUN([SPL_AC_KERNEL], [
117 AC_ARG_WITH([linux],
118 AS_HELP_STRING([--with-linux=PATH],
119 [Path to kernel source]),
120 [kernelsrc="$withval"])
121
122 AC_ARG_WITH([linux-obj],
123 AS_HELP_STRING([--with-linux-obj=PATH],
124 [Path to kernel build objects]),
125 [kernelbuild="$withval"])
126
127 AC_MSG_CHECKING([kernel source directory])
128 if test -z "$kernelsrc"; then
129 if test -e "/lib/modules/$(uname -r)/source"; then
130 headersdir="/lib/modules/$(uname -r)/source"
131 sourcelink=$(readlink -f "$headersdir")
132 elif test -e "/lib/modules/$(uname -r)/build"; then
133 headersdir="/lib/modules/$(uname -r)/build"
134 sourcelink=$(readlink -f "$headersdir")
135 else
136 sourcelink=$(ls -1d /usr/src/kernels/* \
137 /usr/src/linux-* \
138 2>/dev/null | grep -v obj | tail -1)
139 fi
140
141 if test -n "$sourcelink" && test -e ${sourcelink}; then
142 kernelsrc=`readlink -f ${sourcelink}`
143 else
144 kernelsrc="[Not found]"
145 fi
146 else
147 if test "$kernelsrc" = "NONE"; then
148 kernsrcver=NONE
149 fi
150 fi
151
152 AC_MSG_RESULT([$kernelsrc])
153 if test ! -d "$kernelsrc"; then
154 AC_MSG_ERROR([
155 *** Please make sure the kernel devel package for your distribution
156 *** is installed and then try again. If that fails, you can specify the
157 *** location of the kernel source with the '--with-linux=PATH' option.])
158 fi
159
160 AC_MSG_CHECKING([kernel build directory])
161 if test -z "$kernelbuild"; then
162 if test -e "/lib/modules/$(uname -r)/build"; then
163 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
164 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
165 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
166 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
167 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
168 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
169 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
170 else
171 kernelbuild=${kernelsrc}
172 fi
173 fi
174 AC_MSG_RESULT([$kernelbuild])
175
176 AC_MSG_CHECKING([kernel source version])
177 utsrelease1=$kernelbuild/include/linux/version.h
178 utsrelease2=$kernelbuild/include/linux/utsrelease.h
179 utsrelease3=$kernelbuild/include/generated/utsrelease.h
180 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
181 utsrelease=linux/version.h
182 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
183 utsrelease=linux/utsrelease.h
184 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
185 utsrelease=generated/utsrelease.h
186 fi
187
188 if test "$utsrelease"; then
189 kernsrcver=`(echo "#include <$utsrelease>";
190 echo "kernsrcver=UTS_RELEASE") |
191 cpp -I $kernelbuild/include |
192 grep "^kernsrcver=" | cut -d \" -f 2`
193
194 if test -z "$kernsrcver"; then
195 AC_MSG_RESULT([Not found])
196 AC_MSG_ERROR([*** Cannot determine kernel version.])
197 fi
198 else
199 AC_MSG_RESULT([Not found])
200 if test "x$enable_linux_builtin" != xyes; then
201 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
202 else
203 AC_MSG_ERROR([
204 *** Cannot find UTS_RELEASE definition.
205 *** Please run 'make prepare' inside the kernel source tree.])
206 fi
207 fi
208
209 AC_MSG_RESULT([$kernsrcver])
210
211 LINUX=${kernelsrc}
212 LINUX_OBJ=${kernelbuild}
213 LINUX_VERSION=${kernsrcver}
214
215 AC_SUBST(LINUX)
216 AC_SUBST(LINUX_OBJ)
217 AC_SUBST(LINUX_VERSION)
218
219 SPL_AC_MODULE_SYMVERS
220 ])
221
222 dnl #
223 dnl # Default SPL user configuration
224 dnl #
225 AC_DEFUN([SPL_AC_CONFIG_USER], [])
226
227 dnl #
228 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
229 dnl # are missing, it is non-fatal, but you will not be able to build
230 dnl # RPM packages and will be warned if you try too.
231 dnl #
232 dnl # By default, the generic spec file will be used because it requires
233 dnl # minimal dependencies. Distribution specific spec files can be
234 dnl # placed under the 'rpm/<distribution>' directory and enabled using
235 dnl # the --with-spec=<distribution> configure option.
236 dnl #
237 AC_DEFUN([SPL_AC_RPM], [
238 RPM=rpm
239 RPMBUILD=rpmbuild
240
241 AC_MSG_CHECKING([whether $RPM is available])
242 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
243 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
244 HAVE_RPM=yes
245 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
246 ],[
247 HAVE_RPM=no
248 AC_MSG_RESULT([$HAVE_RPM])
249 ])
250
251 AC_MSG_CHECKING([whether $RPMBUILD is available])
252 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
253 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
254 HAVE_RPMBUILD=yes
255 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
256 ],[
257 HAVE_RPMBUILD=no
258 AC_MSG_RESULT([$HAVE_RPMBUILD])
259 ])
260
261 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
262 RPM_DEFINE_UTIL=
263 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
264 RPM_DEFINE_DKMS=
265
266 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
267 SRPM_DEFINE_UTIL=
268 SRPM_DEFINE_KMOD=
269 SRPM_DEFINE_DKMS=
270
271 RPM_SPEC_DIR="rpm/generic"
272 AC_ARG_WITH([spec],
273 AS_HELP_STRING([--with-spec=SPEC],
274 [Spec files 'generic|fedora']),
275 [RPM_SPEC_DIR="rpm/$withval"])
276
277 AC_MSG_CHECKING([whether spec files are available])
278 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
279
280 AC_SUBST(HAVE_RPM)
281 AC_SUBST(RPM)
282 AC_SUBST(RPM_VERSION)
283
284 AC_SUBST(HAVE_RPMBUILD)
285 AC_SUBST(RPMBUILD)
286 AC_SUBST(RPMBUILD_VERSION)
287
288 AC_SUBST(RPM_SPEC_DIR)
289 AC_SUBST(RPM_DEFINE_UTIL)
290 AC_SUBST(RPM_DEFINE_KMOD)
291 AC_SUBST(RPM_DEFINE_DKMS)
292 AC_SUBST(RPM_DEFINE_COMMON)
293 AC_SUBST(SRPM_DEFINE_UTIL)
294 AC_SUBST(SRPM_DEFINE_KMOD)
295 AC_SUBST(SRPM_DEFINE_DKMS)
296 AC_SUBST(SRPM_DEFINE_COMMON)
297 ])
298
299 dnl #
300 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
301 dnl # tools are missing it is non-fatal but you will not be able to build
302 dnl # DEB packages and will be warned if you try too.
303 dnl #
304 AC_DEFUN([SPL_AC_DPKG], [
305 DPKG=dpkg
306 DPKGBUILD=dpkg-buildpackage
307
308 AC_MSG_CHECKING([whether $DPKG is available])
309 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
310 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
311 HAVE_DPKG=yes
312 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
313 ],[
314 HAVE_DPKG=no
315 AC_MSG_RESULT([$HAVE_DPKG])
316 ])
317
318 AC_MSG_CHECKING([whether $DPKGBUILD is available])
319 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
320 DPKGBUILD_VERSION=$(echo $tmp | \
321 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
322 HAVE_DPKGBUILD=yes
323 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
324 ],[
325 HAVE_DPKGBUILD=no
326 AC_MSG_RESULT([$HAVE_DPKGBUILD])
327 ])
328
329 AC_SUBST(HAVE_DPKG)
330 AC_SUBST(DPKG)
331 AC_SUBST(DPKG_VERSION)
332
333 AC_SUBST(HAVE_DPKGBUILD)
334 AC_SUBST(DPKGBUILD)
335 AC_SUBST(DPKGBUILD_VERSION)
336 ])
337
338 dnl #
339 dnl # Until native packaging for various different packing systems
340 dnl # can be added the least we can do is attempt to use alien to
341 dnl # convert the RPM packages to the needed package type. This is
342 dnl # a hack but so far it has worked reasonable well.
343 dnl #
344 AC_DEFUN([SPL_AC_ALIEN], [
345 ALIEN=alien
346
347 AC_MSG_CHECKING([whether $ALIEN is available])
348 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
349 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
350 HAVE_ALIEN=yes
351 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
352 ],[
353 HAVE_ALIEN=no
354 AC_MSG_RESULT([$HAVE_ALIEN])
355 ])
356
357 AC_SUBST(HAVE_ALIEN)
358 AC_SUBST(ALIEN)
359 AC_SUBST(ALIEN_VERSION)
360 ])
361
362 dnl #
363 dnl # Using the VENDOR tag from config.guess set the default
364 dnl # package type for 'make pkg': (rpm | deb | tgz)
365 dnl #
366 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
367 AC_MSG_CHECKING([linux distribution])
368 if test -f /etc/toss-release ; then
369 VENDOR=toss ;
370 elif test -f /etc/fedora-release ; then
371 VENDOR=fedora ;
372 elif test -f /etc/redhat-release ; then
373 VENDOR=redhat ;
374 elif test -f /etc/gentoo-release ; then
375 VENDOR=gentoo ;
376 elif test -f /etc/arch-release ; then
377 VENDOR=arch ;
378 elif test -f /etc/SuSE-release ; then
379 VENDOR=sles ;
380 elif test -f /etc/slackware-version ; then
381 VENDOR=slackware ;
382 elif test -f /etc/lunar.release ; then
383 VENDOR=lunar ;
384 elif test -f /etc/lsb-release ; then
385 VENDOR=ubuntu ;
386 elif test -f /etc/debian_version ; then
387 VENDOR=debian ;
388 else
389 VENDOR= ;
390 fi
391 AC_MSG_RESULT([$VENDOR])
392 AC_SUBST(VENDOR)
393
394 AC_MSG_CHECKING([default package type])
395 case "$VENDOR" in
396 toss) DEFAULT_PACKAGE=rpm ;;
397 redhat) DEFAULT_PACKAGE=rpm ;;
398 fedora) DEFAULT_PACKAGE=rpm ;;
399 gentoo) DEFAULT_PACKAGE=tgz ;;
400 arch) DEFAULT_PACKAGE=tgz ;;
401 sles) DEFAULT_PACKAGE=rpm ;;
402 slackware) DEFAULT_PACKAGE=tgz ;;
403 lunar) DEFAULT_PACKAGE=tgz ;;
404 ubuntu) DEFAULT_PACKAGE=deb ;;
405 debian) DEFAULT_PACKAGE=deb ;;
406 *) DEFAULT_PACKAGE=rpm ;;
407 esac
408
409 AC_MSG_RESULT([$DEFAULT_PACKAGE])
410 AC_SUBST(DEFAULT_PACKAGE)
411 ])
412
413 dnl #
414 dnl # Default SPL user configuration
415 dnl #
416 AC_DEFUN([SPL_AC_PACKAGE], [
417 SPL_AC_DEFAULT_PACKAGE
418 SPL_AC_RPM
419 SPL_AC_DPKG
420 SPL_AC_ALIEN
421 ])
422
423 AC_DEFUN([SPL_AC_LICENSE], [
424 AC_MSG_CHECKING([spl author])
425 AC_MSG_RESULT([$SPL_META_AUTHOR])
426
427 AC_MSG_CHECKING([spl license])
428 AC_MSG_RESULT([$SPL_META_LICENSE])
429 ])
430
431 AC_DEFUN([SPL_AC_CONFIG], [
432 SPL_CONFIG=all
433 AC_ARG_WITH([config],
434 AS_HELP_STRING([--with-config=CONFIG],
435 [Config file 'kernel|user|all|srpm']),
436 [SPL_CONFIG="$withval"])
437 AC_ARG_ENABLE([linux-builtin],
438 [AC_HELP_STRING([--enable-linux-builtin],
439 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
440 [],
441 [enable_linux_builtin=no])
442
443 AC_MSG_CHECKING([spl config])
444 AC_MSG_RESULT([$SPL_CONFIG]);
445 AC_SUBST(SPL_CONFIG)
446
447 case "$SPL_CONFIG" in
448 kernel) SPL_AC_CONFIG_KERNEL ;;
449 user) SPL_AC_CONFIG_USER ;;
450 all) SPL_AC_CONFIG_KERNEL
451 SPL_AC_CONFIG_USER ;;
452 srpm) ;;
453 *)
454 AC_MSG_RESULT([Error!])
455 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
456 user kernel|user|all|srpm]) ;;
457 esac
458
459 AM_CONDITIONAL([CONFIG_USER],
460 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
461 AM_CONDITIONAL([CONFIG_KERNEL],
462 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
463 [test "x$enable_linux_builtin" != xyes ])
464 ])
465
466 dnl #
467 dnl # Enable if the SPL should be compiled with internal debugging enabled.
468 dnl # By default this support is disabled.
469 dnl #
470 AC_DEFUN([SPL_AC_DEBUG], [
471 AC_MSG_CHECKING([whether debugging is enabled])
472 AC_ARG_ENABLE([debug],
473 [AS_HELP_STRING([--enable-debug],
474 [Enable generic debug support @<:@default=no@:>@])],
475 [],
476 [enable_debug=no])
477
478 AS_IF([test "x$enable_debug" = xyes],
479 [
480 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
481 DEBUG_CFLAGS="-DDEBUG -Werror"
482 DEBUG_SPL="_with_debug"
483 ], [
484 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
485 DEBUG_CFLAGS="-DNDEBUG"
486 DEBUG_SPL="_without_debug"
487 ])
488
489 AC_SUBST(DEBUG_CFLAGS)
490 AC_SUBST(DEBUG_SPL)
491 AC_MSG_RESULT([$enable_debug])
492 ])
493
494 dnl #
495 dnl # Enabled by default it provides a basic debug log infrastructure.
496 dnl # Each subsystem registers itself with a name and logs messages
497 dnl # using predefined types. If the debug mask it set to allow the
498 dnl # message type it will be written to the internal log. The log
499 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
500 dnl # after dumping the log it must be decoded using the spl utility.
501 dnl #
502 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
503 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
504 dnl #
505 AC_DEFUN([SPL_AC_DEBUG_LOG], [
506 AC_ARG_ENABLE([debug-log],
507 [AS_HELP_STRING([--enable-debug-log],
508 [Enable basic debug logging @<:@default=yes@:>@])],
509 [],
510 [enable_debug_log=yes])
511
512 AS_IF([test "x$enable_debug_log" = xyes],
513 [
514 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
515 DEBUG_LOG="_with_debug_log"
516 AC_DEFINE([DEBUG_LOG], [1],
517 [Define to 1 to enable basic debug logging])
518 ], [
519 DEBUG_LOG="_without_debug_log"
520 ])
521
522 AC_SUBST(DEBUG_LOG)
523 AC_MSG_CHECKING([whether basic debug logging is enabled])
524 AC_MSG_RESULT([$enable_debug_log])
525 ])
526
527 dnl #
528 dnl # Enabled by default it provides a minimal level of memory tracking.
529 dnl # A total count of bytes allocated is kept for each alloc and free.
530 dnl # Then at module unload time a report to the console will be printed
531 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
532 dnl # and provide an easy way to inspect the kmem based slab.
533 dnl #
534 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
535 AC_ARG_ENABLE([debug-kmem],
536 [AS_HELP_STRING([--enable-debug-kmem],
537 [Enable basic kmem accounting @<:@default=yes@:>@])],
538 [],
539 [enable_debug_kmem=yes])
540
541 AS_IF([test "x$enable_debug_kmem" = xyes],
542 [
543 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
544 DEBUG_KMEM="_with_debug_kmem"
545 AC_DEFINE([DEBUG_KMEM], [1],
546 [Define to 1 to enable basic kmem accounting])
547 ], [
548 DEBUG_KMEM="_without_debug_kmem"
549 ])
550
551 AC_SUBST(DEBUG_KMEM)
552 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
553 AC_MSG_RESULT([$enable_debug_kmem])
554 ])
555
556 dnl #
557 dnl # Disabled by default it provides detailed memory tracking. This
558 dnl # feature also requires --enable-debug-kmem to be set. When enabled
559 dnl # not only will total bytes be tracked but also the location of every
560 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
561 dnl # addresses and where they were allocated will be dumped to the console.
562 dnl # Enabling this feature has a significant impact on performance but it
563 dnl # makes finding memory leaks pretty straight forward.
564 dnl #
565 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
566 AC_ARG_ENABLE([debug-kmem-tracking],
567 [AS_HELP_STRING([--enable-debug-kmem-tracking],
568 [Enable detailed kmem tracking @<:@default=no@:>@])],
569 [],
570 [enable_debug_kmem_tracking=no])
571
572 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
573 [
574 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
575 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
576 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
577 [Define to 1 to enable detailed kmem tracking])
578 ], [
579 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
580 ])
581
582 AC_SUBST(DEBUG_KMEM_TRACKING)
583 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
584 AC_MSG_RESULT([$enable_debug_kmem_tracking])
585 ])
586
587 dnl #
588 dnl # SPL_LINUX_CONFTEST
589 dnl #
590 AC_DEFUN([SPL_LINUX_CONFTEST], [
591 cat confdefs.h - <<_ACEOF >conftest.c
592 $1
593 _ACEOF
594 ])
595
596 dnl #
597 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
598 dnl #
599 m4_define([SPL_LANG_PROGRAM], [
600 $1
601 int
602 main (void)
603 {
604 dnl Do *not* indent the following line: there may be CPP directives.
605 dnl Don't move the `;' right after for the same reason.
606 $2
607 ;
608 return 0;
609 }
610 ])
611
612 dnl #
613 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
614 dnl #
615 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
616 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
617 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
618 echo "obj-m := conftest.o" >build/Makefile
619 modpost_flag=''
620 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
621 AS_IF(
622 [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])],
623 [$4],
624 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
625 )
626 rm -Rf build
627 ])
628
629 dnl #
630 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
631 dnl #
632 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
633 [SPL_LINUX_COMPILE_IFELSE(
634 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
635 [modules],
636 [test -s build/conftest.o],
637 [$3], [$4])
638 ])
639
640 dnl #
641 dnl # SPL_CHECK_SYMBOL_EXPORT
642 dnl # check symbol exported or not
643 dnl #
644 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
645 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
646 $LINUX_OBJ/Module*.symvers 2>/dev/null
647 rc=$?
648 if test $rc -ne 0; then
649 export=0
650 for file in $2; do
651 grep -q -E "EXPORT_SYMBOL.*($1)" \
652 "$LINUX_OBJ/$file" 2>/dev/null
653 rc=$?
654 if test $rc -eq 0; then
655 export=1
656 break;
657 fi
658 done
659 if test $export -eq 0; then :
660 $4
661 else :
662 $3
663 fi
664 else :
665 $3
666 fi
667 ])
668
669 dnl #
670 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
671 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
672 dnl # is called if not compiling for builtin
673 dnl #
674 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
675 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
676 if test $rc -ne 0; then :
677 $6
678 else
679 if test "x$enable_linux_builtin" != xyes; then
680 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
681 fi
682 if test $rc -ne 0; then :
683 $6
684 else :
685 $5
686 fi
687 fi
688 ])
689
690 dnl #
691 dnl # SPL_CHECK_SYMBOL_HEADER
692 dnl # check if a symbol prototype is defined in listed headers.
693 dnl #
694 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
695 AC_MSG_CHECKING([whether symbol $1 exists in header])
696 header=0
697 for file in $3; do
698 grep -q "$2" "$LINUX/$file" 2>/dev/null
699 rc=$?
700 if test $rc -eq 0; then
701 header=1
702 break;
703 fi
704 done
705 if test $header -eq 0; then
706 AC_MSG_RESULT([no])
707 $5
708 else
709 AC_MSG_RESULT([yes])
710 $4
711 fi
712 ])
713
714 dnl #
715 dnl # SPL_CHECK_HEADER
716 dnl # check whether header exists and define HAVE_$2_HEADER
717 dnl #
718 AC_DEFUN([SPL_CHECK_HEADER],
719 [AC_MSG_CHECKING([whether header $1 exists])
720 SPL_LINUX_TRY_COMPILE([
721 #include <$1>
722 ],[
723 return 0;
724 ],[
725 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
726 AC_MSG_RESULT(yes)
727 $3
728 ],[
729 AC_MSG_RESULT(no)
730 $4
731 ])
732 ])
733
734 dnl #
735 dnl # Basic toolchain sanity check. Verify that kernel modules can
736 dnl # be built and which symbols can be used.
737 dnl #
738 AC_DEFUN([SPL_AC_TEST_MODULE],
739 [AC_MSG_CHECKING([whether modules can be built])
740 SPL_LINUX_TRY_COMPILE([],[],[
741 AC_MSG_RESULT([yes])
742 ],[
743 AC_MSG_RESULT([no])
744 if test "x$enable_linux_builtin" != xyes; then
745 AC_MSG_ERROR([*** Unable to build an empty module.])
746 else
747 AC_MSG_ERROR([
748 *** Unable to build an empty module.
749 *** Please run 'make scripts' inside the kernel source tree.])
750 fi
751 ])
752
753 AC_RUN_IFELSE([
754 AC_LANG_PROGRAM([
755 #include "$LINUX/include/linux/license.h"
756 ], [
757 return !license_is_gpl_compatible("$SPL_META_LICENSE");
758 ])
759 ], [
760 AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1],
761 [Define to 1 if GPL-only symbols can be used])
762 ], [
763 ])
764 ])
765
766 dnl #
767 dnl # Use the atomic implemenation based on global spinlocks. This
768 dnl # should only be needed by 32-bit kernels which do not provide
769 dnl # the atomic64_* API. It may be optionally enabled as a fallback
770 dnl # if problems are observed with the direct mapping to the native
771 dnl # Linux atomic operations. You may not disable atomic spinlocks
772 dnl # if you kernel does not an atomic64_* API.
773 dnl #
774 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
775 AC_ARG_ENABLE([atomic-spinlocks],
776 [AS_HELP_STRING([--enable-atomic-spinlocks],
777 [Atomic types use spinlocks @<:@default=check@:>@])],
778 [],
779 [enable_atomic_spinlocks=check])
780
781 SPL_LINUX_TRY_COMPILE([
782 #include <linux/fs.h>
783 ],[
784 atomic64_t *ptr __attribute__ ((unused));
785 ],[
786 have_atomic64_t=yes
787 AC_DEFINE(HAVE_ATOMIC64_T, 1,
788 [kernel defines atomic64_t])
789 ],[
790 have_atomic64_t=no
791 ])
792
793 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
794 AS_IF([test "x$have_atomic64_t" = xyes], [
795 enable_atomic_spinlocks=no
796 ],[
797 enable_atomic_spinlocks=yes
798 ])
799 ])
800
801 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
802 AC_DEFINE([ATOMIC_SPINLOCK], [1],
803 [Atomic types use spinlocks])
804 ],[
805 AS_IF([test "x$have_atomic64_t" = xno], [
806 AC_MSG_FAILURE(
807 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
808 ])
809 ])
810
811 AC_MSG_CHECKING([whether atomic types use spinlocks])
812 AC_MSG_RESULT([$enable_atomic_spinlocks])
813
814 AC_MSG_CHECKING([whether kernel defines atomic64_t])
815 AC_MSG_RESULT([$have_atomic64_t])
816 ])
817
818 dnl #
819 dnl # 2.6.24 API change,
820 dnl # check if atomic64_cmpxchg is defined
821 dnl #
822 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
823 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
824 SPL_LINUX_TRY_COMPILE([
825 #include <linux/fs.h>
826 ],[
827 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
828 ],[
829 AC_MSG_RESULT([yes])
830 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
831 [kernel defines atomic64_cmpxchg])
832 ],[
833 AC_MSG_RESULT([no])
834 ])
835 ])
836
837 dnl #
838 dnl # 2.6.24 API change,
839 dnl # check if atomic64_xchg is defined
840 dnl #
841 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
842 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
843 SPL_LINUX_TRY_COMPILE([
844 #include <linux/fs.h>
845 ],[
846 atomic64_xchg((atomic64_t *)NULL, 0);
847 ],[
848 AC_MSG_RESULT([yes])
849 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
850 [kernel defines atomic64_xchg])
851 ],[
852 AC_MSG_RESULT([no])
853 ])
854 ])
855
856 dnl #
857 dnl # 2.6.24 API change,
858 dnl # check if uintptr_t typedef is defined
859 dnl #
860 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
861 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
862 SPL_LINUX_TRY_COMPILE([
863 #include <linux/types.h>
864 ],[
865 uintptr_t *ptr __attribute__ ((unused));
866 ],[
867 AC_MSG_RESULT([yes])
868 AC_DEFINE(HAVE_UINTPTR_T, 1,
869 [kernel defines uintptr_t])
870 ],[
871 AC_MSG_RESULT([no])
872 ])
873 ])
874
875 dnl #
876 dnl # 2.6.21 API change,
877 dnl # 'register_sysctl_table' use only one argument instead of two
878 dnl #
879 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
880 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
881 SPL_LINUX_TRY_COMPILE([
882 #include <linux/sysctl.h>
883 ],[
884 (void) register_sysctl_table(NULL, 0);
885 ],[
886 AC_MSG_RESULT(yes)
887 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
888 [register_sysctl_table() wants 2 args])
889 ],[
890 AC_MSG_RESULT(no)
891 ])
892 ])
893
894 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
895 tmp_flags="$EXTRA_KCFLAGS"
896 EXTRA_KCFLAGS="-Werror"
897 dnl #
898 dnl # 2.6.23 to 2.6.34 API change
899 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
900 dnl #
901 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
902 SPL_LINUX_TRY_COMPILE([
903 #include <linux/mm.h>
904
905 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
906 ],[
907 struct shrinker cache_shrinker = {
908 .shrink = shrinker_cb,
909 .seeks = DEFAULT_SEEKS,
910 };
911 register_shrinker(&cache_shrinker);
912 ],[
913 AC_MSG_RESULT(yes)
914 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
915 [old shrinker callback wants 2 args])
916 ],[
917 AC_MSG_RESULT(no)
918 dnl #
919 dnl # 2.6.35 - 2.6.39 API change
920 dnl # ->shrink(struct shrinker *,
921 dnl # int nr_to_scan, gfp_t gfp_mask)
922 dnl #
923 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
924 SPL_LINUX_TRY_COMPILE([
925 #include <linux/mm.h>
926
927 int shrinker_cb(struct shrinker *, int nr_to_scan,
928 gfp_t gfp_mask);
929 ],[
930 struct shrinker cache_shrinker = {
931 .shrink = shrinker_cb,
932 .seeks = DEFAULT_SEEKS,
933 };
934 register_shrinker(&cache_shrinker);
935 ],[
936 AC_MSG_RESULT(yes)
937 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
938 [old shrinker callback wants 3 args])
939 ],[
940 AC_MSG_RESULT(no)
941 dnl #
942 dnl # 3.0 - 3.11 API change
943 dnl # ->shrink(struct shrinker *,
944 dnl # struct shrink_control *sc)
945 dnl #
946 AC_MSG_CHECKING(
947 [whether new 2-argument shrinker exists])
948 SPL_LINUX_TRY_COMPILE([
949 #include <linux/mm.h>
950
951 int shrinker_cb(struct shrinker *,
952 struct shrink_control *sc);
953 ],[
954 struct shrinker cache_shrinker = {
955 .shrink = shrinker_cb,
956 .seeks = DEFAULT_SEEKS,
957 };
958 register_shrinker(&cache_shrinker);
959 ],[
960 AC_MSG_RESULT(yes)
961 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
962 [new shrinker callback wants 2 args])
963 ],[
964 AC_MSG_RESULT(no)
965 dnl #
966 dnl # 3.12 API change,
967 dnl # ->shrink() is logically split in to
968 dnl # ->count_objects() and ->scan_objects()
969 dnl #
970 AC_MSG_CHECKING(
971 [whether ->count_objects callback exists])
972 SPL_LINUX_TRY_COMPILE([
973 #include <linux/mm.h>
974
975 unsigned long shrinker_cb(
976 struct shrinker *,
977 struct shrink_control *sc);
978 ],[
979 struct shrinker cache_shrinker = {
980 .count_objects = shrinker_cb,
981 .scan_objects = shrinker_cb,
982 .seeks = DEFAULT_SEEKS,
983 };
984 register_shrinker(&cache_shrinker);
985 ],[
986 AC_MSG_RESULT(yes)
987 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
988 1, [->count_objects exists])
989 ],[
990 AC_MSG_ERROR(error)
991 ])
992 ])
993 ])
994 ])
995 EXTRA_KCFLAGS="$tmp_flags"
996 ])
997
998 dnl #
999 dnl # 2.6.19 API change,
1000 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1001 dnl #
1002 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1003 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1004 SPL_LINUX_TRY_COMPILE([
1005 #include <linux/sysctl.h>
1006 ],[
1007 #ifndef CTL_UNNUMBERED
1008 #error CTL_UNNUMBERED undefined
1009 #endif
1010 ],[
1011 AC_MSG_RESULT(yes)
1012 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1013 [unnumbered sysctl support exists])
1014 ],[
1015 AC_MSG_RESULT(no)
1016 ])
1017 ])
1018
1019 dnl #
1020 dnl # 2.6.33 API change,
1021 dnl # Removed .ctl_name from struct ctl_table.
1022 dnl #
1023 AC_DEFUN([SPL_AC_CTL_NAME], [
1024 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1025 SPL_LINUX_TRY_COMPILE([
1026 #include <linux/sysctl.h>
1027 ],[
1028 struct ctl_table ctl __attribute__ ((unused));
1029 ctl.ctl_name = 0;
1030 ],[
1031 AC_MSG_RESULT(yes)
1032 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1033 ],[
1034 AC_MSG_RESULT(no)
1035 ])
1036 ])
1037
1038 dnl #
1039 dnl # 2.6.16 API change.
1040 dnl # Check if 'fls64()' is available
1041 dnl #
1042 AC_DEFUN([SPL_AC_FLS64],
1043 [AC_MSG_CHECKING([whether fls64() is available])
1044 SPL_LINUX_TRY_COMPILE([
1045 #include <linux/bitops.h>
1046 ],[
1047 return fls64(0);
1048 ],[
1049 AC_MSG_RESULT(yes)
1050 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1051 ],[
1052 AC_MSG_RESULT(no)
1053 ])
1054 ])
1055
1056 dnl #
1057 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1058 dnl #
1059 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1060 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1061 SPL_LINUX_TRY_COMPILE_SYMBOL([
1062 #include <linux/time.h>
1063 ], [
1064 set_normalized_timespec(NULL, 0, 0);
1065 ], [set_normalized_timespec], [kernel/time.c], [
1066 AC_MSG_RESULT(yes)
1067 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1068 [set_normalized_timespec() is available as export])
1069 ], [
1070 AC_MSG_RESULT(no)
1071 ])
1072 ])
1073
1074 dnl #
1075 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1076 dnl # previously it was available in time.h as an inline.
1077 dnl #
1078 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1079 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1080 SPL_LINUX_TRY_COMPILE([
1081 #include <linux/time.h>
1082 void set_normalized_timespec(struct timespec *ts,
1083 time_t sec, long nsec) { }
1084 ],
1085 [],
1086 [
1087 AC_MSG_RESULT(no)
1088 ],[
1089 AC_MSG_RESULT(yes)
1090 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1091 [set_normalized_timespec() is available as inline])
1092 ])
1093 ])
1094
1095 dnl #
1096 dnl # 2.6.18 API change,
1097 dnl # timespec_sub() inline function available in linux/time.h
1098 dnl #
1099 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1100 AC_MSG_CHECKING([whether timespec_sub() is available])
1101 SPL_LINUX_TRY_COMPILE([
1102 #include <linux/time.h>
1103 ],[
1104 struct timespec a = { 0 };
1105 struct timespec b = { 0 };
1106 struct timespec c __attribute__ ((unused));
1107 c = timespec_sub(a, b);
1108 ],[
1109 AC_MSG_RESULT(yes)
1110 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1111 ],[
1112 AC_MSG_RESULT(no)
1113 ])
1114 ])
1115
1116 dnl #
1117 dnl # 2.6.18 API change,
1118 dnl # added linux/uaccess.h
1119 dnl #
1120 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1121 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1122 ])
1123
1124 dnl #
1125 dnl # 2.6.12 API change,
1126 dnl # check whether 'kmalloc_node()' is available.
1127 dnl #
1128 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1129 AC_MSG_CHECKING([whether kmalloc_node() is available])
1130 SPL_LINUX_TRY_COMPILE([
1131 #include <linux/slab.h>
1132 ],[
1133 void *a __attribute__ ((unused));
1134 a = kmalloc_node(1, GFP_KERNEL, 0);
1135 ],[
1136 AC_MSG_RESULT(yes)
1137 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1138 ],[
1139 AC_MSG_RESULT(no)
1140 ])
1141 ])
1142
1143 dnl #
1144 dnl # 2.6.9 API change,
1145 dnl # check whether 'monotonic_clock()' is available it may
1146 dnl # be available for some archs but not others.
1147 dnl #
1148 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1149 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1150 SPL_LINUX_TRY_COMPILE_SYMBOL([
1151 #include <linux/timex.h>
1152 ], [
1153 monotonic_clock();
1154 ], [monotonic_clock], [], [
1155 AC_MSG_RESULT(yes)
1156 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1157 [monotonic_clock() is available])
1158 ], [
1159 AC_MSG_RESULT(no)
1160 ])
1161 ])
1162
1163 dnl #
1164 dnl # 2.6.16 API change,
1165 dnl # check whether 'struct inode' has i_mutex
1166 dnl #
1167 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1168 AC_MSG_CHECKING([whether struct inode has i_mutex])
1169 SPL_LINUX_TRY_COMPILE([
1170 #include <linux/fs.h>
1171 #include <linux/mutex.h>
1172 ],[
1173 struct inode i;
1174 mutex_init(&i.i_mutex);
1175 ],[
1176 AC_MSG_RESULT(yes)
1177 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1178 ],[
1179 AC_MSG_RESULT(no)
1180 ])
1181 ])
1182
1183 dnl #
1184 dnl # 2.6.29 API change,
1185 dnl # Adaptive mutexs were introduced which track the mutex owner. The
1186 dnl # mutex wrappers leverage this functionality to avoid tracking the
1187 dnl # owner multipe times.
1188 dnl #
1189 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1190 AC_MSG_CHECKING([whether struct mutex has owner])
1191 SPL_LINUX_TRY_COMPILE([
1192 #include <linux/mutex.h>
1193 ],[
1194 struct mutex mtx __attribute__ ((unused));
1195 mtx.owner = NULL;
1196 ],[
1197 AC_MSG_RESULT(yes)
1198 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1199 ],[
1200 AC_MSG_RESULT(no)
1201 ])
1202 ])
1203
1204 dnl #
1205 dnl # 2.6.39 API change,
1206 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1207 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1208 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1209 dnl # pointer which frankly makes a lot more sense.
1210 dnl #
1211 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1212 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1213 tmp_flags="$EXTRA_KCFLAGS"
1214 EXTRA_KCFLAGS="-Werror"
1215 SPL_LINUX_TRY_COMPILE([
1216 #include <linux/mutex.h>
1217 #include <linux/sched.h>
1218 ],[
1219 struct mutex mtx __attribute__ ((unused));
1220 mtx.owner = current;
1221 ],[
1222 AC_MSG_RESULT(yes)
1223 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1224 [struct mutex owner is a task_struct])
1225 ],[
1226 AC_MSG_RESULT(no)
1227 ])
1228 EXTRA_KCFLAGS="$tmp_flags"
1229 ])
1230
1231 dnl #
1232 dnl # 2.6.18 API change,
1233 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1234 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1235 dnl # if the mutex validator is disabled or otherwise unavailable.
1236 dnl #
1237 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1238 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1239 SPL_LINUX_TRY_COMPILE([
1240 #include <linux/mutex.h>
1241 ],[
1242 struct mutex mutex;
1243 mutex_init(&mutex);
1244 mutex_lock_nested(&mutex, 0);
1245 ],[
1246 AC_MSG_RESULT(yes)
1247 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1248 [mutex_lock_nested() is available])
1249 ],[
1250 AC_MSG_RESULT(no)
1251 ])
1252 ])
1253
1254 dnl #
1255 dnl # 2.6.27 API change,
1256 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1257 dnl #
1258 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1259 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1260 SPL_LINUX_TRY_COMPILE([
1261 #include <linux/interrupt.h>
1262 #include <linux/smp.h>
1263
1264 void on_each_cpu_func(void *data) { return; }
1265 ],[
1266 on_each_cpu(on_each_cpu_func, NULL, 0);
1267 ],[
1268 AC_MSG_RESULT(yes)
1269 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1270 [on_each_cpu wants 3 args])
1271 ],[
1272 AC_MSG_RESULT(no)
1273 ])
1274 ])
1275
1276 dnl #
1277 dnl # 2.6.18 API change,
1278 dnl # kallsyms_lookup_name no longer exported
1279 dnl #
1280 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1281 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1282 SPL_LINUX_TRY_COMPILE_SYMBOL([
1283 #include <linux/kallsyms.h>
1284 ], [
1285 kallsyms_lookup_name(NULL);
1286 ], [kallsyms_lookup_name], [], [
1287 AC_MSG_RESULT(yes)
1288 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1289 [kallsyms_lookup_name() is available])
1290 ], [
1291 AC_MSG_RESULT(no)
1292 ])
1293 ])
1294
1295 dnl #
1296 dnl # Proposed API change,
1297 dnl # This symbol is not available in stock kernels. You may build a
1298 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1299 dnl # these symbols for use. If your already rolling a custom kernel for
1300 dnl # your environment this is recommended.
1301 dnl #
1302 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1303 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1304 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1305 AC_MSG_RESULT(yes)
1306 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1307 [get_vmalloc_info() is available])
1308 ], [
1309 AC_MSG_RESULT(no)
1310 ])
1311 ])
1312
1313 dnl #
1314 dnl # 3.10 API change,
1315 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1316 dnl #
1317 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1318 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1319 SPL_LINUX_TRY_COMPILE([
1320 #include <linux/vmalloc.h>
1321 struct vmalloc_info { void *a; };
1322 ],[
1323 return 0;
1324 ],[
1325 AC_MSG_RESULT(no)
1326 ],[
1327 AC_MSG_RESULT(yes)
1328 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1329 ])
1330 ])
1331
1332 dnl #
1333 dnl # 3.10 API change,
1334 dnl # PDE is replaced by PDE_DATA
1335 dnl #
1336 AC_DEFUN([SPL_AC_PDE_DATA], [
1337 AC_MSG_CHECKING([whether PDE_DATA() is available])
1338 SPL_LINUX_TRY_COMPILE_SYMBOL([
1339 #include <linux/proc_fs.h>
1340 ], [
1341 PDE_DATA(NULL);
1342 ], [PDE_DATA], [], [
1343 AC_MSG_RESULT(yes)
1344 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1345 ],[
1346 AC_MSG_RESULT(no)
1347 ])
1348 ])
1349
1350 dnl #
1351 dnl # 2.6.17 API change
1352 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1353 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1354 dnl # were exported in 2.6.17 for use by modules which was consistent with
1355 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1356 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1357 dnl # were dropped entirely leaving modules no way to directly iterate over
1358 dnl # the zone list. Because we need access to the zone helpers we check
1359 dnl # if the kernel contains the old or new implementation. Then we check
1360 dnl # to see if the symbols we need for each version are available. If they
1361 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1362 dnl #
1363 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1364 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1365 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1366 rc=$?
1367 if test $rc -eq 0; then
1368 AC_MSG_RESULT([yes])
1369 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1370 else
1371 AC_MSG_RESULT([no])
1372 fi
1373 ])
1374
1375 dnl #
1376 dnl # Proposed API change,
1377 dnl # This symbol is not available in stock kernels. You may build a
1378 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1379 dnl # these symbols for use. If your already rolling a custom kernel for
1380 dnl # your environment this is recommended.
1381 dnl #
1382 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1383 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1384 SPL_LINUX_TRY_COMPILE_SYMBOL([
1385 #include <linux/mmzone.h>
1386 ], [
1387 first_online_pgdat();
1388 ], [first_online_pgdat], [], [
1389 AC_MSG_RESULT(yes)
1390 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1391 [first_online_pgdat() is available])
1392 ], [
1393 AC_MSG_RESULT(no)
1394 ])
1395 ])
1396
1397 dnl #
1398 dnl # Proposed API change,
1399 dnl # This symbol is not available in stock kernels. You may build a
1400 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1401 dnl # these symbols for use. If your already rolling a custom kernel for
1402 dnl # your environment this is recommended.
1403 dnl #
1404 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1405 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1406 SPL_LINUX_TRY_COMPILE_SYMBOL([
1407 #include <linux/mmzone.h>
1408 ], [
1409 next_online_pgdat(NULL);
1410 ], [next_online_pgdat], [], [
1411 AC_MSG_RESULT(yes)
1412 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1413 [next_online_pgdat() is available])
1414 ], [
1415 AC_MSG_RESULT(no)
1416 ])
1417 ])
1418
1419 dnl #
1420 dnl # Proposed API change,
1421 dnl # This symbol is not available in stock kernels. You may build a
1422 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1423 dnl # these symbols for use. If your already rolling a custom kernel for
1424 dnl # your environment this is recommended.
1425 dnl #
1426 AC_DEFUN([SPL_AC_NEXT_ZONE],
1427 [AC_MSG_CHECKING([whether next_zone() is available])
1428 SPL_LINUX_TRY_COMPILE_SYMBOL([
1429 #include <linux/mmzone.h>
1430 ], [
1431 next_zone(NULL);
1432 ], [next_zone], [], [
1433 AC_MSG_RESULT(yes)
1434 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1435 ], [
1436 AC_MSG_RESULT(no)
1437 ])
1438 ])
1439
1440 dnl #
1441 dnl # 2.6.17 API change,
1442 dnl # See SPL_AC_PGDAT_HELPERS for details.
1443 dnl #
1444 AC_DEFUN([SPL_AC_PGDAT_LIST],
1445 [AC_MSG_CHECKING([whether pgdat_list is available])
1446 SPL_LINUX_TRY_COMPILE_SYMBOL([
1447 #include <linux/topology.h>
1448 pg_data_t *tmp = pgdat_list;
1449 ], [], [pgdat_list], [], [
1450 AC_MSG_RESULT(yes)
1451 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1452 ], [
1453 AC_MSG_RESULT(no)
1454 ])
1455 ])
1456
1457 dnl #
1458 dnl # 2.6.18 API change,
1459 dnl # First introduced global_page_state() support as an inline.
1460 dnl #
1461 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1462 AC_MSG_CHECKING([whether global_page_state() is available])
1463 SPL_LINUX_TRY_COMPILE([
1464 #include <linux/mm.h>
1465 ],[
1466 unsigned long state __attribute__ ((unused));
1467 state = global_page_state(0);
1468 ],[
1469 AC_MSG_RESULT(yes)
1470 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1471 [global_page_state() is available])
1472 ],[
1473 AC_MSG_RESULT(no)
1474 ])
1475 ])
1476
1477 dnl #
1478 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1479 dnl # Public global zone stats now include a free page count. However
1480 dnl # the enumerated names of the counters have changed since this API
1481 dnl # was introduced. We need to deduce the corrent name to use. This
1482 dnl # replaces the priviate get_zone_counts() interface.
1483 dnl #
1484 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1485 dnl # is 2.6.30 as of when this was written.
1486 dnl #
1487 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1488 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1489 SPL_LINUX_TRY_COMPILE([
1490 #include <linux/mm.h>
1491 ],[
1492 enum zone_stat_item zsi __attribute__ ((unused));
1493 zsi = NR_FREE_PAGES;
1494 ],[
1495 AC_MSG_RESULT(yes)
1496 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1497 [Page state NR_FREE_PAGES is available])
1498 ],[
1499 AC_MSG_RESULT(no)
1500 ])
1501 ])
1502
1503 dnl #
1504 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1505 dnl # Public global zone stats now include an inactive page count. However
1506 dnl # the enumerated names of the counters have changed since this API
1507 dnl # was introduced. We need to deduce the corrent name to use. This
1508 dnl # replaces the priviate get_zone_counts() interface.
1509 dnl #
1510 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1511 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1512 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1513 dnl #
1514 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1515 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1516 SPL_LINUX_TRY_COMPILE([
1517 #include <linux/mm.h>
1518 ],[
1519 enum zone_stat_item zsi __attribute__ ((unused));
1520 zsi = NR_INACTIVE;
1521 ],[
1522 AC_MSG_RESULT(yes)
1523 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1524 [Page state NR_INACTIVE is available])
1525 ],[
1526 AC_MSG_RESULT(no)
1527 ])
1528
1529 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1530 SPL_LINUX_TRY_COMPILE([
1531 #include <linux/mm.h>
1532 ],[
1533 enum zone_stat_item zsi __attribute__ ((unused));
1534 zsi = NR_INACTIVE_ANON;
1535 ],[
1536 AC_MSG_RESULT(yes)
1537 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1538 [Page state NR_INACTIVE_ANON is available])
1539 ],[
1540 AC_MSG_RESULT(no)
1541 ])
1542
1543 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1544 SPL_LINUX_TRY_COMPILE([
1545 #include <linux/mm.h>
1546 ],[
1547 enum zone_stat_item zsi __attribute__ ((unused));
1548 zsi = NR_INACTIVE_FILE;
1549 ],[
1550 AC_MSG_RESULT(yes)
1551 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1552 [Page state NR_INACTIVE_FILE is available])
1553 ],[
1554 AC_MSG_RESULT(no)
1555 ])
1556 ])
1557
1558 dnl #
1559 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1560 dnl # Public global zone stats now include an active page count. However
1561 dnl # the enumerated names of the counters have changed since this API
1562 dnl # was introduced. We need to deduce the corrent name to use. This
1563 dnl # replaces the priviate get_zone_counts() interface.
1564 dnl #
1565 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1566 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1567 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1568 dnl #
1569 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1570 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1571 SPL_LINUX_TRY_COMPILE([
1572 #include <linux/mm.h>
1573 ],[
1574 enum zone_stat_item zsi __attribute__ ((unused));
1575 zsi = NR_ACTIVE;
1576 ],[
1577 AC_MSG_RESULT(yes)
1578 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1579 [Page state NR_ACTIVE is available])
1580 ],[
1581 AC_MSG_RESULT(no)
1582 ])
1583
1584 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1585 SPL_LINUX_TRY_COMPILE([
1586 #include <linux/mm.h>
1587 ],[
1588 enum zone_stat_item zsi __attribute__ ((unused));
1589 zsi = NR_ACTIVE_ANON;
1590 ],[
1591 AC_MSG_RESULT(yes)
1592 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1593 [Page state NR_ACTIVE_ANON is available])
1594 ],[
1595 AC_MSG_RESULT(no)
1596 ])
1597
1598 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1599 SPL_LINUX_TRY_COMPILE([
1600 #include <linux/mm.h>
1601 ],[
1602 enum zone_stat_item zsi __attribute__ ((unused));
1603 zsi = NR_ACTIVE_FILE;
1604 ],[
1605 AC_MSG_RESULT(yes)
1606 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1607 [Page state NR_ACTIVE_FILE is available])
1608 ],[
1609 AC_MSG_RESULT(no)
1610 ])
1611 ])
1612
1613 dnl #
1614 dnl # Proposed API change for legacy kernels.
1615 dnl # This symbol is not available in older kernels. For kernels post
1616 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1617 dnl # page state information. This symbol is only used in legacy kernels
1618 dnl # any only as a last resort.
1619 dnl
1620 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1621 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1622 SPL_LINUX_TRY_COMPILE([
1623 ],[
1624 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1625 #error "global_page_state needs NR_FREE_PAGES"
1626 #endif
1627
1628 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1629 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1630 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1631 #error "global_page_state needs NR_ACTIVE*"
1632 #endif
1633
1634 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1635 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1636 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1637 #error "global_page_state needs NR_INACTIVE*"
1638 #endif
1639 ],[
1640 AC_MSG_RESULT(no)
1641 ],[
1642 AC_MSG_RESULT(yes)
1643 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1644 [get_zone_counts() is needed])
1645
1646 AC_MSG_CHECKING([whether get_zone_counts() is available])
1647 SPL_LINUX_TRY_COMPILE_SYMBOL([
1648 #include <linux/mmzone.h>
1649 ], [
1650 get_zone_counts(NULL, NULL, NULL);
1651 ], [get_zone_counts], [], [
1652 AC_MSG_RESULT(yes)
1653 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1654 [get_zone_counts() is available])
1655 ], [
1656 AC_MSG_RESULT(no)
1657 ])
1658 ])
1659 ])
1660
1661 dnl #
1662 dnl # 2.6.27 API change,
1663 dnl # The user_path_dir() replaces __user_walk()
1664 dnl #
1665 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1666 [AC_MSG_CHECKING([whether user_path_dir() is available])
1667 SPL_LINUX_TRY_COMPILE_SYMBOL([
1668 #include <linux/fcntl.h>
1669 #include <linux/namei.h>
1670 ], [
1671 user_path_dir(NULL, NULL);
1672 ], [user_path_at], [], [
1673 AC_MSG_RESULT(yes)
1674 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1675 ], [
1676 AC_MSG_RESULT(no)
1677 ])
1678 ])
1679
1680 dnl #
1681 dnl # Symbol available in RHEL kernels not in stock kernels.
1682 dnl #
1683 AC_DEFUN([SPL_AC_SET_FS_PWD],
1684 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1685 SPL_LINUX_TRY_COMPILE_SYMBOL([
1686 #include <linux/spinlock.h>
1687 #include <linux/fs_struct.h>
1688 ], [
1689 (void) set_fs_pwd;
1690 ], [set_fs_pwd], [], [
1691 AC_MSG_RESULT(yes)
1692 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1693 ], [
1694 AC_MSG_RESULT(no)
1695 ])
1696 ])
1697
1698 dnl #
1699 dnl # 3.9 API change
1700 dnl # set_fs_pwd takes const struct path *
1701 dnl #
1702 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1703 tmp_flags="$EXTRA_KCFLAGS"
1704 EXTRA_KCFLAGS="-Werror"
1705 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1706 SPL_LINUX_TRY_COMPILE([
1707 #include <linux/spinlock.h>
1708 #include <linux/fs_struct.h>
1709 #include <linux/path.h>
1710 void (*const set_fs_pwd_func)
1711 (struct fs_struct *, const struct path *)
1712 = set_fs_pwd;
1713 ],[
1714 return 0;
1715 ],[
1716 AC_MSG_RESULT(yes)
1717 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1718 [set_fs_pwd() needs const path *])
1719 ],[
1720 SPL_LINUX_TRY_COMPILE([
1721 #include <linux/spinlock.h>
1722 #include <linux/fs_struct.h>
1723 #include <linux/path.h>
1724 void (*const set_fs_pwd_func)
1725 (struct fs_struct *, struct path *)
1726 = set_fs_pwd;
1727 ],[
1728 return 0;
1729 ],[
1730 AC_MSG_RESULT(no)
1731 ],[
1732 AC_MSG_ERROR(unknown)
1733 ])
1734 ])
1735 EXTRA_KCFLAGS="$tmp_flags"
1736 ])
1737
1738 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1739 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1740 SPL_LINUX_TRY_COMPILE([
1741 #include <linux/fs.h>
1742 ],[
1743 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1744 ],[
1745 AC_MSG_RESULT(yes)
1746 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1747 [vfs_unlink() wants 2 args])
1748 ],[
1749 AC_MSG_RESULT(no)
1750 dnl #
1751 dnl # Linux 3.13 API change
1752 dnl # Added delegated inode
1753 dnl #
1754 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1755 SPL_LINUX_TRY_COMPILE([
1756 #include <linux/fs.h>
1757 ],[
1758 vfs_unlink((struct inode *) NULL,
1759 (struct dentry *) NULL,
1760 (struct inode **) NULL);
1761 ],[
1762 AC_MSG_RESULT(yes)
1763 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1764 [vfs_unlink() wants 3 args])
1765 ],[
1766 AC_MSG_ERROR(no)
1767 ])
1768
1769 ])
1770 ])
1771
1772 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1773 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1774 SPL_LINUX_TRY_COMPILE([
1775 #include <linux/fs.h>
1776 ],[
1777 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1778 (struct inode *) NULL, (struct dentry *) NULL);
1779 ],[
1780 AC_MSG_RESULT(yes)
1781 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1782 [vfs_rename() wants 4 args])
1783 ],[
1784 AC_MSG_RESULT(no)
1785 dnl #
1786 dnl # Linux 3.13 API change
1787 dnl # Added delegated inode
1788 dnl #
1789 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1790 SPL_LINUX_TRY_COMPILE([
1791 #include <linux/fs.h>
1792 ],[
1793 vfs_rename((struct inode *) NULL,
1794 (struct dentry *) NULL,
1795 (struct inode *) NULL,
1796 (struct dentry *) NULL,
1797 (struct inode **) NULL);
1798 ],[
1799 AC_MSG_RESULT(yes)
1800 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1801 [vfs_rename() wants 5 args])
1802 ],[
1803 AC_MSG_RESULT(no)
1804 dnl #
1805 dnl # Linux 3.15 API change
1806 dnl # Added flags
1807 dnl #
1808 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1809 SPL_LINUX_TRY_COMPILE([
1810 #include <linux/fs.h>
1811 ],[
1812 vfs_rename((struct inode *) NULL,
1813 (struct dentry *) NULL,
1814 (struct inode *) NULL,
1815 (struct dentry *) NULL,
1816 (struct inode **) NULL,
1817 (unsigned int) 0);
1818 ],[
1819 AC_MSG_RESULT(yes)
1820 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1821 [vfs_rename() wants 6 args])
1822 ],[
1823 AC_MSG_ERROR(no)
1824 ])
1825 ])
1826 ])
1827 ])
1828
1829 dnl #
1830 dnl # 2.6.36 API change,
1831 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1832 dnl # a spinlock_t to improve the fastpath performance.
1833 dnl #
1834 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1835 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1836 tmp_flags="$EXTRA_KCFLAGS"
1837 EXTRA_KCFLAGS="-Werror"
1838 SPL_LINUX_TRY_COMPILE([
1839 #include <linux/sched.h>
1840 #include <linux/fs_struct.h>
1841 ],[
1842 struct fs_struct fs;
1843 spin_lock_init(&fs.lock);
1844 ],[
1845 AC_MSG_RESULT(yes)
1846 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1847 [struct fs_struct uses spinlock_t])
1848 ],[
1849 AC_MSG_RESULT(no)
1850 ])
1851 EXTRA_KCFLAGS="$tmp_flags"
1852 ])
1853
1854 dnl #
1855 dnl # 2.6.29 API change,
1856 dnl # check whether 'struct cred' exists
1857 dnl #
1858 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1859 AC_MSG_CHECKING([whether struct cred exists])
1860 SPL_LINUX_TRY_COMPILE([
1861 #include <linux/cred.h>
1862 ],[
1863 struct cred *cr __attribute__ ((unused));
1864 cr = NULL;
1865 ],[
1866 AC_MSG_RESULT(yes)
1867 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1868 ],[
1869 AC_MSG_RESULT(no)
1870 ])
1871 ])
1872
1873
1874 dnl #
1875 dnl # User namespaces, use kuid_t in place of uid_t
1876 dnl # where available. Not strictly a user namespaces thing
1877 dnl # but it should prevent surprises
1878 dnl #
1879 AC_DEFUN([SPL_AC_KUIDGID_T], [
1880 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1881 SPL_LINUX_TRY_COMPILE([
1882 #include <linux/uidgid.h>
1883 ], [
1884 kuid_t userid = KUIDT_INIT(0);
1885 kgid_t groupid = KGIDT_INIT(0);
1886 ],[
1887 SPL_LINUX_TRY_COMPILE([
1888 #include <linux/uidgid.h>
1889 ], [
1890 kuid_t userid = 0;
1891 kgid_t groupid = 0;
1892 ],[
1893 AC_MSG_RESULT(yes; optional)
1894 ],[
1895 AC_MSG_RESULT(yes; mandatory)
1896 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1897 ])
1898 ],[
1899 AC_MSG_RESULT(no)
1900 ])
1901 ])
1902
1903 dnl #
1904 dnl # Custom SPL patch may export this symbol.
1905 dnl #
1906 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1907 [AC_MSG_CHECKING([whether groups_search() is available])
1908 SPL_LINUX_TRY_COMPILE_SYMBOL([
1909 #include <linux/cred.h>
1910 #ifdef HAVE_KUIDGID_T
1911 #include <linux/uidgid.h>
1912 #endif
1913 ], [
1914 #ifdef HAVE_KUIDGID_T
1915 groups_search(NULL, KGIDT_INIT(0));
1916 #else
1917 groups_search(NULL, 0);
1918 #endif
1919 ], [groups_search], [], [
1920 AC_MSG_RESULT(yes)
1921 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1922 ], [
1923 AC_MSG_RESULT(no)
1924 ])
1925 ])
1926
1927 dnl #
1928 dnl # 2.6.x API change,
1929 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1930 dnl #
1931 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1932 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1933 SPL_LINUX_TRY_COMPILE_SYMBOL([
1934 #include <linux/sched.h>
1935 ], [
1936 __put_task_struct(NULL);
1937 ], [__put_task_struct], [], [
1938 AC_MSG_RESULT(yes)
1939 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1940 [__put_task_struct() is available])
1941 ], [
1942 AC_MSG_RESULT(no)
1943 ])
1944 ])
1945
1946 dnl #
1947 dnl # 2.6.32 API change,
1948 dnl # Unused 'struct file *' removed from prototype.
1949 dnl #
1950 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1951 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1952 SPL_LINUX_TRY_COMPILE([
1953 #include <linux/sysctl.h>
1954 ],[
1955 proc_dostring(NULL, 0, NULL, NULL, NULL);
1956 ],[
1957 AC_MSG_RESULT(yes)
1958 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1959 [proc_handler() wants 5 args])
1960 ],[
1961 AC_MSG_RESULT(no)
1962 ])
1963 ])
1964
1965 dnl #
1966 dnl # 2.6.x API change,
1967 dnl # kvasprintf() function added.
1968 dnl #
1969 AC_DEFUN([SPL_AC_KVASPRINTF],
1970 [AC_MSG_CHECKING([whether kvasprintf() is available])
1971 SPL_LINUX_TRY_COMPILE_SYMBOL([
1972 #include <linux/kernel.h>
1973 ], [
1974 kvasprintf(0, NULL, *((va_list*)NULL));
1975 ], [kvasprintf], [], [
1976 AC_MSG_RESULT(yes)
1977 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1978 ], [
1979 AC_MSG_RESULT(no)
1980 ])
1981 ])
1982
1983 dnl #
1984 dnl # 2.6.29 API change,
1985 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1986 dnl #
1987 AC_DEFUN([SPL_AC_VFS_FSYNC],
1988 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1989 SPL_LINUX_TRY_COMPILE_SYMBOL([
1990 #include <linux/fs.h>
1991 ], [
1992 (void) vfs_fsync;
1993 ], [vfs_fsync], [fs/sync.c], [
1994 AC_MSG_RESULT(yes)
1995 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1996 ], [
1997 AC_MSG_RESULT(no)
1998 ])
1999 ])
2000
2001 dnl #
2002 dnl # 2.6.35 API change,
2003 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2004 dnl #
2005 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2006 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2007 SPL_LINUX_TRY_COMPILE([
2008 #include <linux/fs.h>
2009 ],[
2010 vfs_fsync(NULL, 0);
2011 ],[
2012 AC_MSG_RESULT(yes)
2013 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2014 ],[
2015 AC_MSG_RESULT(no)
2016 ])
2017 ])
2018
2019 dnl #
2020 dnl # 3.5 API change,
2021 dnl # inode_operations.truncate_range removed
2022 dnl #
2023 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2024 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2025 SPL_LINUX_TRY_COMPILE([
2026 #include <linux/fs.h>
2027 ],[
2028 struct inode_operations ops;
2029 ops.truncate_range = NULL;
2030 ],[
2031 AC_MSG_RESULT(yes)
2032 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2033 [truncate_range() inode operation is available])
2034 ],[
2035 AC_MSG_RESULT(no)
2036 ])
2037 ])
2038
2039 dnl #
2040 dnl # Linux 2.6.38 - 3.x API
2041 dnl #
2042 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2043 AC_MSG_CHECKING([whether fops->fallocate() exists])
2044 SPL_LINUX_TRY_COMPILE([
2045 #include <linux/fs.h>
2046 ],[
2047 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2048 struct file_operations fops __attribute__ ((unused)) = {
2049 .fallocate = fallocate,
2050 };
2051 ],[
2052 AC_MSG_RESULT(yes)
2053 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2054 ],[
2055 AC_MSG_RESULT(no)
2056 ])
2057 ])
2058
2059 dnl #
2060 dnl # Linux 2.6.x - 2.6.37 API
2061 dnl #
2062 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2063 AC_MSG_CHECKING([whether iops->fallocate() exists])
2064 SPL_LINUX_TRY_COMPILE([
2065 #include <linux/fs.h>
2066 ],[
2067 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2068 struct inode_operations fops __attribute__ ((unused)) = {
2069 .fallocate = fallocate,
2070 };
2071 ],[
2072 AC_MSG_RESULT(yes)
2073 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2074 ],[
2075 AC_MSG_RESULT(no)
2076 ])
2077 ])
2078
2079 dnl #
2080 dnl # PaX Linux 2.6.38 - 3.x API
2081 dnl #
2082 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2083 AC_MSG_CHECKING([whether fops->fallocate() exists])
2084 SPL_LINUX_TRY_COMPILE([
2085 #include <linux/fs.h>
2086 ],[
2087 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2088 struct file_operations_no_const fops __attribute__ ((unused)) = {
2089 .fallocate = fallocate,
2090 };
2091 ],[
2092 AC_MSG_RESULT(yes)
2093 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2094 ],[
2095 AC_MSG_RESULT(no)
2096 ])
2097 ])
2098
2099 dnl #
2100 dnl # The fallocate callback was moved from the inode_operations
2101 dnl # structure to the file_operations structure.
2102 dnl #
2103 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2104 SPL_AC_KERNEL_FILE_FALLOCATE
2105 SPL_AC_KERNEL_INODE_FALLOCATE
2106 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2107 ])
2108
2109 dnl #
2110 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2111 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2112 dnl # condition. The fixed version is exported as a symbol. The race
2113 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2114 dnl # call that version while holding sem->wait_lock.
2115 dnl #
2116 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2117 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2118 SPL_LINUX_TRY_COMPILE_SYMBOL([
2119 #include <linux/rwsem.h>
2120 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2121 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2122 AC_MSG_RESULT(yes)
2123 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2124 [rwsem_is_locked() acquires sem->wait_lock])
2125 ], [
2126 AC_MSG_RESULT(no)
2127 ])
2128 ])
2129
2130 dnl #
2131 dnl # 2.6.xx API compat,
2132 dnl # There currently exists no exposed API to partially shrink the dcache.
2133 dnl # The expected mechanism to shrink the cache is a registered shrinker
2134 dnl # which is called during memory pressure.
2135 dnl #
2136 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2137 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2138 SPL_LINUX_TRY_COMPILE_SYMBOL([
2139 #include <linux/dcache.h>
2140 ], [
2141 shrink_dcache_memory(0, 0);
2142 ], [shrink_dcache_memory], [fs/dcache.c], [
2143 AC_MSG_RESULT(yes)
2144 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2145 [shrink_dcache_memory() is available])
2146 ], [
2147 AC_MSG_RESULT(no)
2148 ])
2149 ])
2150
2151 dnl #
2152 dnl # 2.6.xx API compat,
2153 dnl # There currently exists no exposed API to partially shrink the icache.
2154 dnl # The expected mechanism to shrink the cache is a registered shrinker
2155 dnl # which is called during memory pressure.
2156 dnl #
2157 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2158 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2159 SPL_LINUX_TRY_COMPILE_SYMBOL([
2160 #include <linux/dcache.h>
2161 ], [
2162 shrink_icache_memory(0, 0);
2163 ], [shrink_icache_memory], [fs/inode.c], [
2164 AC_MSG_RESULT(yes)
2165 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2166 [shrink_icache_memory() is available])
2167 ], [
2168 AC_MSG_RESULT(no)
2169 ])
2170 ])
2171
2172 dnl #
2173 dnl # 2.6.28 API change
2174 dnl # The kern_path() function has been introduced. We adopt it as the new way
2175 dnl # of looking up paths. When it is not available, we emulate it using the
2176 dnl # older interfaces.
2177 dnl #
2178 AC_DEFUN([SPL_AC_KERN_PATH],
2179 [AC_MSG_CHECKING([whether kern_path() is available])
2180 SPL_LINUX_TRY_COMPILE_SYMBOL([
2181 #include <linux/namei.h>
2182 ], [
2183 int r = kern_path(NULL, 0, NULL);
2184 ], [kern_path], [fs/namei.c], [
2185 AC_MSG_RESULT(yes)
2186 AC_DEFINE(HAVE_KERN_PATH, 1,
2187 [kern_path() is available])
2188 ], [
2189 AC_MSG_RESULT(no)
2190 AC_MSG_CHECKING([whether path_lookup() is available])
2191 SPL_LINUX_TRY_COMPILE_SYMBOL([
2192 #include <linux/namei.h>
2193 ], [
2194 int r = path_lookup(NULL, 0, NULL);
2195 ], [path_lookup], [fs/namei.c], [
2196 AC_MSG_RESULT(yes)
2197 AC_DEFINE(HAVE_KERN_PATH, 1,
2198 [kern_path() is available])
2199 ], [
2200 AC_MSG_RESULT(no)
2201 AC_MSG_ERROR([
2202 *** Neither kern_path() nor path_lookup() is available.
2203 *** Please file an issue:
2204 *** https://github.com/zfsonlinux/spl/issues/new])
2205
2206 ])
2207 ])
2208 ])
2209
2210 dnl #
2211 dnl # /proc/kallsyms support,
2212 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2213 dnl #
2214 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2215 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2216 SPL_LINUX_TRY_COMPILE([
2217 #if !defined(CONFIG_KALLSYMS)
2218 #error CONFIG_KALLSYMS not defined
2219 #endif
2220 ],[ ],[
2221 AC_MSG_RESULT([yes])
2222 ],[
2223 AC_MSG_RESULT([no])
2224 AC_MSG_ERROR([
2225 *** This kernel does not include the required kallsyms support.
2226 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2227 ])
2228 ])
2229
2230 dnl #
2231 dnl # zlib inflate compat,
2232 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2233 dnl #
2234 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2235 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2236 SPL_LINUX_TRY_COMPILE([
2237 #if !defined(CONFIG_ZLIB_INFLATE) && \
2238 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2239 #error CONFIG_ZLIB_INFLATE not defined
2240 #endif
2241 ],[ ],[
2242 AC_MSG_RESULT([yes])
2243 ],[
2244 AC_MSG_RESULT([no])
2245 AC_MSG_ERROR([
2246 *** This kernel does not include the required zlib inflate support.
2247 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2248 ])
2249 ])
2250
2251 dnl #
2252 dnl # zlib deflate compat,
2253 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2254 dnl #
2255 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2256 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2257 SPL_LINUX_TRY_COMPILE([
2258 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2259 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2260 #error CONFIG_ZLIB_DEFLATE not defined
2261 #endif
2262 ],[ ],[
2263 AC_MSG_RESULT([yes])
2264 ],[
2265 AC_MSG_RESULT([no])
2266 AC_MSG_ERROR([
2267 *** This kernel does not include the required zlib deflate support.
2268 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2269 ])
2270 ])
2271
2272 dnl #
2273 dnl # 2.6.39 API compat,
2274 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2275 dnl # This was done to avoid always having to allocate the maximum size
2276 dnl # workspace (268K). The caller can now specific the windowBits and
2277 dnl # memLevel compression parameters to get a smaller workspace.
2278 dnl #
2279 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2280 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2281 SPL_LINUX_TRY_COMPILE([
2282 #include <linux/zlib.h>
2283 ],[
2284 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2285 ],[
2286 AC_MSG_RESULT(yes)
2287 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2288 [zlib_deflate_workspacesize() wants 2 args])
2289 ],[
2290 AC_MSG_RESULT(no)
2291 ])
2292 ])
2293
2294 dnl #
2295 dnl # 2.6.39 API change,
2296 dnl # Shrinker adjust to use common shrink_control structure.
2297 dnl #
2298 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2299 AC_MSG_CHECKING([whether struct shrink_control exists])
2300 SPL_LINUX_TRY_COMPILE([
2301 #include <linux/mm.h>
2302 ],[
2303 struct shrink_control sc __attribute__ ((unused));
2304
2305 sc.nr_to_scan = 0;
2306 sc.gfp_mask = GFP_KERNEL;
2307 ],[
2308 AC_MSG_RESULT(yes)
2309 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2310 [struct shrink_control exists])
2311 ],[
2312 AC_MSG_RESULT(no)
2313 ])
2314 ])
2315
2316 dnl #
2317 dnl # 3.1 API Change
2318 dnl #
2319 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2320 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2321 dnl #
2322 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2323 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2324 tmp_flags="$EXTRA_KCFLAGS"
2325 EXTRA_KCFLAGS="-Werror"
2326 SPL_LINUX_TRY_COMPILE([
2327 #include <linux/rwsem.h>
2328 ],[
2329 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2330 raw_spinlock_t dummy_lock __attribute__ ((unused));
2331 dummy_semaphore.wait_lock = dummy_lock;
2332 ],[
2333 AC_MSG_RESULT(yes)
2334 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2335 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2336 ],[
2337 AC_MSG_RESULT(no)
2338 ])
2339 EXTRA_KCFLAGS="$tmp_flags"
2340 ])
2341
2342 dnl #
2343 dnl # 3.9 API change,
2344 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2345 dnl #
2346 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2347 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2348 SPL_LINUX_TRY_COMPILE([
2349 #include <linux/sched.h>
2350 #include <linux/sched/rt.h>
2351 ],[
2352 return 0;
2353 ],[
2354 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2355 AC_MSG_RESULT(yes)
2356 ],[
2357 AC_MSG_RESULT(no)
2358 ])
2359 ])
2360
2361 dnl #
2362 dnl # 3.9 API change,
2363 dnl # vfs_getattr() uses 2 args
2364 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2365 dnl #
2366 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2367 AC_MSG_CHECKING([whether vfs_getattr() wants])
2368 SPL_LINUX_TRY_COMPILE([
2369 #include <linux/fs.h>
2370 ],[
2371 vfs_getattr((struct path *) NULL,
2372 (struct kstat *)NULL);
2373 ],[
2374 AC_MSG_RESULT(2 args)
2375 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2376 [vfs_getattr wants 2 args])
2377 ],[
2378 SPL_LINUX_TRY_COMPILE([
2379 #include <linux/fs.h>
2380 ],[
2381 vfs_getattr((struct vfsmount *)NULL,
2382 (struct dentry *)NULL,
2383 (struct kstat *)NULL);
2384 ],[
2385 AC_MSG_RESULT(3 args)
2386 ],[
2387 AC_MSG_ERROR(unknown)
2388 ])
2389 ])
2390 ])
2391
2392 dnl #
2393 dnl # 2.6.36 API compatibility.
2394 dnl # Added usleep_range timer.
2395 dnl # usleep_range is a finer precision implementation of msleep
2396 dnl # designed to be a drop-in replacement for udelay where a precise
2397 dnl # sleep / busy-wait is unnecessary.
2398 dnl #
2399 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2400 AC_MSG_CHECKING([whether usleep_range() is available])
2401 SPL_LINUX_TRY_COMPILE([
2402 #include <linux/delay.h>
2403 ],[
2404 usleep_range(0, 0);
2405 ],[
2406 AC_MSG_RESULT(yes)
2407 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2408 [usleep_range is available])
2409 ],[
2410 AC_MSG_RESULT(no)
2411 ])
2412 ])
2413
2414 dnl #
2415 dnl # 2.6.35 API change,
2416 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2417 dnl # private allocation flags which are applied when allocating a new slab
2418 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2419 dnl # non-default flags.
2420 dnl #
2421 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2422 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2423 SPL_LINUX_TRY_COMPILE([
2424 #include <linux/slab.h>
2425 ],[
2426 struct kmem_cache cachep __attribute__ ((unused));
2427 cachep.allocflags = GFP_KERNEL;
2428 ],[
2429 AC_MSG_RESULT(yes)
2430 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2431 [struct kmem_cache has allocflags])
2432 ],[
2433 AC_MSG_RESULT(no)
2434
2435 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2436 SPL_LINUX_TRY_COMPILE([
2437 #include <linux/slab.h>
2438 ],[
2439 struct kmem_cache cachep __attribute__ ((unused));
2440 cachep.gfpflags = GFP_KERNEL;
2441 ],[
2442 AC_MSG_RESULT(yes)
2443 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2444 [struct kmem_cache has gfpflags])
2445 ],[
2446 AC_MSG_RESULT(no)
2447 ])
2448 ])
2449 ])
2450
2451 dnl #
2452 dnl # 3.17 API change,
2453 dnl # wait_on_bit() no longer requires an action argument. The former
2454 dnl # "wait_on_bit" interface required an 'action' function to be provided
2455 dnl # which does the actual waiting. There were over 20 such functions in the
2456 dnl # kernel, many of them identical, though most cases can be satisfied by one
2457 dnl # of just two functions: one which uses io_schedule() and one which just
2458 dnl # uses schedule(). This API change was made to consolidate all of those
2459 dnl # redundant wait functions.
2460 dnl #
2461 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2462 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2463 SPL_LINUX_TRY_COMPILE([
2464 #include <linux/wait.h>
2465 ],[
2466 int (*action)(void *) = NULL;
2467 wait_on_bit(NULL, 0, action, 0);
2468 ],[
2469 AC_MSG_RESULT(yes)
2470 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
2471 ],[
2472 AC_MSG_RESULT(no)
2473 ])
2474 ])