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