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