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