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