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