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