]> git.proxmox.com Git - mirror_spl-debian.git/blob - config/spl-build.m4
Linux 3.4 compat, __clear_close_on_exec replaces FD_CLR
[mirror_spl-debian.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 SPL_AC_KERNEL_CONFIG
12
13 if test "${LINUX_OBJ}" != "${LINUX}"; then
14 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
15 fi
16 AC_SUBST(KERNELMAKE_PARAMS)
17
18 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
19 AC_SUBST(KERNELCPPFLAGS)
20
21 SPL_AC_DEBUG
22 SPL_AC_DEBUG_LOG
23 SPL_AC_DEBUG_KMEM
24 SPL_AC_DEBUG_KMEM_TRACKING
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_3ARGS_INIT_WORK
30 SPL_AC_2ARGS_REGISTER_SYSCTL
31 SPL_AC_SET_SHRINKER
32 SPL_AC_3ARGS_SHRINKER_CALLBACK
33 SPL_AC_PATH_IN_NAMEIDATA
34 SPL_AC_TASK_CURR
35 SPL_AC_CTL_UNNUMBERED
36 SPL_AC_CTL_NAME
37 SPL_AC_FLS64
38 SPL_AC_DEVICE_CREATE
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
43 SPL_AC_TIMESPEC_SUB
44 SPL_AC_INIT_UTSNAME
45 SPL_AC_FDTABLE_HEADER
46 SPL_AC_FILES_FDTABLE
47 SPL_AC_CLEAR_CLOSE_ON_EXEC
48 SPL_AC_UACCESS_HEADER
49 SPL_AC_KMALLOC_NODE
50 SPL_AC_MONOTONIC_CLOCK
51 SPL_AC_INODE_I_MUTEX
52 SPL_AC_MUTEX_OWNER
53 SPL_AC_MUTEX_OWNER_TASK_STRUCT
54 SPL_AC_MUTEX_LOCK_NESTED
55 SPL_AC_3ARGS_ON_EACH_CPU
56 SPL_AC_KALLSYMS_LOOKUP_NAME
57 SPL_AC_GET_VMALLOC_INFO
58 SPL_AC_PGDAT_HELPERS
59 SPL_AC_FIRST_ONLINE_PGDAT
60 SPL_AC_NEXT_ONLINE_PGDAT
61 SPL_AC_NEXT_ZONE
62 SPL_AC_PGDAT_LIST
63 SPL_AC_GLOBAL_PAGE_STATE
64 SPL_AC_ZONE_STAT_ITEM_FREE
65 SPL_AC_ZONE_STAT_ITEM_INACTIVE
66 SPL_AC_ZONE_STAT_ITEM_ACTIVE
67 SPL_AC_GET_ZONE_COUNTS
68 SPL_AC_USER_PATH_DIR
69 SPL_AC_SET_FS_PWD
70 SPL_AC_2ARGS_SET_FS_PWD
71 SPL_AC_2ARGS_VFS_UNLINK
72 SPL_AC_4ARGS_VFS_RENAME
73 SPL_AC_VFS_FSYNC
74 SPL_AC_2ARGS_VFS_FSYNC
75 SPL_AC_FS_STRUCT_SPINLOCK
76 SPL_AC_CRED_STRUCT
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_INVALIDATE_INODES
83 SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES
84 SPL_AC_SHRINK_DCACHE_MEMORY
85 SPL_AC_SHRINK_ICACHE_MEMORY
86 SPL_AC_KERN_PATH_PARENT_HEADER
87 SPL_AC_KERN_PATH_PARENT_SYMBOL
88 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
89 SPL_AC_SHRINK_CONTROL_STRUCT
90 SPL_AC_RWSEM_SPINLOCK_IS_RAW
91 ])
92
93 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
94 modpost=$LINUX/scripts/Makefile.modpost
95 AC_MSG_CHECKING([kernel file name for module symbols])
96 if test -f "$modpost"; then
97 if grep -q Modules.symvers $modpost; then
98 LINUX_SYMBOLS=Modules.symvers
99 else
100 LINUX_SYMBOLS=Module.symvers
101 fi
102
103 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
104 AC_MSG_ERROR([
105 *** Please make sure the kernel devel package for your distribution
106 *** is installed. If your building with a custom kernel make sure the
107 *** kernel is configured, built, and the '--with-linux=PATH' configure
108 *** option refers to the location of the kernel source.])
109 fi
110 else
111 LINUX_SYMBOLS=NONE
112 fi
113 AC_MSG_RESULT($LINUX_SYMBOLS)
114 AC_SUBST(LINUX_SYMBOLS)
115 ])
116
117 AC_DEFUN([SPL_AC_KERNEL], [
118 AC_ARG_WITH([linux],
119 AS_HELP_STRING([--with-linux=PATH],
120 [Path to kernel source]),
121 [kernelsrc="$withval"])
122
123 AC_ARG_WITH([linux-obj],
124 AS_HELP_STRING([--with-linux-obj=PATH],
125 [Path to kernel build objects]),
126 [kernelbuild="$withval"])
127
128 AC_MSG_CHECKING([kernel source directory])
129 if test -z "$kernelsrc"; then
130 if test -e "/lib/modules/$(uname -r)/source"; then
131 headersdir="/lib/modules/$(uname -r)/source"
132 sourcelink=$(readlink -f "$headersdir")
133 elif test -e "/lib/modules/$(uname -r)/build"; then
134 headersdir="/lib/modules/$(uname -r)/build"
135 sourcelink=$(readlink -f "$headersdir")
136 else
137 sourcelink=$(ls -1d /usr/src/kernels/* \
138 /usr/src/linux-* \
139 2>/dev/null | grep -v obj | tail -1)
140 fi
141
142 if test -n "$sourcelink" && test -e ${sourcelink}; then
143 kernelsrc=`readlink -f ${sourcelink}`
144 else
145 AC_MSG_RESULT([Not found])
146 AC_MSG_ERROR([
147 *** Please make sure the kernel devel package for your distribution
148 *** is installed then try again. If that fails you can specify the
149 *** location of the kernel source with the '--with-linux=PATH' option.])
150 fi
151 else
152 if test "$kernelsrc" = "NONE"; then
153 kernsrcver=NONE
154 fi
155 fi
156
157 AC_MSG_RESULT([$kernelsrc])
158 AC_MSG_CHECKING([kernel build directory])
159 if test -z "$kernelbuild"; then
160 if test -e "/lib/modules/$(uname -r)/build"; then
161 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
162 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
163 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
164 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
165 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
166 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
167 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
168 else
169 kernelbuild=${kernelsrc}
170 fi
171 fi
172 AC_MSG_RESULT([$kernelbuild])
173
174 AC_MSG_CHECKING([kernel source version])
175 utsrelease1=$kernelbuild/include/linux/version.h
176 utsrelease2=$kernelbuild/include/linux/utsrelease.h
177 utsrelease3=$kernelbuild/include/generated/utsrelease.h
178 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
179 utsrelease=linux/version.h
180 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
181 utsrelease=linux/utsrelease.h
182 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
183 utsrelease=generated/utsrelease.h
184 fi
185
186 if test "$utsrelease"; then
187 kernsrcver=`(echo "#include <$utsrelease>";
188 echo "kernsrcver=UTS_RELEASE") |
189 cpp -I $kernelbuild/include |
190 grep "^kernsrcver=" | cut -d \" -f 2`
191
192 if test -z "$kernsrcver"; then
193 AC_MSG_RESULT([Not found])
194 AC_MSG_ERROR([*** Cannot determine kernel version.])
195 fi
196 else
197 AC_MSG_RESULT([Not found])
198 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
199 fi
200
201 AC_MSG_RESULT([$kernsrcver])
202
203 LINUX=${kernelsrc}
204 LINUX_OBJ=${kernelbuild}
205 LINUX_VERSION=${kernsrcver}
206
207 AC_SUBST(LINUX)
208 AC_SUBST(LINUX_OBJ)
209 AC_SUBST(LINUX_VERSION)
210
211 SPL_AC_MODULE_SYMVERS
212 ])
213
214 AC_DEFUN([SPL_AC_KERNEL_CONFIG], [
215 SPL_LINUX_CONFIG([PREEMPT],
216 AC_MSG_ERROR([
217 *** Kernel built with CONFIG_PREEMPT which is not supported.
218 ** You must rebuild your kernel without this option.]), [])
219 ])
220
221 dnl #
222 dnl # Default SPL user configuration
223 dnl #
224 AC_DEFUN([SPL_AC_CONFIG_USER], [])
225
226 dnl #
227 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
228 dnl # are missing it is non-fatal but you will not be able to build
229 dnl # RPM packages and will be warned if you try too.
230 dnl #
231 AC_DEFUN([SPL_AC_RPM], [
232 RPM=rpm
233 RPMBUILD=rpmbuild
234
235 AC_MSG_CHECKING([whether $RPM is available])
236 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
237 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
238 HAVE_RPM=yes
239 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
240 ],[
241 HAVE_RPM=no
242 AC_MSG_RESULT([$HAVE_RPM])
243 ])
244
245 AC_MSG_CHECKING([whether $RPMBUILD is available])
246 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
247 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
248 HAVE_RPMBUILD=yes
249 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
250 ],[
251 HAVE_RPMBUILD=no
252 AC_MSG_RESULT([$HAVE_RPMBUILD])
253 ])
254
255 AC_SUBST(HAVE_RPM)
256 AC_SUBST(RPM)
257 AC_SUBST(RPM_VERSION)
258
259 AC_SUBST(HAVE_RPMBUILD)
260 AC_SUBST(RPMBUILD)
261 AC_SUBST(RPMBUILD_VERSION)
262 ])
263
264 dnl #
265 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
266 dnl # tools are missing it is non-fatal but you will not be able to build
267 dnl # DEB packages and will be warned if you try too.
268 dnl #
269 AC_DEFUN([SPL_AC_DPKG], [
270 DPKG=dpkg
271 DPKGBUILD=dpkg-buildpackage
272
273 AC_MSG_CHECKING([whether $DPKG is available])
274 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
275 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
276 HAVE_DPKG=yes
277 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
278 ],[
279 HAVE_DPKG=no
280 AC_MSG_RESULT([$HAVE_DPKG])
281 ])
282
283 AC_MSG_CHECKING([whether $DPKGBUILD is available])
284 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
285 DPKGBUILD_VERSION=$(echo $tmp | \
286 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
287 HAVE_DPKGBUILD=yes
288 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
289 ],[
290 HAVE_DPKGBUILD=no
291 AC_MSG_RESULT([$HAVE_DPKGBUILD])
292 ])
293
294 AC_SUBST(HAVE_DPKG)
295 AC_SUBST(DPKG)
296 AC_SUBST(DPKG_VERSION)
297
298 AC_SUBST(HAVE_DPKGBUILD)
299 AC_SUBST(DPKGBUILD)
300 AC_SUBST(DPKGBUILD_VERSION)
301 ])
302
303 dnl #
304 dnl # Check for pacman+makepkg to build Arch Linux packages. If these
305 dnl # tools are missing it is non-fatal but you will not be able to
306 dnl # build Arch Linux packages and will be warned if you try too.
307 dnl #
308 AC_DEFUN([SPL_AC_PACMAN], [
309 PACMAN=pacman
310 MAKEPKG=makepkg
311
312 AC_MSG_CHECKING([whether $PACMAN is available])
313 tmp=$($PACMAN --version 2>/dev/null)
314 AS_IF([test -n "$tmp"], [
315 PACMAN_VERSION=$(echo $tmp |
316 $AWK '/Pacman/ { print $[3] }' |
317 $SED 's/^v//')
318 HAVE_PACMAN=yes
319 AC_MSG_RESULT([$HAVE_PACMAN ($PACMAN_VERSION)])
320 ],[
321 HAVE_PACMAN=no
322 AC_MSG_RESULT([$HAVE_PACMAN])
323 ])
324
325 AC_MSG_CHECKING([whether $MAKEPKG is available])
326 tmp=$($MAKEPKG --version 2>/dev/null)
327 AS_IF([test -n "$tmp"], [
328 MAKEPKG_VERSION=$(echo $tmp | $AWK '/makepkg/ { print $[3] }')
329 HAVE_MAKEPKG=yes
330 AC_MSG_RESULT([$HAVE_MAKEPKG ($MAKEPKG_VERSION)])
331 ],[
332 HAVE_MAKEPKG=no
333 AC_MSG_RESULT([$HAVE_MAKEPKG])
334 ])
335
336 AC_SUBST(HAVE_PACMAN)
337 AC_SUBST(PACMAN)
338 AC_SUBST(PACMAN_VERSION)
339
340 AC_SUBST(HAVE_MAKEPKG)
341 AC_SUBST(MAKEPKG)
342 AC_SUBST(MAKEPKG_VERSION)
343 ])
344
345 dnl #
346 dnl # Until native packaging for various different packing systems
347 dnl # can be added the least we can do is attempt to use alien to
348 dnl # convert the RPM packages to the needed package type. This is
349 dnl # a hack but so far it has worked reasonable well.
350 dnl #
351 AC_DEFUN([SPL_AC_ALIEN], [
352 ALIEN=alien
353
354 AC_MSG_CHECKING([whether $ALIEN is available])
355 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
356 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
357 HAVE_ALIEN=yes
358 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
359 ],[
360 HAVE_ALIEN=no
361 AC_MSG_RESULT([$HAVE_ALIEN])
362 ])
363
364 AC_SUBST(HAVE_ALIEN)
365 AC_SUBST(ALIEN)
366 AC_SUBST(ALIEN_VERSION)
367 ])
368
369 dnl #
370 dnl # Using the VENDOR tag from config.guess set the default
371 dnl # package type for 'make pkg': (rpm | deb | tgz)
372 dnl #
373 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
374 AC_MSG_CHECKING([linux distribution])
375 if test -f /etc/toss-release ; then
376 VENDOR=toss ;
377 elif test -f /etc/fedora-release ; then
378 VENDOR=fedora ;
379 elif test -f /etc/redhat-release ; then
380 VENDOR=redhat ;
381 elif test -f /etc/gentoo-release ; then
382 VENDOR=gentoo ;
383 elif test -f /etc/arch-release ; then
384 VENDOR=arch ;
385 elif test -f /etc/SuSE-release ; then
386 VENDOR=sles ;
387 elif test -f /etc/slackware-version ; then
388 VENDOR=slackware ;
389 elif test -f /etc/lunar.release ; then
390 VENDOR=lunar ;
391 elif test -f /etc/lsb-release ; then
392 VENDOR=ubuntu ;
393 elif test -f /etc/debian_version ; then
394 VENDOR=debian ;
395 else
396 VENDOR= ;
397 fi
398 AC_MSG_RESULT([$VENDOR])
399 AC_SUBST(VENDOR)
400
401 AC_MSG_CHECKING([default package type])
402 case "$VENDOR" in
403 toss) DEFAULT_PACKAGE=rpm ;;
404 redhat) DEFAULT_PACKAGE=rpm ;;
405 fedora) DEFAULT_PACKAGE=rpm ;;
406 gentoo) DEFAULT_PACKAGE=tgz ;;
407 arch) DEFAULT_PACKAGE=arch ;;
408 sles) DEFAULT_PACKAGE=rpm ;;
409 slackware) DEFAULT_PACKAGE=tgz ;;
410 lunar) DEFAULT_PACKAGE=tgz ;;
411 ubuntu) DEFAULT_PACKAGE=deb ;;
412 debian) DEFAULT_PACKAGE=deb ;;
413 *) DEFAULT_PACKAGE=rpm ;;
414 esac
415
416 AC_MSG_RESULT([$DEFAULT_PACKAGE])
417 AC_SUBST(DEFAULT_PACKAGE)
418 ])
419
420 dnl #
421 dnl # Default SPL user configuration
422 dnl #
423 AC_DEFUN([SPL_AC_PACKAGE], [
424 SPL_AC_DEFAULT_PACKAGE
425 SPL_AC_RPM
426 SPL_AC_DPKG
427 SPL_AC_ALIEN
428
429 AS_IF([test "$VENDOR" = "arch"], [SPL_AC_PACMAN])
430 ])
431
432 AC_DEFUN([SPL_AC_LICENSE], [
433 AC_MSG_CHECKING([spl license])
434 LICENSE=GPL
435 AC_MSG_RESULT([$LICENSE])
436 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
437 AC_SUBST(LICENSE)
438 ])
439
440 AC_DEFUN([SPL_AC_CONFIG], [
441 SPL_CONFIG=all
442 AC_ARG_WITH([config],
443 AS_HELP_STRING([--with-config=CONFIG],
444 [Config file 'kernel|user|all|srpm']),
445 [SPL_CONFIG="$withval"])
446
447 AC_MSG_CHECKING([spl config])
448 AC_MSG_RESULT([$SPL_CONFIG]);
449 AC_SUBST(SPL_CONFIG)
450
451 case "$SPL_CONFIG" in
452 kernel) SPL_AC_CONFIG_KERNEL ;;
453 user) SPL_AC_CONFIG_USER ;;
454 all) SPL_AC_CONFIG_KERNEL
455 SPL_AC_CONFIG_USER ;;
456 srpm) ;;
457 *)
458 AC_MSG_RESULT([Error!])
459 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
460 user kernel|user|all|srpm]) ;;
461 esac
462
463 AM_CONDITIONAL([CONFIG_USER],
464 [test "$SPL_CONFIG" = user] ||
465 [test "$SPL_CONFIG" = all])
466 AM_CONDITIONAL([CONFIG_KERNEL],
467 [test "$SPL_CONFIG" = kernel] ||
468 [test "$SPL_CONFIG" = all])
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
623 echo "obj-m := conftest.o" >build/Makefile
624 AS_IF(
625 [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) >/dev/null && AC_TRY_COMMAND([$3])],
626 [$4],
627 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
628 )
629 rm -Rf build
630 ])
631
632 dnl #
633 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
634 dnl #
635 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
636 [SPL_LINUX_COMPILE_IFELSE(
637 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
638 [modules],
639 [test -s build/conftest.o],
640 [$3], [$4])
641 ])
642
643 dnl #
644 dnl # SPL_LINUX_CONFIG
645 dnl #
646 AC_DEFUN([SPL_LINUX_CONFIG],
647 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
648 SPL_LINUX_TRY_COMPILE([
649 #include <linux/module.h>
650 ],[
651 #ifndef CONFIG_$1
652 #error CONFIG_$1 not #defined
653 #endif
654 ],[
655 AC_MSG_RESULT([yes])
656 $2
657 ],[
658 AC_MSG_RESULT([no])
659 $3
660 ])
661 ])
662
663 dnl #
664 dnl # SPL_CHECK_SYMBOL_EXPORT
665 dnl # check symbol exported or not
666 dnl #
667 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
668 [AC_MSG_CHECKING([whether symbol $1 is exported])
669 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
670 $LINUX_OBJ/Module*.symvers 2>/dev/null
671 rc=$?
672 if test $rc -ne 0; then
673 export=0
674 for file in $2; do
675 grep -q -E "EXPORT_SYMBOL.*($1)" \
676 "$LINUX_OBJ/$file" 2>/dev/null
677 rc=$?
678 if test $rc -eq 0; then
679 export=1
680 break;
681 fi
682 done
683 if test $export -eq 0; then
684 AC_MSG_RESULT([no])
685 $4
686 else
687 AC_MSG_RESULT([yes])
688 $3
689 fi
690 else
691 AC_MSG_RESULT([yes])
692 $3
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 # Use the atomic implemenation based on global spinlocks. This
742 dnl # should only be needed by 32-bit kernels which do not provide
743 dnl # the atomic64_* API. It may be optionally enabled as a fallback
744 dnl # if problems are observed with the direct mapping to the native
745 dnl # Linux atomic operations. You may not disable atomic spinlocks
746 dnl # if you kernel does not an atomic64_* API.
747 dnl #
748 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
749 AC_ARG_ENABLE([atomic-spinlocks],
750 [AS_HELP_STRING([--enable-atomic-spinlocks],
751 [Atomic types use spinlocks @<:@default=check@:>@])],
752 [],
753 [enable_atomic_spinlocks=check])
754
755 SPL_LINUX_TRY_COMPILE([
756 #include <asm/atomic.h>
757 ],[
758 atomic64_t *ptr __attribute__ ((unused));
759 ],[
760 have_atomic64_t=yes
761 AC_DEFINE(HAVE_ATOMIC64_T, 1,
762 [kernel defines atomic64_t])
763 ],[
764 have_atomic64_t=no
765 ])
766
767 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
768 AS_IF([test "x$have_atomic64_t" = xyes], [
769 enable_atomic_spinlocks=no
770 ],[
771 enable_atomic_spinlocks=yes
772 ])
773 ])
774
775 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
776 AC_DEFINE([ATOMIC_SPINLOCK], [1],
777 [Atomic types use spinlocks])
778 ],[
779 AS_IF([test "x$have_atomic64_t" = xno], [
780 AC_MSG_FAILURE(
781 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
782 ])
783 ])
784
785 AC_MSG_CHECKING([whether atomic types use spinlocks])
786 AC_MSG_RESULT([$enable_atomic_spinlocks])
787
788 AC_MSG_CHECKING([whether kernel defines atomic64_t])
789 AC_MSG_RESULT([$have_atomic64_t])
790 ])
791
792 dnl #
793 dnl # 2.6.24 API change,
794 dnl # check if atomic64_cmpxchg is defined
795 dnl #
796 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
797 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
798 SPL_LINUX_TRY_COMPILE([
799 #include <asm/atomic.h>
800 #include <asm/system.h>
801 ],[
802 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
803 ],[
804 AC_MSG_RESULT([yes])
805 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
806 [kernel defines atomic64_cmpxchg])
807 ],[
808 AC_MSG_RESULT([no])
809 ])
810 ])
811
812 dnl #
813 dnl # 2.6.24 API change,
814 dnl # check if atomic64_xchg is defined
815 dnl #
816 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
817 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
818 SPL_LINUX_TRY_COMPILE([
819 #include <asm/atomic.h>
820 ],[
821 atomic64_xchg((atomic64_t *)NULL, 0);
822 ],[
823 AC_MSG_RESULT([yes])
824 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
825 [kernel defines atomic64_xchg])
826 ],[
827 AC_MSG_RESULT([no])
828 ])
829 ])
830
831 dnl #
832 dnl # 2.6.24 API change,
833 dnl # check if uintptr_t typedef is defined
834 dnl #
835 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
836 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
837 SPL_LINUX_TRY_COMPILE([
838 #include <linux/types.h>
839 ],[
840 uintptr_t *ptr __attribute__ ((unused));
841 ],[
842 AC_MSG_RESULT([yes])
843 AC_DEFINE(HAVE_UINTPTR_T, 1,
844 [kernel defines uintptr_t])
845 ],[
846 AC_MSG_RESULT([no])
847 ])
848 ])
849
850 dnl #
851 dnl # 2.6.20 API change,
852 dnl # INIT_WORK use 2 args and not store data inside
853 dnl #
854 AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
855 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
856 SPL_LINUX_TRY_COMPILE([
857 #include <linux/workqueue.h>
858 ],[
859 struct work_struct work __attribute__ ((unused));
860 INIT_WORK(&work, NULL, NULL);
861 ],[
862 AC_MSG_RESULT(yes)
863 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
864 [INIT_WORK wants 3 args])
865 ],[
866 AC_MSG_RESULT(no)
867 ])
868 ])
869
870 dnl #
871 dnl # 2.6.21 API change,
872 dnl # 'register_sysctl_table' use only one argument instead of two
873 dnl #
874 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
875 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
876 SPL_LINUX_TRY_COMPILE([
877 #include <linux/sysctl.h>
878 ],[
879 (void) register_sysctl_table(NULL, 0);
880 ],[
881 AC_MSG_RESULT(yes)
882 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
883 [register_sysctl_table() wants 2 args])
884 ],[
885 AC_MSG_RESULT(no)
886 ])
887 ])
888
889 dnl #
890 dnl # 2.6.23 API change
891 dnl # Old set_shrinker API replaced with register_shrinker
892 dnl #
893 AC_DEFUN([SPL_AC_SET_SHRINKER], [
894 AC_MSG_CHECKING([whether set_shrinker() available])
895 SPL_LINUX_TRY_COMPILE([
896 #include <linux/mm.h>
897 ],[
898 return set_shrinker(DEFAULT_SEEKS, NULL);
899 ],[
900 AC_MSG_RESULT([yes])
901 AC_DEFINE(HAVE_SET_SHRINKER, 1,
902 [set_shrinker() available])
903 ],[
904 AC_MSG_RESULT([no])
905 ])
906 ])
907
908 dnl #
909 dnl # 2.6.35 API change,
910 dnl # Add context to shrinker callback
911 dnl #
912 AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK],
913 [AC_MSG_CHECKING([whether shrinker callback wants 3 args])
914 tmp_flags="$EXTRA_KCFLAGS"
915 EXTRA_KCFLAGS="-Werror"
916 SPL_LINUX_TRY_COMPILE([
917 #include <linux/mm.h>
918
919 int shrinker_cb(struct shrinker *, int, unsigned int);
920 ],[
921 struct shrinker cache_shrinker = {
922 .shrink = shrinker_cb,
923 .seeks = DEFAULT_SEEKS,
924 };
925 register_shrinker(&cache_shrinker);
926 ],[
927 AC_MSG_RESULT(yes)
928 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
929 [shrinker callback wants 3 args])
930 ],[
931 AC_MSG_RESULT(no)
932 ])
933 EXTRA_KCFLAGS="$tmp_flags"
934 ])
935
936 dnl #
937 dnl # 2.6.25 API change,
938 dnl # struct path entry added to struct nameidata
939 dnl #
940 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
941 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
942 SPL_LINUX_TRY_COMPILE([
943 #include <linux/namei.h>
944 ],[
945 struct nameidata nd __attribute__ ((unused));
946
947 nd.path.mnt = NULL;
948 nd.path.dentry = NULL;
949 ],[
950 AC_MSG_RESULT(yes)
951 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
952 [struct path used in struct nameidata])
953 ],[
954 AC_MSG_RESULT(no)
955 ])
956 ])
957
958 dnl #
959 dnl # Custom SPL patch may export this system it is not required
960 dnl #
961 AC_DEFUN([SPL_AC_TASK_CURR], [
962 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
963 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
964 [])
965 ])
966
967 dnl #
968 dnl # 2.6.19 API change,
969 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
970 dnl #
971 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
972 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
973 SPL_LINUX_TRY_COMPILE([
974 #include <linux/sysctl.h>
975 ],[
976 #ifndef CTL_UNNUMBERED
977 #error CTL_UNNUMBERED undefined
978 #endif
979 ],[
980 AC_MSG_RESULT(yes)
981 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
982 [unnumbered sysctl support exists])
983 ],[
984 AC_MSG_RESULT(no)
985 ])
986 ])
987
988 dnl #
989 dnl # 2.6.33 API change,
990 dnl # Removed .ctl_name from struct ctl_table.
991 dnl #
992 AC_DEFUN([SPL_AC_CTL_NAME], [
993 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
994 SPL_LINUX_TRY_COMPILE([
995 #include <linux/sysctl.h>
996 ],[
997 struct ctl_table ctl __attribute__ ((unused));
998 ctl.ctl_name = 0;
999 ],[
1000 AC_MSG_RESULT(yes)
1001 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1002 ],[
1003 AC_MSG_RESULT(no)
1004 ])
1005 ])
1006
1007 dnl #
1008 dnl # 2.6.16 API change.
1009 dnl # Check if 'fls64()' is available
1010 dnl #
1011 AC_DEFUN([SPL_AC_FLS64],
1012 [AC_MSG_CHECKING([whether fls64() is available])
1013 SPL_LINUX_TRY_COMPILE([
1014 #include <linux/bitops.h>
1015 ],[
1016 return fls64(0);
1017 ],[
1018 AC_MSG_RESULT(yes)
1019 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1020 ],[
1021 AC_MSG_RESULT(no)
1022 ])
1023 ])
1024
1025 dnl #
1026 dnl # 2.6.18 API change, check whether device_create() is available.
1027 dnl # Device_create() was introduced in 2.6.18 and depricated
1028 dnl # class_device_create() which was fully removed in 2.6.26.
1029 dnl #
1030 AC_DEFUN([SPL_AC_DEVICE_CREATE], [
1031 SPL_CHECK_SYMBOL_EXPORT(
1032 [device_create],
1033 [drivers/base/core.c],
1034 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1035 [device_create() is available])],
1036 [])
1037 ])
1038
1039 dnl #
1040 dnl # 2.6.27 API change,
1041 dnl # device_create() uses 5 args, new 'drvdata' argument.
1042 dnl #
1043 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1044 AC_MSG_CHECKING([whether device_create() wants 5 args])
1045 tmp_flags="$EXTRA_KCFLAGS"
1046 EXTRA_KCFLAGS="-Werror"
1047 SPL_LINUX_TRY_COMPILE([
1048 #include <linux/device.h>
1049 ],[
1050 device_create(NULL, NULL, 0, NULL, "%d", 1);
1051 ],[
1052 AC_MSG_RESULT(yes)
1053 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1054 [device_create wants 5 args])
1055 ],[
1056 AC_MSG_RESULT(no)
1057 ])
1058 EXTRA_KCFLAGS="$tmp_flags"
1059 ])
1060
1061 dnl #
1062 dnl # 2.6.13 API change, check whether class_device_create() is available.
1063 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1064 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1065 dnl #
1066 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
1067 SPL_CHECK_SYMBOL_EXPORT(
1068 [class_device_create],
1069 [drivers/base/class.c],
1070 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1071 [class_device_create() is available])],
1072 [])
1073 ])
1074
1075 dnl #
1076 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1077 dnl #
1078 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
1079 SPL_CHECK_SYMBOL_EXPORT(
1080 [set_normalized_timespec],
1081 [kernel/time.c],
1082 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1083 [set_normalized_timespec() is available as export])],
1084 [])
1085 ])
1086
1087 dnl #
1088 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1089 dnl # previously it was available in time.h as an inline.
1090 dnl #
1091 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1092 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1093 SPL_LINUX_TRY_COMPILE([
1094 #include <linux/time.h>
1095 void set_normalized_timespec(struct timespec *ts,
1096 time_t sec, long nsec) { }
1097 ],
1098 [],
1099 [
1100 AC_MSG_RESULT(no)
1101 ],[
1102 AC_MSG_RESULT(yes)
1103 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1104 [set_normalized_timespec() is available as inline])
1105 ])
1106 ])
1107
1108 dnl #
1109 dnl # 2.6.18 API change,
1110 dnl # timespec_sub() inline function available in linux/time.h
1111 dnl #
1112 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1113 AC_MSG_CHECKING([whether timespec_sub() is available])
1114 SPL_LINUX_TRY_COMPILE([
1115 #include <linux/time.h>
1116 ],[
1117 struct timespec a = { 0 };
1118 struct timespec b = { 0 };
1119 struct timespec c __attribute__ ((unused));
1120 c = timespec_sub(a, b);
1121 ],[
1122 AC_MSG_RESULT(yes)
1123 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1124 ],[
1125 AC_MSG_RESULT(no)
1126 ])
1127 ])
1128
1129 dnl #
1130 dnl # 2.6.19 API change,
1131 dnl # check if init_utsname() is available in linux/utsname.h
1132 dnl #
1133 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1134 AC_MSG_CHECKING([whether init_utsname() is available])
1135 SPL_LINUX_TRY_COMPILE([
1136 #include <linux/utsname.h>
1137 ],[
1138 struct new_utsname *a __attribute__ ((unused));
1139 a = init_utsname();
1140 ],[
1141 AC_MSG_RESULT(yes)
1142 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1143 ],[
1144 AC_MSG_RESULT(no)
1145 ])
1146 ])
1147
1148 dnl #
1149 dnl # 2.6.26 API change,
1150 dnl # definition of struct fdtable relocated to linux/fdtable.h
1151 dnl #
1152 AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
1153 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
1154 ])
1155
1156 dnl #
1157 dnl # 2.6.14 API change,
1158 dnl # check whether 'files_fdtable()' exists
1159 dnl #
1160 AC_DEFUN([SPL_AC_FILES_FDTABLE], [
1161 AC_MSG_CHECKING([whether files_fdtable() is available])
1162 SPL_LINUX_TRY_COMPILE([
1163 #include <linux/sched.h>
1164 #include <linux/file.h>
1165 #ifdef HAVE_FDTABLE_HEADER
1166 #include <linux/fdtable.h>
1167 #endif
1168 ],[
1169 struct files_struct *files = current->files;
1170 struct fdtable *fdt __attribute__ ((unused));
1171 fdt = files_fdtable(files);
1172 ],[
1173 AC_MSG_RESULT(yes)
1174 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
1175 ],[
1176 AC_MSG_RESULT(no)
1177 ])
1178 ])
1179
1180 dnl #
1181 dnl # 3.4.0 API change,
1182 dnl # check whether '__clear_close_on_exec()' exists
1183 dnl #
1184 AC_DEFUN([SPL_AC_CLEAR_CLOSE_ON_EXEC], [
1185 AC_MSG_CHECKING([whether __clear_close_on_exec() is available])
1186 SPL_LINUX_TRY_COMPILE([
1187 #include <linux/fdtable.h>
1188 ],[
1189 struct fdtable *fdt = NULL;
1190 int fd = 0;
1191
1192 __clear_close_on_exec(fd, fdt);
1193 ],[
1194 AC_MSG_RESULT(yes)
1195 AC_DEFINE(HAVE_CLEAR_CLOSE_ON_EXEC, 1,
1196 [__clear_close_on_exec() is available])
1197 ],[
1198 AC_MSG_RESULT(no)
1199 ])
1200 ])
1201
1202 dnl #
1203 dnl # 2.6.18 API change,
1204 dnl # added linux/uaccess.h
1205 dnl #
1206 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1207 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1208 ])
1209
1210 dnl #
1211 dnl # 2.6.12 API change,
1212 dnl # check whether 'kmalloc_node()' is available.
1213 dnl #
1214 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1215 AC_MSG_CHECKING([whether kmalloc_node() is available])
1216 SPL_LINUX_TRY_COMPILE([
1217 #include <linux/slab.h>
1218 ],[
1219 void *a __attribute__ ((unused));
1220 a = kmalloc_node(1, GFP_KERNEL, 0);
1221 ],[
1222 AC_MSG_RESULT(yes)
1223 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1224 ],[
1225 AC_MSG_RESULT(no)
1226 ])
1227 ])
1228
1229 dnl #
1230 dnl # 2.6.9 API change,
1231 dnl # check whether 'monotonic_clock()' is available it may
1232 dnl # be available for some archs but not others.
1233 dnl #
1234 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1235 SPL_CHECK_SYMBOL_EXPORT(
1236 [monotonic_clock],
1237 [],
1238 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1239 [monotonic_clock() is available])],
1240 [])
1241 ])
1242
1243 dnl #
1244 dnl # 2.6.16 API change,
1245 dnl # check whether 'struct inode' has i_mutex
1246 dnl #
1247 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1248 AC_MSG_CHECKING([whether struct inode has i_mutex])
1249 SPL_LINUX_TRY_COMPILE([
1250 #include <linux/fs.h>
1251 #include <linux/mutex.h>
1252 ],[
1253 struct inode i;
1254 mutex_init(&i.i_mutex);
1255 ],[
1256 AC_MSG_RESULT(yes)
1257 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1258 ],[
1259 AC_MSG_RESULT(no)
1260 ])
1261 ])
1262
1263 dnl #
1264 dnl # 2.6.29 API change,
1265 dnl # Adaptive mutexs introduced.
1266 dnl #
1267 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1268 AC_MSG_CHECKING([whether struct mutex has owner])
1269 SPL_LINUX_TRY_COMPILE([
1270 #include <linux/mutex.h>
1271 ],[
1272 struct mutex mtx __attribute__ ((unused));
1273 mtx.owner = NULL;
1274 ],[
1275 AC_MSG_RESULT(yes)
1276 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1277 ],[
1278 AC_MSG_RESULT(no)
1279 ])
1280 ])
1281
1282 dnl #
1283 dnl # 2.6.39 API change,
1284 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1285 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1286 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1287 dnl # pointer which frankly makes a lot more sense.
1288 dnl #
1289 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1290 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1291 tmp_flags="$EXTRA_KCFLAGS"
1292 EXTRA_KCFLAGS="-Werror"
1293 SPL_LINUX_TRY_COMPILE([
1294 #include <linux/mutex.h>
1295 ],[
1296 struct mutex mtx __attribute__ ((unused));
1297 mtx.owner = current;
1298 ],[
1299 AC_MSG_RESULT(yes)
1300 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1301 [struct mutex owner is a task_struct])
1302 ],[
1303 AC_MSG_RESULT(no)
1304 ])
1305 EXTRA_KCFLAGS="$tmp_flags"
1306 ])
1307
1308 dnl #
1309 dnl # 2.6.18 API change,
1310 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1311 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1312 dnl # if the mutex validator is disabled or otherwise unavailable.
1313 dnl #
1314 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1315 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1316 SPL_LINUX_TRY_COMPILE([
1317 #include <linux/mutex.h>
1318 ],[
1319 struct mutex mutex;
1320 mutex_init(&mutex);
1321 mutex_lock_nested(&mutex, 0);
1322 ],[
1323 AC_MSG_RESULT(yes)
1324 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1325 [mutex_lock_nested() is available])
1326 ],[
1327 AC_MSG_RESULT(no)
1328 ])
1329 ])
1330
1331 dnl #
1332 dnl # 2.6.27 API change,
1333 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1334 dnl #
1335 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1336 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1337 SPL_LINUX_TRY_COMPILE([
1338 #include <linux/smp.h>
1339 ],[
1340 on_each_cpu(NULL, NULL, 0);
1341 ],[
1342 AC_MSG_RESULT(yes)
1343 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1344 [on_each_cpu wants 3 args])
1345 ],[
1346 AC_MSG_RESULT(no)
1347 ])
1348 ])
1349
1350 dnl #
1351 dnl # 2.6.18 API change,
1352 dnl # kallsyms_lookup_name no longer exported
1353 dnl #
1354 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1355 SPL_CHECK_SYMBOL_EXPORT(
1356 [kallsyms_lookup_name],
1357 [],
1358 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1359 [kallsyms_lookup_name() is available])],
1360 [])
1361 ])
1362
1363 dnl #
1364 dnl # Proposed API change,
1365 dnl # This symbol is not available in stock kernels. You may build a
1366 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1367 dnl # these symbols for use. If your already rolling a custom kernel for
1368 dnl # your environment this is recommended.
1369 dnl #
1370 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1371 SPL_CHECK_SYMBOL_EXPORT(
1372 [get_vmalloc_info],
1373 [],
1374 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1375 [get_vmalloc_info() is available])],
1376 [])
1377 ])
1378
1379 dnl #
1380 dnl # 2.6.17 API change
1381 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1382 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1383 dnl # were exported in 2.6.17 for use by modules which was consistent with
1384 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1385 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1386 dnl # were dropped entirely leaving modules no way to directly iterate over
1387 dnl # the zone list. Because we need access to the zone helpers we check
1388 dnl # if the kernel contains the old or new implementation. Then we check
1389 dnl # to see if the symbols we need for each version are available. If they
1390 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1391 dnl #
1392 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1393 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1394 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1395 rc=$?
1396 if test $rc -eq 0; then
1397 AC_MSG_RESULT([yes])
1398 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1399 else
1400 AC_MSG_RESULT([no])
1401 fi
1402 ])
1403
1404 dnl #
1405 dnl # Proposed API change,
1406 dnl # This symbol is not available in stock kernels. You may build a
1407 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1408 dnl # these symbols for use. If your already rolling a custom kernel for
1409 dnl # your environment this is recommended.
1410 dnl #
1411 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1412 SPL_CHECK_SYMBOL_EXPORT(
1413 [first_online_pgdat],
1414 [],
1415 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1416 [first_online_pgdat() is available])],
1417 [])
1418 ])
1419
1420 dnl #
1421 dnl # Proposed API change,
1422 dnl # This symbol is not available in stock kernels. You may build a
1423 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1424 dnl # these symbols for use. If your already rolling a custom kernel for
1425 dnl # your environment this is recommended.
1426 dnl #
1427 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1428 SPL_CHECK_SYMBOL_EXPORT(
1429 [next_online_pgdat],
1430 [],
1431 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1432 [next_online_pgdat() is available])],
1433 [])
1434 ])
1435
1436 dnl #
1437 dnl # Proposed API change,
1438 dnl # This symbol is not available in stock kernels. You may build a
1439 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1440 dnl # these symbols for use. If your already rolling a custom kernel for
1441 dnl # your environment this is recommended.
1442 dnl #
1443 AC_DEFUN([SPL_AC_NEXT_ZONE], [
1444 SPL_CHECK_SYMBOL_EXPORT(
1445 [next_zone],
1446 [],
1447 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1448 [next_zone() is available])],
1449 [])
1450 ])
1451
1452 dnl #
1453 dnl # 2.6.17 API change,
1454 dnl # See SPL_AC_PGDAT_HELPERS for details.
1455 dnl #
1456 AC_DEFUN([SPL_AC_PGDAT_LIST], [
1457 SPL_CHECK_SYMBOL_EXPORT(
1458 [pgdat_list],
1459 [],
1460 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1461 [pgdat_list is available])],
1462 [])
1463 ])
1464
1465 dnl #
1466 dnl # 2.6.18 API change,
1467 dnl # First introduced global_page_state() support as an inline.
1468 dnl #
1469 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1470 AC_MSG_CHECKING([whether global_page_state() is available])
1471 SPL_LINUX_TRY_COMPILE([
1472 #include <linux/mm.h>
1473 ],[
1474 unsigned long state __attribute__ ((unused));
1475 state = global_page_state(0);
1476 ],[
1477 AC_MSG_RESULT(yes)
1478 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1479 [global_page_state() is available])
1480 ],[
1481 AC_MSG_RESULT(no)
1482 ])
1483 ])
1484
1485 dnl #
1486 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1487 dnl # Public global zone stats now include a free page count. However
1488 dnl # the enumerated names of the counters have changed since this API
1489 dnl # was introduced. We need to deduce the corrent name to use. This
1490 dnl # replaces the priviate get_zone_counts() interface.
1491 dnl #
1492 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1493 dnl # is 2.6.30 as of when this was written.
1494 dnl #
1495 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1496 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1497 SPL_LINUX_TRY_COMPILE([
1498 #include <linux/mm.h>
1499 ],[
1500 enum zone_stat_item zsi __attribute__ ((unused));
1501 zsi = NR_FREE_PAGES;
1502 ],[
1503 AC_MSG_RESULT(yes)
1504 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1505 [Page state NR_FREE_PAGES is available])
1506 ],[
1507 AC_MSG_RESULT(no)
1508 ])
1509 ])
1510
1511 dnl #
1512 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1513 dnl # Public global zone stats now include an inactive page count. However
1514 dnl # the enumerated names of the counters have changed since this API
1515 dnl # was introduced. We need to deduce the corrent name to use. This
1516 dnl # replaces the priviate get_zone_counts() interface.
1517 dnl #
1518 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1519 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1520 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1521 dnl #
1522 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1523 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1524 SPL_LINUX_TRY_COMPILE([
1525 #include <linux/mm.h>
1526 ],[
1527 enum zone_stat_item zsi __attribute__ ((unused));
1528 zsi = NR_INACTIVE;
1529 ],[
1530 AC_MSG_RESULT(yes)
1531 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1532 [Page state NR_INACTIVE is available])
1533 ],[
1534 AC_MSG_RESULT(no)
1535 ])
1536
1537 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1538 SPL_LINUX_TRY_COMPILE([
1539 #include <linux/mm.h>
1540 ],[
1541 enum zone_stat_item zsi __attribute__ ((unused));
1542 zsi = NR_INACTIVE_ANON;
1543 ],[
1544 AC_MSG_RESULT(yes)
1545 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1546 [Page state NR_INACTIVE_ANON is available])
1547 ],[
1548 AC_MSG_RESULT(no)
1549 ])
1550
1551 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1552 SPL_LINUX_TRY_COMPILE([
1553 #include <linux/mm.h>
1554 ],[
1555 enum zone_stat_item zsi __attribute__ ((unused));
1556 zsi = NR_INACTIVE_FILE;
1557 ],[
1558 AC_MSG_RESULT(yes)
1559 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1560 [Page state NR_INACTIVE_FILE is available])
1561 ],[
1562 AC_MSG_RESULT(no)
1563 ])
1564 ])
1565
1566 dnl #
1567 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1568 dnl # Public global zone stats now include an active page count. However
1569 dnl # the enumerated names of the counters have changed since this API
1570 dnl # was introduced. We need to deduce the corrent name to use. This
1571 dnl # replaces the priviate get_zone_counts() interface.
1572 dnl #
1573 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1574 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1575 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1576 dnl #
1577 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1578 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1579 SPL_LINUX_TRY_COMPILE([
1580 #include <linux/mm.h>
1581 ],[
1582 enum zone_stat_item zsi __attribute__ ((unused));
1583 zsi = NR_ACTIVE;
1584 ],[
1585 AC_MSG_RESULT(yes)
1586 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1587 [Page state NR_ACTIVE is available])
1588 ],[
1589 AC_MSG_RESULT(no)
1590 ])
1591
1592 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1593 SPL_LINUX_TRY_COMPILE([
1594 #include <linux/mm.h>
1595 ],[
1596 enum zone_stat_item zsi __attribute__ ((unused));
1597 zsi = NR_ACTIVE_ANON;
1598 ],[
1599 AC_MSG_RESULT(yes)
1600 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1601 [Page state NR_ACTIVE_ANON is available])
1602 ],[
1603 AC_MSG_RESULT(no)
1604 ])
1605
1606 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1607 SPL_LINUX_TRY_COMPILE([
1608 #include <linux/mm.h>
1609 ],[
1610 enum zone_stat_item zsi __attribute__ ((unused));
1611 zsi = NR_ACTIVE_FILE;
1612 ],[
1613 AC_MSG_RESULT(yes)
1614 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1615 [Page state NR_ACTIVE_FILE is available])
1616 ],[
1617 AC_MSG_RESULT(no)
1618 ])
1619 ])
1620
1621 dnl #
1622 dnl # Proposed API change for legacy kernels.
1623 dnl # This symbol is not available in older kernels. For kernels post
1624 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1625 dnl # page state information. This symbol is only used in legacy kernels
1626 dnl # any only as a last resort.
1627 dnl
1628 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1629 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1630 SPL_LINUX_TRY_COMPILE([
1631 ],[
1632 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1633 #error "global_page_state needs NR_FREE_PAGES"
1634 #endif
1635
1636 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1637 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1638 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1639 #error "global_page_state needs NR_ACTIVE*"
1640 #endif
1641
1642 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1643 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1644 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1645 #error "global_page_state needs NR_INACTIVE*"
1646 #endif
1647 ],[
1648 AC_MSG_RESULT(no)
1649 ],[
1650 AC_MSG_RESULT(yes)
1651 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1652 [get_zone_counts() is needed])
1653
1654 SPL_CHECK_SYMBOL_EXPORT(
1655 [get_zone_counts],
1656 [],
1657 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1658 [get_zone_counts() is available])],
1659 [])
1660 ])
1661 ])
1662
1663 dnl #
1664 dnl # 2.6.27 API change,
1665 dnl # The user_path_dir() replaces __user_walk()
1666 dnl #
1667 AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1668 SPL_CHECK_SYMBOL_EXPORT(
1669 [user_path_at],
1670 [],
1671 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1672 [user_path_dir() is available])],
1673 [])
1674 ])
1675
1676 dnl #
1677 dnl # Symbol available in RHEL kernels not in stock kernels.
1678 dnl #
1679 AC_DEFUN([SPL_AC_SET_FS_PWD], [
1680 SPL_CHECK_SYMBOL_EXPORT(
1681 [set_fs_pwd],
1682 [],
1683 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1684 [set_fs_pwd() is available])],
1685 [])
1686 ])
1687
1688 dnl #
1689 dnl # 2.6.25 API change,
1690 dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1691 dnl #
1692 AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1693 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1694 SPL_LINUX_TRY_COMPILE([
1695 #include <linux/sched.h>
1696 #include <linux/fs_struct.h>
1697 ],[
1698 set_fs_pwd(NULL, NULL);
1699 ],[
1700 AC_MSG_RESULT(yes)
1701 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1702 [set_fs_pwd() wants 2 args])
1703 ],[
1704 AC_MSG_RESULT(no)
1705 ])
1706 ])
1707
1708 dnl #
1709 dnl # SLES API change, never adopted in mainline,
1710 dnl # Third 'struct vfsmount *' argument removed.
1711 dnl #
1712 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1713 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1714 SPL_LINUX_TRY_COMPILE([
1715 #include <linux/fs.h>
1716 ],[
1717 vfs_unlink(NULL, NULL);
1718 ],[
1719 AC_MSG_RESULT(yes)
1720 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1721 [vfs_unlink() wants 2 args])
1722 ],[
1723 AC_MSG_RESULT(no)
1724 ])
1725 ])
1726
1727 dnl #
1728 dnl # SLES API change, never adopted in mainline,
1729 dnl # Third and sixth 'struct vfsmount *' argument removed.
1730 dnl #
1731 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1732 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1733 SPL_LINUX_TRY_COMPILE([
1734 #include <linux/fs.h>
1735 ],[
1736 vfs_rename(NULL, NULL, NULL, NULL);
1737 ],[
1738 AC_MSG_RESULT(yes)
1739 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1740 [vfs_rename() wants 4 args])
1741 ],[
1742 AC_MSG_RESULT(no)
1743 ])
1744 ])
1745
1746 dnl #
1747 dnl # 2.6.36 API change,
1748 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1749 dnl # a spinlock_t to improve the fastpath performance.
1750 dnl #
1751 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1752 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1753 tmp_flags="$EXTRA_KCFLAGS"
1754 EXTRA_KCFLAGS="-Werror"
1755 SPL_LINUX_TRY_COMPILE([
1756 #include <linux/sched.h>
1757 #include <linux/fs_struct.h>
1758 ],[
1759 struct fs_struct fs;
1760 spin_lock_init(&fs.lock);
1761 ],[
1762 AC_MSG_RESULT(yes)
1763 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1764 [struct fs_struct uses spinlock_t])
1765 ],[
1766 AC_MSG_RESULT(no)
1767 ])
1768 EXTRA_KCFLAGS="$tmp_flags"
1769 ])
1770
1771 dnl #
1772 dnl # 2.6.29 API change,
1773 dnl # check whether 'struct cred' exists
1774 dnl #
1775 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1776 AC_MSG_CHECKING([whether struct cred exists])
1777 SPL_LINUX_TRY_COMPILE([
1778 #include <linux/cred.h>
1779 ],[
1780 struct cred *cr __attribute__ ((unused));
1781 cr = NULL;
1782 ],[
1783 AC_MSG_RESULT(yes)
1784 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1785 ],[
1786 AC_MSG_RESULT(no)
1787 ])
1788 ])
1789
1790 dnl #
1791 dnl # Custom SPL patch may export this symbol.
1792 dnl #
1793 AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1794 SPL_CHECK_SYMBOL_EXPORT(
1795 [groups_search],
1796 [],
1797 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1798 [groups_search() is available])],
1799 [])
1800 ])
1801
1802 dnl #
1803 dnl # 2.6.x API change,
1804 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1805 dnl #
1806 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1807 SPL_CHECK_SYMBOL_EXPORT(
1808 [__put_task_struct],
1809 [],
1810 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1811 [__put_task_struct() is available])],
1812 [])
1813 ])
1814
1815 dnl #
1816 dnl # 2.6.32 API change,
1817 dnl # Unused 'struct file *' removed from prototype.
1818 dnl #
1819 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1820 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1821 SPL_LINUX_TRY_COMPILE([
1822 #include <linux/sysctl.h>
1823 ],[
1824 proc_dostring(NULL, 0, NULL, NULL, NULL);
1825 ],[
1826 AC_MSG_RESULT(yes)
1827 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1828 [proc_handler() wants 5 args])
1829 ],[
1830 AC_MSG_RESULT(no)
1831 ])
1832 ])
1833
1834 dnl #
1835 dnl # 2.6.x API change,
1836 dnl # kvasprintf() function added.
1837 dnl #
1838 AC_DEFUN([SPL_AC_KVASPRINTF], [
1839 SPL_CHECK_SYMBOL_EXPORT(
1840 [kvasprintf],
1841 [],
1842 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1843 [kvasprintf() is available])],
1844 [])
1845 ])
1846
1847 dnl #
1848 dnl # 2.6.29 API change,
1849 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
1850 dnl #
1851 AC_DEFUN([SPL_AC_VFS_FSYNC], [
1852 SPL_CHECK_SYMBOL_EXPORT(
1853 [vfs_fsync],
1854 [fs/sync.c],
1855 [AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])],
1856 [])
1857 ])
1858
1859 dnl #
1860 dnl # 2.6.35 API change,
1861 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
1862 dnl #
1863 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
1864 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
1865 SPL_LINUX_TRY_COMPILE([
1866 #include <linux/fs.h>
1867 ],[
1868 vfs_fsync(NULL, 0);
1869 ],[
1870 AC_MSG_RESULT(yes)
1871 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
1872 ],[
1873 AC_MSG_RESULT(no)
1874 ])
1875 ])
1876
1877 dnl #
1878 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
1879 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
1880 dnl # condition. The fixed version is exported as a symbol. The race
1881 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
1882 dnl # call that version while holding sem->wait_lock.
1883 dnl #
1884 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [
1885 SPL_CHECK_SYMBOL_EXPORT(
1886 [rwsem_is_locked],
1887 [lib/rwsem-spinlock.c],
1888 [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
1889 [rwsem_is_locked() acquires sem->wait_lock])],
1890 [])
1891 ])
1892
1893 dnl #
1894 dnl # 2.6.37 API compat,
1895 dnl # The function invalidate_inodes() is no longer exported by the kernel.
1896 dnl # The prototype however is still available which means it is safe
1897 dnl # to acquire the symbol's address using spl_kallsyms_lookup_name().
1898 dnl #
1899 dnl # The Proxmox VE kernel contains a patch which renames the function
1900 dnl # invalidate_inodes() to invalidate_inodes_check(). In the process
1901 dnl # it adds a 'check' argument and a '#define invalidate_inodes(x)'
1902 dnl # compatibility wrapper for legacy callers. Therefore, if either
1903 dnl # of these functions are exported invalidate_inodes() can be
1904 dnl # safely used.
1905 dnl #
1906 AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [
1907 SPL_CHECK_SYMBOL_EXPORT(
1908 [invalidate_inodes],
1909 [],
1910 [AC_DEFINE(HAVE_INVALIDATE_INODES, 1,
1911 [invalidate_inodes() is available])],
1912 [])
1913 SPL_CHECK_SYMBOL_EXPORT(
1914 [invalidate_inodes_check],
1915 [],
1916 [AC_DEFINE(HAVE_INVALIDATE_INODES_CHECK, 1,
1917 [invalidate_inodes_check() is available])],
1918 [])
1919 ])
1920
1921 dnl #
1922 dnl # 2.6.39 API compat,
1923 dnl # The function invalidate_inodes() now take 2 arguments. The second
1924 dnl # 'kill_dirty' argument describes how invalidate_inodes() should
1925 dnl # handle dirty inodes. Only when set will dirty inodes be discarded,
1926 dnl # otherwise they will be handled as busy.
1927 dnl #
1928 dnl # Unfortunately, we don't have access to the invalidate_inodes()
1929 dnl # prototype so it's not easy to check how many arguments it takes.
1930 dnl # However, this change was done for the benefit of invalidate_device()
1931 dnl # which also added an argument. The invalidate_device() symbol does
1932 dnl # exist in the development headers so if it takes two arguments we
1933 dnl # can fairly safely infer that invalidate_inodes() takes two arguments
1934 dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b.
1935 dnl #
1936 AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES],
1937 [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args])
1938 SPL_LINUX_TRY_COMPILE([
1939 #include <linux/fs.h>
1940 ],[
1941 return __invalidate_device(NULL, 0);
1942 ],[
1943 AC_MSG_RESULT(yes)
1944 AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1,
1945 [invalidate_inodes() wants 2 args])
1946 ],[
1947 AC_MSG_RESULT(no)
1948 ])
1949 ])
1950
1951 dnl #
1952 dnl # 2.6.xx API compat,
1953 dnl # There currently exists no exposed API to partially shrink the dcache.
1954 dnl # The expected mechanism to shrink the cache is a registered shrinker
1955 dnl # which is called during memory pressure.
1956 dnl #
1957 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [
1958 SPL_CHECK_SYMBOL_EXPORT(
1959 [shrink_dcache_memory],
1960 [fs/dcache.c],
1961 [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
1962 [shrink_dcache_memory() is available])],
1963 [])
1964 ])
1965
1966 dnl #
1967 dnl # 2.6.xx API compat,
1968 dnl # There currently exists no exposed API to partially shrink the icache.
1969 dnl # The expected mechanism to shrink the cache is a registered shrinker
1970 dnl # which is called during memory pressure.
1971 dnl #
1972 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [
1973 SPL_CHECK_SYMBOL_EXPORT(
1974 [shrink_icache_memory],
1975 [fs/inode.c],
1976 [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
1977 [shrink_icache_memory() is available])],
1978 [])
1979 ])
1980
1981 dnl #
1982 dnl # 2.6.39 API compat,
1983 dnl # The path_lookup() function has been renamed to kern_path_parent()
1984 dnl # and the flags argument has been removed. The only behavior now
1985 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
1986 dnl # this flag so dropping the flag does not impact us.
1987 dnl #
1988 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
1989 SPL_CHECK_SYMBOL_HEADER(
1990 [kern_path_parent],
1991 [int kern_path_parent(const char \*, struct nameidata \*)],
1992 [include/linux/namei.h],
1993 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
1994 [kern_path_parent() is available])],
1995 [])
1996 ])
1997
1998 dnl #
1999 dnl # 3.1 API compat,
2000 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2001 dnl # However, it remains the prefered interface and since we still have
2002 dnl # access to the prototype we dynamically lookup the required address.
2003 dnl #
2004 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL], [
2005 SPL_CHECK_SYMBOL_EXPORT(
2006 [kern_path_parent],
2007 [fs/namei.c],
2008 [AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2009 [kern_path_parent() is available])],
2010 [])
2011 ])
2012
2013 dnl #
2014 dnl # 2.6.39 API compat,
2015 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2016 dnl # This was done to avoid always having to allocate the maximum size
2017 dnl # workspace (268K). The caller can now specific the windowBits and
2018 dnl # memLevel compression parameters to get a smaller workspace.
2019 dnl #
2020 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2021 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2022 SPL_LINUX_TRY_COMPILE([
2023 #include <linux/zlib.h>
2024 ],[
2025 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2026 ],[
2027 AC_MSG_RESULT(yes)
2028 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2029 [zlib_deflate_workspacesize() wants 2 args])
2030 ],[
2031 AC_MSG_RESULT(no)
2032 ])
2033 ])
2034
2035 dnl #
2036 dnl # 2.6.39 API change,
2037 dnl # Shrinker adjust to use common shrink_control structure.
2038 dnl #
2039 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2040 AC_MSG_CHECKING([whether struct shrink_control exists])
2041 SPL_LINUX_TRY_COMPILE([
2042 #include <linux/mm.h>
2043 ],[
2044 struct shrink_control sc __attribute__ ((unused));
2045
2046 sc.nr_to_scan = 0;
2047 sc.gfp_mask = GFP_KERNEL;
2048 ],[
2049 AC_MSG_RESULT(yes)
2050 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2051 [struct shrink_control exists])
2052 ],[
2053 AC_MSG_RESULT(no)
2054 ])
2055 ])
2056
2057 dnl #
2058 dnl # 3.1 API Change
2059 dnl #
2060 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2061 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2062 dnl #
2063 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2064 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2065 tmp_flags="$EXTRA_KCFLAGS"
2066 EXTRA_KCFLAGS="-Werror"
2067 SPL_LINUX_TRY_COMPILE([
2068 #include <linux/rwsem.h>
2069 ],[
2070 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2071 raw_spinlock_t dummy_lock __attribute__ ((unused));
2072 dummy_semaphore.wait_lock = dummy_lock;
2073 ],[
2074 AC_MSG_RESULT(yes)
2075 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2076 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2077 ],[
2078 AC_MSG_RESULT(no)
2079 ])
2080 EXTRA_KCFLAGS="$tmp_flags"
2081 ])