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