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