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