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