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