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