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