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