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