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