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