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