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