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