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