]> git.proxmox.com Git - mirror_spl.git/blob - config/spl-build.m4
Linux 3.8 compat: Use kuid_t/kgid_t when required
[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_SET_SHRINKER
31 SPL_AC_3ARGS_SHRINKER_CALLBACK
32 SPL_AC_PATH_IN_NAMEIDATA
33 SPL_AC_TASK_CURR
34 SPL_AC_CTL_UNNUMBERED
35 SPL_AC_CTL_NAME
36 SPL_AC_VMALLOC_INFO
37 SPL_AC_PDE_DATA
38 SPL_AC_FLS64
39 SPL_AC_DEVICE_CREATE
40 SPL_AC_5ARGS_DEVICE_CREATE
41 SPL_AC_CLASS_DEVICE_CREATE
42 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
43 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
44 SPL_AC_TIMESPEC_SUB
45 SPL_AC_INIT_UTSNAME
46 SPL_AC_UACCESS_HEADER
47 SPL_AC_KMALLOC_NODE
48 SPL_AC_MONOTONIC_CLOCK
49 SPL_AC_INODE_I_MUTEX
50 SPL_AC_MUTEX_OWNER
51 SPL_AC_MUTEX_OWNER_TASK_STRUCT
52 SPL_AC_MUTEX_LOCK_NESTED
53 SPL_AC_3ARGS_ON_EACH_CPU
54 SPL_AC_KALLSYMS_LOOKUP_NAME
55 SPL_AC_GET_VMALLOC_INFO
56 SPL_AC_PGDAT_HELPERS
57 SPL_AC_FIRST_ONLINE_PGDAT
58 SPL_AC_NEXT_ONLINE_PGDAT
59 SPL_AC_NEXT_ZONE
60 SPL_AC_PGDAT_LIST
61 SPL_AC_GLOBAL_PAGE_STATE
62 SPL_AC_ZONE_STAT_ITEM_FREE
63 SPL_AC_ZONE_STAT_ITEM_INACTIVE
64 SPL_AC_ZONE_STAT_ITEM_ACTIVE
65 SPL_AC_GET_ZONE_COUNTS
66 SPL_AC_USER_PATH_DIR
67 SPL_AC_SET_FS_PWD
68 SPL_AC_SET_FS_PWD_WITH_CONST
69 SPL_AC_2ARGS_VFS_UNLINK
70 SPL_AC_4ARGS_VFS_RENAME
71 SPL_AC_VFS_FSYNC
72 SPL_AC_2ARGS_VFS_FSYNC
73 SPL_AC_INODE_TRUNCATE_RANGE
74 SPL_AC_FS_STRUCT_SPINLOCK
75 SPL_AC_CRED_STRUCT
76 SPL_AC_KUIDGID_T
77 SPL_AC_GROUPS_SEARCH
78 SPL_AC_PUT_TASK_STRUCT
79 SPL_AC_5ARGS_PROC_HANDLER
80 SPL_AC_KVASPRINTF
81 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
82 SPL_AC_KERNEL_FALLOCATE
83 SPL_AC_SHRINK_DCACHE_MEMORY
84 SPL_AC_SHRINK_ICACHE_MEMORY
85 SPL_AC_KERN_PATH_PARENT_HEADER
86 SPL_AC_KERN_PATH_PARENT_SYMBOL
87 SPL_AC_KERN_PATH_LOCKED
88 SPL_AC_CONFIG_KALLSYMS
89 SPL_AC_CONFIG_ZLIB_INFLATE
90 SPL_AC_CONFIG_ZLIB_DEFLATE
91 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
92 SPL_AC_SHRINK_CONTROL_STRUCT
93 SPL_AC_RWSEM_SPINLOCK_IS_RAW
94 SPL_AC_SCHED_RT_HEADER
95 SPL_AC_2ARGS_VFS_GETATTR
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 dnl #
888 dnl # 2.6.23 API change
889 dnl # Old set_shrinker API replaced with register_shrinker
890 dnl #
891 AC_DEFUN([SPL_AC_SET_SHRINKER], [
892 AC_MSG_CHECKING([whether set_shrinker() available])
893 SPL_LINUX_TRY_COMPILE([
894 #include <linux/mm.h>
895 ],[
896 return set_shrinker(DEFAULT_SEEKS, NULL);
897 ],[
898 AC_MSG_RESULT([yes])
899 AC_DEFINE(HAVE_SET_SHRINKER, 1,
900 [set_shrinker() available])
901 ],[
902 AC_MSG_RESULT([no])
903 ])
904 ])
905
906 dnl #
907 dnl # 2.6.35 API change,
908 dnl # Add context to shrinker callback
909 dnl #
910 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
911 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
912 tmp_flags="$EXTRA_KCFLAGS"
913 EXTRA_KCFLAGS="-Werror"
914 SPL_LINUX_TRY_COMPILE([
915 #include <linux/mm.h>
916
917 int shrinker_cb(struct shrinker *, int, unsigned int);
918 ],[
919 struct shrinker cache_shrinker = {
920 .shrink = shrinker_cb,
921 .seeks = DEFAULT_SEEKS,
922 };
923 register_shrinker(&cache_shrinker);
924 ],[
925 AC_MSG_RESULT(yes)
926 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
927 [shrinker callback wants 3 args])
928 ],[
929 AC_MSG_RESULT(no)
930 ])
931 EXTRA_KCFLAGS="$tmp_flags"
932 ])
933
934 dnl #
935 dnl # 2.6.25 API change,
936 dnl # struct path entry added to struct nameidata
937 dnl #
938 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
939 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
940 SPL_LINUX_TRY_COMPILE([
941 #include <linux/namei.h>
942 ],[
943 struct nameidata nd __attribute__ ((unused));
944
945 nd.path.mnt = NULL;
946 nd.path.dentry = NULL;
947 ],[
948 AC_MSG_RESULT(yes)
949 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
950 [struct path used in struct nameidata])
951 ],[
952 AC_MSG_RESULT(no)
953 ])
954 ])
955
956 dnl #
957 dnl # Custom SPL patch may export this system it is not required
958 dnl #
959 AC_DEFUN([SPL_AC_TASK_CURR],
960 [AC_MSG_CHECKING([whether task_curr() is available])
961 SPL_LINUX_TRY_COMPILE_SYMBOL([
962 #include <linux/sched.h>
963 ], [
964 task_curr(NULL);
965 ], [task_curr], [kernel/sched.c], [
966 AC_MSG_RESULT(yes)
967 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
968 ], [
969 AC_MSG_RESULT(no)
970 ])
971 ])
972
973 dnl #
974 dnl # 2.6.19 API change,
975 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
976 dnl #
977 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
978 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
979 SPL_LINUX_TRY_COMPILE([
980 #include <linux/sysctl.h>
981 ],[
982 #ifndef CTL_UNNUMBERED
983 #error CTL_UNNUMBERED undefined
984 #endif
985 ],[
986 AC_MSG_RESULT(yes)
987 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
988 [unnumbered sysctl support exists])
989 ],[
990 AC_MSG_RESULT(no)
991 ])
992 ])
993
994 dnl #
995 dnl # 2.6.33 API change,
996 dnl # Removed .ctl_name from struct ctl_table.
997 dnl #
998 AC_DEFUN([SPL_AC_CTL_NAME], [
999 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1000 SPL_LINUX_TRY_COMPILE([
1001 #include <linux/sysctl.h>
1002 ],[
1003 struct ctl_table ctl __attribute__ ((unused));
1004 ctl.ctl_name = 0;
1005 ],[
1006 AC_MSG_RESULT(yes)
1007 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1008 ],[
1009 AC_MSG_RESULT(no)
1010 ])
1011 ])
1012
1013 dnl #
1014 dnl # 2.6.16 API change.
1015 dnl # Check if 'fls64()' is available
1016 dnl #
1017 AC_DEFUN([SPL_AC_FLS64],
1018 [AC_MSG_CHECKING([whether fls64() is available])
1019 SPL_LINUX_TRY_COMPILE([
1020 #include <linux/bitops.h>
1021 ],[
1022 return fls64(0);
1023 ],[
1024 AC_MSG_RESULT(yes)
1025 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1026 ],[
1027 AC_MSG_RESULT(no)
1028 ])
1029 ])
1030
1031 dnl #
1032 dnl # 2.6.18 API change, check whether device_create() is available.
1033 dnl # Device_create() was introduced in 2.6.18 and depricated
1034 dnl # class_device_create() which was fully removed in 2.6.26.
1035 dnl #
1036 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1037 [AC_MSG_CHECKING([whether device_create() is available])
1038 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1039 AC_MSG_RESULT(yes)
1040 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1041 [device_create() is available])
1042 ], [
1043 AC_MSG_RESULT(no)
1044 ])
1045 ])
1046
1047 dnl #
1048 dnl # 2.6.27 API change,
1049 dnl # device_create() uses 5 args, new 'drvdata' argument.
1050 dnl #
1051 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1052 AC_MSG_CHECKING([whether device_create() wants 5 args])
1053 tmp_flags="$EXTRA_KCFLAGS"
1054 EXTRA_KCFLAGS="-Werror"
1055 SPL_LINUX_TRY_COMPILE([
1056 #include <linux/device.h>
1057 ],[
1058 device_create(NULL, NULL, 0, NULL, "%d", 1);
1059 ],[
1060 AC_MSG_RESULT(yes)
1061 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1062 [device_create wants 5 args])
1063 ],[
1064 AC_MSG_RESULT(no)
1065 ])
1066 EXTRA_KCFLAGS="$tmp_flags"
1067 ])
1068
1069 dnl #
1070 dnl # 2.6.13 API change, check whether class_device_create() is available.
1071 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1072 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1073 dnl #
1074 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1075 [AC_MSG_CHECKING([whether class_device_create() is available])
1076 SPL_LINUX_TRY_COMPILE_SYMBOL([
1077 #include <linux/device.h>
1078 ], [
1079 class_device_create(NULL, NULL, 0, NULL, NULL);
1080 ], [class_device_create], [drivers/base/class.c], [
1081 AC_MSG_RESULT(yes)
1082 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1083 [class_device_create() is available])
1084 ], [
1085 AC_MSG_RESULT(no)
1086 ])
1087 ])
1088
1089 dnl #
1090 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1091 dnl #
1092 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1093 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1094 SPL_LINUX_TRY_COMPILE_SYMBOL([
1095 #include <linux/time.h>
1096 ], [
1097 set_normalized_timespec(NULL, 0, 0);
1098 ], [set_normalized_timespec], [kernel/time.c], [
1099 AC_MSG_RESULT(yes)
1100 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1101 [set_normalized_timespec() is available as export])
1102 ], [
1103 AC_MSG_RESULT(no)
1104 ])
1105 ])
1106
1107 dnl #
1108 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1109 dnl # previously it was available in time.h as an inline.
1110 dnl #
1111 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1112 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1113 SPL_LINUX_TRY_COMPILE([
1114 #include <linux/time.h>
1115 void set_normalized_timespec(struct timespec *ts,
1116 time_t sec, long nsec) { }
1117 ],
1118 [],
1119 [
1120 AC_MSG_RESULT(no)
1121 ],[
1122 AC_MSG_RESULT(yes)
1123 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1124 [set_normalized_timespec() is available as inline])
1125 ])
1126 ])
1127
1128 dnl #
1129 dnl # 2.6.18 API change,
1130 dnl # timespec_sub() inline function available in linux/time.h
1131 dnl #
1132 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1133 AC_MSG_CHECKING([whether timespec_sub() is available])
1134 SPL_LINUX_TRY_COMPILE([
1135 #include <linux/time.h>
1136 ],[
1137 struct timespec a = { 0 };
1138 struct timespec b = { 0 };
1139 struct timespec c __attribute__ ((unused));
1140 c = timespec_sub(a, b);
1141 ],[
1142 AC_MSG_RESULT(yes)
1143 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1144 ],[
1145 AC_MSG_RESULT(no)
1146 ])
1147 ])
1148
1149 dnl #
1150 dnl # 2.6.19 API change,
1151 dnl # check if init_utsname() is available in linux/utsname.h
1152 dnl #
1153 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1154 AC_MSG_CHECKING([whether init_utsname() is available])
1155 SPL_LINUX_TRY_COMPILE([
1156 #include <linux/utsname.h>
1157 ],[
1158 struct new_utsname *a __attribute__ ((unused));
1159 a = init_utsname();
1160 ],[
1161 AC_MSG_RESULT(yes)
1162 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1163 ],[
1164 AC_MSG_RESULT(no)
1165 ])
1166 ])
1167
1168 dnl #
1169 dnl # 2.6.18 API change,
1170 dnl # added linux/uaccess.h
1171 dnl #
1172 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1173 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1174 ])
1175
1176 dnl #
1177 dnl # 2.6.12 API change,
1178 dnl # check whether 'kmalloc_node()' is available.
1179 dnl #
1180 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1181 AC_MSG_CHECKING([whether kmalloc_node() is available])
1182 SPL_LINUX_TRY_COMPILE([
1183 #include <linux/slab.h>
1184 ],[
1185 void *a __attribute__ ((unused));
1186 a = kmalloc_node(1, GFP_KERNEL, 0);
1187 ],[
1188 AC_MSG_RESULT(yes)
1189 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1190 ],[
1191 AC_MSG_RESULT(no)
1192 ])
1193 ])
1194
1195 dnl #
1196 dnl # 2.6.9 API change,
1197 dnl # check whether 'monotonic_clock()' is available it may
1198 dnl # be available for some archs but not others.
1199 dnl #
1200 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1201 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1202 SPL_LINUX_TRY_COMPILE_SYMBOL([
1203 #include <linux/timex.h>
1204 ], [
1205 monotonic_clock();
1206 ], [monotonic_clock], [], [
1207 AC_MSG_RESULT(yes)
1208 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1209 [monotonic_clock() is available])
1210 ], [
1211 AC_MSG_RESULT(no)
1212 ])
1213 ])
1214
1215 dnl #
1216 dnl # 2.6.16 API change,
1217 dnl # check whether 'struct inode' has i_mutex
1218 dnl #
1219 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1220 AC_MSG_CHECKING([whether struct inode has i_mutex])
1221 SPL_LINUX_TRY_COMPILE([
1222 #include <linux/fs.h>
1223 #include <linux/mutex.h>
1224 ],[
1225 struct inode i;
1226 mutex_init(&i.i_mutex);
1227 ],[
1228 AC_MSG_RESULT(yes)
1229 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1230 ],[
1231 AC_MSG_RESULT(no)
1232 ])
1233 ])
1234
1235 dnl #
1236 dnl # 2.6.29 API change,
1237 dnl # Adaptive mutexs introduced.
1238 dnl #
1239 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1240 AC_MSG_CHECKING([whether struct mutex has owner])
1241 SPL_LINUX_TRY_COMPILE([
1242 #include <linux/mutex.h>
1243 ],[
1244 struct mutex mtx __attribute__ ((unused));
1245 mtx.owner = NULL;
1246 ],[
1247 AC_MSG_RESULT(yes)
1248 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1249 ],[
1250 AC_MSG_RESULT(no)
1251 ])
1252 ])
1253
1254 dnl #
1255 dnl # 2.6.39 API change,
1256 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1257 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1258 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1259 dnl # pointer which frankly makes a lot more sense.
1260 dnl #
1261 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1262 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1263 tmp_flags="$EXTRA_KCFLAGS"
1264 EXTRA_KCFLAGS="-Werror"
1265 SPL_LINUX_TRY_COMPILE([
1266 #include <linux/mutex.h>
1267 #include <linux/sched.h>
1268 ],[
1269 struct mutex mtx __attribute__ ((unused));
1270 mtx.owner = current;
1271 ],[
1272 AC_MSG_RESULT(yes)
1273 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1274 [struct mutex owner is a task_struct])
1275 ],[
1276 AC_MSG_RESULT(no)
1277 ])
1278 EXTRA_KCFLAGS="$tmp_flags"
1279 ])
1280
1281 dnl #
1282 dnl # 2.6.18 API change,
1283 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1284 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1285 dnl # if the mutex validator is disabled or otherwise unavailable.
1286 dnl #
1287 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1288 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1289 SPL_LINUX_TRY_COMPILE([
1290 #include <linux/mutex.h>
1291 ],[
1292 struct mutex mutex;
1293 mutex_init(&mutex);
1294 mutex_lock_nested(&mutex, 0);
1295 ],[
1296 AC_MSG_RESULT(yes)
1297 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1298 [mutex_lock_nested() is available])
1299 ],[
1300 AC_MSG_RESULT(no)
1301 ])
1302 ])
1303
1304 dnl #
1305 dnl # 2.6.27 API change,
1306 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1307 dnl #
1308 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1309 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1310 SPL_LINUX_TRY_COMPILE([
1311 #include <linux/interrupt.h>
1312 #include <linux/smp.h>
1313
1314 void on_each_cpu_func(void *data) { return; }
1315 ],[
1316 on_each_cpu(on_each_cpu_func, NULL, 0);
1317 ],[
1318 AC_MSG_RESULT(yes)
1319 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1320 [on_each_cpu wants 3 args])
1321 ],[
1322 AC_MSG_RESULT(no)
1323 ])
1324 ])
1325
1326 dnl #
1327 dnl # 2.6.18 API change,
1328 dnl # kallsyms_lookup_name no longer exported
1329 dnl #
1330 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1331 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1332 SPL_LINUX_TRY_COMPILE_SYMBOL([
1333 #include <linux/kallsyms.h>
1334 ], [
1335 kallsyms_lookup_name(NULL);
1336 ], [kallsyms_lookup_name], [], [
1337 AC_MSG_RESULT(yes)
1338 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1339 [kallsyms_lookup_name() is available])
1340 ], [
1341 AC_MSG_RESULT(no)
1342 ])
1343 ])
1344
1345 dnl #
1346 dnl # Proposed API change,
1347 dnl # This symbol is not available in stock kernels. You may build a
1348 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1349 dnl # these symbols for use. If your already rolling a custom kernel for
1350 dnl # your environment this is recommended.
1351 dnl #
1352 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1353 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1354 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1355 AC_MSG_RESULT(yes)
1356 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1357 [get_vmalloc_info() is available])
1358 ], [
1359 AC_MSG_RESULT(no)
1360 ])
1361 ])
1362
1363 dnl #
1364 dnl # 3.10 API change,
1365 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1366 dnl #
1367 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1368 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1369 SPL_LINUX_TRY_COMPILE([
1370 #include <linux/vmalloc.h>
1371 struct vmalloc_info { void *a; };
1372 ],[
1373 return 0;
1374 ],[
1375 AC_MSG_RESULT(no)
1376 ],[
1377 AC_MSG_RESULT(yes)
1378 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1379 ])
1380 ])
1381
1382 dnl #
1383 dnl # 3.10 API change,
1384 dnl # PDE is replaced by PDE_DATA
1385 dnl #
1386 AC_DEFUN([SPL_AC_PDE_DATA], [
1387 AC_MSG_CHECKING([whether PDE_DATA() is available])
1388 SPL_LINUX_TRY_COMPILE_SYMBOL([
1389 #include <linux/proc_fs.h>
1390 ], [
1391 PDE_DATA(NULL);
1392 ], [PDE_DATA], [], [
1393 AC_MSG_RESULT(yes)
1394 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1395 ],[
1396 AC_MSG_RESULT(no)
1397 ])
1398 ])
1399
1400 dnl #
1401 dnl # 2.6.17 API change
1402 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1403 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1404 dnl # were exported in 2.6.17 for use by modules which was consistent with
1405 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1406 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1407 dnl # were dropped entirely leaving modules no way to directly iterate over
1408 dnl # the zone list. Because we need access to the zone helpers we check
1409 dnl # if the kernel contains the old or new implementation. Then we check
1410 dnl # to see if the symbols we need for each version are available. If they
1411 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1412 dnl #
1413 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1414 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1415 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1416 rc=$?
1417 if test $rc -eq 0; then
1418 AC_MSG_RESULT([yes])
1419 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1420 else
1421 AC_MSG_RESULT([no])
1422 fi
1423 ])
1424
1425 dnl #
1426 dnl # Proposed API change,
1427 dnl # This symbol is not available in stock kernels. You may build a
1428 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1429 dnl # these symbols for use. If your already rolling a custom kernel for
1430 dnl # your environment this is recommended.
1431 dnl #
1432 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1433 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1434 SPL_LINUX_TRY_COMPILE_SYMBOL([
1435 #include <linux/mmzone.h>
1436 ], [
1437 first_online_pgdat();
1438 ], [first_online_pgdat], [], [
1439 AC_MSG_RESULT(yes)
1440 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1441 [first_online_pgdat() is available])
1442 ], [
1443 AC_MSG_RESULT(no)
1444 ])
1445 ])
1446
1447 dnl #
1448 dnl # Proposed API change,
1449 dnl # This symbol is not available in stock kernels. You may build a
1450 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1451 dnl # these symbols for use. If your already rolling a custom kernel for
1452 dnl # your environment this is recommended.
1453 dnl #
1454 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1455 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1456 SPL_LINUX_TRY_COMPILE_SYMBOL([
1457 #include <linux/mmzone.h>
1458 ], [
1459 next_online_pgdat(NULL);
1460 ], [next_online_pgdat], [], [
1461 AC_MSG_RESULT(yes)
1462 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1463 [next_online_pgdat() is available])
1464 ], [
1465 AC_MSG_RESULT(no)
1466 ])
1467 ])
1468
1469 dnl #
1470 dnl # Proposed API change,
1471 dnl # This symbol is not available in stock kernels. You may build a
1472 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1473 dnl # these symbols for use. If your already rolling a custom kernel for
1474 dnl # your environment this is recommended.
1475 dnl #
1476 AC_DEFUN([SPL_AC_NEXT_ZONE],
1477 [AC_MSG_CHECKING([whether next_zone() is available])
1478 SPL_LINUX_TRY_COMPILE_SYMBOL([
1479 #include <linux/mmzone.h>
1480 ], [
1481 next_zone(NULL);
1482 ], [next_zone], [], [
1483 AC_MSG_RESULT(yes)
1484 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1485 ], [
1486 AC_MSG_RESULT(no)
1487 ])
1488 ])
1489
1490 dnl #
1491 dnl # 2.6.17 API change,
1492 dnl # See SPL_AC_PGDAT_HELPERS for details.
1493 dnl #
1494 AC_DEFUN([SPL_AC_PGDAT_LIST],
1495 [AC_MSG_CHECKING([whether pgdat_list is available])
1496 SPL_LINUX_TRY_COMPILE_SYMBOL([
1497 #include <linux/topology.h>
1498 pg_data_t *tmp = pgdat_list;
1499 ], [], [pgdat_list], [], [
1500 AC_MSG_RESULT(yes)
1501 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1502 ], [
1503 AC_MSG_RESULT(no)
1504 ])
1505 ])
1506
1507 dnl #
1508 dnl # 2.6.18 API change,
1509 dnl # First introduced global_page_state() support as an inline.
1510 dnl #
1511 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1512 AC_MSG_CHECKING([whether global_page_state() is available])
1513 SPL_LINUX_TRY_COMPILE([
1514 #include <linux/mm.h>
1515 ],[
1516 unsigned long state __attribute__ ((unused));
1517 state = global_page_state(0);
1518 ],[
1519 AC_MSG_RESULT(yes)
1520 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1521 [global_page_state() is available])
1522 ],[
1523 AC_MSG_RESULT(no)
1524 ])
1525 ])
1526
1527 dnl #
1528 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1529 dnl # Public global zone stats now include a free page count. However
1530 dnl # the enumerated names of the counters have changed since this API
1531 dnl # was introduced. We need to deduce the corrent name to use. This
1532 dnl # replaces the priviate get_zone_counts() interface.
1533 dnl #
1534 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1535 dnl # is 2.6.30 as of when this was written.
1536 dnl #
1537 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1538 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1539 SPL_LINUX_TRY_COMPILE([
1540 #include <linux/mm.h>
1541 ],[
1542 enum zone_stat_item zsi __attribute__ ((unused));
1543 zsi = NR_FREE_PAGES;
1544 ],[
1545 AC_MSG_RESULT(yes)
1546 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1547 [Page state NR_FREE_PAGES is available])
1548 ],[
1549 AC_MSG_RESULT(no)
1550 ])
1551 ])
1552
1553 dnl #
1554 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1555 dnl # Public global zone stats now include an inactive page count. However
1556 dnl # the enumerated names of the counters have changed since this API
1557 dnl # was introduced. We need to deduce the corrent name to use. This
1558 dnl # replaces the priviate get_zone_counts() interface.
1559 dnl #
1560 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1561 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1562 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1563 dnl #
1564 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1565 AC_MSG_CHECKING([whether page state NR_INACTIVE 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;
1571 ],[
1572 AC_MSG_RESULT(yes)
1573 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1574 [Page state NR_INACTIVE is available])
1575 ],[
1576 AC_MSG_RESULT(no)
1577 ])
1578
1579 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON 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_ANON;
1585 ],[
1586 AC_MSG_RESULT(yes)
1587 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1588 [Page state NR_INACTIVE_ANON is available])
1589 ],[
1590 AC_MSG_RESULT(no)
1591 ])
1592
1593 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1594 SPL_LINUX_TRY_COMPILE([
1595 #include <linux/mm.h>
1596 ],[
1597 enum zone_stat_item zsi __attribute__ ((unused));
1598 zsi = NR_INACTIVE_FILE;
1599 ],[
1600 AC_MSG_RESULT(yes)
1601 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1602 [Page state NR_INACTIVE_FILE is available])
1603 ],[
1604 AC_MSG_RESULT(no)
1605 ])
1606 ])
1607
1608 dnl #
1609 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1610 dnl # Public global zone stats now include an active page count. However
1611 dnl # the enumerated names of the counters have changed since this API
1612 dnl # was introduced. We need to deduce the corrent name to use. This
1613 dnl # replaces the priviate get_zone_counts() interface.
1614 dnl #
1615 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1616 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1617 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1618 dnl #
1619 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1620 AC_MSG_CHECKING([whether page state NR_ACTIVE 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;
1626 ],[
1627 AC_MSG_RESULT(yes)
1628 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1629 [Page state NR_ACTIVE is available])
1630 ],[
1631 AC_MSG_RESULT(no)
1632 ])
1633
1634 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON 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_ANON;
1640 ],[
1641 AC_MSG_RESULT(yes)
1642 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1643 [Page state NR_ACTIVE_ANON is available])
1644 ],[
1645 AC_MSG_RESULT(no)
1646 ])
1647
1648 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1649 SPL_LINUX_TRY_COMPILE([
1650 #include <linux/mm.h>
1651 ],[
1652 enum zone_stat_item zsi __attribute__ ((unused));
1653 zsi = NR_ACTIVE_FILE;
1654 ],[
1655 AC_MSG_RESULT(yes)
1656 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1657 [Page state NR_ACTIVE_FILE is available])
1658 ],[
1659 AC_MSG_RESULT(no)
1660 ])
1661 ])
1662
1663 dnl #
1664 dnl # Proposed API change for legacy kernels.
1665 dnl # This symbol is not available in older kernels. For kernels post
1666 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1667 dnl # page state information. This symbol is only used in legacy kernels
1668 dnl # any only as a last resort.
1669 dnl
1670 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1671 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1672 SPL_LINUX_TRY_COMPILE([
1673 ],[
1674 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1675 #error "global_page_state needs NR_FREE_PAGES"
1676 #endif
1677
1678 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1679 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1680 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1681 #error "global_page_state needs NR_ACTIVE*"
1682 #endif
1683
1684 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1685 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1686 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1687 #error "global_page_state needs NR_INACTIVE*"
1688 #endif
1689 ],[
1690 AC_MSG_RESULT(no)
1691 ],[
1692 AC_MSG_RESULT(yes)
1693 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1694 [get_zone_counts() is needed])
1695
1696 AC_MSG_CHECKING([whether get_zone_counts() is available])
1697 SPL_LINUX_TRY_COMPILE_SYMBOL([
1698 #include <linux/mmzone.h>
1699 ], [
1700 get_zone_counts(NULL, NULL, NULL);
1701 ], [get_zone_counts], [], [
1702 AC_MSG_RESULT(yes)
1703 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1704 [get_zone_counts() is available])
1705 ], [
1706 AC_MSG_RESULT(no)
1707 ])
1708 ])
1709 ])
1710
1711 dnl #
1712 dnl # 2.6.27 API change,
1713 dnl # The user_path_dir() replaces __user_walk()
1714 dnl #
1715 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1716 [AC_MSG_CHECKING([whether user_path_dir() is available])
1717 SPL_LINUX_TRY_COMPILE_SYMBOL([
1718 #include <linux/fcntl.h>
1719 #include <linux/namei.h>
1720 ], [
1721 user_path_dir(NULL, NULL);
1722 ], [user_path_at], [], [
1723 AC_MSG_RESULT(yes)
1724 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1725 ], [
1726 AC_MSG_RESULT(no)
1727 ])
1728 ])
1729
1730 dnl #
1731 dnl # Symbol available in RHEL kernels not in stock kernels.
1732 dnl #
1733 AC_DEFUN([SPL_AC_SET_FS_PWD],
1734 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1735 SPL_LINUX_TRY_COMPILE_SYMBOL([
1736 #include <linux/spinlock.h>
1737 #include <linux/fs_struct.h>
1738 ], [
1739 (void) set_fs_pwd;
1740 ], [set_fs_pwd], [], [
1741 AC_MSG_RESULT(yes)
1742 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1743 ], [
1744 AC_MSG_RESULT(no)
1745 ])
1746 ])
1747
1748 dnl #
1749 dnl # 3.9 API change
1750 dnl # set_fs_pwd takes const struct path *
1751 dnl #
1752 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1753 tmp_flags="$EXTRA_KCFLAGS"
1754 EXTRA_KCFLAGS="-Werror"
1755 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
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 *, const struct path *)
1762 = set_fs_pwd;
1763 ],[
1764 return 0;
1765 ],[
1766 AC_MSG_RESULT(yes)
1767 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1768 [set_fs_pwd() needs const path *])
1769 ],[
1770 SPL_LINUX_TRY_COMPILE([
1771 #include <linux/spinlock.h>
1772 #include <linux/fs_struct.h>
1773 #include <linux/path.h>
1774 void (*const set_fs_pwd_func)
1775 (struct fs_struct *, struct path *)
1776 = set_fs_pwd;
1777 ],[
1778 return 0;
1779 ],[
1780 AC_MSG_RESULT(no)
1781 ],[
1782 AC_MSG_ERROR(unknown)
1783 ])
1784 ])
1785 EXTRA_KCFLAGS="$tmp_flags"
1786 ])
1787
1788 dnl #
1789 dnl # SLES API change, never adopted in mainline,
1790 dnl # Third 'struct vfsmount *' argument removed.
1791 dnl #
1792 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1793 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1794 SPL_LINUX_TRY_COMPILE([
1795 #include <linux/fs.h>
1796 ],[
1797 vfs_unlink(NULL, NULL);
1798 ],[
1799 AC_MSG_RESULT(yes)
1800 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1801 [vfs_unlink() wants 2 args])
1802 ],[
1803 AC_MSG_RESULT(no)
1804 ])
1805 ])
1806
1807 dnl #
1808 dnl # SLES API change, never adopted in mainline,
1809 dnl # Third and sixth 'struct vfsmount *' argument removed.
1810 dnl #
1811 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1812 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1813 SPL_LINUX_TRY_COMPILE([
1814 #include <linux/fs.h>
1815 ],[
1816 vfs_rename(NULL, NULL, NULL, NULL);
1817 ],[
1818 AC_MSG_RESULT(yes)
1819 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1820 [vfs_rename() wants 4 args])
1821 ],[
1822 AC_MSG_RESULT(no)
1823 ])
1824 ])
1825
1826 dnl #
1827 dnl # 2.6.36 API change,
1828 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1829 dnl # a spinlock_t to improve the fastpath performance.
1830 dnl #
1831 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1832 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1833 tmp_flags="$EXTRA_KCFLAGS"
1834 EXTRA_KCFLAGS="-Werror"
1835 SPL_LINUX_TRY_COMPILE([
1836 #include <linux/sched.h>
1837 #include <linux/fs_struct.h>
1838 ],[
1839 struct fs_struct fs;
1840 spin_lock_init(&fs.lock);
1841 ],[
1842 AC_MSG_RESULT(yes)
1843 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1844 [struct fs_struct uses spinlock_t])
1845 ],[
1846 AC_MSG_RESULT(no)
1847 ])
1848 EXTRA_KCFLAGS="$tmp_flags"
1849 ])
1850
1851 dnl #
1852 dnl # 2.6.29 API change,
1853 dnl # check whether 'struct cred' exists
1854 dnl #
1855 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1856 AC_MSG_CHECKING([whether struct cred exists])
1857 SPL_LINUX_TRY_COMPILE([
1858 #include <linux/cred.h>
1859 ],[
1860 struct cred *cr __attribute__ ((unused));
1861 cr = NULL;
1862 ],[
1863 AC_MSG_RESULT(yes)
1864 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1865 ],[
1866 AC_MSG_RESULT(no)
1867 ])
1868 ])
1869
1870
1871 dnl #
1872 dnl # User namespaces, use kuid_t in place of uid_t
1873 dnl # where available. Not strictly a user namespaces thing
1874 dnl # but it should prevent surprises
1875 dnl #
1876 AC_DEFUN([SPL_AC_KUIDGID_T], [
1877 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1878 SPL_LINUX_TRY_COMPILE([
1879 #include <linux/uidgid.h>
1880 ], [
1881 kuid_t userid = KUIDT_INIT(0);
1882 kgid_t groupid = KGIDT_INIT(0);
1883 ],[
1884 SPL_LINUX_TRY_COMPILE([
1885 #include <linux/uidgid.h>
1886 ], [
1887 kuid_t userid = 0;
1888 kgid_t groupid = 0;
1889 ],[
1890 AC_MSG_RESULT(yes; optional)
1891 ],[
1892 AC_MSG_RESULT(yes; mandatory)
1893 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
1894 ])
1895 ],[
1896 AC_MSG_RESULT(no)
1897 ])
1898 ])
1899
1900 dnl #
1901 dnl # Custom SPL patch may export this symbol.
1902 dnl #
1903 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
1904 [AC_MSG_CHECKING([whether groups_search() is available])
1905 SPL_LINUX_TRY_COMPILE_SYMBOL([
1906 #include <linux/cred.h>
1907 #ifdef HAVE_KUIDGID_T
1908 #include <linux/uidgid.h>
1909 #endif
1910 ], [
1911 #ifdef HAVE_KUIDGID_T
1912 groups_search(NULL, KGIDT_INIT(0));
1913 #else
1914 groups_search(NULL, 0);
1915 #endif
1916 ], [groups_search], [], [
1917 AC_MSG_RESULT(yes)
1918 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
1919 ], [
1920 AC_MSG_RESULT(no)
1921 ])
1922 ])
1923
1924 dnl #
1925 dnl # 2.6.x API change,
1926 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1927 dnl #
1928 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
1929 [AC_MSG_CHECKING([whether __put_task_struct() is available])
1930 SPL_LINUX_TRY_COMPILE_SYMBOL([
1931 #include <linux/sched.h>
1932 ], [
1933 __put_task_struct(NULL);
1934 ], [__put_task_struct], [], [
1935 AC_MSG_RESULT(yes)
1936 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1937 [__put_task_struct() is available])
1938 ], [
1939 AC_MSG_RESULT(no)
1940 ])
1941 ])
1942
1943 dnl #
1944 dnl # 2.6.32 API change,
1945 dnl # Unused 'struct file *' removed from prototype.
1946 dnl #
1947 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1948 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1949 SPL_LINUX_TRY_COMPILE([
1950 #include <linux/sysctl.h>
1951 ],[
1952 proc_dostring(NULL, 0, NULL, NULL, NULL);
1953 ],[
1954 AC_MSG_RESULT(yes)
1955 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1956 [proc_handler() wants 5 args])
1957 ],[
1958 AC_MSG_RESULT(no)
1959 ])
1960 ])
1961
1962 dnl #
1963 dnl # 2.6.x API change,
1964 dnl # kvasprintf() function added.
1965 dnl #
1966 AC_DEFUN([SPL_AC_KVASPRINTF],
1967 [AC_MSG_CHECKING([whether kvasprintf() is available])
1968 SPL_LINUX_TRY_COMPILE_SYMBOL([
1969 #include <linux/kernel.h>
1970 ], [
1971 kvasprintf(0, NULL, *((va_list*)NULL));
1972 ], [kvasprintf], [], [
1973 AC_MSG_RESULT(yes)
1974 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
1975 ], [
1976 AC_MSG_RESULT(no)
1977 ])
1978 ])
1979
1980 dnl #
1981 dnl # 2.6.29 API change,
1982 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1983 dnl #
1984 AC_DEFUN([SPL_AC_VFS_FSYNC],
1985 [AC_MSG_CHECKING([whether vfs_fsync() is available])
1986 SPL_LINUX_TRY_COMPILE_SYMBOL([
1987 #include <linux/fs.h>
1988 ], [
1989 (void) vfs_fsync;
1990 ], [vfs_fsync], [fs/sync.c], [
1991 AC_MSG_RESULT(yes)
1992 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
1993 ], [
1994 AC_MSG_RESULT(no)
1995 ])
1996 ])
1997
1998 dnl #
1999 dnl # 2.6.35 API change,
2000 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2001 dnl #
2002 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2003 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2004 SPL_LINUX_TRY_COMPILE([
2005 #include <linux/fs.h>
2006 ],[
2007 vfs_fsync(NULL, 0);
2008 ],[
2009 AC_MSG_RESULT(yes)
2010 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2011 ],[
2012 AC_MSG_RESULT(no)
2013 ])
2014 ])
2015
2016 dnl #
2017 dnl # 3.5 API change,
2018 dnl # inode_operations.truncate_range removed
2019 dnl #
2020 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2021 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2022 SPL_LINUX_TRY_COMPILE([
2023 #include <linux/fs.h>
2024 ],[
2025 struct inode_operations ops;
2026 ops.truncate_range = NULL;
2027 ],[
2028 AC_MSG_RESULT(yes)
2029 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2030 [truncate_range() inode operation is available])
2031 ],[
2032 AC_MSG_RESULT(no)
2033 ])
2034 ])
2035
2036 dnl #
2037 dnl # Linux 2.6.38 - 3.x API
2038 dnl #
2039 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2040 AC_MSG_CHECKING([whether fops->fallocate() exists])
2041 SPL_LINUX_TRY_COMPILE([
2042 #include <linux/fs.h>
2043 ],[
2044 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2045 struct file_operations fops __attribute__ ((unused)) = {
2046 .fallocate = fallocate,
2047 };
2048 ],[
2049 AC_MSG_RESULT(yes)
2050 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2051 ],[
2052 AC_MSG_RESULT(no)
2053 ])
2054 ])
2055
2056 dnl #
2057 dnl # Linux 2.6.x - 2.6.37 API
2058 dnl #
2059 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2060 AC_MSG_CHECKING([whether iops->fallocate() exists])
2061 SPL_LINUX_TRY_COMPILE([
2062 #include <linux/fs.h>
2063 ],[
2064 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2065 struct inode_operations fops __attribute__ ((unused)) = {
2066 .fallocate = fallocate,
2067 };
2068 ],[
2069 AC_MSG_RESULT(yes)
2070 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2071 ],[
2072 AC_MSG_RESULT(no)
2073 ])
2074 ])
2075
2076 dnl #
2077 dnl # PaX Linux 2.6.38 - 3.x API
2078 dnl #
2079 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2080 AC_MSG_CHECKING([whether fops->fallocate() exists])
2081 SPL_LINUX_TRY_COMPILE([
2082 #include <linux/fs.h>
2083 ],[
2084 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2085 struct file_operations_no_const fops __attribute__ ((unused)) = {
2086 .fallocate = fallocate,
2087 };
2088 ],[
2089 AC_MSG_RESULT(yes)
2090 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2091 ],[
2092 AC_MSG_RESULT(no)
2093 ])
2094 ])
2095
2096 dnl #
2097 dnl # The fallocate callback was moved from the inode_operations
2098 dnl # structure to the file_operations structure.
2099 dnl #
2100 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2101 SPL_AC_KERNEL_FILE_FALLOCATE
2102 SPL_AC_KERNEL_INODE_FALLOCATE
2103 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2104 ])
2105
2106 dnl #
2107 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2108 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2109 dnl # condition. The fixed version is exported as a symbol. The race
2110 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2111 dnl # call that version while holding sem->wait_lock.
2112 dnl #
2113 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2114 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2115 SPL_LINUX_TRY_COMPILE_SYMBOL([
2116 #include <linux/rwsem.h>
2117 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2118 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2119 AC_MSG_RESULT(yes)
2120 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2121 [rwsem_is_locked() acquires sem->wait_lock])
2122 ], [
2123 AC_MSG_RESULT(no)
2124 ])
2125 ])
2126
2127 dnl #
2128 dnl # 2.6.xx API compat,
2129 dnl # There currently exists no exposed API to partially shrink the dcache.
2130 dnl # The expected mechanism to shrink the cache is a registered shrinker
2131 dnl # which is called during memory pressure.
2132 dnl #
2133 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2134 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2135 SPL_LINUX_TRY_COMPILE_SYMBOL([
2136 #include <linux/dcache.h>
2137 ], [
2138 shrink_dcache_memory(0, 0);
2139 ], [shrink_dcache_memory], [fs/dcache.c], [
2140 AC_MSG_RESULT(yes)
2141 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2142 [shrink_dcache_memory() is available])
2143 ], [
2144 AC_MSG_RESULT(no)
2145 ])
2146 ])
2147
2148 dnl #
2149 dnl # 2.6.xx API compat,
2150 dnl # There currently exists no exposed API to partially shrink the icache.
2151 dnl # The expected mechanism to shrink the cache is a registered shrinker
2152 dnl # which is called during memory pressure.
2153 dnl #
2154 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2155 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2156 SPL_LINUX_TRY_COMPILE_SYMBOL([
2157 #include <linux/dcache.h>
2158 ], [
2159 shrink_icache_memory(0, 0);
2160 ], [shrink_icache_memory], [fs/inode.c], [
2161 AC_MSG_RESULT(yes)
2162 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2163 [shrink_icache_memory() is available])
2164 ], [
2165 AC_MSG_RESULT(no)
2166 ])
2167 ])
2168
2169 dnl #
2170 dnl # 2.6.39 API compat,
2171 dnl # The path_lookup() function has been renamed to kern_path_parent()
2172 dnl # and the flags argument has been removed. The only behavior now
2173 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2174 dnl # this flag so dropping the flag does not impact us.
2175 dnl #
2176 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2177 SPL_CHECK_SYMBOL_HEADER(
2178 [kern_path_parent],
2179 [int kern_path_parent(const char \*, struct nameidata \*)],
2180 [include/linux/namei.h],
2181 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2182 [kern_path_parent() is available])],
2183 [])
2184 ])
2185
2186 dnl #
2187 dnl # 3.1 API compat,
2188 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2189 dnl # However, it remains the prefered interface and since we still have
2190 dnl # access to the prototype we dynamically lookup the required address.
2191 dnl #
2192 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2193 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2194 SPL_LINUX_TRY_COMPILE_SYMBOL([
2195 #include <linux/namei.h>
2196 ], [
2197 kern_path_parent(NULL, NULL);
2198 ], [kern_path_parent], [fs/namei.c], [
2199 AC_MSG_RESULT(yes)
2200 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2201 [kern_path_parent() is available])
2202 ], [
2203 AC_MSG_RESULT(no)
2204 ])
2205 ])
2206
2207 dnl #
2208 dnl # 3.6 API compat,
2209 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2210 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2211 dnl #
2212 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2213 SPL_CHECK_SYMBOL_HEADER(
2214 [kern_path_locked],
2215 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2216 [include/linux/namei.h],
2217 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2218 [kern_path_locked() is available])],
2219 [])
2220 ])
2221
2222 dnl #
2223 dnl # /proc/kallsyms support,
2224 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2225 dnl #
2226 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2227 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2228 SPL_LINUX_TRY_COMPILE([
2229 #if !defined(CONFIG_KALLSYMS)
2230 #error CONFIG_KALLSYMS not defined
2231 #endif
2232 ],[ ],[
2233 AC_MSG_RESULT([yes])
2234 ],[
2235 AC_MSG_RESULT([no])
2236 AC_MSG_ERROR([
2237 *** This kernel does not include the required kallsyms support.
2238 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2239 ])
2240 ])
2241
2242 dnl #
2243 dnl # zlib inflate compat,
2244 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2245 dnl #
2246 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2247 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2248 SPL_LINUX_TRY_COMPILE([
2249 #if !defined(CONFIG_ZLIB_INFLATE) && \
2250 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2251 #error CONFIG_ZLIB_INFLATE not defined
2252 #endif
2253 ],[ ],[
2254 AC_MSG_RESULT([yes])
2255 ],[
2256 AC_MSG_RESULT([no])
2257 AC_MSG_ERROR([
2258 *** This kernel does not include the required zlib inflate support.
2259 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2260 ])
2261 ])
2262
2263 dnl #
2264 dnl # zlib deflate compat,
2265 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2266 dnl #
2267 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2268 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2269 SPL_LINUX_TRY_COMPILE([
2270 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2271 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2272 #error CONFIG_ZLIB_DEFLATE not defined
2273 #endif
2274 ],[ ],[
2275 AC_MSG_RESULT([yes])
2276 ],[
2277 AC_MSG_RESULT([no])
2278 AC_MSG_ERROR([
2279 *** This kernel does not include the required zlib deflate support.
2280 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2281 ])
2282 ])
2283
2284 dnl #
2285 dnl # 2.6.39 API compat,
2286 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2287 dnl # This was done to avoid always having to allocate the maximum size
2288 dnl # workspace (268K). The caller can now specific the windowBits and
2289 dnl # memLevel compression parameters to get a smaller workspace.
2290 dnl #
2291 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2292 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2293 SPL_LINUX_TRY_COMPILE([
2294 #include <linux/zlib.h>
2295 ],[
2296 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2297 ],[
2298 AC_MSG_RESULT(yes)
2299 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2300 [zlib_deflate_workspacesize() wants 2 args])
2301 ],[
2302 AC_MSG_RESULT(no)
2303 ])
2304 ])
2305
2306 dnl #
2307 dnl # 2.6.39 API change,
2308 dnl # Shrinker adjust to use common shrink_control structure.
2309 dnl #
2310 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2311 AC_MSG_CHECKING([whether struct shrink_control exists])
2312 SPL_LINUX_TRY_COMPILE([
2313 #include <linux/mm.h>
2314 ],[
2315 struct shrink_control sc __attribute__ ((unused));
2316
2317 sc.nr_to_scan = 0;
2318 sc.gfp_mask = GFP_KERNEL;
2319 ],[
2320 AC_MSG_RESULT(yes)
2321 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2322 [struct shrink_control exists])
2323 ],[
2324 AC_MSG_RESULT(no)
2325 ])
2326 ])
2327
2328 dnl #
2329 dnl # 3.1 API Change
2330 dnl #
2331 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2332 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2333 dnl #
2334 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2335 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2336 tmp_flags="$EXTRA_KCFLAGS"
2337 EXTRA_KCFLAGS="-Werror"
2338 SPL_LINUX_TRY_COMPILE([
2339 #include <linux/rwsem.h>
2340 ],[
2341 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2342 raw_spinlock_t dummy_lock __attribute__ ((unused));
2343 dummy_semaphore.wait_lock = dummy_lock;
2344 ],[
2345 AC_MSG_RESULT(yes)
2346 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2347 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2348 ],[
2349 AC_MSG_RESULT(no)
2350 ])
2351 EXTRA_KCFLAGS="$tmp_flags"
2352 ])
2353
2354 dnl #
2355 dnl # 3.9 API change,
2356 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2357 dnl #
2358 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2359 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2360 SPL_LINUX_TRY_COMPILE([
2361 #include <linux/sched.h>
2362 #include <linux/sched/rt.h>
2363 ],[
2364 return 0;
2365 ],[
2366 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2367 AC_MSG_RESULT(yes)
2368 ],[
2369 AC_MSG_RESULT(no)
2370 ])
2371 ])
2372
2373 dnl #
2374 dnl # 3.9 API change,
2375 dnl # vfs_getattr() uses 2 args
2376 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2377 dnl #
2378 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2379 AC_MSG_CHECKING([whether vfs_getattr() wants])
2380 SPL_LINUX_TRY_COMPILE([
2381 #include <linux/fs.h>
2382 ],[
2383 vfs_getattr((struct path *) NULL,
2384 (struct kstat *)NULL);
2385 ],[
2386 AC_MSG_RESULT(2 args)
2387 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2388 [vfs_getattr wants 2 args])
2389 ],[
2390 SPL_LINUX_TRY_COMPILE([
2391 #include <linux/fs.h>
2392 ],[
2393 vfs_getattr((struct vfsmount *)NULL,
2394 (struct dentry *)NULL,
2395 (struct kstat *)NULL);
2396 ],[
2397 AC_MSG_RESULT(3 args)
2398 ],[
2399 AC_MSG_ERROR(unknown)
2400 ])
2401 ])
2402 ])