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