]>
Commit | Line | Data |
---|---|---|
716154c5 BB |
1 | ############################################################################### |
2 | # Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. | |
3 | # Copyright (C) 2007 The Regents of the University of California. | |
4 | # Written by Brian Behlendorf <behlendorf1@llnl.gov>. | |
5 | ############################################################################### | |
6 | # SPL_AC_CONFIG_KERNEL: Default SPL kernel configuration. | |
7 | ############################################################################### | |
8 | ||
86933a6e BB |
9 | AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ |
10 | SPL_AC_KERNEL | |
7731d46b | 11 | SPL_AC_KERNEL_CONFIG |
86933a6e | 12 | |
86933a6e BB |
13 | if test "${LINUX_OBJ}" != "${LINUX}"; then |
14 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" | |
15 | fi | |
86933a6e | 16 | AC_SUBST(KERNELMAKE_PARAMS) |
a7958f7e BB |
17 | |
18 | KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes" | |
86933a6e BB |
19 | AC_SUBST(KERNELCPPFLAGS) |
20 | ||
21 | SPL_AC_DEBUG | |
22 | SPL_AC_DEBUG_KMEM | |
055ffd98 | 23 | SPL_AC_DEBUG_KMEM_TRACKING |
5e9b5d83 | 24 | SPL_AC_ATOMIC_SPINLOCK |
302b88e6 BB |
25 | SPL_AC_TYPE_ATOMIC64_CMPXCHG |
26 | SPL_AC_TYPE_ATOMIC64_XCHG | |
d04c8a56 | 27 | SPL_AC_TYPE_UINTPTR_T |
86933a6e BB |
28 | SPL_AC_3ARGS_INIT_WORK |
29 | SPL_AC_2ARGS_REGISTER_SYSCTL | |
30 | SPL_AC_SET_SHRINKER | |
23aa63cb | 31 | SPL_AC_3ARGS_SHRINKER_CALLBACK |
86933a6e BB |
32 | SPL_AC_PATH_IN_NAMEIDATA |
33 | SPL_AC_TASK_CURR | |
34 | SPL_AC_CTL_UNNUMBERED | |
79a3bf13 | 35 | SPL_AC_CTL_NAME |
86933a6e BB |
36 | SPL_AC_FLS64 |
37 | SPL_AC_DEVICE_CREATE | |
38 | SPL_AC_5ARGS_DEVICE_CREATE | |
39 | SPL_AC_CLASS_DEVICE_CREATE | |
40 | SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT | |
41 | SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE | |
42 | SPL_AC_TIMESPEC_SUB | |
43 | SPL_AC_INIT_UTSNAME | |
44 | SPL_AC_FDTABLE_HEADER | |
45 | SPL_AC_FILES_FDTABLE | |
46 | SPL_AC_UACCESS_HEADER | |
47 | SPL_AC_KMALLOC_NODE | |
48 | SPL_AC_MONOTONIC_CLOCK | |
49 | SPL_AC_INODE_I_MUTEX | |
4d54fdee | 50 | SPL_AC_MUTEX_OWNER |
86933a6e | 51 | SPL_AC_MUTEX_LOCK_NESTED |
86933a6e BB |
52 | SPL_AC_3ARGS_ON_EACH_CPU |
53 | SPL_AC_KALLSYMS_LOOKUP_NAME | |
54 | SPL_AC_GET_VMALLOC_INFO | |
55 | SPL_AC_PGDAT_HELPERS | |
56 | SPL_AC_FIRST_ONLINE_PGDAT | |
57 | SPL_AC_NEXT_ONLINE_PGDAT | |
58 | SPL_AC_NEXT_ZONE | |
59 | SPL_AC_PGDAT_LIST | |
86933a6e | 60 | SPL_AC_GLOBAL_PAGE_STATE |
6ae7fef5 BB |
61 | SPL_AC_ZONE_STAT_ITEM_FREE |
62 | SPL_AC_ZONE_STAT_ITEM_INACTIVE | |
63 | SPL_AC_ZONE_STAT_ITEM_ACTIVE | |
64 | SPL_AC_GET_ZONE_COUNTS | |
7119bf70 | 65 | SPL_AC_USER_PATH_DIR |
51a727e9 BB |
66 | SPL_AC_SET_FS_PWD |
67 | SPL_AC_2ARGS_SET_FS_PWD | |
86933a6e BB |
68 | SPL_AC_2ARGS_VFS_UNLINK |
69 | SPL_AC_4ARGS_VFS_RENAME | |
9b2048c2 | 70 | SPL_AC_FS_STRUCT_SPINLOCK |
ec7d53e9 BB |
71 | SPL_AC_CRED_STRUCT |
72 | SPL_AC_GROUPS_SEARCH | |
e811949a | 73 | SPL_AC_PUT_TASK_STRUCT |
3977f837 | 74 | SPL_AC_5ARGS_PROC_HANDLER |
b868e22f | 75 | SPL_AC_KVASPRINTF |
f0ff89fc | 76 | SPL_AC_3ARGS_FILE_FSYNC |
46aa7b39 | 77 | SPL_AC_EXPORTED_RWSEM_IS_LOCKED |
914b0631 | 78 | SPL_AC_KERNEL_INVALIDATE_INODES |
9b0f9079 | 79 | SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES |
e76f4bf1 BB |
80 | SPL_AC_SHRINK_DCACHE_MEMORY |
81 | SPL_AC_SHRINK_ICACHE_MEMORY | |
b1cbc461 | 82 | SPL_AC_KERN_PATH_PARENT |
86933a6e BB |
83 | ]) |
84 | ||
85 | AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ | |
bb339d06 | 86 | modpost=$LINUX/scripts/Makefile.modpost |
86933a6e | 87 | AC_MSG_CHECKING([kernel file name for module symbols]) |
bb339d06 BB |
88 | if test -f "$modpost"; then |
89 | if grep -q Modules.symvers $modpost; then | |
90 | LINUX_SYMBOLS=Modules.symvers | |
91 | else | |
92 | LINUX_SYMBOLS=Module.symvers | |
93 | fi | |
912fd84d BB |
94 | |
95 | if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then | |
96 | AC_MSG_ERROR([ | |
97 | *** Please make sure the kernel devel package for your distribution | |
98 | *** is installed. If your building with a custom kernel make sure the | |
99 | *** kernel is configured, built, and the '--with-linux=PATH' configure | |
100 | *** option refers to the location of the kernel source.]) | |
101 | fi | |
86933a6e | 102 | else |
bb339d06 | 103 | LINUX_SYMBOLS=NONE |
86933a6e BB |
104 | fi |
105 | AC_MSG_RESULT($LINUX_SYMBOLS) | |
106 | AC_SUBST(LINUX_SYMBOLS) | |
107 | ]) | |
108 | ||
57d86234 | 109 | AC_DEFUN([SPL_AC_KERNEL], [ |
57d86234 | 110 | AC_ARG_WITH([linux], |
111 | AS_HELP_STRING([--with-linux=PATH], | |
112 | [Path to kernel source]), | |
39a3d2a4 | 113 | [kernelsrc="$withval"]) |
57d86234 | 114 | |
115 | AC_ARG_WITH([linux-obj], | |
116 | AS_HELP_STRING([--with-linux-obj=PATH], | |
117 | [Path to kernel build objects]), | |
118 | [kernelbuild="$withval"]) | |
119 | ||
120 | AC_MSG_CHECKING([kernel source directory]) | |
121 | if test -z "$kernelsrc"; then | |
22ccfaa8 BB |
122 | if test -e "/lib/modules/$(uname -r)/source"; then |
123 | headersdir="/lib/modules/$(uname -r)/source" | |
124 | sourcelink=$(readlink -f "$headersdir") | |
125 | elif test -e "/lib/modules/$(uname -r)/build"; then | |
126 | headersdir="/lib/modules/$(uname -r)/build" | |
534c4e38 BM |
127 | sourcelink=$(readlink -f "$headersdir") |
128 | else | |
129 | sourcelink=$(ls -1d /usr/src/kernels/* \ | |
130 | /usr/src/linux-* \ | |
131 | 2>/dev/null | grep -v obj | tail -1) | |
132 | fi | |
57d86234 | 133 | |
8fd4e3af | 134 | if test -n "$sourcelink" && test -e ${sourcelink}; then |
d4326403 | 135 | kernelsrc=`readlink -f ${sourcelink}` |
d4326403 | 136 | else |
57d86234 | 137 | AC_MSG_RESULT([Not found]) |
138 | AC_MSG_ERROR([ | |
8fd4e3af BB |
139 | *** Please make sure the kernel devel package for your distribution |
140 | *** is installed then try again. If that fails you can specify the | |
141 | *** location of the kernel source with the '--with-linux=PATH' option.]) | |
57d86234 | 142 | fi |
c5f70460 BB |
143 | else |
144 | if test "$kernelsrc" = "NONE"; then | |
145 | kernsrcver=NONE | |
146 | fi | |
57d86234 | 147 | fi |
148 | ||
149 | AC_MSG_RESULT([$kernelsrc]) | |
150 | AC_MSG_CHECKING([kernel build directory]) | |
39a3d2a4 | 151 | if test -z "$kernelbuild"; then |
22ccfaa8 BB |
152 | if test -e "/lib/modules/$(uname -r)/build"; then |
153 | kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` | |
154 | elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then | |
e2d28a37 BB |
155 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} |
156 | elif test -d ${kernelsrc}-obj/${target_cpu}/default; then | |
157 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default | |
158 | elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then | |
159 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} | |
39a3d2a4 BB |
160 | else |
161 | kernelbuild=${kernelsrc} | |
162 | fi | |
bf338d8d | 163 | fi |
57d86234 | 164 | AC_MSG_RESULT([$kernelbuild]) |
165 | ||
166 | AC_MSG_CHECKING([kernel source version]) | |
fd921c2e BB |
167 | utsrelease1=$kernelbuild/include/linux/version.h |
168 | utsrelease2=$kernelbuild/include/linux/utsrelease.h | |
169 | utsrelease3=$kernelbuild/include/generated/utsrelease.h | |
170 | if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then | |
171 | utsrelease=linux/version.h | |
172 | elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then | |
173 | utsrelease=linux/utsrelease.h | |
174 | elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then | |
175 | utsrelease=generated/utsrelease.h | |
176 | fi | |
57d86234 | 177 | |
fd921c2e BB |
178 | if test "$utsrelease"; then |
179 | kernsrcver=`(echo "#include <$utsrelease>"; | |
57d86234 | 180 | echo "kernsrcver=UTS_RELEASE") | |
d4326403 | 181 | cpp -I $kernelbuild/include | |
57d86234 | 182 | grep "^kernsrcver=" | cut -d \" -f 2` |
57d86234 | 183 | |
fd921c2e BB |
184 | if test -z "$kernsrcver"; then |
185 | AC_MSG_RESULT([Not found]) | |
186 | AC_MSG_ERROR([*** Cannot determine kernel version.]) | |
187 | fi | |
188 | else | |
57d86234 | 189 | AC_MSG_RESULT([Not found]) |
fd921c2e | 190 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) |
57d86234 | 191 | fi |
192 | ||
193 | AC_MSG_RESULT([$kernsrcver]) | |
194 | ||
57d86234 | 195 | LINUX=${kernelsrc} |
196 | LINUX_OBJ=${kernelbuild} | |
c5f70460 BB |
197 | LINUX_VERSION=${kernsrcver} |
198 | ||
57d86234 | 199 | AC_SUBST(LINUX) |
200 | AC_SUBST(LINUX_OBJ) | |
c5f70460 | 201 | AC_SUBST(LINUX_VERSION) |
57d86234 | 202 | |
86933a6e | 203 | SPL_AC_MODULE_SYMVERS |
2e0e7e69 BB |
204 | ]) |
205 | ||
7731d46b BB |
206 | AC_DEFUN([SPL_AC_KERNEL_CONFIG], [ |
207 | SPL_LINUX_CONFIG([PREEMPT], | |
208 | AC_MSG_ERROR([ | |
209 | *** Kernel built with CONFIG_PREEMPT which is not supported. | |
210 | ** You must rebuild your kernel without this option.]), []) | |
211 | ]) | |
212 | ||
86933a6e | 213 | dnl # |
287b2fb1 BB |
214 | dnl # Explicitly check for gawk, we require it for the the usermode |
215 | dnl # helper. For some reason the standard awk command does not | |
216 | dnl # behave correctly when invoked from the usermode helper. | |
86933a6e | 217 | dnl # |
287b2fb1 | 218 | AC_DEFUN([SPL_AC_GAWK], [ |
18142514 BB |
219 | AS_IF([test "x$AWK" != xgawk], [ |
220 | AC_MSG_ERROR([ | |
221 | *** Required util gawk missing. Please install the required | |
222 | *** gawk package for your distribution and try again.]) | |
223 | ]) | |
224 | ]) | |
86933a6e | 225 | |
287b2fb1 BB |
226 | dnl # |
227 | dnl # Default SPL user configuration | |
228 | dnl # | |
229 | AC_DEFUN([SPL_AC_CONFIG_USER], [ | |
230 | SPL_AC_GAWK | |
231 | ]) | |
232 | ||
233 | dnl # | |
234 | dnl # Check for rpm+rpmbuild to build RPM packages. If these tools | |
235 | dnl # are missing it is non-fatal but you will not be able to build | |
236 | dnl # RPM packages and will be warned if you try too. | |
237 | dnl # | |
238 | AC_DEFUN([SPL_AC_RPM], [ | |
239 | RPM=rpm | |
240 | RPMBUILD=rpmbuild | |
241 | ||
242 | AC_MSG_CHECKING([whether $RPM is available]) | |
243 | AS_IF([tmp=$($RPM --version 2>/dev/null)], [ | |
244 | RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
245 | HAVE_RPM=yes | |
246 | AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) | |
247 | ],[ | |
248 | HAVE_RPM=no | |
249 | AC_MSG_RESULT([$HAVE_RPM]) | |
250 | ]) | |
251 | ||
252 | AC_MSG_CHECKING([whether $RPMBUILD is available]) | |
253 | AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ | |
254 | RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
255 | HAVE_RPMBUILD=yes | |
256 | AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) | |
257 | ],[ | |
258 | HAVE_RPMBUILD=no | |
259 | AC_MSG_RESULT([$HAVE_RPMBUILD]) | |
260 | ]) | |
261 | ||
262 | AC_SUBST(HAVE_RPM) | |
263 | AC_SUBST(RPM) | |
264 | AC_SUBST(RPM_VERSION) | |
265 | ||
266 | AC_SUBST(HAVE_RPMBUILD) | |
267 | AC_SUBST(RPMBUILD) | |
268 | AC_SUBST(RPMBUILD_VERSION) | |
269 | ]) | |
270 | ||
271 | dnl # | |
272 | dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these | |
273 | dnl # tools are missing it is non-fatal but you will not be able to build | |
274 | dnl # DEB packages and will be warned if you try too. | |
275 | dnl # | |
276 | AC_DEFUN([SPL_AC_DPKG], [ | |
277 | DPKG=dpkg | |
278 | DPKGBUILD=dpkg-buildpackage | |
279 | ||
280 | AC_MSG_CHECKING([whether $DPKG is available]) | |
281 | AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ | |
282 | DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') | |
283 | HAVE_DPKG=yes | |
284 | AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) | |
285 | ],[ | |
286 | HAVE_DPKG=no | |
287 | AC_MSG_RESULT([$HAVE_DPKG]) | |
288 | ]) | |
289 | ||
290 | AC_MSG_CHECKING([whether $DPKGBUILD is available]) | |
291 | AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ | |
292 | DPKGBUILD_VERSION=$(echo $tmp | \ | |
293 | $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') | |
294 | HAVE_DPKGBUILD=yes | |
295 | AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) | |
296 | ],[ | |
297 | HAVE_DPKGBUILD=no | |
298 | AC_MSG_RESULT([$HAVE_DPKGBUILD]) | |
299 | ]) | |
300 | ||
301 | AC_SUBST(HAVE_DPKG) | |
302 | AC_SUBST(DPKG) | |
303 | AC_SUBST(DPKG_VERSION) | |
304 | ||
305 | AC_SUBST(HAVE_DPKGBUILD) | |
306 | AC_SUBST(DPKGBUILD) | |
307 | AC_SUBST(DPKGBUILD_VERSION) | |
308 | ]) | |
309 | ||
310 | dnl # | |
311 | dnl # Until native packaging for various different packing systems | |
312 | dnl # can be added the least we can do is attempt to use alien to | |
313 | dnl # convert the RPM packages to the needed package type. This is | |
314 | dnl # a hack but so far it has worked reasonable well. | |
315 | dnl # | |
316 | AC_DEFUN([SPL_AC_ALIEN], [ | |
317 | ALIEN=alien | |
318 | ||
319 | AC_MSG_CHECKING([whether $ALIEN is available]) | |
320 | AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [ | |
321 | ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }') | |
322 | HAVE_ALIEN=yes | |
323 | AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)]) | |
324 | ],[ | |
325 | HAVE_ALIEN=no | |
326 | AC_MSG_RESULT([$HAVE_ALIEN]) | |
327 | ]) | |
328 | ||
329 | AC_SUBST(HAVE_ALIEN) | |
330 | AC_SUBST(ALIEN) | |
331 | AC_SUBST(ALIEN_VERSION) | |
332 | ]) | |
333 | ||
334 | dnl # | |
335 | dnl # Using the VENDOR tag from config.guess set the default | |
336 | dnl # package type for 'make pkg': (rpm | deb | tgz) | |
337 | dnl # | |
338 | AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [ | |
73fc084e BB |
339 | AC_MSG_CHECKING([linux distribution]) |
340 | if test -f /etc/redhat-release ; then | |
341 | VENDOR=redhat ; | |
342 | elif test -f /etc/fedora-release ; then | |
343 | VENDOR=fedora ; | |
344 | elif test -f /etc/lsb-release ; then | |
345 | VENDOR=ubuntu ; | |
346 | elif test -f /etc/debian_version ; then | |
347 | VENDOR=debian ; | |
348 | elif test -f /etc/SuSE-release ; then | |
349 | VENDOR=sles ; | |
350 | elif test -f /etc/slackware-version ; then | |
351 | VENDOR=slackware ; | |
352 | elif test -f /etc/gentoo-release ; then | |
353 | VENDOR=gentoo ; | |
354 | else | |
355 | VENDOR= ; | |
356 | fi | |
357 | AC_MSG_RESULT([$VENDOR]) | |
358 | AC_SUBST(VENDOR) | |
287b2fb1 BB |
359 | |
360 | AC_MSG_CHECKING([default package type]) | |
361 | case "$VENDOR" in | |
362 | fedora) DEFAULT_PACKAGE=rpm ;; | |
363 | redhat) DEFAULT_PACKAGE=rpm ;; | |
364 | sles) DEFAULT_PACKAGE=rpm ;; | |
365 | ubuntu) DEFAULT_PACKAGE=deb ;; | |
366 | debian) DEFAULT_PACKAGE=deb ;; | |
367 | slackware) DEFAULT_PACKAGE=tgz ;; | |
368 | *) DEFAULT_PACKAGE=rpm ;; | |
369 | esac | |
370 | ||
371 | AC_MSG_RESULT([$DEFAULT_PACKAGE]) | |
372 | AC_SUBST(DEFAULT_PACKAGE) | |
373 | ]) | |
374 | ||
375 | dnl # | |
376 | dnl # Default SPL user configuration | |
377 | dnl # | |
378 | AC_DEFUN([SPL_AC_PACKAGE], [ | |
379 | SPL_AC_RPM | |
380 | SPL_AC_DPKG | |
381 | SPL_AC_ALIEN | |
382 | SPL_AC_DEFAULT_PACKAGE | |
383 | ]) | |
384 | ||
6a1c3d41 | 385 | AC_DEFUN([SPL_AC_LICENSE], [ |
86933a6e BB |
386 | AC_MSG_CHECKING([spl license]) |
387 | LICENSE=GPL | |
388 | AC_MSG_RESULT([$LICENSE]) | |
6a1c3d41 | 389 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS" |
86933a6e BB |
390 | AC_SUBST(LICENSE) |
391 | ]) | |
392 | ||
393 | AC_DEFUN([SPL_AC_CONFIG], [ | |
394 | SPL_CONFIG=all | |
395 | AC_ARG_WITH([config], | |
396 | AS_HELP_STRING([--with-config=CONFIG], | |
c1541dfe | 397 | [Config file 'kernel|user|all|srpm']), |
86933a6e BB |
398 | [SPL_CONFIG="$withval"]) |
399 | ||
400 | AC_MSG_CHECKING([spl config]) | |
401 | AC_MSG_RESULT([$SPL_CONFIG]); | |
402 | AC_SUBST(SPL_CONFIG) | |
403 | ||
404 | case "$SPL_CONFIG" in | |
405 | kernel) SPL_AC_CONFIG_KERNEL ;; | |
406 | user) SPL_AC_CONFIG_USER ;; | |
407 | all) SPL_AC_CONFIG_KERNEL | |
408 | SPL_AC_CONFIG_USER ;; | |
c1541dfe | 409 | srpm) ;; |
86933a6e BB |
410 | *) |
411 | AC_MSG_RESULT([Error!]) | |
412 | AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config, | |
c1541dfe | 413 | user kernel|user|all|srpm]) ;; |
86933a6e BB |
414 | esac |
415 | ||
416 | AM_CONDITIONAL([CONFIG_USER], | |
417 | [test "$SPL_CONFIG" = user] || | |
418 | [test "$SPL_CONFIG" = all]) | |
419 | AM_CONDITIONAL([CONFIG_KERNEL], | |
420 | [test "$SPL_CONFIG" = kernel] || | |
421 | [test "$SPL_CONFIG" = all]) | |
6a1c3d41 | 422 | ]) |
423 | ||
055ffd98 BB |
424 | dnl # |
425 | dnl # Enable if the SPL should be compiled with internal debugging enabled. | |
426 | dnl # By default this support is disabled. | |
427 | dnl # | |
57d86234 | 428 | AC_DEFUN([SPL_AC_DEBUG], [ |
c950d148 | 429 | AC_MSG_CHECKING([whether debugging is enabled]) |
055ffd98 BB |
430 | AC_ARG_ENABLE([debug], |
431 | [AS_HELP_STRING([--enable-debug], | |
432 | [Enable generic debug support @<:@default=no@:>@])], | |
433 | [], | |
434 | [enable_debug=no]) | |
435 | ||
436 | AS_IF([test "x$enable_debug" = xyes], | |
c950d148 | 437 | [ |
c950d148 BB |
438 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" |
439 | DEBUG_CFLAGS="-DDEBUG -Werror" | |
440 | ], | |
441 | [ | |
c950d148 BB |
442 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" |
443 | DEBUG_CFLAGS="-DNDEBUG" | |
444 | ]) | |
055ffd98 | 445 | |
c950d148 | 446 | AC_SUBST(DEBUG_CFLAGS) |
055ffd98 | 447 | AC_MSG_RESULT([$enable_debug]) |
57d86234 | 448 | ]) |
449 | ||
055ffd98 BB |
450 | dnl # |
451 | dnl # Enabled by default it provides a minimal level of memory tracking. | |
452 | dnl # A total count of bytes allocated is kept for each alloc and free. | |
453 | dnl # Then at module unload time a report to the console will be printed | |
454 | dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist | |
455 | dnl # and provide an easy way to inspect the kmem based slab. | |
456 | dnl # | |
57d86234 | 457 | AC_DEFUN([SPL_AC_DEBUG_KMEM], [ |
055ffd98 BB |
458 | AC_ARG_ENABLE([debug-kmem], |
459 | [AS_HELP_STRING([--enable-debug-kmem], | |
460 | [Enable basic kmem accounting @<:@default=yes@:>@])], | |
461 | [], | |
462 | [enable_debug_kmem=yes]) | |
57d86234 | 463 | |
055ffd98 BB |
464 | AS_IF([test "x$enable_debug_kmem" = xyes], |
465 | [AC_DEFINE([DEBUG_KMEM], [1], | |
466 | [Define to 1 to enable basic kmem accounting]) | |
467 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"]) | |
468 | ||
469 | AC_MSG_CHECKING([whether basic kmem accounting is enabled]) | |
470 | AC_MSG_RESULT([$enable_debug_kmem]) | |
57d86234 | 471 | ]) |
472 | ||
055ffd98 BB |
473 | dnl # |
474 | dnl # Disabled by default it provides detailed memory tracking. This | |
475 | dnl # feature also requires --enable-debug-kmem to be set. When enabled | |
476 | dnl # not only will total bytes be tracked but also the location of every | |
477 | dnl # alloc and free. When the SPL module is unloaded a list of all leaked | |
478 | dnl # addresses and where they were allocated will be dumped to the console. | |
479 | dnl # Enabling this feature has a significant impact on performance but it | |
480 | dnl # makes finding memory leaks pretty straight forward. | |
481 | dnl # | |
482 | AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ | |
483 | AC_ARG_ENABLE([debug-kmem-tracking], | |
484 | [AS_HELP_STRING([--enable-debug-kmem-tracking], | |
485 | [Enable detailed kmem tracking @<:@default=no@:>@])], | |
486 | [], | |
487 | [enable_debug_kmem_tracking=no]) | |
488 | ||
489 | AS_IF([test "x$enable_debug_kmem_tracking" = xyes], | |
490 | [AC_DEFINE([DEBUG_KMEM_TRACKING], [1], | |
491 | [Define to 1 to enable detailed kmem tracking]) | |
492 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"]) | |
493 | ||
494 | AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) | |
495 | AC_MSG_RESULT([$enable_debug_kmem_tracking]) | |
57d86234 | 496 | ]) |
497 | ||
498 | dnl # | |
499 | dnl # SPL_LINUX_CONFTEST | |
500 | dnl # | |
501 | AC_DEFUN([SPL_LINUX_CONFTEST], [ | |
dbe561d8 | 502 | cat confdefs.h - <<_ACEOF >conftest.c |
57d86234 | 503 | $1 |
504 | _ACEOF | |
505 | ]) | |
506 | ||
507 | dnl # | |
508 | dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY]) | |
509 | dnl # | |
510 | m4_define([SPL_LANG_PROGRAM], [ | |
511 | $1 | |
512 | int | |
513 | main (void) | |
514 | { | |
515 | dnl Do *not* indent the following line: there may be CPP directives. | |
516 | dnl Don't move the `;' right after for the same reason. | |
517 | $2 | |
518 | ; | |
519 | return 0; | |
520 | } | |
521 | ]) | |
522 | ||
523 | dnl # | |
524 | dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE | |
525 | dnl # | |
526 | AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [ | |
c5f70460 BB |
527 | m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])]) |
528 | rm -Rf build && mkdir -p build | |
529 | echo "obj-m := conftest.o" >build/Makefile | |
530 | AS_IF( | |
3d0cb2d3 | 531 | [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 |
532 | [$4], |
533 | [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] | |
534 | ) | |
535 | rm -Rf build | |
57d86234 | 536 | ]) |
537 | ||
538 | dnl # | |
539 | dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE | |
540 | dnl # | |
541 | AC_DEFUN([SPL_LINUX_TRY_COMPILE], | |
542 | [SPL_LINUX_COMPILE_IFELSE( | |
d50bd9e2 | 543 | [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])], |
544 | [modules], | |
545 | [test -s build/conftest.o], | |
546 | [$3], [$4]) | |
57d86234 | 547 | ]) |
548 | ||
549 | dnl # | |
550 | dnl # SPL_LINUX_CONFIG | |
551 | dnl # | |
552 | AC_DEFUN([SPL_LINUX_CONFIG], | |
553 | [AC_MSG_CHECKING([whether Linux was built with CONFIG_$1]) | |
554 | SPL_LINUX_TRY_COMPILE([ | |
555 | #ifndef AUTOCONF_INCLUDED | |
556 | #include <linux/config.h> | |
557 | #endif | |
558 | ],[ | |
559 | #ifndef CONFIG_$1 | |
560 | #error CONFIG_$1 not #defined | |
561 | #endif | |
562 | ],[ | |
563 | AC_MSG_RESULT([yes]) | |
564 | $2 | |
565 | ],[ | |
566 | AC_MSG_RESULT([no]) | |
567 | $3 | |
568 | ]) | |
569 | ]) | |
570 | ||
571 | dnl # | |
572 | dnl # SPL_CHECK_SYMBOL_EXPORT | |
573 | dnl # check symbol exported or not | |
574 | dnl # | |
575 | AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], | |
576 | [AC_MSG_CHECKING([whether symbol $1 is exported]) | |
2e0e7e69 BB |
577 | grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ |
578 | $LINUX_OBJ/Module*.symvers 2>/dev/null | |
57d86234 | 579 | rc=$? |
580 | if test $rc -ne 0; then | |
581 | export=0 | |
582 | for file in $2; do | |
2e0e7e69 BB |
583 | grep -q -E "EXPORT_SYMBOL.*($1)" \ |
584 | "$LINUX_OBJ/$file" 2>/dev/null | |
57d86234 | 585 | rc=$? |
586 | if test $rc -eq 0; then | |
587 | export=1 | |
588 | break; | |
589 | fi | |
590 | done | |
591 | if test $export -eq 0; then | |
592 | AC_MSG_RESULT([no]) | |
593 | $4 | |
594 | else | |
595 | AC_MSG_RESULT([yes]) | |
596 | $3 | |
597 | fi | |
598 | else | |
599 | AC_MSG_RESULT([yes]) | |
600 | $3 | |
601 | fi | |
602 | ]) | |
603 | ||
86de8532 | 604 | dnl # |
605 | dnl # SPL_CHECK_HEADER | |
606 | dnl # check whether header exists and define HAVE_$2_HEADER | |
607 | dnl # | |
608 | AC_DEFUN([SPL_CHECK_HEADER], | |
609 | [AC_MSG_CHECKING([whether header $1 exists]) | |
610 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 611 | #include <$1> |
86de8532 | 612 | ],[ |
613 | return 0; | |
614 | ],[ | |
615 | AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists]) | |
616 | AC_MSG_RESULT(yes) | |
617 | $3 | |
618 | ],[ | |
619 | AC_MSG_RESULT(no) | |
620 | $4 | |
621 | ]) | |
622 | ]) | |
6a6cafbe | 623 | |
57d86234 | 624 | dnl # |
d04c8a56 BB |
625 | dnl # Use the atomic implemenation based on global spinlocks. This |
626 | dnl # should only be needed by 32-bit kernels which do not provide | |
627 | dnl # the atomic64_* API. It may be optionally enabled as a fallback | |
628 | dnl # if problems are observed with the direct mapping to the native | |
629 | dnl # Linux atomic operations. You may not disable atomic spinlocks | |
630 | dnl # if you kernel does not an atomic64_* API. | |
57d86234 | 631 | dnl # |
d04c8a56 BB |
632 | AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ |
633 | AC_ARG_ENABLE([atomic-spinlocks], | |
634 | [AS_HELP_STRING([--enable-atomic-spinlocks], | |
635 | [Atomic types use spinlocks @<:@default=check@:>@])], | |
636 | [], | |
637 | [enable_atomic_spinlocks=check]) | |
57d86234 | 638 | |
a0f6da3d | 639 | SPL_LINUX_TRY_COMPILE([ |
640 | #include <asm/atomic.h> | |
641 | ],[ | |
03318641 | 642 | atomic64_t *ptr __attribute__ ((unused)); |
a0f6da3d | 643 | ],[ |
d04c8a56 | 644 | have_atomic64_t=yes |
a0f6da3d | 645 | AC_DEFINE(HAVE_ATOMIC64_T, 1, |
d04c8a56 | 646 | [kernel defines atomic64_t]) |
a0f6da3d | 647 | ],[ |
d04c8a56 BB |
648 | have_atomic64_t=no |
649 | ]) | |
650 | ||
651 | AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [ | |
652 | AS_IF([test "x$have_atomic64_t" = xyes], [ | |
653 | enable_atomic_spinlocks=no | |
654 | ],[ | |
655 | enable_atomic_spinlocks=yes | |
656 | ]) | |
a0f6da3d | 657 | ]) |
d04c8a56 BB |
658 | |
659 | AS_IF([test "x$enable_atomic_spinlocks" = xyes], [ | |
660 | AC_DEFINE([ATOMIC_SPINLOCK], [1], | |
661 | [Atomic types use spinlocks]) | |
662 | ],[ | |
663 | AS_IF([test "x$have_atomic64_t" = xno], [ | |
664 | AC_MSG_FAILURE( | |
665 | [--disable-atomic-spinlocks given but required atomic64 support is unavailable]) | |
666 | ]) | |
667 | ]) | |
668 | ||
669 | AC_MSG_CHECKING([whether atomic types use spinlocks]) | |
670 | AC_MSG_RESULT([$enable_atomic_spinlocks]) | |
671 | ||
672 | AC_MSG_CHECKING([whether kernel defines atomic64_t]) | |
673 | AC_MSG_RESULT([$have_atomic64_t]) | |
a0f6da3d | 674 | ]) |
675 | ||
302b88e6 BB |
676 | dnl # |
677 | dnl # 2.6.24 API change, | |
678 | dnl # check if atomic64_cmpxchg is defined | |
679 | dnl # | |
680 | AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG], | |
681 | [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg]) | |
682 | SPL_LINUX_TRY_COMPILE([ | |
683 | #include <asm/atomic.h> | |
5ec44a37 | 684 | #include <asm/system.h> |
302b88e6 BB |
685 | ],[ |
686 | atomic64_cmpxchg((atomic64_t *)NULL, 0, 0); | |
687 | ],[ | |
688 | AC_MSG_RESULT([yes]) | |
689 | AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1, | |
690 | [kernel defines atomic64_cmpxchg]) | |
691 | ],[ | |
692 | AC_MSG_RESULT([no]) | |
693 | ]) | |
694 | ]) | |
695 | ||
696 | dnl # | |
697 | dnl # 2.6.24 API change, | |
698 | dnl # check if atomic64_xchg is defined | |
699 | dnl # | |
700 | AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG], | |
701 | [AC_MSG_CHECKING([whether kernel defines atomic64_xchg]) | |
702 | SPL_LINUX_TRY_COMPILE([ | |
703 | #include <asm/atomic.h> | |
704 | ],[ | |
705 | atomic64_xchg((atomic64_t *)NULL, 0); | |
706 | ],[ | |
707 | AC_MSG_RESULT([yes]) | |
708 | AC_DEFINE(HAVE_ATOMIC64_XCHG, 1, | |
709 | [kernel defines atomic64_xchg]) | |
710 | ],[ | |
711 | AC_MSG_RESULT([no]) | |
712 | ]) | |
713 | ]) | |
714 | ||
d04c8a56 BB |
715 | dnl # |
716 | dnl # 2.6.24 API change, | |
717 | dnl # check if uintptr_t typedef is defined | |
718 | dnl # | |
719 | AC_DEFUN([SPL_AC_TYPE_UINTPTR_T], | |
720 | [AC_MSG_CHECKING([whether kernel defines uintptr_t]) | |
721 | SPL_LINUX_TRY_COMPILE([ | |
722 | #include <linux/types.h> | |
723 | ],[ | |
03318641 | 724 | uintptr_t *ptr __attribute__ ((unused)); |
d04c8a56 BB |
725 | ],[ |
726 | AC_MSG_RESULT([yes]) | |
727 | AC_DEFINE(HAVE_UINTPTR_T, 1, | |
728 | [kernel defines uintptr_t]) | |
729 | ],[ | |
730 | AC_MSG_RESULT([no]) | |
731 | ]) | |
732 | ]) | |
733 | ||
57d86234 | 734 | dnl # |
3d061e9d | 735 | dnl # 2.6.20 API change, |
57d86234 | 736 | dnl # INIT_WORK use 2 args and not store data inside |
737 | dnl # | |
738 | AC_DEFUN([SPL_AC_3ARGS_INIT_WORK], | |
739 | [AC_MSG_CHECKING([whether INIT_WORK wants 3 args]) | |
740 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 741 | #include <linux/workqueue.h> |
57d86234 | 742 | ],[ |
03318641 | 743 | struct work_struct work __attribute__ ((unused)); |
d50bd9e2 | 744 | INIT_WORK(&work, NULL, NULL); |
57d86234 | 745 | ],[ |
d50bd9e2 | 746 | AC_MSG_RESULT(yes) |
747 | AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1, | |
748 | [INIT_WORK wants 3 args]) | |
57d86234 | 749 | ],[ |
d50bd9e2 | 750 | AC_MSG_RESULT(no) |
57d86234 | 751 | ]) |
752 | ]) | |
753 | ||
754 | dnl # | |
3d061e9d | 755 | dnl # 2.6.21 API change, |
57d86234 | 756 | dnl # 'register_sysctl_table' use only one argument instead of two |
757 | dnl # | |
758 | AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL], | |
759 | [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args]) | |
760 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 761 | #include <linux/sysctl.h> |
57d86234 | 762 | ],[ |
03318641 | 763 | (void) register_sysctl_table(NULL, 0); |
57d86234 | 764 | ],[ |
d50bd9e2 | 765 | AC_MSG_RESULT(yes) |
766 | AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1, | |
767 | [register_sysctl_table() wants 2 args]) | |
57d86234 | 768 | ],[ |
d50bd9e2 | 769 | AC_MSG_RESULT(no) |
57d86234 | 770 | ]) |
771 | ]) | |
772 | ||
57d86234 | 773 | dnl # |
3d061e9d | 774 | dnl # 2.6.23 API change |
57d86234 | 775 | dnl # Old set_shrinker API replaced with register_shrinker |
776 | dnl # | |
777 | AC_DEFUN([SPL_AC_SET_SHRINKER], [ | |
778 | AC_MSG_CHECKING([whether set_shrinker() available]) | |
779 | SPL_LINUX_TRY_COMPILE([ | |
780 | #include <linux/mm.h> | |
781 | ],[ | |
782 | return set_shrinker(DEFAULT_SEEKS, NULL); | |
783 | ],[ | |
784 | AC_MSG_RESULT([yes]) | |
785 | AC_DEFINE(HAVE_SET_SHRINKER, 1, | |
786 | [set_shrinker() available]) | |
787 | ],[ | |
788 | AC_MSG_RESULT([no]) | |
789 | ]) | |
790 | ]) | |
791 | ||
23aa63cb BB |
792 | dnl # |
793 | dnl # 2.6.35 API change, | |
794 | dnl # Add context to shrinker callback | |
795 | dnl # | |
796 | AC_DEFUN([SPL_AC_3ARGS_SHRINKER_CALLBACK], | |
797 | [AC_MSG_CHECKING([whether shrinker callback wants 3 args]) | |
798 | tmp_flags="$EXTRA_KCFLAGS" | |
799 | EXTRA_KCFLAGS="-Werror" | |
800 | SPL_LINUX_TRY_COMPILE([ | |
801 | #include <linux/mm.h> | |
802 | ||
803 | int shrinker_cb(struct shrinker *, int, unsigned int); | |
804 | ],[ | |
805 | struct shrinker cache_shrinker = { | |
806 | .shrink = shrinker_cb, | |
807 | .seeks = DEFAULT_SEEKS, | |
808 | }; | |
809 | register_shrinker(&cache_shrinker); | |
810 | ],[ | |
811 | AC_MSG_RESULT(yes) | |
812 | AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, | |
813 | [shrinker callback wants 3 args]) | |
814 | ],[ | |
815 | AC_MSG_RESULT(no) | |
816 | ]) | |
817 | EXTRA_KCFLAGS="$tmp_flags" | |
818 | ]) | |
819 | ||
57d86234 | 820 | dnl # |
3d061e9d | 821 | dnl # 2.6.25 API change, |
57d86234 | 822 | dnl # struct path entry added to struct nameidata |
823 | dnl # | |
824 | AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA], | |
825 | [AC_MSG_CHECKING([whether struct path used in struct nameidata]) | |
826 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 827 | #include <linux/namei.h> |
57d86234 | 828 | ],[ |
03318641 | 829 | struct nameidata nd __attribute__ ((unused)); |
57d86234 | 830 | |
831 | nd.path.mnt = NULL; | |
832 | nd.path.dentry = NULL; | |
833 | ],[ | |
d50bd9e2 | 834 | AC_MSG_RESULT(yes) |
835 | AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1, | |
836 | [struct path used in struct nameidata]) | |
57d86234 | 837 | ],[ |
d50bd9e2 | 838 | AC_MSG_RESULT(no) |
57d86234 | 839 | ]) |
840 | ]) | |
841 | ||
842 | dnl # | |
843 | dnl # Custom SPL patch may export this system it is not required | |
844 | dnl # | |
845 | AC_DEFUN([SPL_AC_TASK_CURR], [ | |
846 | SPL_CHECK_SYMBOL_EXPORT([task_curr], [kernel/sched.c], | |
847 | [AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() exported])], | |
848 | []) | |
849 | ]) | |
850 | ||
851 | dnl # | |
3d061e9d | 852 | dnl # 2.6.19 API change, |
57d86234 | 853 | dnl # Use CTL_UNNUMBERED when binary sysctl is not required |
854 | dnl # | |
855 | AC_DEFUN([SPL_AC_CTL_UNNUMBERED], | |
856 | [AC_MSG_CHECKING([whether unnumbered sysctl support exists]) | |
857 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 858 | #include <linux/sysctl.h> |
57d86234 | 859 | ],[ |
860 | #ifndef CTL_UNNUMBERED | |
861 | #error CTL_UNNUMBERED undefined | |
862 | #endif | |
863 | ],[ | |
d50bd9e2 | 864 | AC_MSG_RESULT(yes) |
865 | AC_DEFINE(HAVE_CTL_UNNUMBERED, 1, | |
866 | [unnumbered sysctl support exists]) | |
57d86234 | 867 | ],[ |
d50bd9e2 | 868 | AC_MSG_RESULT(no) |
57d86234 | 869 | ]) |
870 | ]) | |
877a32e9 | 871 | |
79a3bf13 BB |
872 | dnl # |
873 | dnl # 2.6.33 API change, | |
874 | dnl # Removed .ctl_name from struct ctl_table. | |
875 | dnl # | |
876 | AC_DEFUN([SPL_AC_CTL_NAME], [ | |
877 | AC_MSG_CHECKING([whether struct ctl_table has ctl_name]) | |
878 | SPL_LINUX_TRY_COMPILE([ | |
879 | #include <linux/sysctl.h> | |
880 | ],[ | |
03318641 | 881 | struct ctl_table ctl __attribute__ ((unused)); |
79a3bf13 BB |
882 | ctl.ctl_name = 0; |
883 | ],[ | |
884 | AC_MSG_RESULT(yes) | |
885 | AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name]) | |
886 | ],[ | |
887 | AC_MSG_RESULT(no) | |
888 | ]) | |
889 | ]) | |
890 | ||
877a32e9 | 891 | dnl # |
892 | dnl # 2.6.16 API change. | |
893 | dnl # Check if 'fls64()' is available | |
894 | dnl # | |
895 | AC_DEFUN([SPL_AC_FLS64], | |
6a6cafbe | 896 | [AC_MSG_CHECKING([whether fls64() is available]) |
897 | SPL_LINUX_TRY_COMPILE([ | |
898 | #include <linux/bitops.h> | |
899 | ],[ | |
900 | return fls64(0); | |
901 | ],[ | |
902 | AC_MSG_RESULT(yes) | |
903 | AC_DEFINE(HAVE_FLS64, 1, [fls64() is available]) | |
904 | ],[ | |
905 | AC_MSG_RESULT(no) | |
906 | ]) | |
877a32e9 | 907 | ]) |
46c685d0 | 908 | |
909 | dnl # | |
910 | dnl # 2.6.18 API change, check whether device_create() is available. | |
911 | dnl # Device_create() was introduced in 2.6.18 and depricated | |
912 | dnl # class_device_create() which was fully removed in 2.6.26. | |
913 | dnl # | |
914 | AC_DEFUN([SPL_AC_DEVICE_CREATE], [ | |
915 | SPL_CHECK_SYMBOL_EXPORT( | |
916 | [device_create], | |
917 | [drivers/base/core.c], | |
918 | [AC_DEFINE(HAVE_DEVICE_CREATE, 1, | |
919 | [device_create() is available])], | |
6a6cafbe | 920 | []) |
46c685d0 | 921 | ]) |
922 | ||
8123ac4f BB |
923 | dnl # |
924 | dnl # 2.6.27 API change, | |
925 | dnl # device_create() uses 5 args, new 'drvdata' argument. | |
926 | dnl # | |
927 | AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [ | |
928 | AC_MSG_CHECKING([whether device_create() wants 5 args]) | |
929 | tmp_flags="$EXTRA_KCFLAGS" | |
930 | EXTRA_KCFLAGS="-Werror" | |
931 | SPL_LINUX_TRY_COMPILE([ | |
932 | #include <linux/device.h> | |
933 | ],[ | |
934 | device_create(NULL, NULL, 0, NULL, "%d", 1); | |
935 | ],[ | |
936 | AC_MSG_RESULT(yes) | |
937 | AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1, | |
938 | [device_create wants 5 args]) | |
939 | ],[ | |
940 | AC_MSG_RESULT(no) | |
941 | ]) | |
942 | EXTRA_KCFLAGS="$tmp_flags" | |
943 | ]) | |
944 | ||
46c685d0 | 945 | dnl # |
946 | dnl # 2.6.13 API change, check whether class_device_create() is available. | |
947 | dnl # Class_device_create() was introduced in 2.6.13 and depricated | |
948 | dnl # class_simple_device_add() which was fully removed in 2.6.13. | |
949 | dnl # | |
950 | AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], [ | |
951 | SPL_CHECK_SYMBOL_EXPORT( | |
952 | [class_device_create], | |
953 | [drivers/base/class.c], | |
954 | [AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1, | |
955 | [class_device_create() is available])], | |
6a6cafbe | 956 | []) |
46c685d0 | 957 | ]) |
6a6cafbe | 958 | |
6a6cafbe | 959 | dnl # |
960 | dnl # 2.6.26 API change, set_normalized_timespec() is exported. | |
961 | dnl # | |
962 | AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], [ | |
963 | SPL_CHECK_SYMBOL_EXPORT( | |
964 | [set_normalized_timespec], | |
965 | [kernel/time.c], | |
966 | [AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1, | |
967 | [set_normalized_timespec() is available as export])], | |
968 | []) | |
969 | ]) | |
970 | ||
971 | dnl # | |
972 | dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c | |
973 | dnl # previously it was available in time.h as an inline. | |
974 | dnl # | |
86de8532 | 975 | AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [ |
976 | AC_MSG_CHECKING([whether set_normalized_timespec() is an inline]) | |
6a6cafbe | 977 | SPL_LINUX_TRY_COMPILE([ |
978 | #include <linux/time.h> | |
6a6cafbe | 979 | void set_normalized_timespec(struct timespec *ts, |
25557fd8 | 980 | time_t sec, long nsec) { } |
981 | ], | |
982 | [], | |
983 | [ | |
6a6cafbe | 984 | AC_MSG_RESULT(no) |
985 | ],[ | |
986 | AC_MSG_RESULT(yes) | |
987 | AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1, | |
988 | [set_normalized_timespec() is available as inline]) | |
989 | ]) | |
990 | ]) | |
991 | ||
992 | dnl # | |
993 | dnl # 2.6.18 API change, | |
994 | dnl # timespec_sub() inline function available in linux/time.h | |
995 | dnl # | |
86de8532 | 996 | AC_DEFUN([SPL_AC_TIMESPEC_SUB], [ |
997 | AC_MSG_CHECKING([whether timespec_sub() is available]) | |
6a6cafbe | 998 | SPL_LINUX_TRY_COMPILE([ |
999 | #include <linux/time.h> | |
1000 | ],[ | |
03318641 BB |
1001 | struct timespec a = { 0 }; |
1002 | struct timespec b = { 0 }; | |
1003 | struct timespec c __attribute__ ((unused)); | |
6a6cafbe | 1004 | c = timespec_sub(a, b); |
1005 | ],[ | |
1006 | AC_MSG_RESULT(yes) | |
1007 | AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available]) | |
1008 | ],[ | |
1009 | AC_MSG_RESULT(no) | |
1010 | ]) | |
1011 | ]) | |
1012 | ||
86de8532 | 1013 | dnl # |
3d061e9d | 1014 | dnl # 2.6.19 API change, |
1015 | dnl # check if init_utsname() is available in linux/utsname.h | |
1016 | dnl # | |
1017 | AC_DEFUN([SPL_AC_INIT_UTSNAME], [ | |
1018 | AC_MSG_CHECKING([whether init_utsname() is available]) | |
1019 | SPL_LINUX_TRY_COMPILE([ | |
1020 | #include <linux/utsname.h> | |
1021 | ],[ | |
03318641 BB |
1022 | struct new_utsname *a __attribute__ ((unused)); |
1023 | a = init_utsname(); | |
3d061e9d | 1024 | ],[ |
1025 | AC_MSG_RESULT(yes) | |
1026 | AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available]) | |
1027 | ],[ | |
1028 | AC_MSG_RESULT(no) | |
1029 | ]) | |
1030 | ]) | |
1031 | ||
1032 | dnl # | |
1033 | dnl # 2.6.26 API change, | |
1034 | dnl # definition of struct fdtable relocated to linux/fdtable.h | |
86de8532 | 1035 | dnl # |
1036 | AC_DEFUN([SPL_AC_FDTABLE_HEADER], [ | |
1037 | SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], []) | |
1038 | ]) | |
322640b7 | 1039 | |
1040 | dnl # | |
3d061e9d | 1041 | dnl # 2.6.14 API change, |
1042 | dnl # check whether 'files_fdtable()' exists | |
1043 | dnl # | |
1044 | AC_DEFUN([SPL_AC_FILES_FDTABLE], [ | |
1045 | AC_MSG_CHECKING([whether files_fdtable() is available]) | |
1046 | SPL_LINUX_TRY_COMPILE([ | |
1047 | #include <linux/sched.h> | |
1048 | #include <linux/file.h> | |
1049 | #ifdef HAVE_FDTABLE_HEADER | |
1050 | #include <linux/fdtable.h> | |
1051 | #endif | |
1052 | ],[ | |
1053 | struct files_struct *files = current->files; | |
03318641 BB |
1054 | struct fdtable *fdt __attribute__ ((unused)); |
1055 | fdt = files_fdtable(files); | |
3d061e9d | 1056 | ],[ |
1057 | AC_MSG_RESULT(yes) | |
1058 | AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available]) | |
1059 | ],[ | |
1060 | AC_MSG_RESULT(no) | |
1061 | ]) | |
1062 | ]) | |
1063 | ||
1064 | dnl # | |
1065 | dnl # 2.6.18 API change, | |
1066 | dnl # added linux/uaccess.h | |
322640b7 | 1067 | dnl # |
1068 | AC_DEFUN([SPL_AC_UACCESS_HEADER], [ | |
1069 | SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], []) | |
1070 | ]) | |
3d061e9d | 1071 | |
1072 | dnl # | |
1073 | dnl # 2.6.12 API change, | |
1074 | dnl # check whether 'kmalloc_node()' is available. | |
1075 | dnl # | |
1076 | AC_DEFUN([SPL_AC_KMALLOC_NODE], [ | |
1077 | AC_MSG_CHECKING([whether kmalloc_node() is available]) | |
1078 | SPL_LINUX_TRY_COMPILE([ | |
1079 | #include <linux/slab.h> | |
1080 | ],[ | |
03318641 BB |
1081 | void *a __attribute__ ((unused)); |
1082 | a = kmalloc_node(1, GFP_KERNEL, 0); | |
3d061e9d | 1083 | ],[ |
1084 | AC_MSG_RESULT(yes) | |
1085 | AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available]) | |
1086 | ],[ | |
1087 | AC_MSG_RESULT(no) | |
1088 | ]) | |
1089 | ]) | |
1090 | ||
1091 | dnl # | |
1092 | dnl # 2.6.9 API change, | |
1093 | dnl # check whether 'monotonic_clock()' is available it may | |
1094 | dnl # be available for some archs but not others. | |
1095 | dnl # | |
1096 | AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], [ | |
1097 | SPL_CHECK_SYMBOL_EXPORT( | |
1098 | [monotonic_clock], | |
1099 | [], | |
1100 | [AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, | |
1101 | [monotonic_clock() is available])], | |
1102 | []) | |
1103 | ]) | |
1104 | ||
1105 | dnl # | |
1106 | dnl # 2.6.16 API change, | |
1107 | dnl # check whether 'struct inode' has i_mutex | |
1108 | dnl # | |
1109 | AC_DEFUN([SPL_AC_INODE_I_MUTEX], [ | |
1110 | AC_MSG_CHECKING([whether struct inode has i_mutex]) | |
1111 | SPL_LINUX_TRY_COMPILE([ | |
1112 | #include <linux/fs.h> | |
1113 | #include <linux/mutex.h> | |
1114 | ],[ | |
1115 | struct inode i; | |
1116 | mutex_init(&i.i_mutex); | |
1117 | ],[ | |
1118 | AC_MSG_RESULT(yes) | |
1119 | AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex]) | |
1120 | ],[ | |
1121 | AC_MSG_RESULT(no) | |
1122 | ]) | |
1123 | ]) | |
b61a6e8b | 1124 | |
4d54fdee BB |
1125 | dnl # |
1126 | dnl # 2.6.29 API change, | |
1127 | dnl # Adaptive mutexs introduced. | |
1128 | dnl # | |
1129 | AC_DEFUN([SPL_AC_MUTEX_OWNER], [ | |
1130 | AC_MSG_CHECKING([whether struct mutex has owner]) | |
1131 | SPL_LINUX_TRY_COMPILE([ | |
1132 | #include <linux/mutex.h> | |
1133 | ],[ | |
03318641 | 1134 | struct mutex mtx __attribute__ ((unused)); |
4d54fdee BB |
1135 | mtx.owner = NULL; |
1136 | ],[ | |
1137 | AC_MSG_RESULT(yes) | |
1138 | AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner]) | |
1139 | ],[ | |
1140 | AC_MSG_RESULT(no) | |
1141 | ]) | |
1142 | ]) | |
1143 | ||
6c9433c1 BB |
1144 | dnl # |
1145 | dnl # 2.6.18 API change, | |
1146 | dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h, | |
1147 | dnl # as part of the mutex validator. Fallback to using 'mutex_lock()' | |
1148 | dnl # if the mutex validator is disabled or otherwise unavailable. | |
1149 | dnl # | |
1150 | AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [ | |
1151 | AC_MSG_CHECKING([whether mutex_lock_nested() is available]) | |
1152 | SPL_LINUX_TRY_COMPILE([ | |
1153 | #include <linux/mutex.h> | |
1154 | ],[ | |
1155 | struct mutex mutex; | |
1156 | mutex_init(&mutex); | |
1157 | mutex_lock_nested(&mutex, 0); | |
1158 | ],[ | |
1159 | AC_MSG_RESULT(yes) | |
1160 | AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1, | |
1161 | [mutex_lock_nested() is available]) | |
1162 | ],[ | |
1163 | AC_MSG_RESULT(no) | |
1164 | ]) | |
1165 | ]) | |
1166 | ||
31a033ec BB |
1167 | dnl # |
1168 | dnl # 2.6.27 API change, | |
1169 | dnl # on_each_cpu() uses 3 args, no 'retry' argument | |
1170 | dnl # | |
1171 | AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [ | |
1172 | AC_MSG_CHECKING([whether on_each_cpu() wants 3 args]) | |
1173 | SPL_LINUX_TRY_COMPILE([ | |
1174 | #include <linux/smp.h> | |
1175 | ],[ | |
1176 | on_each_cpu(NULL, NULL, 0); | |
1177 | ],[ | |
1178 | AC_MSG_RESULT(yes) | |
1179 | AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1, | |
1180 | [on_each_cpu wants 3 args]) | |
1181 | ],[ | |
1182 | AC_MSG_RESULT(no) | |
1183 | ]) | |
1184 | ]) | |
36b313da BB |
1185 | |
1186 | dnl # | |
d1ff2312 BB |
1187 | dnl # 2.6.18 API change, |
1188 | dnl # kallsyms_lookup_name no longer exported | |
1189 | dnl # | |
1190 | AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], [ | |
1191 | SPL_CHECK_SYMBOL_EXPORT( | |
1192 | [kallsyms_lookup_name], | |
1193 | [], | |
1194 | [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1, | |
1195 | [kallsyms_lookup_name() is available])], | |
1196 | []) | |
1197 | ]) | |
1198 | ||
1199 | dnl # | |
e11d6c5f BB |
1200 | dnl # Proposed API change, |
1201 | dnl # This symbol is not available in stock kernels. You may build a | |
1202 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1203 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1204 | dnl # your environment this is recommended. | |
d1ff2312 BB |
1205 | dnl # |
1206 | AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], [ | |
1207 | SPL_CHECK_SYMBOL_EXPORT( | |
1208 | [get_vmalloc_info], | |
1209 | [], | |
1210 | [AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1, | |
1211 | [get_vmalloc_info() is available])], | |
1212 | []) | |
1213 | ]) | |
1214 | ||
5232d256 BB |
1215 | dnl # |
1216 | dnl # 2.6.17 API change | |
1217 | dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and | |
1218 | dnl # next_zone() are introduced to simplify for_each_zone(). These symbols | |
1219 | dnl # were exported in 2.6.17 for use by modules which was consistent with | |
1220 | dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19 | |
1221 | dnl # the symbols were exported as 'unused', and by 2.6.20 they exports | |
1222 | dnl # were dropped entirely leaving modules no way to directly iterate over | |
1223 | dnl # the zone list. Because we need access to the zone helpers we check | |
1224 | dnl # if the kernel contains the old or new implementation. Then we check | |
1225 | dnl # to see if the symbols we need for each version are available. If they | |
1226 | dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name(). | |
1227 | dnl # | |
1228 | AC_DEFUN([SPL_AC_PGDAT_HELPERS], [ | |
1229 | AC_MSG_CHECKING([whether symbol *_pgdat exist]) | |
1230 | grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null | |
1231 | rc=$? | |
1232 | if test $rc -eq 0; then | |
1233 | AC_MSG_RESULT([yes]) | |
1234 | AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available]) | |
1235 | else | |
1236 | AC_MSG_RESULT([no]) | |
1237 | fi | |
1238 | ]) | |
1239 | ||
d1ff2312 | 1240 | dnl # |
e11d6c5f BB |
1241 | dnl # Proposed API change, |
1242 | dnl # This symbol is not available in stock kernels. You may build a | |
1243 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1244 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1245 | dnl # your environment this is recommended. | |
36b313da BB |
1246 | dnl # |
1247 | AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], [ | |
1248 | SPL_CHECK_SYMBOL_EXPORT( | |
1249 | [first_online_pgdat], | |
1250 | [], | |
1251 | [AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1, | |
1252 | [first_online_pgdat() is available])], | |
1253 | []) | |
1254 | ]) | |
1255 | ||
1256 | dnl # | |
e11d6c5f BB |
1257 | dnl # Proposed API change, |
1258 | dnl # This symbol is not available in stock kernels. You may build a | |
1259 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1260 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1261 | dnl # your environment this is recommended. | |
36b313da BB |
1262 | dnl # |
1263 | AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], [ | |
1264 | SPL_CHECK_SYMBOL_EXPORT( | |
1265 | [next_online_pgdat], | |
1266 | [], | |
1267 | [AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1, | |
1268 | [next_online_pgdat() is available])], | |
1269 | []) | |
1270 | ]) | |
1271 | ||
1272 | dnl # | |
e11d6c5f BB |
1273 | dnl # Proposed API change, |
1274 | dnl # This symbol is not available in stock kernels. You may build a | |
1275 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1276 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1277 | dnl # your environment this is recommended. | |
36b313da BB |
1278 | dnl # |
1279 | AC_DEFUN([SPL_AC_NEXT_ZONE], [ | |
1280 | SPL_CHECK_SYMBOL_EXPORT( | |
1281 | [next_zone], | |
1282 | [], | |
1283 | [AC_DEFINE(HAVE_NEXT_ZONE, 1, | |
1284 | [next_zone() is available])], | |
1285 | []) | |
1286 | ]) | |
4ab13d3b | 1287 | |
5232d256 BB |
1288 | dnl # |
1289 | dnl # 2.6.17 API change, | |
1290 | dnl # See SPL_AC_PGDAT_HELPERS for details. | |
1291 | dnl # | |
1292 | AC_DEFUN([SPL_AC_PGDAT_LIST], [ | |
1293 | SPL_CHECK_SYMBOL_EXPORT( | |
1294 | [pgdat_list], | |
1295 | [], | |
1296 | [AC_DEFINE(HAVE_PGDAT_LIST, 1, | |
1297 | [pgdat_list is available])], | |
1298 | []) | |
1299 | ]) | |
1300 | ||
96dded38 BB |
1301 | dnl # |
1302 | dnl # 2.6.18 API change, | |
1303 | dnl # First introduced global_page_state() support as an inline. | |
1304 | dnl # | |
1305 | AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [ | |
1306 | AC_MSG_CHECKING([whether global_page_state() is available]) | |
1307 | SPL_LINUX_TRY_COMPILE([ | |
6ae7fef5 | 1308 | #include <linux/mm.h> |
96dded38 | 1309 | ],[ |
03318641 | 1310 | unsigned long state __attribute__ ((unused)); |
6ae7fef5 | 1311 | state = global_page_state(0); |
96dded38 BB |
1312 | ],[ |
1313 | AC_MSG_RESULT(yes) | |
1314 | AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1, | |
1315 | [global_page_state() is available]) | |
1316 | ],[ | |
1317 | AC_MSG_RESULT(no) | |
1318 | ]) | |
1319 | ]) | |
1320 | ||
e11d6c5f | 1321 | dnl # |
6ae7fef5 BB |
1322 | dnl # 2.6.21 API change (plus subsequent naming convention changes), |
1323 | dnl # Public global zone stats now include a free page count. However | |
1324 | dnl # the enumerated names of the counters have changed since this API | |
1325 | dnl # was introduced. We need to deduce the corrent name to use. This | |
1326 | dnl # replaces the priviate get_zone_counts() interface. | |
1327 | dnl # | |
1328 | dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which | |
1329 | dnl # is 2.6.30 as of when this was written. | |
e11d6c5f | 1330 | dnl # |
6ae7fef5 BB |
1331 | AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [ |
1332 | AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available]) | |
e11d6c5f | 1333 | SPL_LINUX_TRY_COMPILE([ |
6ae7fef5 | 1334 | #include <linux/mm.h> |
e11d6c5f | 1335 | ],[ |
03318641 | 1336 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 | 1337 | zsi = NR_FREE_PAGES; |
e11d6c5f BB |
1338 | ],[ |
1339 | AC_MSG_RESULT(yes) | |
6ae7fef5 BB |
1340 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1, |
1341 | [Page state NR_FREE_PAGES is available]) | |
e11d6c5f BB |
1342 | ],[ |
1343 | AC_MSG_RESULT(no) | |
1344 | ]) | |
1345 | ]) | |
a093c6a4 | 1346 | |
6ae7fef5 BB |
1347 | dnl # |
1348 | dnl # 2.6.21 API change (plus subsequent naming convention changes), | |
1349 | dnl # Public global zone stats now include an inactive page count. However | |
1350 | dnl # the enumerated names of the counters have changed since this API | |
1351 | dnl # was introduced. We need to deduce the corrent name to use. This | |
1352 | dnl # replaces the priviate get_zone_counts() interface. | |
1353 | dnl # | |
1354 | dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both | |
1355 | dnl # anonymous and file inactive pages. As of 2.6.28 it was split in | |
1356 | dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE. | |
1357 | dnl # | |
1358 | AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [ | |
1359 | AC_MSG_CHECKING([whether page state NR_INACTIVE is available]) | |
1360 | SPL_LINUX_TRY_COMPILE([ | |
1361 | #include <linux/mm.h> | |
1362 | ],[ | |
03318641 | 1363 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1364 | zsi = NR_INACTIVE; |
1365 | ],[ | |
1366 | AC_MSG_RESULT(yes) | |
1367 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1, | |
1368 | [Page state NR_INACTIVE is available]) | |
1369 | ],[ | |
1370 | AC_MSG_RESULT(no) | |
1371 | ]) | |
1372 | ||
1373 | AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available]) | |
1374 | SPL_LINUX_TRY_COMPILE([ | |
1375 | #include <linux/mm.h> | |
1376 | ],[ | |
03318641 | 1377 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1378 | zsi = NR_INACTIVE_ANON; |
1379 | ],[ | |
1380 | AC_MSG_RESULT(yes) | |
1381 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1, | |
1382 | [Page state NR_INACTIVE_ANON is available]) | |
1383 | ],[ | |
1384 | AC_MSG_RESULT(no) | |
1385 | ]) | |
1386 | ||
1387 | AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available]) | |
1388 | SPL_LINUX_TRY_COMPILE([ | |
1389 | #include <linux/mm.h> | |
1390 | ],[ | |
03318641 | 1391 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1392 | zsi = NR_INACTIVE_FILE; |
1393 | ],[ | |
1394 | AC_MSG_RESULT(yes) | |
1395 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1, | |
1396 | [Page state NR_INACTIVE_FILE is available]) | |
1397 | ],[ | |
1398 | AC_MSG_RESULT(no) | |
1399 | ]) | |
1400 | ]) | |
1401 | ||
1402 | dnl # | |
1403 | dnl # 2.6.21 API change (plus subsequent naming convention changes), | |
1404 | dnl # Public global zone stats now include an active page count. However | |
1405 | dnl # the enumerated names of the counters have changed since this API | |
1406 | dnl # was introduced. We need to deduce the corrent name to use. This | |
1407 | dnl # replaces the priviate get_zone_counts() interface. | |
1408 | dnl # | |
1409 | dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both | |
1410 | dnl # anonymous and file active pages. As of 2.6.28 it was split in | |
1411 | dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE. | |
1412 | dnl # | |
1413 | AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [ | |
1414 | AC_MSG_CHECKING([whether page state NR_ACTIVE is available]) | |
1415 | SPL_LINUX_TRY_COMPILE([ | |
1416 | #include <linux/mm.h> | |
1417 | ],[ | |
03318641 | 1418 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1419 | zsi = NR_ACTIVE; |
1420 | ],[ | |
1421 | AC_MSG_RESULT(yes) | |
1422 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1, | |
1423 | [Page state NR_ACTIVE is available]) | |
1424 | ],[ | |
1425 | AC_MSG_RESULT(no) | |
1426 | ]) | |
1427 | ||
1428 | AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available]) | |
1429 | SPL_LINUX_TRY_COMPILE([ | |
1430 | #include <linux/mm.h> | |
1431 | ],[ | |
03318641 | 1432 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1433 | zsi = NR_ACTIVE_ANON; |
1434 | ],[ | |
1435 | AC_MSG_RESULT(yes) | |
1436 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1, | |
1437 | [Page state NR_ACTIVE_ANON is available]) | |
1438 | ],[ | |
1439 | AC_MSG_RESULT(no) | |
1440 | ]) | |
1441 | ||
1442 | AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available]) | |
1443 | SPL_LINUX_TRY_COMPILE([ | |
1444 | #include <linux/mm.h> | |
1445 | ],[ | |
03318641 | 1446 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1447 | zsi = NR_ACTIVE_FILE; |
1448 | ],[ | |
1449 | AC_MSG_RESULT(yes) | |
1450 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1, | |
1451 | [Page state NR_ACTIVE_FILE is available]) | |
1452 | ],[ | |
1453 | AC_MSG_RESULT(no) | |
1454 | ]) | |
1455 | ]) | |
1456 | ||
1457 | dnl # | |
1458 | dnl # Proposed API change for legacy kernels. | |
1459 | dnl # This symbol is not available in older kernels. For kernels post | |
1460 | dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active | |
1461 | dnl # page state information. This symbol is only used in legacy kernels | |
1462 | dnl # any only as a last resort. | |
1463 | dnl | |
1464 | AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [ | |
1465 | AC_MSG_CHECKING([whether symbol get_zone_counts is needed]) | |
1466 | SPL_LINUX_TRY_COMPILE([ | |
1467 | ],[ | |
1468 | #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES) | |
1469 | #error "global_page_state needs NR_FREE_PAGES" | |
1470 | #endif | |
1471 | ||
1472 | #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \ | |
1473 | !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \ | |
1474 | !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE) | |
1475 | #error "global_page_state needs NR_ACTIVE*" | |
1476 | #endif | |
1477 | ||
1478 | #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \ | |
1479 | !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \ | |
1480 | !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE) | |
1481 | #error "global_page_state needs NR_INACTIVE*" | |
1482 | #endif | |
1483 | ],[ | |
1484 | AC_MSG_RESULT(no) | |
1485 | ],[ | |
1486 | AC_MSG_RESULT(yes) | |
1487 | AC_DEFINE(NEED_GET_ZONE_COUNTS, 1, | |
1488 | [get_zone_counts() is needed]) | |
1489 | ||
1490 | SPL_CHECK_SYMBOL_EXPORT( | |
1491 | [get_zone_counts], | |
1492 | [], | |
1493 | [AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1, | |
1494 | [get_zone_counts() is available])], | |
1495 | []) | |
1496 | ]) | |
1497 | ]) | |
1498 | ||
7119bf70 BB |
1499 | dnl # |
1500 | dnl # 2.6.27 API change, | |
1501 | dnl # The user_path_dir() replaces __user_walk() | |
1502 | dnl # | |
1503 | AC_DEFUN([SPL_AC_USER_PATH_DIR], [ | |
1504 | SPL_CHECK_SYMBOL_EXPORT( | |
1505 | [user_path_at], | |
1506 | [], | |
1507 | [AC_DEFINE(HAVE_USER_PATH_DIR, 1, | |
1508 | [user_path_dir() is available])], | |
1509 | []) | |
1510 | ]) | |
1511 | ||
51a727e9 BB |
1512 | dnl # |
1513 | dnl # Symbol available in RHEL kernels not in stock kernels. | |
1514 | dnl # | |
1515 | AC_DEFUN([SPL_AC_SET_FS_PWD], [ | |
1516 | SPL_CHECK_SYMBOL_EXPORT( | |
1517 | [set_fs_pwd], | |
1518 | [], | |
1519 | [AC_DEFINE(HAVE_SET_FS_PWD, 1, | |
1520 | [set_fs_pwd() is available])], | |
1521 | []) | |
1522 | ]) | |
1523 | ||
1524 | dnl # | |
1525 | dnl # 2.6.25 API change, | |
1526 | dnl # Simplied API by replacing mnt+dentry args with a single path arg. | |
1527 | dnl # | |
1528 | AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD], | |
1529 | [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args]) | |
1530 | SPL_LINUX_TRY_COMPILE([ | |
1531 | #include <linux/sched.h> | |
baf2979e | 1532 | #include <linux/fs_struct.h> |
51a727e9 BB |
1533 | ],[ |
1534 | set_fs_pwd(NULL, NULL); | |
1535 | ],[ | |
1536 | AC_MSG_RESULT(yes) | |
1537 | AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1, | |
1538 | [set_fs_pwd() wants 2 args]) | |
1539 | ],[ | |
1540 | AC_MSG_RESULT(no) | |
1541 | ]) | |
1542 | ]) | |
1543 | ||
a093c6a4 BB |
1544 | dnl # |
1545 | dnl # SLES API change, never adopted in mainline, | |
1546 | dnl # Third 'struct vfsmount *' argument removed. | |
1547 | dnl # | |
1548 | AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK], | |
1549 | [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args]) | |
1550 | SPL_LINUX_TRY_COMPILE([ | |
1551 | #include <linux/fs.h> | |
1552 | ],[ | |
1553 | vfs_unlink(NULL, NULL); | |
1554 | ],[ | |
1555 | AC_MSG_RESULT(yes) | |
1556 | AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1, | |
1557 | [vfs_unlink() wants 2 args]) | |
1558 | ],[ | |
1559 | AC_MSG_RESULT(no) | |
1560 | ]) | |
1561 | ]) | |
1562 | ||
1563 | dnl # | |
1564 | dnl # SLES API change, never adopted in mainline, | |
1565 | dnl # Third and sixth 'struct vfsmount *' argument removed. | |
1566 | dnl # | |
1567 | AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME], | |
1568 | [AC_MSG_CHECKING([whether vfs_rename() wants 4 args]) | |
1569 | SPL_LINUX_TRY_COMPILE([ | |
1570 | #include <linux/fs.h> | |
1571 | ],[ | |
1572 | vfs_rename(NULL, NULL, NULL, NULL); | |
1573 | ],[ | |
1574 | AC_MSG_RESULT(yes) | |
1575 | AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1, | |
1576 | [vfs_rename() wants 4 args]) | |
1577 | ],[ | |
1578 | AC_MSG_RESULT(no) | |
1579 | ]) | |
1580 | ]) | |
ec7d53e9 | 1581 | |
9b2048c2 BB |
1582 | dnl # |
1583 | dnl # 2.6.36 API change, | |
1584 | dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to | |
1585 | dnl # a spinlock_t to improve the fastpath performance. | |
1586 | dnl # | |
1587 | AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [ | |
1588 | AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t]) | |
1589 | SPL_LINUX_TRY_COMPILE([ | |
1590 | #include <linux/sched.h> | |
1591 | #include <linux/fs_struct.h> | |
1592 | ],[ | |
1593 | struct fs_struct fs; | |
1594 | spin_lock_init(&fs.lock); | |
1595 | ],[ | |
1596 | AC_MSG_RESULT(yes) | |
1597 | AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1, | |
1598 | [struct fs_struct uses spinlock_t]) | |
1599 | ],[ | |
1600 | AC_MSG_RESULT(no) | |
1601 | ]) | |
1602 | ]) | |
1603 | ||
ec7d53e9 BB |
1604 | dnl # |
1605 | dnl # 2.6.29 API change, | |
1606 | dnl # check whether 'struct cred' exists | |
1607 | dnl # | |
1608 | AC_DEFUN([SPL_AC_CRED_STRUCT], [ | |
1609 | AC_MSG_CHECKING([whether struct cred exists]) | |
1610 | SPL_LINUX_TRY_COMPILE([ | |
1611 | #include <linux/cred.h> | |
1612 | ],[ | |
03318641 | 1613 | struct cred *cr __attribute__ ((unused)); |
ec7d53e9 BB |
1614 | cr = NULL; |
1615 | ],[ | |
1616 | AC_MSG_RESULT(yes) | |
1617 | AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists]) | |
1618 | ],[ | |
1619 | AC_MSG_RESULT(no) | |
1620 | ]) | |
1621 | ]) | |
1622 | ||
1623 | dnl # | |
e811949a | 1624 | dnl # Custom SPL patch may export this symbol. |
ec7d53e9 BB |
1625 | dnl # |
1626 | AC_DEFUN([SPL_AC_GROUPS_SEARCH], [ | |
1627 | SPL_CHECK_SYMBOL_EXPORT( | |
1628 | [groups_search], | |
1629 | [], | |
1630 | [AC_DEFINE(HAVE_GROUPS_SEARCH, 1, | |
1631 | [groups_search() is available])], | |
1632 | []) | |
1633 | ]) | |
e811949a BB |
1634 | |
1635 | dnl # | |
1636 | dnl # 2.6.x API change, | |
1637 | dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere. | |
1638 | dnl # | |
1639 | AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], [ | |
1640 | SPL_CHECK_SYMBOL_EXPORT( | |
1641 | [__put_task_struct], | |
1642 | [], | |
1643 | [AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1, | |
1644 | [__put_task_struct() is available])], | |
1645 | []) | |
1646 | ]) | |
3977f837 BB |
1647 | |
1648 | dnl # | |
1649 | dnl # 2.6.32 API change, | |
1650 | dnl # Unused 'struct file *' removed from prototype. | |
1651 | dnl # | |
1652 | AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [ | |
1653 | AC_MSG_CHECKING([whether proc_handler() wants 5 args]) | |
1654 | SPL_LINUX_TRY_COMPILE([ | |
1655 | #include <linux/sysctl.h> | |
1656 | ],[ | |
1657 | proc_dostring(NULL, 0, NULL, NULL, NULL); | |
1658 | ],[ | |
1659 | AC_MSG_RESULT(yes) | |
1660 | AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1, | |
1661 | [proc_handler() wants 5 args]) | |
1662 | ],[ | |
1663 | AC_MSG_RESULT(no) | |
1664 | ]) | |
1665 | ]) | |
b868e22f BB |
1666 | |
1667 | dnl # | |
1668 | dnl # 2.6.x API change, | |
1669 | dnl # kvasprintf() function added. | |
1670 | dnl # | |
1671 | AC_DEFUN([SPL_AC_KVASPRINTF], [ | |
1672 | SPL_CHECK_SYMBOL_EXPORT( | |
1673 | [kvasprintf], | |
1674 | [], | |
1675 | [AC_DEFINE(HAVE_KVASPRINTF, 1, | |
1676 | [kvasprintf() is available])], | |
1677 | []) | |
1678 | ]) | |
f0ff89fc BB |
1679 | |
1680 | dnl # | |
1681 | dnl # 2.6.35 API change, | |
1682 | dnl # Unused 'struct dentry *' removed from prototype. | |
1683 | dnl # | |
1684 | AC_DEFUN([SPL_AC_3ARGS_FILE_FSYNC], [ | |
1685 | AC_MSG_CHECKING([whether file_fsync() wants 3 args]) | |
1686 | SPL_LINUX_TRY_COMPILE([ | |
1687 | #include <linux/buffer_head.h> | |
1688 | ],[ | |
1689 | file_fsync(NULL, NULL, 0); | |
1690 | ],[ | |
1691 | AC_MSG_RESULT(yes) | |
1692 | AC_DEFINE(HAVE_3ARGS_FILE_FSYNC, 1, | |
1693 | [file_fsync() wants 3 args]) | |
1694 | ],[ | |
1695 | AC_MSG_RESULT(no) | |
1696 | ]) | |
1697 | ]) | |
46aa7b39 NB |
1698 | |
1699 | dnl # | |
1700 | dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5. | |
1701 | dnl # Earlier versions of rwsem_is_locked() were inline and had a race | |
1702 | dnl # condition. The fixed version is exported as a symbol. The race | |
1703 | dnl # condition is fixed by acquiring sem->wait_lock, so we must not | |
1704 | dnl # call that version while holding sem->wait_lock. | |
1705 | dnl # | |
1706 | AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], [ | |
1707 | SPL_CHECK_SYMBOL_EXPORT( | |
1708 | [rwsem_is_locked], | |
1709 | [lib/rwsem-spinlock.c], | |
1710 | [AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1, | |
1711 | [rwsem_is_locked() acquires sem->wait_lock])], | |
1712 | []) | |
1713 | ]) | |
914b0631 BB |
1714 | |
1715 | dnl # | |
1716 | dnl # 2.6.37 API compat, | |
1717 | dnl # The function invalidate_inodes() is no longer exported by the kernel. | |
1718 | dnl # The prototype however is still available which means it is safe | |
1719 | dnl # to acquire the symbol's address using spl_kallsyms_lookup_name(). | |
1720 | dnl # | |
1721 | AC_DEFUN([SPL_AC_KERNEL_INVALIDATE_INODES], [ | |
1722 | SPL_CHECK_SYMBOL_EXPORT( | |
1723 | [invalidate_inodes], | |
1724 | [], | |
1725 | [AC_DEFINE(HAVE_INVALIDATE_INODES, 1, | |
1726 | [invalidate_inodes() is available])], | |
1727 | []) | |
1728 | ]) | |
e76f4bf1 | 1729 | |
9b0f9079 BB |
1730 | dnl # |
1731 | dnl # 2.6.39 API compat, | |
1732 | dnl # The function invalidate_inodes() now take 2 arguments. The second | |
1733 | dnl # 'kill_dirty' argument describes how invalidate_inodes() should | |
1734 | dnl # handle dirty inodes. Only when set will dirty inodes be discarded, | |
1735 | dnl # otherwise they will be handled as busy. | |
1736 | dnl # | |
1737 | dnl # Unfortunately, we don't have access to the invalidate_inodes() | |
1738 | dnl # prototype so it's not easy to check how many arguments it takes. | |
1739 | dnl # However, this change was done for the benefit of invalidate_device() | |
1740 | dnl # which also added an argument. The invalidate_device() symbol does | |
1741 | dnl # exist in the development headers so if it takes two arguments we | |
1742 | dnl # can fairly safely infer that invalidate_inodes() takes two arguments | |
1743 | dnl # as well. See commit 93b270f76e7ef3b81001576860c2701931cdc78b. | |
1744 | dnl # | |
1745 | AC_DEFUN([SPL_AC_KERNEL_2ARGS_INVALIDATE_INODES], | |
1746 | [AC_MSG_CHECKING([whether invalidate_inodes() wants 2 args]) | |
1747 | SPL_LINUX_TRY_COMPILE([ | |
1748 | #include <linux/fs.h> | |
1749 | ],[ | |
1750 | return __invalidate_device(NULL, 0); | |
1751 | ],[ | |
1752 | AC_MSG_RESULT(yes) | |
1753 | AC_DEFINE(HAVE_2ARGS_INVALIDATE_INODES, 1, | |
1754 | [invalidate_inodes() wants 2 args]) | |
1755 | ],[ | |
1756 | AC_MSG_RESULT(no) | |
1757 | ]) | |
1758 | ]) | |
1759 | ||
e76f4bf1 BB |
1760 | dnl # |
1761 | dnl # 2.6.xx API compat, | |
1762 | dnl # There currently exists no exposed API to partially shrink the dcache. | |
1763 | dnl # The expected mechanism to shrink the cache is a registered shrinker | |
1764 | dnl # which is called during memory pressure. | |
1765 | dnl # | |
1766 | AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], [ | |
1767 | SPL_CHECK_SYMBOL_EXPORT( | |
1768 | [shrink_dcache_memory], | |
1769 | [fs/dcache.c], | |
1770 | [AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1, | |
1771 | [shrink_dcache_memory() is available])], | |
1772 | []) | |
1773 | ]) | |
1774 | ||
1775 | dnl # | |
1776 | dnl # 2.6.xx API compat, | |
1777 | dnl # There currently exists no exposed API to partially shrink the icache. | |
1778 | dnl # The expected mechanism to shrink the cache is a registered shrinker | |
1779 | dnl # which is called during memory pressure. | |
1780 | dnl # | |
1781 | AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], [ | |
1782 | SPL_CHECK_SYMBOL_EXPORT( | |
1783 | [shrink_icache_memory], | |
1784 | [fs/inode.c], | |
1785 | [AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1, | |
1786 | [shrink_icache_memory() is available])], | |
1787 | []) | |
1788 | ]) | |
b1cbc461 BB |
1789 | |
1790 | dnl # | |
1791 | dnl # 2.6.39 API compat, | |
1792 | dnl # The path_lookup() function has been renamed to kern_path_parent() | |
1793 | dnl # and the flags argument has been removed. The only behavior now | |
1794 | dnl # offered is that of LOOKUP_PARENT. The spl already always passed | |
1795 | dnl # this flag so dropping the flag does not impact us. | |
1796 | dnl # | |
1797 | AC_DEFUN([SPL_AC_KERN_PATH_PARENT], [ | |
1798 | SPL_CHECK_SYMBOL_EXPORT( | |
1799 | [kern_path_parent], | |
1800 | [fs/namei.c], | |
1801 | [AC_DEFINE(HAVE_KERN_PATH_PARENT, 1, | |
1802 | [kern_path_parent() is available])], | |
1803 | []) | |
1804 | ]) |