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