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