]> git.proxmox.com Git - mirror_spl.git/blame - config/spl-build.m4
Linux 3.15: vfs_rename() added a flags argument
[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 29 SPL_AC_2ARGS_REGISTER_SYSCTL
c3d9c0df 30 SPL_AC_SHRINKER_CALLBACK
86933a6e
BB
31 SPL_AC_PATH_IN_NAMEIDATA
32 SPL_AC_TASK_CURR
33 SPL_AC_CTL_UNNUMBERED
79a3bf13 34 SPL_AC_CTL_NAME
c02ab72f 35 SPL_AC_VMALLOC_INFO
1ddf9722 36 SPL_AC_PDE_DATA
86933a6e
BB
37 SPL_AC_FLS64
38 SPL_AC_DEVICE_CREATE
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
43 SPL_AC_TIMESPEC_SUB
44 SPL_AC_INIT_UTSNAME
86933a6e
BB
45 SPL_AC_UACCESS_HEADER
46 SPL_AC_KMALLOC_NODE
47 SPL_AC_MONOTONIC_CLOCK
48 SPL_AC_INODE_I_MUTEX
4d54fdee 49 SPL_AC_MUTEX_OWNER
86fd39f3 50 SPL_AC_MUTEX_OWNER_TASK_STRUCT
86933a6e 51 SPL_AC_MUTEX_LOCK_NESTED
86933a6e
BB
52 SPL_AC_3ARGS_ON_EACH_CPU
53 SPL_AC_KALLSYMS_LOOKUP_NAME
54 SPL_AC_GET_VMALLOC_INFO
55 SPL_AC_PGDAT_HELPERS
56 SPL_AC_FIRST_ONLINE_PGDAT
57 SPL_AC_NEXT_ONLINE_PGDAT
58 SPL_AC_NEXT_ZONE
59 SPL_AC_PGDAT_LIST
86933a6e 60 SPL_AC_GLOBAL_PAGE_STATE
6ae7fef5
BB
61 SPL_AC_ZONE_STAT_ITEM_FREE
62 SPL_AC_ZONE_STAT_ITEM_INACTIVE
63 SPL_AC_ZONE_STAT_ITEM_ACTIVE
64 SPL_AC_GET_ZONE_COUNTS
7119bf70 65 SPL_AC_USER_PATH_DIR
51a727e9 66 SPL_AC_SET_FS_PWD
a54718cf 67 SPL_AC_SET_FS_PWD_WITH_CONST
86933a6e
BB
68 SPL_AC_2ARGS_VFS_UNLINK
69 SPL_AC_4ARGS_VFS_RENAME
0d0b5237
BB
70 SPL_AC_VFS_FSYNC
71 SPL_AC_2ARGS_VFS_FSYNC
bbdc6ae4 72 SPL_AC_INODE_TRUNCATE_RANGE
9b2048c2 73 SPL_AC_FS_STRUCT_SPINLOCK
ec7d53e9 74 SPL_AC_CRED_STRUCT
f7fd6ddd 75 SPL_AC_KUIDGID_T
ec7d53e9 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
184c6873 95 SPL_AC_USLEEP_RANGE
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
c3d9c0df 887AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
23aa63cb
BB
888 tmp_flags="$EXTRA_KCFLAGS"
889 EXTRA_KCFLAGS="-Werror"
c3d9c0df
RY
890 dnl #
891 dnl # 2.6.23 to 2.6.34 API change
892 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
893 dnl #
894 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
23aa63cb
BB
895 SPL_LINUX_TRY_COMPILE([
896 #include <linux/mm.h>
897
c3d9c0df 898 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
23aa63cb
BB
899 ],[
900 struct shrinker cache_shrinker = {
901 .shrink = shrinker_cb,
902 .seeks = DEFAULT_SEEKS,
903 };
904 register_shrinker(&cache_shrinker);
905 ],[
906 AC_MSG_RESULT(yes)
c3d9c0df
RY
907 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
908 [old shrinker callback wants 2 args])
23aa63cb
BB
909 ],[
910 AC_MSG_RESULT(no)
c3d9c0df
RY
911 dnl #
912 dnl # 2.6.35 - 2.6.39 API change
913 dnl # ->shrink(struct shrinker *,
914 dnl # int nr_to_scan, gfp_t gfp_mask)
915 dnl #
916 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
917 SPL_LINUX_TRY_COMPILE([
918 #include <linux/mm.h>
919
920 int shrinker_cb(struct shrinker *, int nr_to_scan,
921 gfp_t gfp_mask);
922 ],[
923 struct shrinker cache_shrinker = {
924 .shrink = shrinker_cb,
925 .seeks = DEFAULT_SEEKS,
926 };
927 register_shrinker(&cache_shrinker);
928 ],[
929 AC_MSG_RESULT(yes)
930 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
931 [old shrinker callback wants 3 args])
932 ],[
933 AC_MSG_RESULT(no)
934 dnl #
935 dnl # 3.0 - 3.11 API change
936 dnl # ->shrink(struct shrinker *,
937 dnl # struct shrink_control *sc)
938 dnl #
939 AC_MSG_CHECKING(
940 [whether new 2-argument shrinker exists])
941 SPL_LINUX_TRY_COMPILE([
942 #include <linux/mm.h>
943
944 int shrinker_cb(struct shrinker *,
945 struct shrink_control *sc);
946 ],[
947 struct shrinker cache_shrinker = {
948 .shrink = shrinker_cb,
949 .seeks = DEFAULT_SEEKS,
950 };
951 register_shrinker(&cache_shrinker);
952 ],[
953 AC_MSG_RESULT(yes)
954 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
955 [new shrinker callback wants 2 args])
956 ],[
957 AC_MSG_RESULT(no)
958 dnl #
959 dnl # 3.12 API change,
960 dnl # ->shrink() is logically split in to
961 dnl # ->count_objects() and ->scan_objects()
962 dnl #
963 AC_MSG_CHECKING(
964 [whether ->count_objects callback exists])
965 SPL_LINUX_TRY_COMPILE([
966 #include <linux/mm.h>
967
968 unsigned long shrinker_cb(
969 struct shrinker *,
970 struct shrink_control *sc);
971 ],[
972 struct shrinker cache_shrinker = {
973 .count_objects = shrinker_cb,
974 .scan_objects = shrinker_cb,
975 .seeks = DEFAULT_SEEKS,
976 };
977 register_shrinker(&cache_shrinker);
978 ],[
979 AC_MSG_RESULT(yes)
980 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
981 1, [->count_objects exists])
982 ],[
983 AC_MSG_ERROR(error)
984 ])
985 ])
986 ])
23aa63cb
BB
987 ])
988 EXTRA_KCFLAGS="$tmp_flags"
989])
990
57d86234 991dnl #
3d061e9d 992dnl # 2.6.25 API change,
57d86234 993dnl # struct path entry added to struct nameidata
994dnl #
995AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
996 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
997 SPL_LINUX_TRY_COMPILE([
d50bd9e2 998 #include <linux/namei.h>
57d86234 999 ],[
03318641 1000 struct nameidata nd __attribute__ ((unused));
57d86234 1001
1002 nd.path.mnt = NULL;
1003 nd.path.dentry = NULL;
1004 ],[
d50bd9e2 1005 AC_MSG_RESULT(yes)
1006 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
1007 [struct path used in struct nameidata])
57d86234 1008 ],[
d50bd9e2 1009 AC_MSG_RESULT(no)
57d86234 1010 ])
1011])
1012
1013dnl #
1014dnl # Custom SPL patch may export this system it is not required
1015dnl #
723aa3b0
ED
1016AC_DEFUN([SPL_AC_TASK_CURR],
1017 [AC_MSG_CHECKING([whether task_curr() is available])
1018 SPL_LINUX_TRY_COMPILE_SYMBOL([
1019 #include <linux/sched.h>
1020 ], [
1021 task_curr(NULL);
1022 ], [task_curr], [kernel/sched.c], [
1023 AC_MSG_RESULT(yes)
1024 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1025 ], [
1026 AC_MSG_RESULT(no)
1027 ])
57d86234 1028])
1029
1030dnl #
3d061e9d 1031dnl # 2.6.19 API change,
57d86234 1032dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1033dnl #
1034AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1035 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1036 SPL_LINUX_TRY_COMPILE([
d50bd9e2 1037 #include <linux/sysctl.h>
57d86234 1038 ],[
1039 #ifndef CTL_UNNUMBERED
1040 #error CTL_UNNUMBERED undefined
1041 #endif
1042 ],[
d50bd9e2 1043 AC_MSG_RESULT(yes)
1044 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1045 [unnumbered sysctl support exists])
57d86234 1046 ],[
d50bd9e2 1047 AC_MSG_RESULT(no)
57d86234 1048 ])
1049])
877a32e9 1050
79a3bf13
BB
1051dnl #
1052dnl # 2.6.33 API change,
1053dnl # Removed .ctl_name from struct ctl_table.
1054dnl #
1055AC_DEFUN([SPL_AC_CTL_NAME], [
1056 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1057 SPL_LINUX_TRY_COMPILE([
1058 #include <linux/sysctl.h>
1059 ],[
03318641 1060 struct ctl_table ctl __attribute__ ((unused));
79a3bf13
BB
1061 ctl.ctl_name = 0;
1062 ],[
1063 AC_MSG_RESULT(yes)
1064 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1065 ],[
1066 AC_MSG_RESULT(no)
1067 ])
1068])
1069
877a32e9 1070dnl #
1071dnl # 2.6.16 API change.
1072dnl # Check if 'fls64()' is available
1073dnl #
1074AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 1075 [AC_MSG_CHECKING([whether fls64() is available])
1076 SPL_LINUX_TRY_COMPILE([
1077 #include <linux/bitops.h>
1078 ],[
1079 return fls64(0);
1080 ],[
1081 AC_MSG_RESULT(yes)
1082 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1083 ],[
1084 AC_MSG_RESULT(no)
1085 ])
877a32e9 1086])
46c685d0 1087
1088dnl #
1089dnl # 2.6.18 API change, check whether device_create() is available.
1090dnl # Device_create() was introduced in 2.6.18 and depricated
1091dnl # class_device_create() which was fully removed in 2.6.26.
1092dnl #
723aa3b0
ED
1093AC_DEFUN([SPL_AC_DEVICE_CREATE],
1094 [AC_MSG_CHECKING([whether device_create() is available])
1095 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1096 AC_MSG_RESULT(yes)
1097 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1098 [device_create() is available])
1099 ], [
1100 AC_MSG_RESULT(no)
1101 ])
46c685d0 1102])
1103
8123ac4f
BB
1104dnl #
1105dnl # 2.6.27 API change,
1106dnl # device_create() uses 5 args, new 'drvdata' argument.
1107dnl #
1108AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1109 AC_MSG_CHECKING([whether device_create() wants 5 args])
1110 tmp_flags="$EXTRA_KCFLAGS"
1111 EXTRA_KCFLAGS="-Werror"
1112 SPL_LINUX_TRY_COMPILE([
1113 #include <linux/device.h>
1114 ],[
1115 device_create(NULL, NULL, 0, NULL, "%d", 1);
1116 ],[
1117 AC_MSG_RESULT(yes)
1118 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1119 [device_create wants 5 args])
1120 ],[
1121 AC_MSG_RESULT(no)
1122 ])
1123 EXTRA_KCFLAGS="$tmp_flags"
1124])
1125
46c685d0 1126dnl #
1127dnl # 2.6.13 API change, check whether class_device_create() is available.
1128dnl # Class_device_create() was introduced in 2.6.13 and depricated
1129dnl # class_simple_device_add() which was fully removed in 2.6.13.
1130dnl #
723aa3b0
ED
1131AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1132 [AC_MSG_CHECKING([whether class_device_create() is available])
1133 SPL_LINUX_TRY_COMPILE_SYMBOL([
1134 #include <linux/device.h>
1135 ], [
1136 class_device_create(NULL, NULL, 0, NULL, NULL);
1137 ], [class_device_create], [drivers/base/class.c], [
1138 AC_MSG_RESULT(yes)
1139 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1140 [class_device_create() is available])
1141 ], [
1142 AC_MSG_RESULT(no)
1143 ])
46c685d0 1144])
6a6cafbe 1145
6a6cafbe 1146dnl #
1147dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1148dnl #
723aa3b0
ED
1149AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1150 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1151 SPL_LINUX_TRY_COMPILE_SYMBOL([
1152 #include <linux/time.h>
1153 ], [
1154 set_normalized_timespec(NULL, 0, 0);
1155 ], [set_normalized_timespec], [kernel/time.c], [
1156 AC_MSG_RESULT(yes)
1157 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1158 [set_normalized_timespec() is available as export])
1159 ], [
1160 AC_MSG_RESULT(no)
1161 ])
6a6cafbe 1162])
1163
1164dnl #
1165dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1166dnl # previously it was available in time.h as an inline.
1167dnl #
86de8532 1168AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1169 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 1170 SPL_LINUX_TRY_COMPILE([
1171 #include <linux/time.h>
6a6cafbe 1172 void set_normalized_timespec(struct timespec *ts,
25557fd8 1173 time_t sec, long nsec) { }
1174 ],
1175 [],
1176 [
6a6cafbe 1177 AC_MSG_RESULT(no)
1178 ],[
1179 AC_MSG_RESULT(yes)
1180 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1181 [set_normalized_timespec() is available as inline])
1182 ])
1183])
1184
1185dnl #
1186dnl # 2.6.18 API change,
1187dnl # timespec_sub() inline function available in linux/time.h
1188dnl #
86de8532 1189AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1190 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 1191 SPL_LINUX_TRY_COMPILE([
1192 #include <linux/time.h>
1193 ],[
03318641
BB
1194 struct timespec a = { 0 };
1195 struct timespec b = { 0 };
1196 struct timespec c __attribute__ ((unused));
6a6cafbe 1197 c = timespec_sub(a, b);
1198 ],[
1199 AC_MSG_RESULT(yes)
1200 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1201 ],[
1202 AC_MSG_RESULT(no)
1203 ])
1204])
1205
86de8532 1206dnl #
3d061e9d 1207dnl # 2.6.19 API change,
1208dnl # check if init_utsname() is available in linux/utsname.h
1209dnl #
1210AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1211 AC_MSG_CHECKING([whether init_utsname() is available])
1212 SPL_LINUX_TRY_COMPILE([
1213 #include <linux/utsname.h>
1214 ],[
03318641
BB
1215 struct new_utsname *a __attribute__ ((unused));
1216 a = init_utsname();
3d061e9d 1217 ],[
1218 AC_MSG_RESULT(yes)
1219 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1220 ],[
1221 AC_MSG_RESULT(no)
1222 ])
1223])
1224
3d061e9d 1225dnl #
1226dnl # 2.6.18 API change,
1227dnl # added linux/uaccess.h
322640b7 1228dnl #
1229AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1230 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1231])
3d061e9d 1232
1233dnl #
1234dnl # 2.6.12 API change,
1235dnl # check whether 'kmalloc_node()' is available.
1236dnl #
1237AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1238 AC_MSG_CHECKING([whether kmalloc_node() is available])
1239 SPL_LINUX_TRY_COMPILE([
1240 #include <linux/slab.h>
1241 ],[
03318641
BB
1242 void *a __attribute__ ((unused));
1243 a = kmalloc_node(1, GFP_KERNEL, 0);
3d061e9d 1244 ],[
1245 AC_MSG_RESULT(yes)
1246 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1247 ],[
1248 AC_MSG_RESULT(no)
1249 ])
1250])
1251
1252dnl #
1253dnl # 2.6.9 API change,
1254dnl # check whether 'monotonic_clock()' is available it may
1255dnl # be available for some archs but not others.
1256dnl #
723aa3b0
ED
1257AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1258 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1259 SPL_LINUX_TRY_COMPILE_SYMBOL([
1260 #include <linux/timex.h>
1261 ], [
1262 monotonic_clock();
1263 ], [monotonic_clock], [], [
1264 AC_MSG_RESULT(yes)
1265 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1266 [monotonic_clock() is available])
1267 ], [
1268 AC_MSG_RESULT(no)
1269 ])
3d061e9d 1270])
1271
1272dnl #
1273dnl # 2.6.16 API change,
1274dnl # check whether 'struct inode' has i_mutex
1275dnl #
1276AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1277 AC_MSG_CHECKING([whether struct inode has i_mutex])
1278 SPL_LINUX_TRY_COMPILE([
1279 #include <linux/fs.h>
1280 #include <linux/mutex.h>
1281 ],[
1282 struct inode i;
1283 mutex_init(&i.i_mutex);
1284 ],[
1285 AC_MSG_RESULT(yes)
1286 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1287 ],[
1288 AC_MSG_RESULT(no)
1289 ])
1290])
b61a6e8b 1291
4d54fdee
BB
1292dnl #
1293dnl # 2.6.29 API change,
1294dnl # Adaptive mutexs introduced.
1295dnl #
1296AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1297 AC_MSG_CHECKING([whether struct mutex has owner])
1298 SPL_LINUX_TRY_COMPILE([
1299 #include <linux/mutex.h>
1300 ],[
03318641 1301 struct mutex mtx __attribute__ ((unused));
4d54fdee
BB
1302 mtx.owner = NULL;
1303 ],[
1304 AC_MSG_RESULT(yes)
1305 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1306 ],[
1307 AC_MSG_RESULT(no)
1308 ])
1309])
1310
86fd39f3
BB
1311dnl #
1312dnl # 2.6.39 API change,
1313dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1314dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1315dnl # was defined. As of 2.6.39 this was changed to a task_struct
1316dnl # pointer which frankly makes a lot more sense.
1317dnl #
1318AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1319 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1320 tmp_flags="$EXTRA_KCFLAGS"
1321 EXTRA_KCFLAGS="-Werror"
1322 SPL_LINUX_TRY_COMPILE([
1323 #include <linux/mutex.h>
a0625691 1324 #include <linux/sched.h>
86fd39f3
BB
1325 ],[
1326 struct mutex mtx __attribute__ ((unused));
1327 mtx.owner = current;
1328 ],[
1329 AC_MSG_RESULT(yes)
1330 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1331 [struct mutex owner is a task_struct])
1332 ],[
1333 AC_MSG_RESULT(no)
1334 ])
1335 EXTRA_KCFLAGS="$tmp_flags"
1336])
1337
6c9433c1
BB
1338dnl #
1339dnl # 2.6.18 API change,
1340dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1341dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1342dnl # if the mutex validator is disabled or otherwise unavailable.
1343dnl #
1344AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1345 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1346 SPL_LINUX_TRY_COMPILE([
1347 #include <linux/mutex.h>
1348 ],[
1349 struct mutex mutex;
1350 mutex_init(&mutex);
1351 mutex_lock_nested(&mutex, 0);
1352 ],[
1353 AC_MSG_RESULT(yes)
1354 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1355 [mutex_lock_nested() is available])
1356 ],[
1357 AC_MSG_RESULT(no)
1358 ])
1359])
1360
31a033ec
BB
1361dnl #
1362dnl # 2.6.27 API change,
1363dnl # on_each_cpu() uses 3 args, no 'retry' argument
1364dnl #
1365AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1366 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1367 SPL_LINUX_TRY_COMPILE([
050cd84e 1368 #include <linux/interrupt.h>
31a033ec 1369 #include <linux/smp.h>
050cd84e
BB
1370
1371 void on_each_cpu_func(void *data) { return; }
31a033ec 1372 ],[
050cd84e 1373 on_each_cpu(on_each_cpu_func, NULL, 0);
31a033ec
BB
1374 ],[
1375 AC_MSG_RESULT(yes)
1376 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1377 [on_each_cpu wants 3 args])
1378 ],[
1379 AC_MSG_RESULT(no)
1380 ])
1381])
36b313da
BB
1382
1383dnl #
d1ff2312
BB
1384dnl # 2.6.18 API change,
1385dnl # kallsyms_lookup_name no longer exported
1386dnl #
723aa3b0
ED
1387AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1388 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1389 SPL_LINUX_TRY_COMPILE_SYMBOL([
1390 #include <linux/kallsyms.h>
1391 ], [
1392 kallsyms_lookup_name(NULL);
1393 ], [kallsyms_lookup_name], [], [
1394 AC_MSG_RESULT(yes)
1395 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1396 [kallsyms_lookup_name() is available])
1397 ], [
1398 AC_MSG_RESULT(no)
1399 ])
d1ff2312
BB
1400])
1401
1402dnl #
e11d6c5f
BB
1403dnl # Proposed API change,
1404dnl # This symbol is not available in stock kernels. You may build a
1405dnl # custom kernel with the *-spl-export-symbols.patch which will export
1406dnl # these symbols for use. If your already rolling a custom kernel for
1407dnl # your environment this is recommended.
d1ff2312 1408dnl #
723aa3b0
ED
1409AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1410 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1411 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1412 AC_MSG_RESULT(yes)
1413 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1414 [get_vmalloc_info() is available])
1415 ], [
1416 AC_MSG_RESULT(no)
1417 ])
d1ff2312
BB
1418])
1419
c02ab72f
YS
1420dnl #
1421dnl # 3.10 API change,
1422dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1423dnl #
1424AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1425 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1426 SPL_LINUX_TRY_COMPILE([
1427 #include <linux/vmalloc.h>
1428 struct vmalloc_info { void *a; };
1429 ],[
1430 return 0;
1431 ],[
1432 AC_MSG_RESULT(no)
1433 ],[
1434 AC_MSG_RESULT(yes)
1435 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1436 ])
1437])
1438
1ddf9722
YS
1439dnl #
1440dnl # 3.10 API change,
1441dnl # PDE is replaced by PDE_DATA
1442dnl #
1443AC_DEFUN([SPL_AC_PDE_DATA], [
1444 AC_MSG_CHECKING([whether PDE_DATA() is available])
1445 SPL_LINUX_TRY_COMPILE_SYMBOL([
1446 #include <linux/proc_fs.h>
1447 ], [
1448 PDE_DATA(NULL);
1449 ], [PDE_DATA], [], [
1450 AC_MSG_RESULT(yes)
1451 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1452 ],[
1453 AC_MSG_RESULT(no)
1454 ])
1455])
1456
5232d256
BB
1457dnl #
1458dnl # 2.6.17 API change
1459dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1460dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1461dnl # were exported in 2.6.17 for use by modules which was consistent with
1462dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1463dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1464dnl # were dropped entirely leaving modules no way to directly iterate over
1465dnl # the zone list. Because we need access to the zone helpers we check
1466dnl # if the kernel contains the old or new implementation. Then we check
1467dnl # to see if the symbols we need for each version are available. If they
1468dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1469dnl #
1470AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1471 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1472 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1473 rc=$?
1474 if test $rc -eq 0; then
1475 AC_MSG_RESULT([yes])
723aa3b0 1476 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
5232d256
BB
1477 else
1478 AC_MSG_RESULT([no])
1479 fi
1480])
1481
d1ff2312 1482dnl #
e11d6c5f
BB
1483dnl # Proposed API change,
1484dnl # This symbol is not available in stock kernels. You may build a
1485dnl # custom kernel with the *-spl-export-symbols.patch which will export
1486dnl # these symbols for use. If your already rolling a custom kernel for
1487dnl # your environment this is recommended.
36b313da 1488dnl #
723aa3b0
ED
1489AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1490 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1491 SPL_LINUX_TRY_COMPILE_SYMBOL([
1492 #include <linux/mmzone.h>
1493 ], [
1494 first_online_pgdat();
1495 ], [first_online_pgdat], [], [
1496 AC_MSG_RESULT(yes)
1497 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1498 [first_online_pgdat() is available])
1499 ], [
1500 AC_MSG_RESULT(no)
1501 ])
36b313da
BB
1502])
1503
1504dnl #
e11d6c5f
BB
1505dnl # Proposed API change,
1506dnl # This symbol is not available in stock kernels. You may build a
1507dnl # custom kernel with the *-spl-export-symbols.patch which will export
1508dnl # these symbols for use. If your already rolling a custom kernel for
1509dnl # your environment this is recommended.
36b313da 1510dnl #
723aa3b0
ED
1511AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1512 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1513 SPL_LINUX_TRY_COMPILE_SYMBOL([
1514 #include <linux/mmzone.h>
1515 ], [
1516 next_online_pgdat(NULL);
1517 ], [next_online_pgdat], [], [
1518 AC_MSG_RESULT(yes)
1519 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1520 [next_online_pgdat() is available])
1521 ], [
1522 AC_MSG_RESULT(no)
1523 ])
36b313da
BB
1524])
1525
1526dnl #
e11d6c5f
BB
1527dnl # Proposed API change,
1528dnl # This symbol is not available in stock kernels. You may build a
1529dnl # custom kernel with the *-spl-export-symbols.patch which will export
1530dnl # these symbols for use. If your already rolling a custom kernel for
1531dnl # your environment this is recommended.
36b313da 1532dnl #
723aa3b0
ED
1533AC_DEFUN([SPL_AC_NEXT_ZONE],
1534 [AC_MSG_CHECKING([whether next_zone() is available])
1535 SPL_LINUX_TRY_COMPILE_SYMBOL([
1536 #include <linux/mmzone.h>
1537 ], [
1538 next_zone(NULL);
1539 ], [next_zone], [], [
1540 AC_MSG_RESULT(yes)
1541 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1542 ], [
1543 AC_MSG_RESULT(no)
1544 ])
36b313da 1545])
4ab13d3b 1546
5232d256
BB
1547dnl #
1548dnl # 2.6.17 API change,
1549dnl # See SPL_AC_PGDAT_HELPERS for details.
1550dnl #
723aa3b0
ED
1551AC_DEFUN([SPL_AC_PGDAT_LIST],
1552 [AC_MSG_CHECKING([whether pgdat_list is available])
1553 SPL_LINUX_TRY_COMPILE_SYMBOL([
1554 #include <linux/topology.h>
1555 pg_data_t *tmp = pgdat_list;
1556 ], [], [pgdat_list], [], [
1557 AC_MSG_RESULT(yes)
1558 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1559 ], [
1560 AC_MSG_RESULT(no)
1561 ])
5232d256
BB
1562])
1563
96dded38
BB
1564dnl #
1565dnl # 2.6.18 API change,
1566dnl # First introduced global_page_state() support as an inline.
1567dnl #
1568AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1569 AC_MSG_CHECKING([whether global_page_state() is available])
1570 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1571 #include <linux/mm.h>
96dded38 1572 ],[
03318641 1573 unsigned long state __attribute__ ((unused));
6ae7fef5 1574 state = global_page_state(0);
96dded38
BB
1575 ],[
1576 AC_MSG_RESULT(yes)
1577 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1578 [global_page_state() is available])
1579 ],[
1580 AC_MSG_RESULT(no)
1581 ])
1582])
1583
e11d6c5f 1584dnl #
6ae7fef5
BB
1585dnl # 2.6.21 API change (plus subsequent naming convention changes),
1586dnl # Public global zone stats now include a free page count. However
1587dnl # the enumerated names of the counters have changed since this API
1588dnl # was introduced. We need to deduce the corrent name to use. This
1589dnl # replaces the priviate get_zone_counts() interface.
1590dnl #
1591dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1592dnl # is 2.6.30 as of when this was written.
e11d6c5f 1593dnl #
6ae7fef5
BB
1594AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1595 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
e11d6c5f 1596 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1597 #include <linux/mm.h>
e11d6c5f 1598 ],[
03318641 1599 enum zone_stat_item zsi __attribute__ ((unused));
6ae7fef5 1600 zsi = NR_FREE_PAGES;
e11d6c5f
BB
1601 ],[
1602 AC_MSG_RESULT(yes)
6ae7fef5
BB
1603 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1604 [Page state NR_FREE_PAGES is available])
e11d6c5f
BB
1605 ],[
1606 AC_MSG_RESULT(no)
1607 ])
1608])
a093c6a4 1609
6ae7fef5
BB
1610dnl #
1611dnl # 2.6.21 API change (plus subsequent naming convention changes),
1612dnl # Public global zone stats now include an inactive page count. However
1613dnl # the enumerated names of the counters have changed since this API
1614dnl # was introduced. We need to deduce the corrent name to use. This
1615dnl # replaces the priviate get_zone_counts() interface.
1616dnl #
1617dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1618dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1619dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1620dnl #
1621AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1622 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1623 SPL_LINUX_TRY_COMPILE([
1624 #include <linux/mm.h>
1625 ],[
03318641 1626 enum zone_stat_item zsi __attribute__ ((unused));
6ae7fef5
BB
1627 zsi = NR_INACTIVE;
1628 ],[
1629 AC_MSG_RESULT(yes)
1630 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1631 [Page state NR_INACTIVE is available])
1632 ],[
1633 AC_MSG_RESULT(no)
1634 ])
1635
1636 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1637 SPL_LINUX_TRY_COMPILE([
1638 #include <linux/mm.h>
1639 ],[
03318641 1640 enum zone_stat_item zsi __attribute__ ((unused));
6ae7fef5
BB
1641 zsi = NR_INACTIVE_ANON;
1642 ],[
1643 AC_MSG_RESULT(yes)
1644 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1645 [Page state NR_INACTIVE_ANON is available])
1646 ],[
1647 AC_MSG_RESULT(no)
1648 ])
1649
1650 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1651 SPL_LINUX_TRY_COMPILE([
1652 #include <linux/mm.h>
1653 ],[
03318641 1654 enum zone_stat_item zsi __attribute__ ((unused));
6ae7fef5
BB
1655 zsi = NR_INACTIVE_FILE;
1656 ],[
1657 AC_MSG_RESULT(yes)
1658 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1659 [Page state NR_INACTIVE_FILE is available])
1660 ],[
1661 AC_MSG_RESULT(no)
1662 ])
1663])
1664
1665dnl #
1666dnl # 2.6.21 API change (plus subsequent naming convention changes),
1667dnl # Public global zone stats now include an active page count. However
1668dnl # the enumerated names of the counters have changed since this API
1669dnl # was introduced. We need to deduce the corrent name to use. This
1670dnl # replaces the priviate get_zone_counts() interface.
1671dnl #
1672dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1673dnl # anonymous and file active pages. As of 2.6.28 it was split in
1674dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1675dnl #
1676AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1677 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1678 SPL_LINUX_TRY_COMPILE([
1679 #include <linux/mm.h>
1680 ],[
03318641 1681 enum zone_stat_item zsi __attribute__ ((unused));
6ae7fef5
BB
1682 zsi = NR_ACTIVE;
1683 ],[
1684 AC_MSG_RESULT(yes)
1685 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1686 [Page state NR_ACTIVE is available])
1687 ],[
1688 AC_MSG_RESULT(no)
1689 ])
1690
1691 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1692 SPL_LINUX_TRY_COMPILE([
1693 #include <linux/mm.h>
1694 ],[
03318641 1695 enum zone_stat_item zsi __attribute__ ((unused));
6ae7fef5
BB
1696 zsi = NR_ACTIVE_ANON;
1697 ],[
1698 AC_MSG_RESULT(yes)
1699 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1700 [Page state NR_ACTIVE_ANON is available])
1701 ],[
1702 AC_MSG_RESULT(no)
1703 ])
1704
1705 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1706 SPL_LINUX_TRY_COMPILE([
1707 #include <linux/mm.h>
1708 ],[
03318641 1709 enum zone_stat_item zsi __attribute__ ((unused));
6ae7fef5
BB
1710 zsi = NR_ACTIVE_FILE;
1711 ],[
1712 AC_MSG_RESULT(yes)
1713 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1714 [Page state NR_ACTIVE_FILE is available])
1715 ],[
1716 AC_MSG_RESULT(no)
1717 ])
1718])
1719
1720dnl #
1721dnl # Proposed API change for legacy kernels.
1722dnl # This symbol is not available in older kernels. For kernels post
1723dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1724dnl # page state information. This symbol is only used in legacy kernels
1725dnl # any only as a last resort.
1726dnl
1727AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1728 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1729 SPL_LINUX_TRY_COMPILE([
1730 ],[
1731 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1732 #error "global_page_state needs NR_FREE_PAGES"
1733 #endif
1734
1735 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1736 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1737 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1738 #error "global_page_state needs NR_ACTIVE*"
1739 #endif
1740
1741 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1742 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1743 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1744 #error "global_page_state needs NR_INACTIVE*"
1745 #endif
1746 ],[
1747 AC_MSG_RESULT(no)
1748 ],[
1749 AC_MSG_RESULT(yes)
1750 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1751 [get_zone_counts() is needed])
1752
723aa3b0
ED
1753 AC_MSG_CHECKING([whether get_zone_counts() is available])
1754 SPL_LINUX_TRY_COMPILE_SYMBOL([
1755 #include <linux/mmzone.h>
1756 ], [
1757 get_zone_counts(NULL, NULL, NULL);
1758 ], [get_zone_counts], [], [
1759 AC_MSG_RESULT(yes)
1760 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1761 [get_zone_counts() is available])
1762 ], [
1763 AC_MSG_RESULT(no)
1764 ])
6ae7fef5
BB
1765 ])
1766])
1767
7119bf70
BB
1768dnl #
1769dnl # 2.6.27 API change,
1770dnl # The user_path_dir() replaces __user_walk()
1771dnl #
723aa3b0
ED
1772AC_DEFUN([SPL_AC_USER_PATH_DIR],
1773 [AC_MSG_CHECKING([whether user_path_dir() is available])
1774 SPL_LINUX_TRY_COMPILE_SYMBOL([
1775 #include <linux/fcntl.h>
1776 #include <linux/namei.h>
1777 ], [
1778 user_path_dir(NULL, NULL);
1779 ], [user_path_at], [], [
1780 AC_MSG_RESULT(yes)
1781 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1782 ], [
1783 AC_MSG_RESULT(no)
1784 ])
7119bf70
BB
1785])
1786
51a727e9
BB
1787dnl #
1788dnl # Symbol available in RHEL kernels not in stock kernels.
1789dnl #
723aa3b0
ED
1790AC_DEFUN([SPL_AC_SET_FS_PWD],
1791 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1792 SPL_LINUX_TRY_COMPILE_SYMBOL([
1793 #include <linux/spinlock.h>
1794 #include <linux/fs_struct.h>
1795 ], [
1796 (void) set_fs_pwd;
1797 ], [set_fs_pwd], [], [
1798 AC_MSG_RESULT(yes)
1799 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1800 ], [
1801 AC_MSG_RESULT(no)
1802 ])
51a727e9
BB
1803])
1804
a54718cf
RY
1805dnl #
1806dnl # 3.9 API change
1807dnl # set_fs_pwd takes const struct path *
1808dnl #
1809AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
a54718cf
RY
1810 tmp_flags="$EXTRA_KCFLAGS"
1811 EXTRA_KCFLAGS="-Werror"
1812 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1813 SPL_LINUX_TRY_COMPILE([
1814 #include <linux/spinlock.h>
1815 #include <linux/fs_struct.h>
1816 #include <linux/path.h>
1817 void (*const set_fs_pwd_func)
1818 (struct fs_struct *, const struct path *)
1819 = set_fs_pwd;
1820 ],[
1821 return 0;
1822 ],[
1823 AC_MSG_RESULT(yes)
1824 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1825 [set_fs_pwd() needs const path *])
1826 ],[
1827 SPL_LINUX_TRY_COMPILE([
1828 #include <linux/spinlock.h>
1829 #include <linux/fs_struct.h>
1830 #include <linux/path.h>
1831 void (*const set_fs_pwd_func)
1832 (struct fs_struct *, struct path *)
1833 = set_fs_pwd;
1834 ],[
1835 return 0;
1836 ],[
1837 AC_MSG_RESULT(no)
1838 ],[
1839 AC_MSG_ERROR(unknown)
1840 ])
1841 ])
1842 EXTRA_KCFLAGS="$tmp_flags"
a54718cf
RY
1843])
1844
a093c6a4
BB
1845AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1846 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1847 SPL_LINUX_TRY_COMPILE([
1848 #include <linux/fs.h>
1849 ],[
50a0749e 1850 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
a093c6a4
BB
1851 ],[
1852 AC_MSG_RESULT(yes)
1853 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1854 [vfs_unlink() wants 2 args])
1855 ],[
1856 AC_MSG_RESULT(no)
50a0749e
RY
1857 dnl #
1858 dnl # Linux 3.13 API change
1859 dnl # Added delegated inode
1860 dnl #
1861 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1862 SPL_LINUX_TRY_COMPILE([
1863 #include <linux/fs.h>
1864 ],[
1865 vfs_unlink((struct inode *) NULL,
1866 (struct dentry *) NULL,
1867 (struct inode **) NULL);
1868 ],[
1869 AC_MSG_RESULT(yes)
1870 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1871 [vfs_unlink() wants 3 args])
1872 ],[
1873 AC_MSG_ERROR(no)
1874 ])
1875
a093c6a4
BB
1876 ])
1877])
1878
a093c6a4
BB
1879AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1880 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1881 SPL_LINUX_TRY_COMPILE([
1882 #include <linux/fs.h>
1883 ],[
50a0749e
RY
1884 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1885 (struct inode *) NULL, (struct dentry *) NULL);
a093c6a4
BB
1886 ],[
1887 AC_MSG_RESULT(yes)
1888 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1889 [vfs_rename() wants 4 args])
1890 ],[
1891 AC_MSG_RESULT(no)
50a0749e
RY
1892 dnl #
1893 dnl # Linux 3.13 API change
1894 dnl # Added delegated inode
1895 dnl #
1896 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1897 SPL_LINUX_TRY_COMPILE([
1898 #include <linux/fs.h>
1899 ],[
1900 vfs_rename((struct inode *) NULL,
1901 (struct dentry *) NULL,
1902 (struct inode *) NULL,
1903 (struct dentry *) NULL,
1904 (struct inode **) NULL);
1905 ],[
1906 AC_MSG_RESULT(yes)
1907 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1908 [vfs_rename() wants 5 args])
1909 ],[
ad3412ef
CC
1910 AC_MSG_RESULT(no)
1911 dnl #
1912 dnl # Linux 3.15 API change
1913 dnl # Added flags
1914 dnl #
1915 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1916 SPL_LINUX_TRY_COMPILE([
1917 #include <linux/fs.h>
1918 ],[
1919 vfs_rename((struct inode *) NULL,
1920 (struct dentry *) NULL,
1921 (struct inode *) NULL,
1922 (struct dentry *) NULL,
1923 (struct inode **) NULL,
1924 (unsigned int) 0);
1925 ],[
1926 AC_MSG_RESULT(yes)
1927 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1928 [vfs_rename() wants 6 args])
1929 ],[
1930 AC_MSG_ERROR(no)
1931 ])
50a0749e 1932 ])
a093c6a4
BB
1933 ])
1934])
ec7d53e9 1935
9b2048c2
BB
1936dnl #
1937dnl # 2.6.36 API change,
1938dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1939dnl # a spinlock_t to improve the fastpath performance.
1940dnl #
1941AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1942 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
97fd6a07
BB
1943 tmp_flags="$EXTRA_KCFLAGS"
1944 EXTRA_KCFLAGS="-Werror"
9b2048c2
BB
1945 SPL_LINUX_TRY_COMPILE([
1946 #include <linux/sched.h>
1947 #include <linux/fs_struct.h>
1948 ],[
1949 struct fs_struct fs;
1950 spin_lock_init(&fs.lock);
1951 ],[
1952 AC_MSG_RESULT(yes)
1953 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1954 [struct fs_struct uses spinlock_t])
1955 ],[
1956 AC_MSG_RESULT(no)
1957 ])
97fd6a07 1958 EXTRA_KCFLAGS="$tmp_flags"
9b2048c2
BB
1959])
1960
ec7d53e9
BB
1961dnl #
1962dnl # 2.6.29 API change,
1963dnl # check whether 'struct cred' exists
1964dnl #
1965AC_DEFUN([SPL_AC_CRED_STRUCT], [
1966 AC_MSG_CHECKING([whether struct cred exists])
1967 SPL_LINUX_TRY_COMPILE([
1968 #include <linux/cred.h>
1969 ],[
03318641 1970 struct cred *cr __attribute__ ((unused));
ec7d53e9
BB
1971 cr = NULL;
1972 ],[
1973 AC_MSG_RESULT(yes)
1974 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1975 ],[
1976 AC_MSG_RESULT(no)
1977 ])
1978])
1979
f7fd6ddd
RY
1980
1981dnl #
1982dnl # User namespaces, use kuid_t in place of uid_t
1983dnl # where available. Not strictly a user namespaces thing
1984dnl # but it should prevent surprises
1985dnl #
1986AC_DEFUN([SPL_AC_KUIDGID_T], [
1987 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1988 SPL_LINUX_TRY_COMPILE([
1989 #include <linux/uidgid.h>
1990 ], [
1991 kuid_t userid = KUIDT_INIT(0);
1992 kgid_t groupid = KGIDT_INIT(0);
1993 ],[
1994 SPL_LINUX_TRY_COMPILE([
1995 #include <linux/uidgid.h>
1996 ], [
1997 kuid_t userid = 0;
1998 kgid_t groupid = 0;
1999 ],[
2000 AC_MSG_RESULT(yes; optional)
2001 ],[
2002 AC_MSG_RESULT(yes; mandatory)
2003 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
2004 ])
2005 ],[
2006 AC_MSG_RESULT(no)
2007 ])
2008])
2009
ec7d53e9 2010dnl #
e811949a 2011dnl # Custom SPL patch may export this symbol.
ec7d53e9 2012dnl #
723aa3b0
ED
2013AC_DEFUN([SPL_AC_GROUPS_SEARCH],
2014 [AC_MSG_CHECKING([whether groups_search() is available])
2015 SPL_LINUX_TRY_COMPILE_SYMBOL([
2016 #include <linux/cred.h>
f7fd6ddd
RY
2017 #ifdef HAVE_KUIDGID_T
2018 #include <linux/uidgid.h>
2019 #endif
723aa3b0 2020 ], [
f7fd6ddd
RY
2021 #ifdef HAVE_KUIDGID_T
2022 groups_search(NULL, KGIDT_INIT(0));
2023 #else
723aa3b0 2024 groups_search(NULL, 0);
f7fd6ddd 2025 #endif
723aa3b0
ED
2026 ], [groups_search], [], [
2027 AC_MSG_RESULT(yes)
2028 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
2029 ], [
2030 AC_MSG_RESULT(no)
2031 ])
ec7d53e9 2032])
e811949a
BB
2033
2034dnl #
2035dnl # 2.6.x API change,
2036dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
2037dnl #
723aa3b0
ED
2038AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
2039 [AC_MSG_CHECKING([whether __put_task_struct() is available])
2040 SPL_LINUX_TRY_COMPILE_SYMBOL([
2041 #include <linux/sched.h>
2042 ], [
2043 __put_task_struct(NULL);
2044 ], [__put_task_struct], [], [
2045 AC_MSG_RESULT(yes)
2046 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
2047 [__put_task_struct() is available])
2048 ], [
2049 AC_MSG_RESULT(no)
2050 ])
e811949a 2051])
3977f837
BB
2052
2053dnl #
2054dnl # 2.6.32 API change,
2055dnl # Unused 'struct file *' removed from prototype.
2056dnl #
2057AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
2058 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
2059 SPL_LINUX_TRY_COMPILE([
2060 #include <linux/sysctl.h>
2061 ],[
2062 proc_dostring(NULL, 0, NULL, NULL, NULL);
2063 ],[
2064 AC_MSG_RESULT(yes)
2065 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
2066 [proc_handler() wants 5 args])
2067 ],[
2068 AC_MSG_RESULT(no)
2069 ])
2070])
b868e22f
BB
2071
2072dnl #
2073dnl # 2.6.x API change,
2074dnl # kvasprintf() function added.
2075dnl #
723aa3b0
ED
2076AC_DEFUN([SPL_AC_KVASPRINTF],
2077 [AC_MSG_CHECKING([whether kvasprintf() is available])
2078 SPL_LINUX_TRY_COMPILE_SYMBOL([
2079 #include <linux/kernel.h>
2080 ], [
2081 kvasprintf(0, NULL, *((va_list*)NULL));
2082 ], [kvasprintf], [], [
2083 AC_MSG_RESULT(yes)
2084 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
2085 ], [
2086 AC_MSG_RESULT(no)
2087 ])
b868e22f 2088])
f0ff89fc 2089
0d0b5237
BB
2090dnl #
2091dnl # 2.6.29 API change,
2092dnl # vfs_fsync() funcation added, prior to this use file_fsync().
2093dnl #
723aa3b0
ED
2094AC_DEFUN([SPL_AC_VFS_FSYNC],
2095 [AC_MSG_CHECKING([whether vfs_fsync() is available])
2096 SPL_LINUX_TRY_COMPILE_SYMBOL([
2097 #include <linux/fs.h>
2098 ], [
2099 (void) vfs_fsync;
2100 ], [vfs_fsync], [fs/sync.c], [
2101 AC_MSG_RESULT(yes)
2102 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2103 ], [
2104 AC_MSG_RESULT(no)
2105 ])
0d0b5237
BB
2106])
2107
f0ff89fc
BB
2108dnl #
2109dnl # 2.6.35 API change,
0d0b5237 2110dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
f0ff89fc 2111dnl #
0d0b5237
BB
2112AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2113 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
f0ff89fc 2114 SPL_LINUX_TRY_COMPILE([
0d0b5237 2115 #include <linux/fs.h>
f0ff89fc 2116 ],[
0d0b5237 2117 vfs_fsync(NULL, 0);
f0ff89fc
BB
2118 ],[
2119 AC_MSG_RESULT(yes)
0d0b5237 2120 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
f0ff89fc
BB
2121 ],[
2122 AC_MSG_RESULT(no)
2123 ])
2124])
46aa7b39 2125
bbdc6ae4
ED
2126dnl #
2127dnl # 3.5 API change,
2128dnl # inode_operations.truncate_range removed
bbdc6ae4
ED
2129dnl #
2130AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2131 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2132 SPL_LINUX_TRY_COMPILE([
2133 #include <linux/fs.h>
2134 ],[
2135 struct inode_operations ops;
2136 ops.truncate_range = NULL;
2137 ],[
2138 AC_MSG_RESULT(yes)
2139 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2140 [truncate_range() inode operation is available])
2141 ],[
2142 AC_MSG_RESULT(no)
2143 ])
1c7b3eaf
BB
2144])
2145
2146dnl #
2147dnl # Linux 2.6.38 - 3.x API
2148dnl #
2149AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2150 AC_MSG_CHECKING([whether fops->fallocate() exists])
2151 SPL_LINUX_TRY_COMPILE([
2152 #include <linux/fs.h>
2153 ],[
2154 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2155 struct file_operations fops __attribute__ ((unused)) = {
2156 .fallocate = fallocate,
2157 };
2158 ],[
2159 AC_MSG_RESULT(yes)
2160 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2161 ],[
2162 AC_MSG_RESULT(no)
2163 ])
2164])
2165
2166dnl #
2167dnl # Linux 2.6.x - 2.6.37 API
2168dnl #
2169AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2170 AC_MSG_CHECKING([whether iops->fallocate() exists])
2171 SPL_LINUX_TRY_COMPILE([
2172 #include <linux/fs.h>
2173 ],[
2174 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2175 struct inode_operations fops __attribute__ ((unused)) = {
2176 .fallocate = fallocate,
2177 };
2178 ],[
2179 AC_MSG_RESULT(yes)
2180 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2181 ],[
2182 AC_MSG_RESULT(no)
2183 ])
2184])
2185
2186dnl #
2187dnl # PaX Linux 2.6.38 - 3.x API
2188dnl #
2189AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2190 AC_MSG_CHECKING([whether fops->fallocate() exists])
2191 SPL_LINUX_TRY_COMPILE([
2192 #include <linux/fs.h>
2193 ],[
2194 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2195 struct file_operations_no_const fops __attribute__ ((unused)) = {
2196 .fallocate = fallocate,
2197 };
2198 ],[
2199 AC_MSG_RESULT(yes)
2200 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2201 ],[
2202 AC_MSG_RESULT(no)
2203 ])
2204])
2205
2206dnl #
2207dnl # The fallocate callback was moved from the inode_operations
2208dnl # structure to the file_operations structure.
2209dnl #
2210AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2211 SPL_AC_KERNEL_FILE_FALLOCATE
2212 SPL_AC_KERNEL_INODE_FALLOCATE
2213 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2214])
bbdc6ae4 2215
46aa7b39
NB
2216dnl #
2217dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2218dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2219dnl # condition. The fixed version is exported as a symbol. The race
2220dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2221dnl # call that version while holding sem->wait_lock.
2222dnl #
723aa3b0
ED
2223AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2224 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2225 SPL_LINUX_TRY_COMPILE_SYMBOL([
2226 #include <linux/rwsem.h>
2227 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2228 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2229 AC_MSG_RESULT(yes)
2230 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2231 [rwsem_is_locked() acquires sem->wait_lock])
2232 ], [
2233 AC_MSG_RESULT(no)
2234 ])
46aa7b39 2235])
914b0631 2236
e76f4bf1
BB
2237dnl #
2238dnl # 2.6.xx API compat,
2239dnl # There currently exists no exposed API to partially shrink the dcache.
2240dnl # The expected mechanism to shrink the cache is a registered shrinker
2241dnl # which is called during memory pressure.
2242dnl #
723aa3b0
ED
2243AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2244 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2245 SPL_LINUX_TRY_COMPILE_SYMBOL([
2246 #include <linux/dcache.h>
2247 ], [
2248 shrink_dcache_memory(0, 0);
2249 ], [shrink_dcache_memory], [fs/dcache.c], [
2250 AC_MSG_RESULT(yes)
2251 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2252 [shrink_dcache_memory() is available])
2253 ], [
2254 AC_MSG_RESULT(no)
2255 ])
e76f4bf1
BB
2256])
2257
2258dnl #
2259dnl # 2.6.xx API compat,
2260dnl # There currently exists no exposed API to partially shrink the icache.
2261dnl # The expected mechanism to shrink the cache is a registered shrinker
2262dnl # which is called during memory pressure.
2263dnl #
723aa3b0
ED
2264AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2265 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2266 SPL_LINUX_TRY_COMPILE_SYMBOL([
2267 #include <linux/dcache.h>
2268 ], [
2269 shrink_icache_memory(0, 0);
2270 ], [shrink_icache_memory], [fs/inode.c], [
2271 AC_MSG_RESULT(yes)
2272 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2273 [shrink_icache_memory() is available])
2274 ], [
2275 AC_MSG_RESULT(no)
2276 ])
e76f4bf1 2277])
b1cbc461
BB
2278
2279dnl #
2280dnl # 2.6.39 API compat,
2281dnl # The path_lookup() function has been renamed to kern_path_parent()
2282dnl # and the flags argument has been removed. The only behavior now
2283dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2284dnl # this flag so dropping the flag does not impact us.
2285dnl #
12ff95ff
BB
2286AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2287 SPL_CHECK_SYMBOL_HEADER(
2288 [kern_path_parent],
2289 [int kern_path_parent(const char \*, struct nameidata \*)],
2290 [include/linux/namei.h],
2291 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2292 [kern_path_parent() is available])],
2293 [])
2294])
2295
2296dnl #
2297dnl # 3.1 API compat,
2298dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2299dnl # However, it remains the prefered interface and since we still have
2300dnl # access to the prototype we dynamically lookup the required address.
2301dnl #
723aa3b0
ED
2302AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2303 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2304 SPL_LINUX_TRY_COMPILE_SYMBOL([
2305 #include <linux/namei.h>
2306 ], [
2307 kern_path_parent(NULL, NULL);
2308 ], [kern_path_parent], [fs/namei.c], [
2309 AC_MSG_RESULT(yes)
2310 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2311 [kern_path_parent() is available])
2312 ], [
2313 AC_MSG_RESULT(no)
2314 ])
b1cbc461 2315])
3dfc591a 2316
bcb15891
YS
2317dnl #
2318dnl # 3.6 API compat,
2319dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2320dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2321dnl #
2322AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2323 SPL_CHECK_SYMBOL_HEADER(
2324 [kern_path_locked],
2325 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2326 [include/linux/namei.h],
2327 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2328 [kern_path_locked() is available])],
2329 [])
2330])
2331
de081a2a
BB
2332dnl #
2333dnl # /proc/kallsyms support,
2334dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2335dnl #
2336AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2337 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2338 SPL_LINUX_TRY_COMPILE([
2339 #if !defined(CONFIG_KALLSYMS)
2340 #error CONFIG_KALLSYMS not defined
2341 #endif
2342 ],[ ],[
2343 AC_MSG_RESULT([yes])
2344 ],[
2345 AC_MSG_RESULT([no])
2346 AC_MSG_ERROR([
2347 *** This kernel does not include the required kallsyms support.
2348 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2349 ])
2350])
2351
42b3ce62
BB
2352dnl #
2353dnl # zlib inflate compat,
2354dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2355dnl #
2356AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2357 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2358 SPL_LINUX_TRY_COMPILE([
2359 #if !defined(CONFIG_ZLIB_INFLATE) && \
2360 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2361 #error CONFIG_ZLIB_INFLATE not defined
2362 #endif
2363 ],[ ],[
2364 AC_MSG_RESULT([yes])
2365 ],[
2366 AC_MSG_RESULT([no])
2367 AC_MSG_ERROR([
2368 *** This kernel does not include the required zlib inflate support.
2369 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2370 ])
2371])
2372
2373dnl #
2374dnl # zlib deflate compat,
2375dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2376dnl #
2377AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2378 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2379 SPL_LINUX_TRY_COMPILE([
2380 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2381 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2382 #error CONFIG_ZLIB_DEFLATE not defined
2383 #endif
2384 ],[ ],[
2385 AC_MSG_RESULT([yes])
2386 ],[
2387 AC_MSG_RESULT([no])
2388 AC_MSG_ERROR([
2389 *** This kernel does not include the required zlib deflate support.
2390 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2391 ])
2392])
2393
3dfc591a
BB
2394dnl #
2395dnl # 2.6.39 API compat,
2396dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2397dnl # This was done to avoid always having to allocate the maximum size
2398dnl # workspace (268K). The caller can now specific the windowBits and
2399dnl # memLevel compression parameters to get a smaller workspace.
2400dnl #
2401AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2402 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2403 SPL_LINUX_TRY_COMPILE([
2404 #include <linux/zlib.h>
2405 ],[
2406 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2407 ],[
2408 AC_MSG_RESULT(yes)
2409 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2410 [zlib_deflate_workspacesize() wants 2 args])
2411 ],[
2412 AC_MSG_RESULT(no)
2413 ])
2414])
a55bcaad
BB
2415
2416dnl #
2417dnl # 2.6.39 API change,
2418dnl # Shrinker adjust to use common shrink_control structure.
2419dnl #
2420AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2421 AC_MSG_CHECKING([whether struct shrink_control exists])
2422 SPL_LINUX_TRY_COMPILE([
2423 #include <linux/mm.h>
2424 ],[
2425 struct shrink_control sc __attribute__ ((unused));
2426
2427 sc.nr_to_scan = 0;
2428 sc.gfp_mask = GFP_KERNEL;
2429 ],[
2430 AC_MSG_RESULT(yes)
2431 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2432 [struct shrink_control exists])
2433 ],[
2434 AC_MSG_RESULT(no)
2435 ])
2436])
588d9004
DH
2437
2438dnl #
2439dnl # 3.1 API Change
2440dnl #
2441dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2442dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2443dnl #
2444AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2445 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2446 tmp_flags="$EXTRA_KCFLAGS"
2447 EXTRA_KCFLAGS="-Werror"
2448 SPL_LINUX_TRY_COMPILE([
2449 #include <linux/rwsem.h>
2450 ],[
2451 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2452 raw_spinlock_t dummy_lock __attribute__ ((unused));
2453 dummy_semaphore.wait_lock = dummy_lock;
2454 ],[
2455 AC_MSG_RESULT(yes)
2456 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2457 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2458 ],[
2459 AC_MSG_RESULT(no)
2460 ])
2461 EXTRA_KCFLAGS="$tmp_flags"
2462])
10087fe1
RY
2463
2464dnl #
2465dnl # 3.9 API change,
2466dnl # Moved things from linux/sched.h to linux/sched/rt.h
2467dnl #
2468AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2469 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2470 SPL_LINUX_TRY_COMPILE([
2471 #include <linux/sched.h>
2472 #include <linux/sched/rt.h>
2473 ],[
2474 return 0;
2475 ],[
2476 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2477 AC_MSG_RESULT(yes)
2478 ],[
2479 AC_MSG_RESULT(no)
2480 ])
2481])
2a305c34
RY
2482
2483dnl #
2484dnl # 3.9 API change,
2485dnl # vfs_getattr() uses 2 args
2486dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2487dnl #
2488AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2489 AC_MSG_CHECKING([whether vfs_getattr() wants])
2490 SPL_LINUX_TRY_COMPILE([
2491 #include <linux/fs.h>
2492 ],[
2493 vfs_getattr((struct path *) NULL,
2494 (struct kstat *)NULL);
2495 ],[
2496 AC_MSG_RESULT(2 args)
2497 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2498 [vfs_getattr wants 2 args])
2499 ],[
2500 SPL_LINUX_TRY_COMPILE([
2501 #include <linux/fs.h>
2502 ],[
2503 vfs_getattr((struct vfsmount *)NULL,
2504 (struct dentry *)NULL,
2505 (struct kstat *)NULL);
2506 ],[
2507 AC_MSG_RESULT(3 args)
2508 ],[
2509 AC_MSG_ERROR(unknown)
2510 ])
2511 ])
2512])
184c6873
NB
2513
2514dnl #
2515dnl # 2.6.36 API compatibility.
2516dnl # Added usleep_range timer.
2517dnl # usleep_range is a finer precision implementation of msleep
2518dnl # designed to be a drop-in replacement for udelay where a precise
2519dnl # sleep / busy-wait is unnecessary.
2520dnl #
2521AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2522 AC_MSG_CHECKING([whether usleep_range() is available])
2523 SPL_LINUX_TRY_COMPILE([
2524 #include <linux/delay.h>
2525 ],[
2526 usleep_range(0, 0);
2527 ],[
2528 AC_MSG_RESULT(yes)
2529 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2530 [usleep_range is available])
2531 ],[
2532 AC_MSG_RESULT(no)
2533 ])
2534])