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