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