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