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