]> git.proxmox.com Git - mirror_spl.git/blame - config/spl-build.m4
Correctly detect atomic64_cmpxchg support
[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 dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
13 dnl # compiler options are added by the kernel build system.
14 abs_srcdir=`readlink -f ${srcdir}`
c950d148 15 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
16b719f0
BB
16 KERNELCPPFLAGS="$KERNELCPPFLAGS -I${abs_srcdir}/include"
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -include ${abs_srcdir}/spl_config.h"
86933a6e
BB
18
19 if test "${LINUX_OBJ}" != "${LINUX}"; then
20 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
21 fi
22
23 AC_SUBST(KERNELMAKE_PARAMS)
24 AC_SUBST(KERNELCPPFLAGS)
25
26 SPL_AC_DEBUG
27 SPL_AC_DEBUG_KMEM
055ffd98 28 SPL_AC_DEBUG_KMEM_TRACKING
5e9b5d83 29 SPL_AC_ATOMIC_SPINLOCK
302b88e6
BB
30 SPL_AC_TYPE_ATOMIC64_CMPXCHG
31 SPL_AC_TYPE_ATOMIC64_XCHG
d04c8a56 32 SPL_AC_TYPE_UINTPTR_T
86933a6e
BB
33 SPL_AC_3ARGS_INIT_WORK
34 SPL_AC_2ARGS_REGISTER_SYSCTL
35 SPL_AC_SET_SHRINKER
36 SPL_AC_PATH_IN_NAMEIDATA
37 SPL_AC_TASK_CURR
38 SPL_AC_CTL_UNNUMBERED
79a3bf13 39 SPL_AC_CTL_NAME
86933a6e
BB
40 SPL_AC_FLS64
41 SPL_AC_DEVICE_CREATE
42 SPL_AC_5ARGS_DEVICE_CREATE
43 SPL_AC_CLASS_DEVICE_CREATE
44 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
45 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
46 SPL_AC_TIMESPEC_SUB
47 SPL_AC_INIT_UTSNAME
48 SPL_AC_FDTABLE_HEADER
49 SPL_AC_FILES_FDTABLE
50 SPL_AC_UACCESS_HEADER
51 SPL_AC_KMALLOC_NODE
52 SPL_AC_MONOTONIC_CLOCK
53 SPL_AC_INODE_I_MUTEX
4d54fdee 54 SPL_AC_MUTEX_OWNER
86933a6e 55 SPL_AC_MUTEX_LOCK_NESTED
86933a6e
BB
56 SPL_AC_3ARGS_ON_EACH_CPU
57 SPL_AC_KALLSYMS_LOOKUP_NAME
58 SPL_AC_GET_VMALLOC_INFO
59 SPL_AC_PGDAT_HELPERS
60 SPL_AC_FIRST_ONLINE_PGDAT
61 SPL_AC_NEXT_ONLINE_PGDAT
62 SPL_AC_NEXT_ZONE
63 SPL_AC_PGDAT_LIST
86933a6e 64 SPL_AC_GLOBAL_PAGE_STATE
6ae7fef5
BB
65 SPL_AC_ZONE_STAT_ITEM_FREE
66 SPL_AC_ZONE_STAT_ITEM_INACTIVE
67 SPL_AC_ZONE_STAT_ITEM_ACTIVE
68 SPL_AC_GET_ZONE_COUNTS
7119bf70 69 SPL_AC_USER_PATH_DIR
51a727e9
BB
70 SPL_AC_SET_FS_PWD
71 SPL_AC_2ARGS_SET_FS_PWD
86933a6e
BB
72 SPL_AC_2ARGS_VFS_UNLINK
73 SPL_AC_4ARGS_VFS_RENAME
ec7d53e9
BB
74 SPL_AC_CRED_STRUCT
75 SPL_AC_GROUPS_SEARCH
e811949a 76 SPL_AC_PUT_TASK_STRUCT
3977f837 77 SPL_AC_5ARGS_PROC_HANDLER
b868e22f 78 SPL_AC_KVASPRINTF
f0ff89fc 79 SPL_AC_3ARGS_FILE_FSYNC
86933a6e
BB
80])
81
82AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
bb339d06 83 modpost=$LINUX/scripts/Makefile.modpost
86933a6e 84 AC_MSG_CHECKING([kernel file name for module symbols])
bb339d06
BB
85 if test -f "$modpost"; then
86 if grep -q Modules.symvers $modpost; then
87 LINUX_SYMBOLS=Modules.symvers
88 else
89 LINUX_SYMBOLS=Module.symvers
90 fi
86933a6e 91 else
bb339d06 92 LINUX_SYMBOLS=NONE
86933a6e
BB
93 fi
94 AC_MSG_RESULT($LINUX_SYMBOLS)
95 AC_SUBST(LINUX_SYMBOLS)
96])
97
57d86234 98AC_DEFUN([SPL_AC_KERNEL], [
57d86234 99 AC_ARG_WITH([linux],
100 AS_HELP_STRING([--with-linux=PATH],
101 [Path to kernel source]),
39a3d2a4 102 [kernelsrc="$withval"])
57d86234 103
104 AC_ARG_WITH([linux-obj],
105 AS_HELP_STRING([--with-linux-obj=PATH],
106 [Path to kernel build objects]),
107 [kernelbuild="$withval"])
108
109 AC_MSG_CHECKING([kernel source directory])
110 if test -z "$kernelsrc"; then
534c4e38
BM
111 headersdir="/lib/modules/$(uname -r)/build"
112 if test -e "$headersdir"; then
113 sourcelink=$(readlink -f "$headersdir")
114 else
115 sourcelink=$(ls -1d /usr/src/kernels/* \
116 /usr/src/linux-* \
117 2>/dev/null | grep -v obj | tail -1)
118 fi
57d86234 119
8fd4e3af 120 if test -n "$sourcelink" && test -e ${sourcelink}; then
d4326403 121 kernelsrc=`readlink -f ${sourcelink}`
d4326403 122 else
57d86234 123 AC_MSG_RESULT([Not found])
124 AC_MSG_ERROR([
8fd4e3af
BB
125 *** Please make sure the kernel devel package for your distribution
126 *** is installed then try again. If that fails you can specify the
127 *** location of the kernel source with the '--with-linux=PATH' option.])
57d86234 128 fi
c5f70460
BB
129 else
130 if test "$kernelsrc" = "NONE"; then
131 kernsrcver=NONE
132 fi
57d86234 133 fi
134
135 AC_MSG_RESULT([$kernelsrc])
136 AC_MSG_CHECKING([kernel build directory])
39a3d2a4 137 if test -z "$kernelbuild"; then
e2d28a37
BB
138 if test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
139 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
140 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
141 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
142 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
143 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
39a3d2a4
BB
144 else
145 kernelbuild=${kernelsrc}
146 fi
bf338d8d 147 fi
57d86234 148 AC_MSG_RESULT([$kernelbuild])
149
150 AC_MSG_CHECKING([kernel source version])
fd921c2e
BB
151 utsrelease1=$kernelbuild/include/linux/version.h
152 utsrelease2=$kernelbuild/include/linux/utsrelease.h
153 utsrelease3=$kernelbuild/include/generated/utsrelease.h
154 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
155 utsrelease=linux/version.h
156 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
157 utsrelease=linux/utsrelease.h
158 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
159 utsrelease=generated/utsrelease.h
160 fi
57d86234 161
fd921c2e
BB
162 if test "$utsrelease"; then
163 kernsrcver=`(echo "#include <$utsrelease>";
57d86234 164 echo "kernsrcver=UTS_RELEASE") |
d4326403 165 cpp -I $kernelbuild/include |
57d86234 166 grep "^kernsrcver=" | cut -d \" -f 2`
57d86234 167
fd921c2e
BB
168 if test -z "$kernsrcver"; then
169 AC_MSG_RESULT([Not found])
170 AC_MSG_ERROR([*** Cannot determine kernel version.])
171 fi
172 else
57d86234 173 AC_MSG_RESULT([Not found])
fd921c2e 174 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
57d86234 175 fi
176
177 AC_MSG_RESULT([$kernsrcver])
178
57d86234 179 LINUX=${kernelsrc}
180 LINUX_OBJ=${kernelbuild}
c5f70460
BB
181 LINUX_VERSION=${kernsrcver}
182
57d86234 183 AC_SUBST(LINUX)
184 AC_SUBST(LINUX_OBJ)
c5f70460 185 AC_SUBST(LINUX_VERSION)
57d86234 186
86933a6e 187 SPL_AC_MODULE_SYMVERS
2e0e7e69
BB
188])
189
86933a6e 190dnl #
287b2fb1
BB
191dnl # Explicitly check for gawk, we require it for the the usermode
192dnl # helper. For some reason the standard awk command does not
193dnl # behave correctly when invoked from the usermode helper.
86933a6e 194dnl #
287b2fb1 195AC_DEFUN([SPL_AC_GAWK], [
18142514
BB
196 AS_IF([test "x$AWK" != xgawk], [
197 AC_MSG_ERROR([
198 *** Required util gawk missing. Please install the required
199 *** gawk package for your distribution and try again.])
200 ])
201])
86933a6e 202
287b2fb1
BB
203dnl #
204dnl # Default SPL user configuration
205dnl #
206AC_DEFUN([SPL_AC_CONFIG_USER], [
207 SPL_AC_GAWK
208])
209
210dnl #
211dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
212dnl # are missing it is non-fatal but you will not be able to build
213dnl # RPM packages and will be warned if you try too.
214dnl #
215AC_DEFUN([SPL_AC_RPM], [
216 RPM=rpm
217 RPMBUILD=rpmbuild
218
219 AC_MSG_CHECKING([whether $RPM is available])
220 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
221 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
222 HAVE_RPM=yes
223 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
224 ],[
225 HAVE_RPM=no
226 AC_MSG_RESULT([$HAVE_RPM])
227 ])
228
229 AC_MSG_CHECKING([whether $RPMBUILD is available])
230 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
231 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
232 HAVE_RPMBUILD=yes
233 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
234 ],[
235 HAVE_RPMBUILD=no
236 AC_MSG_RESULT([$HAVE_RPMBUILD])
237 ])
238
239 AC_SUBST(HAVE_RPM)
240 AC_SUBST(RPM)
241 AC_SUBST(RPM_VERSION)
242
243 AC_SUBST(HAVE_RPMBUILD)
244 AC_SUBST(RPMBUILD)
245 AC_SUBST(RPMBUILD_VERSION)
246])
247
248dnl #
249dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
250dnl # tools are missing it is non-fatal but you will not be able to build
251dnl # DEB packages and will be warned if you try too.
252dnl #
253AC_DEFUN([SPL_AC_DPKG], [
254 DPKG=dpkg
255 DPKGBUILD=dpkg-buildpackage
256
257 AC_MSG_CHECKING([whether $DPKG is available])
258 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
259 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
260 HAVE_DPKG=yes
261 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
262 ],[
263 HAVE_DPKG=no
264 AC_MSG_RESULT([$HAVE_DPKG])
265 ])
266
267 AC_MSG_CHECKING([whether $DPKGBUILD is available])
268 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
269 DPKGBUILD_VERSION=$(echo $tmp | \
270 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
271 HAVE_DPKGBUILD=yes
272 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
273 ],[
274 HAVE_DPKGBUILD=no
275 AC_MSG_RESULT([$HAVE_DPKGBUILD])
276 ])
277
278 AC_SUBST(HAVE_DPKG)
279 AC_SUBST(DPKG)
280 AC_SUBST(DPKG_VERSION)
281
282 AC_SUBST(HAVE_DPKGBUILD)
283 AC_SUBST(DPKGBUILD)
284 AC_SUBST(DPKGBUILD_VERSION)
285])
286
287dnl #
288dnl # Until native packaging for various different packing systems
289dnl # can be added the least we can do is attempt to use alien to
290dnl # convert the RPM packages to the needed package type. This is
291dnl # a hack but so far it has worked reasonable well.
292dnl #
293AC_DEFUN([SPL_AC_ALIEN], [
294 ALIEN=alien
295
296 AC_MSG_CHECKING([whether $ALIEN is available])
297 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
298 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
299 HAVE_ALIEN=yes
300 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
301 ],[
302 HAVE_ALIEN=no
303 AC_MSG_RESULT([$HAVE_ALIEN])
304 ])
305
306 AC_SUBST(HAVE_ALIEN)
307 AC_SUBST(ALIEN)
308 AC_SUBST(ALIEN_VERSION)
309])
310
311dnl #
312dnl # Using the VENDOR tag from config.guess set the default
313dnl # package type for 'make pkg': (rpm | deb | tgz)
314dnl #
315AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
316 VENDOR=$(echo $ac_build_alias | cut -f2 -d'-')
317
318 AC_MSG_CHECKING([default package type])
319 case "$VENDOR" in
320 fedora) DEFAULT_PACKAGE=rpm ;;
321 redhat) DEFAULT_PACKAGE=rpm ;;
322 sles) DEFAULT_PACKAGE=rpm ;;
323 ubuntu) DEFAULT_PACKAGE=deb ;;
324 debian) DEFAULT_PACKAGE=deb ;;
325 slackware) DEFAULT_PACKAGE=tgz ;;
326 *) DEFAULT_PACKAGE=rpm ;;
327 esac
328
329 AC_MSG_RESULT([$DEFAULT_PACKAGE])
330 AC_SUBST(DEFAULT_PACKAGE)
331])
332
333dnl #
334dnl # Default SPL user configuration
335dnl #
336AC_DEFUN([SPL_AC_PACKAGE], [
337 SPL_AC_RPM
338 SPL_AC_DPKG
339 SPL_AC_ALIEN
340 SPL_AC_DEFAULT_PACKAGE
341])
342
6a1c3d41 343AC_DEFUN([SPL_AC_LICENSE], [
86933a6e
BB
344 AC_MSG_CHECKING([spl license])
345 LICENSE=GPL
346 AC_MSG_RESULT([$LICENSE])
6a1c3d41 347 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
86933a6e
BB
348 AC_SUBST(LICENSE)
349])
350
351AC_DEFUN([SPL_AC_CONFIG], [
352 SPL_CONFIG=all
353 AC_ARG_WITH([config],
354 AS_HELP_STRING([--with-config=CONFIG],
c1541dfe 355 [Config file 'kernel|user|all|srpm']),
86933a6e
BB
356 [SPL_CONFIG="$withval"])
357
358 AC_MSG_CHECKING([spl config])
359 AC_MSG_RESULT([$SPL_CONFIG]);
360 AC_SUBST(SPL_CONFIG)
361
362 case "$SPL_CONFIG" in
363 kernel) SPL_AC_CONFIG_KERNEL ;;
364 user) SPL_AC_CONFIG_USER ;;
365 all) SPL_AC_CONFIG_KERNEL
366 SPL_AC_CONFIG_USER ;;
c1541dfe 367 srpm) ;;
86933a6e
BB
368 *)
369 AC_MSG_RESULT([Error!])
370 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
c1541dfe 371 user kernel|user|all|srpm]) ;;
86933a6e
BB
372 esac
373
374 AM_CONDITIONAL([CONFIG_USER],
375 [test "$SPL_CONFIG" = user] ||
376 [test "$SPL_CONFIG" = all])
377 AM_CONDITIONAL([CONFIG_KERNEL],
378 [test "$SPL_CONFIG" = kernel] ||
379 [test "$SPL_CONFIG" = all])
6a1c3d41 380])
381
055ffd98
BB
382dnl #
383dnl # Enable if the SPL should be compiled with internal debugging enabled.
384dnl # By default this support is disabled.
385dnl #
57d86234 386AC_DEFUN([SPL_AC_DEBUG], [
c950d148 387 AC_MSG_CHECKING([whether debugging is enabled])
055ffd98
BB
388 AC_ARG_ENABLE([debug],
389 [AS_HELP_STRING([--enable-debug],
390 [Enable generic debug support @<:@default=no@:>@])],
391 [],
392 [enable_debug=no])
393
394 AS_IF([test "x$enable_debug" = xyes],
c950d148 395 [
c950d148
BB
396 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
397 DEBUG_CFLAGS="-DDEBUG -Werror"
398 ],
399 [
c950d148
BB
400 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
401 DEBUG_CFLAGS="-DNDEBUG"
402 ])
055ffd98 403
c950d148 404 AC_SUBST(DEBUG_CFLAGS)
055ffd98 405 AC_MSG_RESULT([$enable_debug])
57d86234 406])
407
055ffd98
BB
408dnl #
409dnl # Enabled by default it provides a minimal level of memory tracking.
410dnl # A total count of bytes allocated is kept for each alloc and free.
411dnl # Then at module unload time a report to the console will be printed
412dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
413dnl # and provide an easy way to inspect the kmem based slab.
414dnl #
57d86234 415AC_DEFUN([SPL_AC_DEBUG_KMEM], [
055ffd98
BB
416 AC_ARG_ENABLE([debug-kmem],
417 [AS_HELP_STRING([--enable-debug-kmem],
418 [Enable basic kmem accounting @<:@default=yes@:>@])],
419 [],
420 [enable_debug_kmem=yes])
57d86234 421
055ffd98
BB
422 AS_IF([test "x$enable_debug_kmem" = xyes],
423 [AC_DEFINE([DEBUG_KMEM], [1],
424 [Define to 1 to enable basic kmem accounting])
425 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"])
426
427 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
428 AC_MSG_RESULT([$enable_debug_kmem])
57d86234 429])
430
055ffd98
BB
431dnl #
432dnl # Disabled by default it provides detailed memory tracking. This
433dnl # feature also requires --enable-debug-kmem to be set. When enabled
434dnl # not only will total bytes be tracked but also the location of every
435dnl # alloc and free. When the SPL module is unloaded a list of all leaked
436dnl # addresses and where they were allocated will be dumped to the console.
437dnl # Enabling this feature has a significant impact on performance but it
438dnl # makes finding memory leaks pretty straight forward.
439dnl #
440AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
441 AC_ARG_ENABLE([debug-kmem-tracking],
442 [AS_HELP_STRING([--enable-debug-kmem-tracking],
443 [Enable detailed kmem tracking @<:@default=no@:>@])],
444 [],
445 [enable_debug_kmem_tracking=no])
446
447 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
448 [AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
449 [Define to 1 to enable detailed kmem tracking])
450 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"])
451
452 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
453 AC_MSG_RESULT([$enable_debug_kmem_tracking])
57d86234 454])
455
456dnl #
457dnl # SPL_LINUX_CONFTEST
458dnl #
459AC_DEFUN([SPL_LINUX_CONFTEST], [
dbe561d8 460cat confdefs.h - <<_ACEOF >conftest.c
57d86234 461$1
462_ACEOF
463])
464
465dnl #
466dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
467dnl #
468m4_define([SPL_LANG_PROGRAM], [
469$1
470int
471main (void)
472{
473dnl Do *not* indent the following line: there may be CPP directives.
474dnl Don't move the `;' right after for the same reason.
475$2
476 ;
477 return 0;
478}
479])
480
481dnl #
482dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
483dnl #
484AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
c5f70460
BB
485 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
486 rm -Rf build && mkdir -p build
487 echo "obj-m := conftest.o" >build/Makefile
488 AS_IF(
3d0cb2d3 489 [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) >/dev/null && AC_TRY_COMMAND([$3])],
c5f70460
BB
490 [$4],
491 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
492 )
493 rm -Rf build
57d86234 494])
495
496dnl #
497dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
498dnl #
499AC_DEFUN([SPL_LINUX_TRY_COMPILE],
500 [SPL_LINUX_COMPILE_IFELSE(
d50bd9e2 501 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
502 [modules],
503 [test -s build/conftest.o],
504 [$3], [$4])
57d86234 505])
506
507dnl #
508dnl # SPL_LINUX_CONFIG
509dnl #
510AC_DEFUN([SPL_LINUX_CONFIG],
511 [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1])
512 SPL_LINUX_TRY_COMPILE([
513 #ifndef AUTOCONF_INCLUDED
514 #include <linux/config.h>
515 #endif
516 ],[
517 #ifndef CONFIG_$1
518 #error CONFIG_$1 not #defined
519 #endif
520 ],[
521 AC_MSG_RESULT([yes])
522 $2
523 ],[
524 AC_MSG_RESULT([no])
525 $3
526 ])
527])
528
529dnl #
530dnl # SPL_CHECK_SYMBOL_EXPORT
531dnl # check symbol exported or not
532dnl #
533AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT],
534 [AC_MSG_CHECKING([whether symbol $1 is exported])
2e0e7e69
BB
535 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
536 $LINUX_OBJ/Module*.symvers 2>/dev/null
57d86234 537 rc=$?
538 if test $rc -ne 0; then
539 export=0
540 for file in $2; do
2e0e7e69
BB
541 grep -q -E "EXPORT_SYMBOL.*($1)" \
542 "$LINUX_OBJ/$file" 2>/dev/null
57d86234 543 rc=$?
544 if test $rc -eq 0; then
545 export=1
546 break;
547 fi
548 done
549 if test $export -eq 0; then
550 AC_MSG_RESULT([no])
551 $4
552 else
553 AC_MSG_RESULT([yes])
554 $3
555 fi
556 else
557 AC_MSG_RESULT([yes])
558 $3
559 fi
560])
561
86de8532 562dnl #
563dnl # SPL_CHECK_HEADER
564dnl # check whether header exists and define HAVE_$2_HEADER
565dnl #
566AC_DEFUN([SPL_CHECK_HEADER],
567 [AC_MSG_CHECKING([whether header $1 exists])
568 SPL_LINUX_TRY_COMPILE([
d50bd9e2 569 #include <$1>
86de8532 570 ],[
571 return 0;
572 ],[
573 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
574 AC_MSG_RESULT(yes)
575 $3
576 ],[
577 AC_MSG_RESULT(no)
578 $4
579 ])
580])
6a6cafbe 581
57d86234 582dnl #
d04c8a56
BB
583dnl # Use the atomic implemenation based on global spinlocks. This
584dnl # should only be needed by 32-bit kernels which do not provide
585dnl # the atomic64_* API. It may be optionally enabled as a fallback
586dnl # if problems are observed with the direct mapping to the native
587dnl # Linux atomic operations. You may not disable atomic spinlocks
588dnl # if you kernel does not an atomic64_* API.
57d86234 589dnl #
d04c8a56
BB
590AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
591 AC_ARG_ENABLE([atomic-spinlocks],
592 [AS_HELP_STRING([--enable-atomic-spinlocks],
593 [Atomic types use spinlocks @<:@default=check@:>@])],
594 [],
595 [enable_atomic_spinlocks=check])
57d86234 596
a0f6da3d 597 SPL_LINUX_TRY_COMPILE([
598 #include <asm/atomic.h>
599 ],[
600 atomic64_t *ptr;
601 ],[
d04c8a56 602 have_atomic64_t=yes
a0f6da3d 603 AC_DEFINE(HAVE_ATOMIC64_T, 1,
d04c8a56 604 [kernel defines atomic64_t])
a0f6da3d 605 ],[
d04c8a56
BB
606 have_atomic64_t=no
607 ])
608
609 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
610 AS_IF([test "x$have_atomic64_t" = xyes], [
611 enable_atomic_spinlocks=no
612 ],[
613 enable_atomic_spinlocks=yes
614 ])
a0f6da3d 615 ])
d04c8a56
BB
616
617 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
618 AC_DEFINE([ATOMIC_SPINLOCK], [1],
619 [Atomic types use spinlocks])
620 ],[
621 AS_IF([test "x$have_atomic64_t" = xno], [
622 AC_MSG_FAILURE(
623 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
624 ])
625 ])
626
627 AC_MSG_CHECKING([whether atomic types use spinlocks])
628 AC_MSG_RESULT([$enable_atomic_spinlocks])
629
630 AC_MSG_CHECKING([whether kernel defines atomic64_t])
631 AC_MSG_RESULT([$have_atomic64_t])
a0f6da3d 632])
633
302b88e6
BB
634dnl #
635dnl # 2.6.24 API change,
636dnl # check if atomic64_cmpxchg is defined
637dnl #
638AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
639 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
640 SPL_LINUX_TRY_COMPILE([
641 #include <asm/atomic.h>
5ec44a37 642 #include <asm/system.h>
302b88e6
BB
643 ],[
644 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
645 ],[
646 AC_MSG_RESULT([yes])
647 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
648 [kernel defines atomic64_cmpxchg])
649 ],[
650 AC_MSG_RESULT([no])
651 ])
652])
653
654dnl #
655dnl # 2.6.24 API change,
656dnl # check if atomic64_xchg is defined
657dnl #
658AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
659 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
660 SPL_LINUX_TRY_COMPILE([
661 #include <asm/atomic.h>
662 ],[
663 atomic64_xchg((atomic64_t *)NULL, 0);
664 ],[
665 AC_MSG_RESULT([yes])
666 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
667 [kernel defines atomic64_xchg])
668 ],[
669 AC_MSG_RESULT([no])
670 ])
671])
672
d04c8a56
BB
673dnl #
674dnl # 2.6.24 API change,
675dnl # check if uintptr_t typedef is defined
676dnl #
677AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
678 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
679 SPL_LINUX_TRY_COMPILE([
680 #include <linux/types.h>
681 ],[
682 uintptr_t *ptr;
683 ],[
684 AC_MSG_RESULT([yes])
685 AC_DEFINE(HAVE_UINTPTR_T, 1,
686 [kernel defines uintptr_t])
687 ],[
688 AC_MSG_RESULT([no])
689 ])
690])
691
57d86234 692dnl #
3d061e9d 693dnl # 2.6.20 API change,
57d86234 694dnl # INIT_WORK use 2 args and not store data inside
695dnl #
696AC_DEFUN([SPL_AC_3ARGS_INIT_WORK],
697 [AC_MSG_CHECKING([whether INIT_WORK wants 3 args])
698 SPL_LINUX_TRY_COMPILE([
d50bd9e2 699 #include <linux/workqueue.h>
57d86234 700 ],[
d50bd9e2 701 struct work_struct work;
702 INIT_WORK(&work, NULL, NULL);
57d86234 703 ],[
d50bd9e2 704 AC_MSG_RESULT(yes)
705 AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
706 [INIT_WORK wants 3 args])
57d86234 707 ],[
d50bd9e2 708 AC_MSG_RESULT(no)
57d86234 709 ])
710])
711
712dnl #
3d061e9d 713dnl # 2.6.21 API change,
57d86234 714dnl # 'register_sysctl_table' use only one argument instead of two
715dnl #
716AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
717 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
718 SPL_LINUX_TRY_COMPILE([
d50bd9e2 719 #include <linux/sysctl.h>
57d86234 720 ],[
d50bd9e2 721 return register_sysctl_table(NULL,0);
57d86234 722 ],[
d50bd9e2 723 AC_MSG_RESULT(yes)
724 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
725 [register_sysctl_table() wants 2 args])
57d86234 726 ],[
d50bd9e2 727 AC_MSG_RESULT(no)
57d86234 728 ])
729])
730
57d86234 731dnl #
3d061e9d 732dnl # 2.6.23 API change
57d86234 733dnl # Old set_shrinker API replaced with register_shrinker
734dnl #
735AC_DEFUN([SPL_AC_SET_SHRINKER], [
736 AC_MSG_CHECKING([whether set_shrinker() available])
737 SPL_LINUX_TRY_COMPILE([
738 #include <linux/mm.h>
739 ],[
740 return set_shrinker(DEFAULT_SEEKS, NULL);
741 ],[
742 AC_MSG_RESULT([yes])
743 AC_DEFINE(HAVE_SET_SHRINKER, 1,
744 [set_shrinker() available])
745 ],[
746 AC_MSG_RESULT([no])
747 ])
748])
749
750dnl #
3d061e9d 751dnl # 2.6.25 API change,
57d86234 752dnl # struct path entry added to struct nameidata
753dnl #
754AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
755 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
756 SPL_LINUX_TRY_COMPILE([
d50bd9e2 757 #include <linux/namei.h>
57d86234 758 ],[
d50bd9e2 759 struct nameidata nd;
57d86234 760
761 nd.path.mnt = NULL;
762 nd.path.dentry = NULL;
763 ],[
d50bd9e2 764 AC_MSG_RESULT(yes)
765 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
766 [struct path used in struct nameidata])
57d86234 767 ],[
d50bd9e2 768 AC_MSG_RESULT(no)
57d86234 769 ])
770])
771
772dnl #
773dnl # Custom SPL patch may export this system it is not required
774dnl #
775AC_DEFUN([SPL_AC_TASK_CURR], [
776 SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c],
777 [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])],
778 [])
779])
780
781dnl #
3d061e9d 782dnl # 2.6.19 API change,
57d86234 783dnl # Use CTL_UNNUMBERED when binary sysctl is not required
784dnl #
785AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
786 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
787 SPL_LINUX_TRY_COMPILE([
d50bd9e2 788 #include <linux/sysctl.h>
57d86234 789 ],[
790 #ifndef CTL_UNNUMBERED
791 #error CTL_UNNUMBERED undefined
792 #endif
793 ],[
d50bd9e2 794 AC_MSG_RESULT(yes)
795 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
796 [unnumbered sysctl support exists])
57d86234 797 ],[
d50bd9e2 798 AC_MSG_RESULT(no)
57d86234 799 ])
800])
877a32e9 801
79a3bf13
BB
802dnl #
803dnl # 2.6.33 API change,
804dnl # Removed .ctl_name from struct ctl_table.
805dnl #
806AC_DEFUN([SPL_AC_CTL_NAME], [
807 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
808 SPL_LINUX_TRY_COMPILE([
809 #include <linux/sysctl.h>
810 ],[
811 struct ctl_table ctl;
812 ctl.ctl_name = 0;
813 ],[
814 AC_MSG_RESULT(yes)
815 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
816 ],[
817 AC_MSG_RESULT(no)
818 ])
819])
820
877a32e9 821dnl #
822dnl # 2.6.16 API change.
823dnl # Check if 'fls64()' is available
824dnl #
825AC_DEFUN([SPL_AC_FLS64],
6a6cafbe 826 [AC_MSG_CHECKING([whether fls64() is available])
827 SPL_LINUX_TRY_COMPILE([
828 #include <linux/bitops.h>
829 ],[
830 return fls64(0);
831 ],[
832 AC_MSG_RESULT(yes)
833 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
834 ],[
835 AC_MSG_RESULT(no)
836 ])
877a32e9 837])
46c685d0 838
839dnl #
840dnl # 2.6.18 API change, check whether device_create() is available.
841dnl # Device_create() was introduced in 2.6.18 and depricated
842dnl # class_device_create() which was fully removed in 2.6.26.
843dnl #
844AC_DEFUN([SPL_AC_DEVICE_CREATE], [
845 SPL_CHECK_SYMBOL_EXPORT(
846 [device_create],
847 [drivers/base/core.c],
848 [AC_DEFINE(HAVE_DEVICE_CREATE, 1,
849 [device_create() is available])],
6a6cafbe 850 [])
46c685d0 851])
852
8123ac4f
BB
853dnl #
854dnl # 2.6.27 API change,
855dnl # device_create() uses 5 args, new 'drvdata' argument.
856dnl #
857AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
858 AC_MSG_CHECKING([whether device_create() wants 5 args])
859 tmp_flags="$EXTRA_KCFLAGS"
860 EXTRA_KCFLAGS="-Werror"
861 SPL_LINUX_TRY_COMPILE([
862 #include <linux/device.h>
863 ],[
864 device_create(NULL, NULL, 0, NULL, "%d", 1);
865 ],[
866 AC_MSG_RESULT(yes)
867 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
868 [device_create wants 5 args])
869 ],[
870 AC_MSG_RESULT(no)
871 ])
872 EXTRA_KCFLAGS="$tmp_flags"
873])
874
46c685d0 875dnl #
876dnl # 2.6.13 API change, check whether class_device_create() is available.
877dnl # Class_device_create() was introduced in 2.6.13 and depricated
878dnl # class_simple_device_add() which was fully removed in 2.6.13.
879dnl #
880AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [
881 SPL_CHECK_SYMBOL_EXPORT(
882 [class_device_create],
883 [drivers/base/class.c],
884 [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
885 [class_device_create() is available])],
6a6cafbe 886 [])
46c685d0 887])
6a6cafbe 888
6a6cafbe 889dnl #
890dnl # 2.6.26 API change, set_normalized_timespec() is exported.
891dnl #
892AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [
893 SPL_CHECK_SYMBOL_EXPORT(
894 [set_normalized_timespec],
895 [kernel/time.c],
896 [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
897 [set_normalized_timespec() is available as export])],
898 [])
899])
900
901dnl #
902dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
903dnl # previously it was available in time.h as an inline.
904dnl #
86de8532 905AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
906 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
6a6cafbe 907 SPL_LINUX_TRY_COMPILE([
908 #include <linux/time.h>
6a6cafbe 909 void set_normalized_timespec(struct timespec *ts,
25557fd8 910 time_t sec, long nsec) { }
911 ],
912 [],
913 [
6a6cafbe 914 AC_MSG_RESULT(no)
915 ],[
916 AC_MSG_RESULT(yes)
917 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
918 [set_normalized_timespec() is available as inline])
919 ])
920])
921
922dnl #
923dnl # 2.6.18 API change,
924dnl # timespec_sub() inline function available in linux/time.h
925dnl #
86de8532 926AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
927 AC_MSG_CHECKING([whether timespec_sub() is available])
6a6cafbe 928 SPL_LINUX_TRY_COMPILE([
929 #include <linux/time.h>
930 ],[
931 struct timespec a, b, c = { 0 };
932 c = timespec_sub(a, b);
933 ],[
934 AC_MSG_RESULT(yes)
935 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
936 ],[
937 AC_MSG_RESULT(no)
938 ])
939])
940
86de8532 941dnl #
3d061e9d 942dnl # 2.6.19 API change,
943dnl # check if init_utsname() is available in linux/utsname.h
944dnl #
945AC_DEFUN([SPL_AC_INIT_UTSNAME], [
946 AC_MSG_CHECKING([whether init_utsname() is available])
947 SPL_LINUX_TRY_COMPILE([
948 #include <linux/utsname.h>
949 ],[
950 struct new_utsname *a = init_utsname();
951 ],[
952 AC_MSG_RESULT(yes)
953 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
954 ],[
955 AC_MSG_RESULT(no)
956 ])
957])
958
959dnl #
960dnl # 2.6.26 API change,
961dnl # definition of struct fdtable relocated to linux/fdtable.h
86de8532 962dnl #
963AC_DEFUN([SPL_AC_FDTABLE_HEADER], [
964 SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], [])
965])
322640b7 966
967dnl #
3d061e9d 968dnl # 2.6.14 API change,
969dnl # check whether 'files_fdtable()' exists
970dnl #
971AC_DEFUN([SPL_AC_FILES_FDTABLE], [
972 AC_MSG_CHECKING([whether files_fdtable() is available])
973 SPL_LINUX_TRY_COMPILE([
974 #include <linux/sched.h>
975 #include <linux/file.h>
976 #ifdef HAVE_FDTABLE_HEADER
977 #include <linux/fdtable.h>
978 #endif
979 ],[
980 struct files_struct *files = current->files;
981 struct fdtable *fdt = files_fdtable(files);
982 ],[
983 AC_MSG_RESULT(yes)
984 AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available])
985 ],[
986 AC_MSG_RESULT(no)
987 ])
988])
989
990dnl #
991dnl # 2.6.18 API change,
992dnl # added linux/uaccess.h
322640b7 993dnl #
994AC_DEFUN([SPL_AC_UACCESS_HEADER], [
995 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
996])
3d061e9d 997
998dnl #
999dnl # 2.6.12 API change,
1000dnl # check whether 'kmalloc_node()' is available.
1001dnl #
1002AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1003 AC_MSG_CHECKING([whether kmalloc_node() is available])
1004 SPL_LINUX_TRY_COMPILE([
1005 #include <linux/slab.h>
1006 ],[
1007 void *a = kmalloc_node(1, GFP_KERNEL, 0);
1008 ],[
1009 AC_MSG_RESULT(yes)
1010 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1011 ],[
1012 AC_MSG_RESULT(no)
1013 ])
1014])
1015
1016dnl #
1017dnl # 2.6.9 API change,
1018dnl # check whether 'monotonic_clock()' is available it may
1019dnl # be available for some archs but not others.
1020dnl #
1021AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [
1022 SPL_CHECK_SYMBOL_EXPORT(
1023 [monotonic_clock],
1024 [],
1025 [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1026 [monotonic_clock() is available])],
1027 [])
1028])
1029
1030dnl #
1031dnl # 2.6.16 API change,
1032dnl # check whether 'struct inode' has i_mutex
1033dnl #
1034AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1035 AC_MSG_CHECKING([whether struct inode has i_mutex])
1036 SPL_LINUX_TRY_COMPILE([
1037 #include <linux/fs.h>
1038 #include <linux/mutex.h>
1039 ],[
1040 struct inode i;
1041 mutex_init(&i.i_mutex);
1042 ],[
1043 AC_MSG_RESULT(yes)
1044 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1045 ],[
1046 AC_MSG_RESULT(no)
1047 ])
1048])
b61a6e8b 1049
4d54fdee
BB
1050dnl #
1051dnl # 2.6.29 API change,
1052dnl # Adaptive mutexs introduced.
1053dnl #
1054AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1055 AC_MSG_CHECKING([whether struct mutex has owner])
1056 SPL_LINUX_TRY_COMPILE([
1057 #include <linux/mutex.h>
1058 ],[
1059 struct mutex mtx;
1060 mtx.owner = NULL;
1061 ],[
1062 AC_MSG_RESULT(yes)
1063 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1064 ],[
1065 AC_MSG_RESULT(no)
1066 ])
1067])
1068
6c9433c1
BB
1069dnl #
1070dnl # 2.6.18 API change,
1071dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1072dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1073dnl # if the mutex validator is disabled or otherwise unavailable.
1074dnl #
1075AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1076 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1077 SPL_LINUX_TRY_COMPILE([
1078 #include <linux/mutex.h>
1079 ],[
1080 struct mutex mutex;
1081 mutex_init(&mutex);
1082 mutex_lock_nested(&mutex, 0);
1083 ],[
1084 AC_MSG_RESULT(yes)
1085 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1086 [mutex_lock_nested() is available])
1087 ],[
1088 AC_MSG_RESULT(no)
1089 ])
1090])
1091
31a033ec
BB
1092dnl #
1093dnl # 2.6.27 API change,
1094dnl # on_each_cpu() uses 3 args, no 'retry' argument
1095dnl #
1096AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1097 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1098 SPL_LINUX_TRY_COMPILE([
1099 #include <linux/smp.h>
1100 ],[
1101 on_each_cpu(NULL, NULL, 0);
1102 ],[
1103 AC_MSG_RESULT(yes)
1104 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1105 [on_each_cpu wants 3 args])
1106 ],[
1107 AC_MSG_RESULT(no)
1108 ])
1109])
36b313da
BB
1110
1111dnl #
d1ff2312
BB
1112dnl # 2.6.18 API change,
1113dnl # kallsyms_lookup_name no longer exported
1114dnl #
1115AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [
1116 SPL_CHECK_SYMBOL_EXPORT(
1117 [kallsyms_lookup_name],
1118 [],
1119 [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1120 [kallsyms_lookup_name() is available])],
1121 [])
1122])
1123
1124dnl #
e11d6c5f
BB
1125dnl # Proposed API change,
1126dnl # This symbol is not available in stock kernels. You may build a
1127dnl # custom kernel with the *-spl-export-symbols.patch which will export
1128dnl # these symbols for use. If your already rolling a custom kernel for
1129dnl # your environment this is recommended.
d1ff2312
BB
1130dnl #
1131AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [
1132 SPL_CHECK_SYMBOL_EXPORT(
1133 [get_vmalloc_info],
1134 [],
1135 [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1136 [get_vmalloc_info() is available])],
1137 [])
1138])
1139
5232d256
BB
1140dnl #
1141dnl # 2.6.17 API change
1142dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1143dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1144dnl # were exported in 2.6.17 for use by modules which was consistent with
1145dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1146dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1147dnl # were dropped entirely leaving modules no way to directly iterate over
1148dnl # the zone list. Because we need access to the zone helpers we check
1149dnl # if the kernel contains the old or new implementation. Then we check
1150dnl # to see if the symbols we need for each version are available. If they
1151dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1152dnl #
1153AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1154 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1155 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1156 rc=$?
1157 if test $rc -eq 0; then
1158 AC_MSG_RESULT([yes])
1159 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1160 else
1161 AC_MSG_RESULT([no])
1162 fi
1163])
1164
d1ff2312 1165dnl #
e11d6c5f
BB
1166dnl # Proposed API change,
1167dnl # This symbol is not available in stock kernels. You may build a
1168dnl # custom kernel with the *-spl-export-symbols.patch which will export
1169dnl # these symbols for use. If your already rolling a custom kernel for
1170dnl # your environment this is recommended.
36b313da
BB
1171dnl #
1172AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [
1173 SPL_CHECK_SYMBOL_EXPORT(
1174 [first_online_pgdat],
1175 [],
1176 [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1177 [first_online_pgdat() is available])],
1178 [])
1179])
1180
1181dnl #
e11d6c5f
BB
1182dnl # Proposed API change,
1183dnl # This symbol is not available in stock kernels. You may build a
1184dnl # custom kernel with the *-spl-export-symbols.patch which will export
1185dnl # these symbols for use. If your already rolling a custom kernel for
1186dnl # your environment this is recommended.
36b313da
BB
1187dnl #
1188AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [
1189 SPL_CHECK_SYMBOL_EXPORT(
1190 [next_online_pgdat],
1191 [],
1192 [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1193 [next_online_pgdat() is available])],
1194 [])
1195])
1196
1197dnl #
e11d6c5f
BB
1198dnl # Proposed API change,
1199dnl # This symbol is not available in stock kernels. You may build a
1200dnl # custom kernel with the *-spl-export-symbols.patch which will export
1201dnl # these symbols for use. If your already rolling a custom kernel for
1202dnl # your environment this is recommended.
36b313da
BB
1203dnl #
1204AC_DEFUN([SPL_AC_NEXT_ZONE], [
1205 SPL_CHECK_SYMBOL_EXPORT(
1206 [next_zone],
1207 [],
1208 [AC_DEFINE(HAVE_NEXT_ZONE, 1,
1209 [next_zone() is available])],
1210 [])
1211])
4ab13d3b 1212
5232d256
BB
1213dnl #
1214dnl # 2.6.17 API change,
1215dnl # See SPL_AC_PGDAT_HELPERS for details.
1216dnl #
1217AC_DEFUN([SPL_AC_PGDAT_LIST], [
1218 SPL_CHECK_SYMBOL_EXPORT(
1219 [pgdat_list],
1220 [],
1221 [AC_DEFINE(HAVE_PGDAT_LIST, 1,
1222 [pgdat_list is available])],
1223 [])
1224])
1225
96dded38
BB
1226dnl #
1227dnl # 2.6.18 API change,
1228dnl # First introduced global_page_state() support as an inline.
1229dnl #
1230AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1231 AC_MSG_CHECKING([whether global_page_state() is available])
1232 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1233 #include <linux/mm.h>
96dded38
BB
1234 ],[
1235 unsigned long state;
6ae7fef5 1236 state = global_page_state(0);
96dded38
BB
1237 ],[
1238 AC_MSG_RESULT(yes)
1239 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1240 [global_page_state() is available])
1241 ],[
1242 AC_MSG_RESULT(no)
1243 ])
1244])
1245
e11d6c5f 1246dnl #
6ae7fef5
BB
1247dnl # 2.6.21 API change (plus subsequent naming convention changes),
1248dnl # Public global zone stats now include a free page count. However
1249dnl # the enumerated names of the counters have changed since this API
1250dnl # was introduced. We need to deduce the corrent name to use. This
1251dnl # replaces the priviate get_zone_counts() interface.
1252dnl #
1253dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1254dnl # is 2.6.30 as of when this was written.
e11d6c5f 1255dnl #
6ae7fef5
BB
1256AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1257 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
e11d6c5f 1258 SPL_LINUX_TRY_COMPILE([
6ae7fef5 1259 #include <linux/mm.h>
e11d6c5f 1260 ],[
6ae7fef5
BB
1261 enum zone_stat_item zsi;
1262 zsi = NR_FREE_PAGES;
e11d6c5f
BB
1263 ],[
1264 AC_MSG_RESULT(yes)
6ae7fef5
BB
1265 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1266 [Page state NR_FREE_PAGES is available])
e11d6c5f
BB
1267 ],[
1268 AC_MSG_RESULT(no)
1269 ])
1270])
a093c6a4 1271
6ae7fef5
BB
1272dnl #
1273dnl # 2.6.21 API change (plus subsequent naming convention changes),
1274dnl # Public global zone stats now include an inactive page count. However
1275dnl # the enumerated names of the counters have changed since this API
1276dnl # was introduced. We need to deduce the corrent name to use. This
1277dnl # replaces the priviate get_zone_counts() interface.
1278dnl #
1279dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1280dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1281dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1282dnl #
1283AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1284 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1285 SPL_LINUX_TRY_COMPILE([
1286 #include <linux/mm.h>
1287 ],[
1288 enum zone_stat_item zsi;
1289 zsi = NR_INACTIVE;
1290 ],[
1291 AC_MSG_RESULT(yes)
1292 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1293 [Page state NR_INACTIVE is available])
1294 ],[
1295 AC_MSG_RESULT(no)
1296 ])
1297
1298 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1299 SPL_LINUX_TRY_COMPILE([
1300 #include <linux/mm.h>
1301 ],[
1302 enum zone_stat_item zsi;
1303 zsi = NR_INACTIVE_ANON;
1304 ],[
1305 AC_MSG_RESULT(yes)
1306 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1307 [Page state NR_INACTIVE_ANON is available])
1308 ],[
1309 AC_MSG_RESULT(no)
1310 ])
1311
1312 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1313 SPL_LINUX_TRY_COMPILE([
1314 #include <linux/mm.h>
1315 ],[
1316 enum zone_stat_item zsi;
1317 zsi = NR_INACTIVE_FILE;
1318 ],[
1319 AC_MSG_RESULT(yes)
1320 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1321 [Page state NR_INACTIVE_FILE is available])
1322 ],[
1323 AC_MSG_RESULT(no)
1324 ])
1325])
1326
1327dnl #
1328dnl # 2.6.21 API change (plus subsequent naming convention changes),
1329dnl # Public global zone stats now include an active page count. However
1330dnl # the enumerated names of the counters have changed since this API
1331dnl # was introduced. We need to deduce the corrent name to use. This
1332dnl # replaces the priviate get_zone_counts() interface.
1333dnl #
1334dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1335dnl # anonymous and file active pages. As of 2.6.28 it was split in
1336dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1337dnl #
1338AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1339 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1340 SPL_LINUX_TRY_COMPILE([
1341 #include <linux/mm.h>
1342 ],[
1343 enum zone_stat_item zsi;
1344 zsi = NR_ACTIVE;
1345 ],[
1346 AC_MSG_RESULT(yes)
1347 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1348 [Page state NR_ACTIVE is available])
1349 ],[
1350 AC_MSG_RESULT(no)
1351 ])
1352
1353 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1354 SPL_LINUX_TRY_COMPILE([
1355 #include <linux/mm.h>
1356 ],[
1357 enum zone_stat_item zsi;
1358 zsi = NR_ACTIVE_ANON;
1359 ],[
1360 AC_MSG_RESULT(yes)
1361 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1362 [Page state NR_ACTIVE_ANON is available])
1363 ],[
1364 AC_MSG_RESULT(no)
1365 ])
1366
1367 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1368 SPL_LINUX_TRY_COMPILE([
1369 #include <linux/mm.h>
1370 ],[
1371 enum zone_stat_item zsi;
1372 zsi = NR_ACTIVE_FILE;
1373 ],[
1374 AC_MSG_RESULT(yes)
1375 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1376 [Page state NR_ACTIVE_FILE is available])
1377 ],[
1378 AC_MSG_RESULT(no)
1379 ])
1380])
1381
1382dnl #
1383dnl # Proposed API change for legacy kernels.
1384dnl # This symbol is not available in older kernels. For kernels post
1385dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1386dnl # page state information. This symbol is only used in legacy kernels
1387dnl # any only as a last resort.
1388dnl
1389AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1390 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1391 SPL_LINUX_TRY_COMPILE([
1392 ],[
1393 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1394 #error "global_page_state needs NR_FREE_PAGES"
1395 #endif
1396
1397 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1398 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1399 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1400 #error "global_page_state needs NR_ACTIVE*"
1401 #endif
1402
1403 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1404 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1405 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1406 #error "global_page_state needs NR_INACTIVE*"
1407 #endif
1408 ],[
1409 AC_MSG_RESULT(no)
1410 ],[
1411 AC_MSG_RESULT(yes)
1412 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1413 [get_zone_counts() is needed])
1414
1415 SPL_CHECK_SYMBOL_EXPORT(
1416 [get_zone_counts],
1417 [],
1418 [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1419 [get_zone_counts() is available])],
1420 [])
1421 ])
1422])
1423
7119bf70
BB
1424dnl #
1425dnl # 2.6.27 API change,
1426dnl # The user_path_dir() replaces __user_walk()
1427dnl #
1428AC_DEFUN([SPL_AC_USER_PATH_DIR], [
1429 SPL_CHECK_SYMBOL_EXPORT(
1430 [user_path_at],
1431 [],
1432 [AC_DEFINE(HAVE_USER_PATH_DIR, 1,
1433 [user_path_dir() is available])],
1434 [])
1435])
1436
51a727e9
BB
1437dnl #
1438dnl # Symbol available in RHEL kernels not in stock kernels.
1439dnl #
1440AC_DEFUN([SPL_AC_SET_FS_PWD], [
1441 SPL_CHECK_SYMBOL_EXPORT(
1442 [set_fs_pwd],
1443 [],
1444 [AC_DEFINE(HAVE_SET_FS_PWD, 1,
1445 [set_fs_pwd() is available])],
1446 [])
1447])
1448
1449dnl #
1450dnl # 2.6.25 API change,
1451dnl # Simplied API by replacing mnt+dentry args with a single path arg.
1452dnl #
1453AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
1454 [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
1455 SPL_LINUX_TRY_COMPILE([
1456 #include <linux/sched.h>
baf2979e 1457 #include <linux/fs_struct.h>
51a727e9
BB
1458 ],[
1459 set_fs_pwd(NULL, NULL);
1460 ],[
1461 AC_MSG_RESULT(yes)
1462 AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
1463 [set_fs_pwd() wants 2 args])
1464 ],[
1465 AC_MSG_RESULT(no)
1466 ])
1467])
1468
a093c6a4
BB
1469dnl #
1470dnl # SLES API change, never adopted in mainline,
1471dnl # Third 'struct vfsmount *' argument removed.
1472dnl #
1473AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1474 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1475 SPL_LINUX_TRY_COMPILE([
1476 #include <linux/fs.h>
1477 ],[
1478 vfs_unlink(NULL, NULL);
1479 ],[
1480 AC_MSG_RESULT(yes)
1481 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1482 [vfs_unlink() wants 2 args])
1483 ],[
1484 AC_MSG_RESULT(no)
1485 ])
1486])
1487
1488dnl #
1489dnl # SLES API change, never adopted in mainline,
1490dnl # Third and sixth 'struct vfsmount *' argument removed.
1491dnl #
1492AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1493 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1494 SPL_LINUX_TRY_COMPILE([
1495 #include <linux/fs.h>
1496 ],[
1497 vfs_rename(NULL, NULL, NULL, NULL);
1498 ],[
1499 AC_MSG_RESULT(yes)
1500 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1501 [vfs_rename() wants 4 args])
1502 ],[
1503 AC_MSG_RESULT(no)
1504 ])
1505])
ec7d53e9
BB
1506
1507dnl #
1508dnl # 2.6.29 API change,
1509dnl # check whether 'struct cred' exists
1510dnl #
1511AC_DEFUN([SPL_AC_CRED_STRUCT], [
1512 AC_MSG_CHECKING([whether struct cred exists])
1513 SPL_LINUX_TRY_COMPILE([
1514 #include <linux/cred.h>
1515 ],[
1516 struct cred *cr;
1517 cr = NULL;
1518 ],[
1519 AC_MSG_RESULT(yes)
1520 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1521 ],[
1522 AC_MSG_RESULT(no)
1523 ])
1524])
1525
1526dnl #
e811949a 1527dnl # Custom SPL patch may export this symbol.
ec7d53e9
BB
1528dnl #
1529AC_DEFUN([SPL_AC_GROUPS_SEARCH], [
1530 SPL_CHECK_SYMBOL_EXPORT(
1531 [groups_search],
1532 [],
1533 [AC_DEFINE(HAVE_GROUPS_SEARCH, 1,
1534 [groups_search() is available])],
1535 [])
1536])
e811949a
BB
1537
1538dnl #
1539dnl # 2.6.x API change,
1540dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
1541dnl #
1542AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [
1543 SPL_CHECK_SYMBOL_EXPORT(
1544 [__put_task_struct],
1545 [],
1546 [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
1547 [__put_task_struct() is available])],
1548 [])
1549])
3977f837
BB
1550
1551dnl #
1552dnl # 2.6.32 API change,
1553dnl # Unused 'struct file *' removed from prototype.
1554dnl #
1555AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
1556 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
1557 SPL_LINUX_TRY_COMPILE([
1558 #include <linux/sysctl.h>
1559 ],[
1560 proc_dostring(NULL, 0, NULL, NULL, NULL);
1561 ],[
1562 AC_MSG_RESULT(yes)
1563 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
1564 [proc_handler() wants 5 args])
1565 ],[
1566 AC_MSG_RESULT(no)
1567 ])
1568])
b868e22f
BB
1569
1570dnl #
1571dnl # 2.6.x API change,
1572dnl # kvasprintf() function added.
1573dnl #
1574AC_DEFUN([SPL_AC_KVASPRINTF], [
1575 SPL_CHECK_SYMBOL_EXPORT(
1576 [kvasprintf],
1577 [],
1578 [AC_DEFINE(HAVE_KVASPRINTF, 1,
1579 [kvasprintf() is available])],
1580 [])
1581])
f0ff89fc
BB
1582
1583dnl #
1584dnl # 2.6.35 API change,
1585dnl # Unused 'struct dentry *' removed from prototype.
1586dnl #
1587AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [
1588 AC_MSG_CHECKING([whether file_fsync() wants 3 args])
1589 SPL_LINUX_TRY_COMPILE([
1590 #include <linux/buffer_head.h>
1591 ],[
1592 file_fsync(NULL, NULL, 0);
1593 ],[
1594 AC_MSG_RESULT(yes)
1595 AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1,
1596 [file_fsync() wants 3 args])
1597 ],[
1598 AC_MSG_RESULT(no)
1599 ])
1600])