]>
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 | |
4b2220f0 | 21 | SPL_AC_DEBUG_LOG |
86933a6e | 22 | SPL_AC_DEBUG_KMEM |
055ffd98 | 23 | SPL_AC_DEBUG_KMEM_TRACKING |
0408008b | 24 | SPL_AC_TEST_MODULE |
5e9b5d83 | 25 | SPL_AC_ATOMIC_SPINLOCK |
302b88e6 BB |
26 | SPL_AC_TYPE_ATOMIC64_CMPXCHG |
27 | SPL_AC_TYPE_ATOMIC64_XCHG | |
d04c8a56 | 28 | SPL_AC_TYPE_UINTPTR_T |
86933a6e | 29 | SPL_AC_2ARGS_REGISTER_SYSCTL |
c3d9c0df | 30 | SPL_AC_SHRINKER_CALLBACK |
86933a6e BB |
31 | SPL_AC_TASK_CURR |
32 | SPL_AC_CTL_UNNUMBERED | |
79a3bf13 | 33 | SPL_AC_CTL_NAME |
c02ab72f | 34 | SPL_AC_VMALLOC_INFO |
1ddf9722 | 35 | SPL_AC_PDE_DATA |
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 | |
86933a6e BB |
44 | SPL_AC_UACCESS_HEADER |
45 | SPL_AC_KMALLOC_NODE | |
46 | SPL_AC_MONOTONIC_CLOCK | |
47 | SPL_AC_INODE_I_MUTEX | |
4d54fdee | 48 | SPL_AC_MUTEX_OWNER |
86fd39f3 | 49 | SPL_AC_MUTEX_OWNER_TASK_STRUCT |
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 | 65 | SPL_AC_SET_FS_PWD |
a54718cf | 66 | SPL_AC_SET_FS_PWD_WITH_CONST |
86933a6e BB |
67 | SPL_AC_2ARGS_VFS_UNLINK |
68 | SPL_AC_4ARGS_VFS_RENAME | |
0d0b5237 BB |
69 | SPL_AC_VFS_FSYNC |
70 | SPL_AC_2ARGS_VFS_FSYNC | |
bbdc6ae4 | 71 | SPL_AC_INODE_TRUNCATE_RANGE |
9b2048c2 | 72 | SPL_AC_FS_STRUCT_SPINLOCK |
ec7d53e9 | 73 | SPL_AC_CRED_STRUCT |
f7fd6ddd | 74 | SPL_AC_KUIDGID_T |
ec7d53e9 | 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 |
1c7b3eaf | 80 | SPL_AC_KERNEL_FALLOCATE |
e76f4bf1 BB |
81 | SPL_AC_SHRINK_DCACHE_MEMORY |
82 | SPL_AC_SHRINK_ICACHE_MEMORY | |
ec18fe3c | 83 | SPL_AC_KERN_PATH |
de081a2a | 84 | SPL_AC_CONFIG_KALLSYMS |
42b3ce62 BB |
85 | SPL_AC_CONFIG_ZLIB_INFLATE |
86 | SPL_AC_CONFIG_ZLIB_DEFLATE | |
3dfc591a | 87 | SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE |
a55bcaad | 88 | SPL_AC_SHRINK_CONTROL_STRUCT |
588d9004 | 89 | SPL_AC_RWSEM_SPINLOCK_IS_RAW |
10087fe1 | 90 | SPL_AC_SCHED_RT_HEADER |
2a305c34 | 91 | SPL_AC_2ARGS_VFS_GETATTR |
184c6873 | 92 | SPL_AC_USLEEP_RANGE |
a073aeb0 | 93 | SPL_AC_KMEM_CACHE_ALLOCFLAGS |
2fc44f66 | 94 | SPL_AC_WAIT_ON_BIT |
86933a6e BB |
95 | ]) |
96 | ||
97 | AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ | |
bb339d06 | 98 | modpost=$LINUX/scripts/Makefile.modpost |
86933a6e | 99 | AC_MSG_CHECKING([kernel file name for module symbols]) |
0408008b | 100 | if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then |
bb339d06 BB |
101 | if grep -q Modules.symvers $modpost; then |
102 | LINUX_SYMBOLS=Modules.symvers | |
103 | else | |
104 | LINUX_SYMBOLS=Module.symvers | |
105 | fi | |
912fd84d BB |
106 | |
107 | if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then | |
108 | AC_MSG_ERROR([ | |
109 | *** Please make sure the kernel devel package for your distribution | |
7a8a6393 | 110 | *** is installed. If you are building with a custom kernel, make sure the |
912fd84d BB |
111 | *** kernel is configured, built, and the '--with-linux=PATH' configure |
112 | *** option refers to the location of the kernel source.]) | |
113 | fi | |
86933a6e | 114 | else |
bb339d06 | 115 | LINUX_SYMBOLS=NONE |
86933a6e BB |
116 | fi |
117 | AC_MSG_RESULT($LINUX_SYMBOLS) | |
118 | AC_SUBST(LINUX_SYMBOLS) | |
119 | ]) | |
120 | ||
57d86234 | 121 | AC_DEFUN([SPL_AC_KERNEL], [ |
57d86234 | 122 | AC_ARG_WITH([linux], |
123 | AS_HELP_STRING([--with-linux=PATH], | |
124 | [Path to kernel source]), | |
39a3d2a4 | 125 | [kernelsrc="$withval"]) |
57d86234 | 126 | |
127 | AC_ARG_WITH([linux-obj], | |
128 | AS_HELP_STRING([--with-linux-obj=PATH], | |
129 | [Path to kernel build objects]), | |
130 | [kernelbuild="$withval"]) | |
131 | ||
132 | AC_MSG_CHECKING([kernel source directory]) | |
133 | if test -z "$kernelsrc"; then | |
22ccfaa8 BB |
134 | if test -e "/lib/modules/$(uname -r)/source"; then |
135 | headersdir="/lib/modules/$(uname -r)/source" | |
136 | sourcelink=$(readlink -f "$headersdir") | |
137 | elif test -e "/lib/modules/$(uname -r)/build"; then | |
138 | headersdir="/lib/modules/$(uname -r)/build" | |
534c4e38 BM |
139 | sourcelink=$(readlink -f "$headersdir") |
140 | else | |
141 | sourcelink=$(ls -1d /usr/src/kernels/* \ | |
723aa3b0 | 142 | /usr/src/linux-* \ |
534c4e38 BM |
143 | 2>/dev/null | grep -v obj | tail -1) |
144 | fi | |
57d86234 | 145 | |
8fd4e3af | 146 | if test -n "$sourcelink" && test -e ${sourcelink}; then |
d4326403 | 147 | kernelsrc=`readlink -f ${sourcelink}` |
d4326403 | 148 | else |
251677e9 | 149 | kernelsrc="[Not found]" |
57d86234 | 150 | fi |
c5f70460 BB |
151 | else |
152 | if test "$kernelsrc" = "NONE"; then | |
153 | kernsrcver=NONE | |
154 | fi | |
57d86234 | 155 | fi |
156 | ||
157 | AC_MSG_RESULT([$kernelsrc]) | |
251677e9 BB |
158 | if test ! -d "$kernelsrc"; then |
159 | AC_MSG_ERROR([ | |
160 | *** Please make sure the kernel devel package for your distribution | |
7a8a6393 | 161 | *** is installed and then try again. If that fails, you can specify the |
251677e9 BB |
162 | *** location of the kernel source with the '--with-linux=PATH' option.]) |
163 | fi | |
164 | ||
57d86234 | 165 | AC_MSG_CHECKING([kernel build directory]) |
39a3d2a4 | 166 | if test -z "$kernelbuild"; then |
22ccfaa8 BB |
167 | if test -e "/lib/modules/$(uname -r)/build"; then |
168 | kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` | |
169 | elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then | |
e2d28a37 BB |
170 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} |
171 | elif test -d ${kernelsrc}-obj/${target_cpu}/default; then | |
172 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default | |
173 | elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then | |
174 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} | |
39a3d2a4 BB |
175 | else |
176 | kernelbuild=${kernelsrc} | |
177 | fi | |
bf338d8d | 178 | fi |
57d86234 | 179 | AC_MSG_RESULT([$kernelbuild]) |
180 | ||
181 | AC_MSG_CHECKING([kernel source version]) | |
fd921c2e BB |
182 | utsrelease1=$kernelbuild/include/linux/version.h |
183 | utsrelease2=$kernelbuild/include/linux/utsrelease.h | |
184 | utsrelease3=$kernelbuild/include/generated/utsrelease.h | |
185 | if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then | |
186 | utsrelease=linux/version.h | |
187 | elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then | |
188 | utsrelease=linux/utsrelease.h | |
189 | elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then | |
190 | utsrelease=generated/utsrelease.h | |
191 | fi | |
57d86234 | 192 | |
fd921c2e BB |
193 | if test "$utsrelease"; then |
194 | kernsrcver=`(echo "#include <$utsrelease>"; | |
57d86234 | 195 | echo "kernsrcver=UTS_RELEASE") | |
d4326403 | 196 | cpp -I $kernelbuild/include | |
57d86234 | 197 | grep "^kernsrcver=" | cut -d \" -f 2` |
57d86234 | 198 | |
fd921c2e BB |
199 | if test -z "$kernsrcver"; then |
200 | AC_MSG_RESULT([Not found]) | |
201 | AC_MSG_ERROR([*** Cannot determine kernel version.]) | |
202 | fi | |
203 | else | |
57d86234 | 204 | AC_MSG_RESULT([Not found]) |
0408008b ED |
205 | if test "x$enable_linux_builtin" != xyes; then |
206 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) | |
207 | else | |
208 | AC_MSG_ERROR([ | |
209 | *** Cannot find UTS_RELEASE definition. | |
210 | *** Please run 'make prepare' inside the kernel source tree.]) | |
211 | fi | |
57d86234 | 212 | fi |
213 | ||
214 | AC_MSG_RESULT([$kernsrcver]) | |
215 | ||
57d86234 | 216 | LINUX=${kernelsrc} |
217 | LINUX_OBJ=${kernelbuild} | |
c5f70460 BB |
218 | LINUX_VERSION=${kernsrcver} |
219 | ||
57d86234 | 220 | AC_SUBST(LINUX) |
221 | AC_SUBST(LINUX_OBJ) | |
c5f70460 | 222 | AC_SUBST(LINUX_VERSION) |
57d86234 | 223 | |
86933a6e | 224 | SPL_AC_MODULE_SYMVERS |
2e0e7e69 BB |
225 | ]) |
226 | ||
287b2fb1 BB |
227 | dnl # |
228 | dnl # Default SPL user configuration | |
229 | dnl # | |
ad35b6a6 | 230 | AC_DEFUN([SPL_AC_CONFIG_USER], []) |
287b2fb1 BB |
231 | |
232 | dnl # | |
233 | dnl # Check for rpm+rpmbuild to build RPM packages. If these tools | |
7a8a6393 | 234 | dnl # are missing, it is non-fatal, but you will not be able to build |
287b2fb1 BB |
235 | dnl # RPM packages and will be warned if you try too. |
236 | dnl # | |
7a8a6393 | 237 | dnl # By default, the generic spec file will be used because it requires |
493972c8 BB |
238 | dnl # minimal dependencies. Distribution specific spec files can be |
239 | dnl # placed under the 'rpm/<distribution>' directory and enabled using | |
240 | dnl # the --with-spec=<distribution> configure option. | |
241 | dnl # | |
287b2fb1 BB |
242 | AC_DEFUN([SPL_AC_RPM], [ |
243 | RPM=rpm | |
244 | RPMBUILD=rpmbuild | |
245 | ||
246 | AC_MSG_CHECKING([whether $RPM is available]) | |
247 | AS_IF([tmp=$($RPM --version 2>/dev/null)], [ | |
248 | RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
249 | HAVE_RPM=yes | |
250 | AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) | |
251 | ],[ | |
252 | HAVE_RPM=no | |
253 | AC_MSG_RESULT([$HAVE_RPM]) | |
254 | ]) | |
255 | ||
256 | AC_MSG_CHECKING([whether $RPMBUILD is available]) | |
257 | AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ | |
258 | RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
259 | HAVE_RPMBUILD=yes | |
260 | AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) | |
261 | ],[ | |
262 | HAVE_RPMBUILD=no | |
263 | AC_MSG_RESULT([$HAVE_RPMBUILD]) | |
264 | ]) | |
265 | ||
493972c8 BB |
266 | RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"' |
267 | RPM_DEFINE_UTIL= | |
268 | RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"' | |
269 | RPM_DEFINE_DKMS= | |
270 | ||
271 | SRPM_DEFINE_COMMON='--define "build_src_rpm 1"' | |
272 | SRPM_DEFINE_UTIL= | |
273 | SRPM_DEFINE_KMOD= | |
274 | SRPM_DEFINE_DKMS= | |
275 | ||
276 | RPM_SPEC_DIR="rpm/generic" | |
277 | AC_ARG_WITH([spec], | |
278 | AS_HELP_STRING([--with-spec=SPEC], | |
279 | [Spec files 'generic|fedora']), | |
280 | [RPM_SPEC_DIR="rpm/$withval"]) | |
281 | ||
282 | AC_MSG_CHECKING([whether spec files are available]) | |
283 | AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)]) | |
284 | ||
287b2fb1 BB |
285 | AC_SUBST(HAVE_RPM) |
286 | AC_SUBST(RPM) | |
287 | AC_SUBST(RPM_VERSION) | |
288 | ||
289 | AC_SUBST(HAVE_RPMBUILD) | |
290 | AC_SUBST(RPMBUILD) | |
291 | AC_SUBST(RPMBUILD_VERSION) | |
493972c8 BB |
292 | |
293 | AC_SUBST(RPM_SPEC_DIR) | |
294 | AC_SUBST(RPM_DEFINE_UTIL) | |
295 | AC_SUBST(RPM_DEFINE_KMOD) | |
296 | AC_SUBST(RPM_DEFINE_DKMS) | |
297 | AC_SUBST(RPM_DEFINE_COMMON) | |
298 | AC_SUBST(SRPM_DEFINE_UTIL) | |
299 | AC_SUBST(SRPM_DEFINE_KMOD) | |
300 | AC_SUBST(SRPM_DEFINE_DKMS) | |
301 | AC_SUBST(SRPM_DEFINE_COMMON) | |
287b2fb1 BB |
302 | ]) |
303 | ||
304 | dnl # | |
305 | dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these | |
306 | dnl # tools are missing it is non-fatal but you will not be able to build | |
307 | dnl # DEB packages and will be warned if you try too. | |
308 | dnl # | |
309 | AC_DEFUN([SPL_AC_DPKG], [ | |
310 | DPKG=dpkg | |
311 | DPKGBUILD=dpkg-buildpackage | |
312 | ||
313 | AC_MSG_CHECKING([whether $DPKG is available]) | |
314 | AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ | |
315 | DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') | |
316 | HAVE_DPKG=yes | |
317 | AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) | |
318 | ],[ | |
319 | HAVE_DPKG=no | |
320 | AC_MSG_RESULT([$HAVE_DPKG]) | |
321 | ]) | |
322 | ||
323 | AC_MSG_CHECKING([whether $DPKGBUILD is available]) | |
324 | AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ | |
325 | DPKGBUILD_VERSION=$(echo $tmp | \ | |
326 | $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') | |
327 | HAVE_DPKGBUILD=yes | |
328 | AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) | |
329 | ],[ | |
330 | HAVE_DPKGBUILD=no | |
331 | AC_MSG_RESULT([$HAVE_DPKGBUILD]) | |
332 | ]) | |
333 | ||
334 | AC_SUBST(HAVE_DPKG) | |
335 | AC_SUBST(DPKG) | |
336 | AC_SUBST(DPKG_VERSION) | |
337 | ||
338 | AC_SUBST(HAVE_DPKGBUILD) | |
339 | AC_SUBST(DPKGBUILD) | |
340 | AC_SUBST(DPKGBUILD_VERSION) | |
341 | ]) | |
342 | ||
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 | 372 | AC_MSG_CHECKING([linux distribution]) |
a3a69b74 BB |
373 | if test -f /etc/toss-release ; then |
374 | VENDOR=toss ; | |
73fc084e BB |
375 | elif test -f /etc/fedora-release ; then |
376 | VENDOR=fedora ; | |
a3a69b74 BB |
377 | elif test -f /etc/redhat-release ; then |
378 | VENDOR=redhat ; | |
379 | elif test -f /etc/gentoo-release ; then | |
380 | VENDOR=gentoo ; | |
cd2817f8 PS |
381 | elif test -f /etc/arch-release ; then |
382 | VENDOR=arch ; | |
73fc084e BB |
383 | elif test -f /etc/SuSE-release ; then |
384 | VENDOR=sles ; | |
385 | elif test -f /etc/slackware-version ; then | |
386 | VENDOR=slackware ; | |
a3a69b74 BB |
387 | elif test -f /etc/lunar.release ; then |
388 | VENDOR=lunar ; | |
389 | elif test -f /etc/lsb-release ; then | |
390 | VENDOR=ubuntu ; | |
391 | elif test -f /etc/debian_version ; then | |
392 | VENDOR=debian ; | |
73fc084e BB |
393 | else |
394 | VENDOR= ; | |
395 | fi | |
396 | AC_MSG_RESULT([$VENDOR]) | |
397 | AC_SUBST(VENDOR) | |
287b2fb1 BB |
398 | |
399 | AC_MSG_CHECKING([default package type]) | |
400 | case "$VENDOR" in | |
a3a69b74 BB |
401 | toss) DEFAULT_PACKAGE=rpm ;; |
402 | redhat) DEFAULT_PACKAGE=rpm ;; | |
403 | fedora) DEFAULT_PACKAGE=rpm ;; | |
404 | gentoo) DEFAULT_PACKAGE=tgz ;; | |
5f0a4b08 | 405 | arch) DEFAULT_PACKAGE=tgz ;; |
a3a69b74 BB |
406 | sles) DEFAULT_PACKAGE=rpm ;; |
407 | slackware) DEFAULT_PACKAGE=tgz ;; | |
408 | lunar) DEFAULT_PACKAGE=tgz ;; | |
409 | ubuntu) DEFAULT_PACKAGE=deb ;; | |
410 | debian) DEFAULT_PACKAGE=deb ;; | |
411 | *) DEFAULT_PACKAGE=rpm ;; | |
287b2fb1 BB |
412 | esac |
413 | ||
414 | AC_MSG_RESULT([$DEFAULT_PACKAGE]) | |
415 | AC_SUBST(DEFAULT_PACKAGE) | |
416 | ]) | |
417 | ||
418 | dnl # | |
419 | dnl # Default SPL user configuration | |
420 | dnl # | |
421 | AC_DEFUN([SPL_AC_PACKAGE], [ | |
0b14b9f3 | 422 | SPL_AC_DEFAULT_PACKAGE |
287b2fb1 BB |
423 | SPL_AC_RPM |
424 | SPL_AC_DPKG | |
425 | SPL_AC_ALIEN | |
287b2fb1 BB |
426 | ]) |
427 | ||
6a1c3d41 | 428 | AC_DEFUN([SPL_AC_LICENSE], [ |
86933a6e BB |
429 | AC_MSG_CHECKING([spl license]) |
430 | LICENSE=GPL | |
431 | AC_MSG_RESULT([$LICENSE]) | |
6a1c3d41 | 432 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS" |
86933a6e BB |
433 | AC_SUBST(LICENSE) |
434 | ]) | |
435 | ||
436 | AC_DEFUN([SPL_AC_CONFIG], [ | |
0408008b ED |
437 | SPL_CONFIG=all |
438 | AC_ARG_WITH([config], | |
439 | AS_HELP_STRING([--with-config=CONFIG], | |
440 | [Config file 'kernel|user|all|srpm']), | |
441 | [SPL_CONFIG="$withval"]) | |
442 | AC_ARG_ENABLE([linux-builtin], | |
443 | [AC_HELP_STRING([--enable-linux-builtin], | |
444 | [Configure for builtin in-tree kernel modules @<:@default=no@:>@])], | |
445 | [], | |
446 | [enable_linux_builtin=no]) | |
447 | ||
448 | AC_MSG_CHECKING([spl config]) | |
449 | AC_MSG_RESULT([$SPL_CONFIG]); | |
450 | AC_SUBST(SPL_CONFIG) | |
451 | ||
452 | case "$SPL_CONFIG" in | |
453 | kernel) SPL_AC_CONFIG_KERNEL ;; | |
454 | user) SPL_AC_CONFIG_USER ;; | |
455 | all) SPL_AC_CONFIG_KERNEL | |
456 | SPL_AC_CONFIG_USER ;; | |
c1541dfe | 457 | srpm) ;; |
0408008b ED |
458 | *) |
459 | AC_MSG_RESULT([Error!]) | |
460 | AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config, | |
461 | user kernel|user|all|srpm]) ;; | |
462 | esac | |
463 | ||
464 | AM_CONDITIONAL([CONFIG_USER], | |
465 | [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all]) | |
466 | AM_CONDITIONAL([CONFIG_KERNEL], | |
467 | [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] && | |
468 | [test "x$enable_linux_builtin" != xyes ]) | |
6a1c3d41 | 469 | ]) |
470 | ||
055ffd98 BB |
471 | dnl # |
472 | dnl # Enable if the SPL should be compiled with internal debugging enabled. | |
473 | dnl # By default this support is disabled. | |
474 | dnl # | |
57d86234 | 475 | AC_DEFUN([SPL_AC_DEBUG], [ |
c950d148 | 476 | AC_MSG_CHECKING([whether debugging is enabled]) |
055ffd98 BB |
477 | AC_ARG_ENABLE([debug], |
478 | [AS_HELP_STRING([--enable-debug], | |
479 | [Enable generic debug support @<:@default=no@:>@])], | |
480 | [], | |
481 | [enable_debug=no]) | |
482 | ||
483 | AS_IF([test "x$enable_debug" = xyes], | |
c950d148 | 484 | [ |
c950d148 BB |
485 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" |
486 | DEBUG_CFLAGS="-DDEBUG -Werror" | |
3c208a54 BB |
487 | DEBUG_SPL="_with_debug" |
488 | ], [ | |
c950d148 BB |
489 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" |
490 | DEBUG_CFLAGS="-DNDEBUG" | |
3c208a54 | 491 | DEBUG_SPL="_without_debug" |
c950d148 | 492 | ]) |
055ffd98 | 493 | |
c950d148 | 494 | AC_SUBST(DEBUG_CFLAGS) |
3c208a54 | 495 | AC_SUBST(DEBUG_SPL) |
055ffd98 | 496 | AC_MSG_RESULT([$enable_debug]) |
57d86234 | 497 | ]) |
498 | ||
4b2220f0 BB |
499 | dnl # |
500 | dnl # Enabled by default it provides a basic debug log infrastructure. | |
501 | dnl # Each subsystem registers itself with a name and logs messages | |
502 | dnl # using predefined types. If the debug mask it set to allow the | |
503 | dnl # message type it will be written to the internal log. The log | |
504 | dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry, | |
505 | dnl # after dumping the log it must be decoded using the spl utility. | |
506 | dnl # | |
507 | dnl # echo 1 >/proc/sys/kernel/spl/debug/dump | |
508 | dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt | |
509 | dnl # | |
510 | AC_DEFUN([SPL_AC_DEBUG_LOG], [ | |
511 | AC_ARG_ENABLE([debug-log], | |
512 | [AS_HELP_STRING([--enable-debug-log], | |
513 | [Enable basic debug logging @<:@default=yes@:>@])], | |
514 | [], | |
515 | [enable_debug_log=yes]) | |
516 | ||
517 | AS_IF([test "x$enable_debug_log" = xyes], | |
3c208a54 BB |
518 | [ |
519 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" | |
520 | DEBUG_LOG="_with_debug_log" | |
521 | AC_DEFINE([DEBUG_LOG], [1], | |
4b2220f0 | 522 | [Define to 1 to enable basic debug logging]) |
3c208a54 BB |
523 | ], [ |
524 | DEBUG_LOG="_without_debug_log" | |
525 | ]) | |
4b2220f0 | 526 | |
3c208a54 | 527 | AC_SUBST(DEBUG_LOG) |
4b2220f0 BB |
528 | AC_MSG_CHECKING([whether basic debug logging is enabled]) |
529 | AC_MSG_RESULT([$enable_debug_log]) | |
530 | ]) | |
531 | ||
055ffd98 BB |
532 | dnl # |
533 | dnl # Enabled by default it provides a minimal level of memory tracking. | |
534 | dnl # A total count of bytes allocated is kept for each alloc and free. | |
535 | dnl # Then at module unload time a report to the console will be printed | |
536 | dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist | |
537 | dnl # and provide an easy way to inspect the kmem based slab. | |
538 | dnl # | |
57d86234 | 539 | AC_DEFUN([SPL_AC_DEBUG_KMEM], [ |
055ffd98 BB |
540 | AC_ARG_ENABLE([debug-kmem], |
541 | [AS_HELP_STRING([--enable-debug-kmem], | |
542 | [Enable basic kmem accounting @<:@default=yes@:>@])], | |
543 | [], | |
544 | [enable_debug_kmem=yes]) | |
57d86234 | 545 | |
055ffd98 | 546 | AS_IF([test "x$enable_debug_kmem" = xyes], |
3c208a54 BB |
547 | [ |
548 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" | |
549 | DEBUG_KMEM="_with_debug_kmem" | |
550 | AC_DEFINE([DEBUG_KMEM], [1], | |
055ffd98 | 551 | [Define to 1 to enable basic kmem accounting]) |
3c208a54 BB |
552 | ], [ |
553 | DEBUG_KMEM="_without_debug_kmem" | |
554 | ]) | |
055ffd98 | 555 | |
3c208a54 | 556 | AC_SUBST(DEBUG_KMEM) |
055ffd98 BB |
557 | AC_MSG_CHECKING([whether basic kmem accounting is enabled]) |
558 | AC_MSG_RESULT([$enable_debug_kmem]) | |
57d86234 | 559 | ]) |
560 | ||
055ffd98 BB |
561 | dnl # |
562 | dnl # Disabled by default it provides detailed memory tracking. This | |
563 | dnl # feature also requires --enable-debug-kmem to be set. When enabled | |
564 | dnl # not only will total bytes be tracked but also the location of every | |
565 | dnl # alloc and free. When the SPL module is unloaded a list of all leaked | |
566 | dnl # addresses and where they were allocated will be dumped to the console. | |
567 | dnl # Enabling this feature has a significant impact on performance but it | |
568 | dnl # makes finding memory leaks pretty straight forward. | |
569 | dnl # | |
570 | AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ | |
571 | AC_ARG_ENABLE([debug-kmem-tracking], | |
572 | [AS_HELP_STRING([--enable-debug-kmem-tracking], | |
573 | [Enable detailed kmem tracking @<:@default=no@:>@])], | |
574 | [], | |
575 | [enable_debug_kmem_tracking=no]) | |
576 | ||
577 | AS_IF([test "x$enable_debug_kmem_tracking" = xyes], | |
3c208a54 BB |
578 | [ |
579 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" | |
580 | DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" | |
581 | AC_DEFINE([DEBUG_KMEM_TRACKING], [1], | |
055ffd98 | 582 | [Define to 1 to enable detailed kmem tracking]) |
3c208a54 BB |
583 | ], [ |
584 | DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" | |
585 | ]) | |
055ffd98 | 586 | |
3c208a54 | 587 | AC_SUBST(DEBUG_KMEM_TRACKING) |
055ffd98 BB |
588 | AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) |
589 | AC_MSG_RESULT([$enable_debug_kmem_tracking]) | |
57d86234 | 590 | ]) |
591 | ||
592 | dnl # | |
593 | dnl # SPL_LINUX_CONFTEST | |
594 | dnl # | |
595 | AC_DEFUN([SPL_LINUX_CONFTEST], [ | |
dbe561d8 | 596 | cat confdefs.h - <<_ACEOF >conftest.c |
57d86234 | 597 | $1 |
598 | _ACEOF | |
599 | ]) | |
600 | ||
601 | dnl # | |
602 | dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY]) | |
603 | dnl # | |
604 | m4_define([SPL_LANG_PROGRAM], [ | |
605 | $1 | |
606 | int | |
607 | main (void) | |
608 | { | |
609 | dnl Do *not* indent the following line: there may be CPP directives. | |
610 | dnl Don't move the `;' right after for the same reason. | |
611 | $2 | |
612 | ; | |
613 | return 0; | |
614 | } | |
615 | ]) | |
616 | ||
617 | dnl # | |
618 | dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE | |
619 | dnl # | |
620 | AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [ | |
c5f70460 | 621 | m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])]) |
df7cc5bc | 622 | rm -Rf build && mkdir -p build && touch build/conftest.mod.c |
c5f70460 | 623 | echo "obj-m := conftest.o" >build/Makefile |
df7cc5bc ED |
624 | modpost_flag='' |
625 | test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage | |
c5f70460 | 626 | AS_IF( |
df7cc5bc ED |
627 | [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 $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])], |
628 | [$4], | |
629 | [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] | |
c5f70460 BB |
630 | ) |
631 | rm -Rf build | |
57d86234 | 632 | ]) |
633 | ||
634 | dnl # | |
635 | dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE | |
636 | dnl # | |
637 | AC_DEFUN([SPL_LINUX_TRY_COMPILE], | |
638 | [SPL_LINUX_COMPILE_IFELSE( | |
d50bd9e2 | 639 | [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])], |
640 | [modules], | |
641 | [test -s build/conftest.o], | |
642 | [$3], [$4]) | |
57d86234 | 643 | ]) |
644 | ||
57d86234 | 645 | dnl # |
646 | dnl # SPL_CHECK_SYMBOL_EXPORT | |
647 | dnl # check symbol exported or not | |
648 | dnl # | |
723aa3b0 | 649 | AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [ |
2e0e7e69 BB |
650 | grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ |
651 | $LINUX_OBJ/Module*.symvers 2>/dev/null | |
57d86234 | 652 | rc=$? |
653 | if test $rc -ne 0; then | |
654 | export=0 | |
655 | for file in $2; do | |
2e0e7e69 BB |
656 | grep -q -E "EXPORT_SYMBOL.*($1)" \ |
657 | "$LINUX_OBJ/$file" 2>/dev/null | |
57d86234 | 658 | rc=$? |
723aa3b0 ED |
659 | if test $rc -eq 0; then |
660 | export=1 | |
661 | break; | |
662 | fi | |
57d86234 | 663 | done |
723aa3b0 | 664 | if test $export -eq 0; then : |
57d86234 | 665 | $4 |
723aa3b0 | 666 | else : |
57d86234 | 667 | $3 |
668 | fi | |
723aa3b0 | 669 | else : |
57d86234 | 670 | $3 |
671 | fi | |
672 | ]) | |
673 | ||
723aa3b0 ED |
674 | dnl # |
675 | dnl # SPL_LINUX_TRY_COMPILE_SYMBOL | |
676 | dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT | |
677 | dnl # is called if not compiling for builtin | |
678 | dnl # | |
679 | AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [ | |
680 | SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1]) | |
681 | if test $rc -ne 0; then : | |
682 | $6 | |
683 | else | |
684 | if test "x$enable_linux_builtin" != xyes; then | |
685 | SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1]) | |
686 | fi | |
687 | if test $rc -ne 0; then : | |
688 | $6 | |
689 | else : | |
690 | $5 | |
691 | fi | |
692 | fi | |
693 | ]) | |
694 | ||
12ff95ff BB |
695 | dnl # |
696 | dnl # SPL_CHECK_SYMBOL_HEADER | |
697 | dnl # check if a symbol prototype is defined in listed headers. | |
698 | dnl # | |
699 | AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [ | |
700 | AC_MSG_CHECKING([whether symbol $1 exists in header]) | |
701 | header=0 | |
702 | for file in $3; do | |
703 | grep -q "$2" "$LINUX/$file" 2>/dev/null | |
704 | rc=$? | |
723aa3b0 ED |
705 | if test $rc -eq 0; then |
706 | header=1 | |
707 | break; | |
708 | fi | |
12ff95ff BB |
709 | done |
710 | if test $header -eq 0; then | |
711 | AC_MSG_RESULT([no]) | |
712 | $5 | |
713 | else | |
714 | AC_MSG_RESULT([yes]) | |
715 | $4 | |
716 | fi | |
717 | ]) | |
718 | ||
86de8532 | 719 | dnl # |
720 | dnl # SPL_CHECK_HEADER | |
721 | dnl # check whether header exists and define HAVE_$2_HEADER | |
722 | dnl # | |
723 | AC_DEFUN([SPL_CHECK_HEADER], | |
724 | [AC_MSG_CHECKING([whether header $1 exists]) | |
725 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 726 | #include <$1> |
86de8532 | 727 | ],[ |
728 | return 0; | |
729 | ],[ | |
730 | AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists]) | |
731 | AC_MSG_RESULT(yes) | |
732 | $3 | |
733 | ],[ | |
734 | AC_MSG_RESULT(no) | |
735 | $4 | |
736 | ]) | |
737 | ]) | |
6a6cafbe | 738 | |
0408008b ED |
739 | dnl # |
740 | dnl # Basic toolchain sanity check. | |
741 | dnl # | |
742 | AC_DEFUN([SPL_AC_TEST_MODULE], | |
743 | [AC_MSG_CHECKING([whether modules can be built]) | |
744 | SPL_LINUX_TRY_COMPILE([],[],[ | |
745 | AC_MSG_RESULT([yes]) | |
746 | ],[ | |
747 | AC_MSG_RESULT([no]) | |
748 | if test "x$enable_linux_builtin" != xyes; then | |
749 | AC_MSG_ERROR([*** Unable to build an empty module.]) | |
750 | else | |
751 | AC_MSG_ERROR([ | |
752 | *** Unable to build an empty module. | |
753 | *** Please run 'make scripts' inside the kernel source tree.]) | |
754 | fi | |
755 | ]) | |
756 | ]) | |
757 | ||
57d86234 | 758 | dnl # |
d04c8a56 BB |
759 | dnl # Use the atomic implemenation based on global spinlocks. This |
760 | dnl # should only be needed by 32-bit kernels which do not provide | |
761 | dnl # the atomic64_* API. It may be optionally enabled as a fallback | |
762 | dnl # if problems are observed with the direct mapping to the native | |
763 | dnl # Linux atomic operations. You may not disable atomic spinlocks | |
764 | dnl # if you kernel does not an atomic64_* API. | |
57d86234 | 765 | dnl # |
d04c8a56 BB |
766 | AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ |
767 | AC_ARG_ENABLE([atomic-spinlocks], | |
768 | [AS_HELP_STRING([--enable-atomic-spinlocks], | |
769 | [Atomic types use spinlocks @<:@default=check@:>@])], | |
770 | [], | |
771 | [enable_atomic_spinlocks=check]) | |
57d86234 | 772 | |
a0f6da3d | 773 | SPL_LINUX_TRY_COMPILE([ |
dd3678fc | 774 | #include <linux/fs.h> |
a0f6da3d | 775 | ],[ |
03318641 | 776 | atomic64_t *ptr __attribute__ ((unused)); |
a0f6da3d | 777 | ],[ |
d04c8a56 | 778 | have_atomic64_t=yes |
a0f6da3d | 779 | AC_DEFINE(HAVE_ATOMIC64_T, 1, |
d04c8a56 | 780 | [kernel defines atomic64_t]) |
a0f6da3d | 781 | ],[ |
d04c8a56 BB |
782 | have_atomic64_t=no |
783 | ]) | |
784 | ||
785 | AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [ | |
786 | AS_IF([test "x$have_atomic64_t" = xyes], [ | |
787 | enable_atomic_spinlocks=no | |
788 | ],[ | |
789 | enable_atomic_spinlocks=yes | |
790 | ]) | |
a0f6da3d | 791 | ]) |
d04c8a56 BB |
792 | |
793 | AS_IF([test "x$enable_atomic_spinlocks" = xyes], [ | |
794 | AC_DEFINE([ATOMIC_SPINLOCK], [1], | |
795 | [Atomic types use spinlocks]) | |
796 | ],[ | |
797 | AS_IF([test "x$have_atomic64_t" = xno], [ | |
798 | AC_MSG_FAILURE( | |
799 | [--disable-atomic-spinlocks given but required atomic64 support is unavailable]) | |
800 | ]) | |
801 | ]) | |
802 | ||
803 | AC_MSG_CHECKING([whether atomic types use spinlocks]) | |
804 | AC_MSG_RESULT([$enable_atomic_spinlocks]) | |
805 | ||
806 | AC_MSG_CHECKING([whether kernel defines atomic64_t]) | |
807 | AC_MSG_RESULT([$have_atomic64_t]) | |
a0f6da3d | 808 | ]) |
809 | ||
302b88e6 BB |
810 | dnl # |
811 | dnl # 2.6.24 API change, | |
812 | dnl # check if atomic64_cmpxchg is defined | |
813 | dnl # | |
814 | AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG], | |
815 | [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg]) | |
816 | SPL_LINUX_TRY_COMPILE([ | |
dd3678fc | 817 | #include <linux/fs.h> |
302b88e6 BB |
818 | ],[ |
819 | atomic64_cmpxchg((atomic64_t *)NULL, 0, 0); | |
820 | ],[ | |
821 | AC_MSG_RESULT([yes]) | |
822 | AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1, | |
823 | [kernel defines atomic64_cmpxchg]) | |
824 | ],[ | |
825 | AC_MSG_RESULT([no]) | |
826 | ]) | |
827 | ]) | |
828 | ||
829 | dnl # | |
830 | dnl # 2.6.24 API change, | |
831 | dnl # check if atomic64_xchg is defined | |
832 | dnl # | |
833 | AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG], | |
834 | [AC_MSG_CHECKING([whether kernel defines atomic64_xchg]) | |
835 | SPL_LINUX_TRY_COMPILE([ | |
dd3678fc | 836 | #include <linux/fs.h> |
302b88e6 BB |
837 | ],[ |
838 | atomic64_xchg((atomic64_t *)NULL, 0); | |
839 | ],[ | |
840 | AC_MSG_RESULT([yes]) | |
841 | AC_DEFINE(HAVE_ATOMIC64_XCHG, 1, | |
842 | [kernel defines atomic64_xchg]) | |
843 | ],[ | |
844 | AC_MSG_RESULT([no]) | |
845 | ]) | |
846 | ]) | |
847 | ||
d04c8a56 BB |
848 | dnl # |
849 | dnl # 2.6.24 API change, | |
850 | dnl # check if uintptr_t typedef is defined | |
851 | dnl # | |
852 | AC_DEFUN([SPL_AC_TYPE_UINTPTR_T], | |
853 | [AC_MSG_CHECKING([whether kernel defines uintptr_t]) | |
854 | SPL_LINUX_TRY_COMPILE([ | |
855 | #include <linux/types.h> | |
856 | ],[ | |
03318641 | 857 | uintptr_t *ptr __attribute__ ((unused)); |
d04c8a56 BB |
858 | ],[ |
859 | AC_MSG_RESULT([yes]) | |
860 | AC_DEFINE(HAVE_UINTPTR_T, 1, | |
861 | [kernel defines uintptr_t]) | |
862 | ],[ | |
863 | AC_MSG_RESULT([no]) | |
864 | ]) | |
865 | ]) | |
866 | ||
57d86234 | 867 | dnl # |
3d061e9d | 868 | dnl # 2.6.21 API change, |
57d86234 | 869 | dnl # 'register_sysctl_table' use only one argument instead of two |
870 | dnl # | |
871 | AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL], | |
872 | [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args]) | |
873 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 874 | #include <linux/sysctl.h> |
57d86234 | 875 | ],[ |
03318641 | 876 | (void) register_sysctl_table(NULL, 0); |
57d86234 | 877 | ],[ |
d50bd9e2 | 878 | AC_MSG_RESULT(yes) |
879 | AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1, | |
880 | [register_sysctl_table() wants 2 args]) | |
57d86234 | 881 | ],[ |
d50bd9e2 | 882 | AC_MSG_RESULT(no) |
57d86234 | 883 | ]) |
884 | ]) | |
885 | ||
c3d9c0df | 886 | AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[ |
23aa63cb BB |
887 | tmp_flags="$EXTRA_KCFLAGS" |
888 | EXTRA_KCFLAGS="-Werror" | |
c3d9c0df RY |
889 | dnl # |
890 | dnl # 2.6.23 to 2.6.34 API change | |
891 | dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask) | |
892 | dnl # | |
893 | AC_MSG_CHECKING([whether old 2-argument shrinker exists]) | |
23aa63cb BB |
894 | SPL_LINUX_TRY_COMPILE([ |
895 | #include <linux/mm.h> | |
896 | ||
c3d9c0df | 897 | int shrinker_cb(int nr_to_scan, gfp_t gfp_mask); |
23aa63cb BB |
898 | ],[ |
899 | struct shrinker cache_shrinker = { | |
900 | .shrink = shrinker_cb, | |
901 | .seeks = DEFAULT_SEEKS, | |
902 | }; | |
903 | register_shrinker(&cache_shrinker); | |
904 | ],[ | |
905 | AC_MSG_RESULT(yes) | |
c3d9c0df RY |
906 | AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1, |
907 | [old shrinker callback wants 2 args]) | |
23aa63cb BB |
908 | ],[ |
909 | AC_MSG_RESULT(no) | |
c3d9c0df RY |
910 | dnl # |
911 | dnl # 2.6.35 - 2.6.39 API change | |
912 | dnl # ->shrink(struct shrinker *, | |
913 | dnl # int nr_to_scan, gfp_t gfp_mask) | |
914 | dnl # | |
915 | AC_MSG_CHECKING([whether old 3-argument shrinker exists]) | |
916 | SPL_LINUX_TRY_COMPILE([ | |
917 | #include <linux/mm.h> | |
918 | ||
919 | int shrinker_cb(struct shrinker *, int nr_to_scan, | |
920 | gfp_t gfp_mask); | |
921 | ],[ | |
922 | struct shrinker cache_shrinker = { | |
923 | .shrink = shrinker_cb, | |
924 | .seeks = DEFAULT_SEEKS, | |
925 | }; | |
926 | register_shrinker(&cache_shrinker); | |
927 | ],[ | |
928 | AC_MSG_RESULT(yes) | |
929 | AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, | |
930 | [old shrinker callback wants 3 args]) | |
931 | ],[ | |
932 | AC_MSG_RESULT(no) | |
933 | dnl # | |
934 | dnl # 3.0 - 3.11 API change | |
935 | dnl # ->shrink(struct shrinker *, | |
936 | dnl # struct shrink_control *sc) | |
937 | dnl # | |
938 | AC_MSG_CHECKING( | |
939 | [whether new 2-argument shrinker exists]) | |
940 | SPL_LINUX_TRY_COMPILE([ | |
941 | #include <linux/mm.h> | |
942 | ||
943 | int shrinker_cb(struct shrinker *, | |
944 | struct shrink_control *sc); | |
945 | ],[ | |
946 | struct shrinker cache_shrinker = { | |
947 | .shrink = shrinker_cb, | |
948 | .seeks = DEFAULT_SEEKS, | |
949 | }; | |
950 | register_shrinker(&cache_shrinker); | |
951 | ],[ | |
952 | AC_MSG_RESULT(yes) | |
953 | AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1, | |
954 | [new shrinker callback wants 2 args]) | |
955 | ],[ | |
956 | AC_MSG_RESULT(no) | |
957 | dnl # | |
958 | dnl # 3.12 API change, | |
959 | dnl # ->shrink() is logically split in to | |
960 | dnl # ->count_objects() and ->scan_objects() | |
961 | dnl # | |
962 | AC_MSG_CHECKING( | |
963 | [whether ->count_objects callback exists]) | |
964 | SPL_LINUX_TRY_COMPILE([ | |
965 | #include <linux/mm.h> | |
966 | ||
967 | unsigned long shrinker_cb( | |
968 | struct shrinker *, | |
969 | struct shrink_control *sc); | |
970 | ],[ | |
971 | struct shrinker cache_shrinker = { | |
972 | .count_objects = shrinker_cb, | |
973 | .scan_objects = shrinker_cb, | |
974 | .seeks = DEFAULT_SEEKS, | |
975 | }; | |
976 | register_shrinker(&cache_shrinker); | |
977 | ],[ | |
978 | AC_MSG_RESULT(yes) | |
979 | AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, | |
980 | 1, [->count_objects exists]) | |
981 | ],[ | |
982 | AC_MSG_ERROR(error) | |
983 | ]) | |
984 | ]) | |
985 | ]) | |
23aa63cb BB |
986 | ]) |
987 | EXTRA_KCFLAGS="$tmp_flags" | |
988 | ]) | |
989 | ||
57d86234 | 990 | dnl # |
991 | dnl # Custom SPL patch may export this system it is not required | |
992 | dnl # | |
723aa3b0 ED |
993 | AC_DEFUN([SPL_AC_TASK_CURR], |
994 | [AC_MSG_CHECKING([whether task_curr() is available]) | |
995 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
996 | #include <linux/sched.h> | |
997 | ], [ | |
998 | task_curr(NULL); | |
999 | ], [task_curr], [kernel/sched.c], [ | |
1000 | AC_MSG_RESULT(yes) | |
1001 | AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available]) | |
1002 | ], [ | |
1003 | AC_MSG_RESULT(no) | |
1004 | ]) | |
57d86234 | 1005 | ]) |
1006 | ||
1007 | dnl # | |
3d061e9d | 1008 | dnl # 2.6.19 API change, |
57d86234 | 1009 | dnl # Use CTL_UNNUMBERED when binary sysctl is not required |
1010 | dnl # | |
1011 | AC_DEFUN([SPL_AC_CTL_UNNUMBERED], | |
1012 | [AC_MSG_CHECKING([whether unnumbered sysctl support exists]) | |
1013 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 1014 | #include <linux/sysctl.h> |
57d86234 | 1015 | ],[ |
1016 | #ifndef CTL_UNNUMBERED | |
1017 | #error CTL_UNNUMBERED undefined | |
1018 | #endif | |
1019 | ],[ | |
d50bd9e2 | 1020 | AC_MSG_RESULT(yes) |
1021 | AC_DEFINE(HAVE_CTL_UNNUMBERED, 1, | |
1022 | [unnumbered sysctl support exists]) | |
57d86234 | 1023 | ],[ |
d50bd9e2 | 1024 | AC_MSG_RESULT(no) |
57d86234 | 1025 | ]) |
1026 | ]) | |
877a32e9 | 1027 | |
79a3bf13 BB |
1028 | dnl # |
1029 | dnl # 2.6.33 API change, | |
1030 | dnl # Removed .ctl_name from struct ctl_table. | |
1031 | dnl # | |
1032 | AC_DEFUN([SPL_AC_CTL_NAME], [ | |
1033 | AC_MSG_CHECKING([whether struct ctl_table has ctl_name]) | |
1034 | SPL_LINUX_TRY_COMPILE([ | |
1035 | #include <linux/sysctl.h> | |
1036 | ],[ | |
03318641 | 1037 | struct ctl_table ctl __attribute__ ((unused)); |
79a3bf13 BB |
1038 | ctl.ctl_name = 0; |
1039 | ],[ | |
1040 | AC_MSG_RESULT(yes) | |
1041 | AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name]) | |
1042 | ],[ | |
1043 | AC_MSG_RESULT(no) | |
1044 | ]) | |
1045 | ]) | |
1046 | ||
877a32e9 | 1047 | dnl # |
1048 | dnl # 2.6.16 API change. | |
1049 | dnl # Check if 'fls64()' is available | |
1050 | dnl # | |
1051 | AC_DEFUN([SPL_AC_FLS64], | |
6a6cafbe | 1052 | [AC_MSG_CHECKING([whether fls64() is available]) |
1053 | SPL_LINUX_TRY_COMPILE([ | |
1054 | #include <linux/bitops.h> | |
1055 | ],[ | |
1056 | return fls64(0); | |
1057 | ],[ | |
1058 | AC_MSG_RESULT(yes) | |
1059 | AC_DEFINE(HAVE_FLS64, 1, [fls64() is available]) | |
1060 | ],[ | |
1061 | AC_MSG_RESULT(no) | |
1062 | ]) | |
877a32e9 | 1063 | ]) |
46c685d0 | 1064 | |
1065 | dnl # | |
1066 | dnl # 2.6.18 API change, check whether device_create() is available. | |
1067 | dnl # Device_create() was introduced in 2.6.18 and depricated | |
1068 | dnl # class_device_create() which was fully removed in 2.6.26. | |
1069 | dnl # | |
723aa3b0 ED |
1070 | AC_DEFUN([SPL_AC_DEVICE_CREATE], |
1071 | [AC_MSG_CHECKING([whether device_create() is available]) | |
1072 | SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [ | |
1073 | AC_MSG_RESULT(yes) | |
1074 | AC_DEFINE(HAVE_DEVICE_CREATE, 1, | |
1075 | [device_create() is available]) | |
1076 | ], [ | |
1077 | AC_MSG_RESULT(no) | |
1078 | ]) | |
46c685d0 | 1079 | ]) |
1080 | ||
8123ac4f BB |
1081 | dnl # |
1082 | dnl # 2.6.27 API change, | |
1083 | dnl # device_create() uses 5 args, new 'drvdata' argument. | |
1084 | dnl # | |
1085 | AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [ | |
1086 | AC_MSG_CHECKING([whether device_create() wants 5 args]) | |
1087 | tmp_flags="$EXTRA_KCFLAGS" | |
1088 | EXTRA_KCFLAGS="-Werror" | |
1089 | SPL_LINUX_TRY_COMPILE([ | |
1090 | #include <linux/device.h> | |
1091 | ],[ | |
1092 | device_create(NULL, NULL, 0, NULL, "%d", 1); | |
1093 | ],[ | |
1094 | AC_MSG_RESULT(yes) | |
1095 | AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1, | |
1096 | [device_create wants 5 args]) | |
1097 | ],[ | |
1098 | AC_MSG_RESULT(no) | |
1099 | ]) | |
1100 | EXTRA_KCFLAGS="$tmp_flags" | |
1101 | ]) | |
1102 | ||
46c685d0 | 1103 | dnl # |
1104 | dnl # 2.6.13 API change, check whether class_device_create() is available. | |
1105 | dnl # Class_device_create() was introduced in 2.6.13 and depricated | |
1106 | dnl # class_simple_device_add() which was fully removed in 2.6.13. | |
1107 | dnl # | |
723aa3b0 ED |
1108 | AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE], |
1109 | [AC_MSG_CHECKING([whether class_device_create() is available]) | |
1110 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1111 | #include <linux/device.h> | |
1112 | ], [ | |
1113 | class_device_create(NULL, NULL, 0, NULL, NULL); | |
1114 | ], [class_device_create], [drivers/base/class.c], [ | |
1115 | AC_MSG_RESULT(yes) | |
1116 | AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1, | |
1117 | [class_device_create() is available]) | |
1118 | ], [ | |
1119 | AC_MSG_RESULT(no) | |
1120 | ]) | |
46c685d0 | 1121 | ]) |
6a6cafbe | 1122 | |
6a6cafbe | 1123 | dnl # |
1124 | dnl # 2.6.26 API change, set_normalized_timespec() is exported. | |
1125 | dnl # | |
723aa3b0 ED |
1126 | AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT], |
1127 | [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export]) | |
1128 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1129 | #include <linux/time.h> | |
1130 | ], [ | |
1131 | set_normalized_timespec(NULL, 0, 0); | |
1132 | ], [set_normalized_timespec], [kernel/time.c], [ | |
1133 | AC_MSG_RESULT(yes) | |
1134 | AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1, | |
1135 | [set_normalized_timespec() is available as export]) | |
1136 | ], [ | |
1137 | AC_MSG_RESULT(no) | |
1138 | ]) | |
6a6cafbe | 1139 | ]) |
1140 | ||
1141 | dnl # | |
1142 | dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c | |
1143 | dnl # previously it was available in time.h as an inline. | |
1144 | dnl # | |
86de8532 | 1145 | AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [ |
1146 | AC_MSG_CHECKING([whether set_normalized_timespec() is an inline]) | |
6a6cafbe | 1147 | SPL_LINUX_TRY_COMPILE([ |
1148 | #include <linux/time.h> | |
6a6cafbe | 1149 | void set_normalized_timespec(struct timespec *ts, |
25557fd8 | 1150 | time_t sec, long nsec) { } |
1151 | ], | |
1152 | [], | |
1153 | [ | |
6a6cafbe | 1154 | AC_MSG_RESULT(no) |
1155 | ],[ | |
1156 | AC_MSG_RESULT(yes) | |
1157 | AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1, | |
1158 | [set_normalized_timespec() is available as inline]) | |
1159 | ]) | |
1160 | ]) | |
1161 | ||
1162 | dnl # | |
1163 | dnl # 2.6.18 API change, | |
1164 | dnl # timespec_sub() inline function available in linux/time.h | |
1165 | dnl # | |
86de8532 | 1166 | AC_DEFUN([SPL_AC_TIMESPEC_SUB], [ |
1167 | AC_MSG_CHECKING([whether timespec_sub() is available]) | |
6a6cafbe | 1168 | SPL_LINUX_TRY_COMPILE([ |
1169 | #include <linux/time.h> | |
1170 | ],[ | |
03318641 BB |
1171 | struct timespec a = { 0 }; |
1172 | struct timespec b = { 0 }; | |
1173 | struct timespec c __attribute__ ((unused)); | |
6a6cafbe | 1174 | c = timespec_sub(a, b); |
1175 | ],[ | |
1176 | AC_MSG_RESULT(yes) | |
1177 | AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available]) | |
1178 | ],[ | |
1179 | AC_MSG_RESULT(no) | |
1180 | ]) | |
1181 | ]) | |
1182 | ||
86de8532 | 1183 | dnl # |
3d061e9d | 1184 | dnl # 2.6.19 API change, |
1185 | dnl # check if init_utsname() is available in linux/utsname.h | |
1186 | dnl # | |
1187 | AC_DEFUN([SPL_AC_INIT_UTSNAME], [ | |
1188 | AC_MSG_CHECKING([whether init_utsname() is available]) | |
1189 | SPL_LINUX_TRY_COMPILE([ | |
1190 | #include <linux/utsname.h> | |
1191 | ],[ | |
03318641 BB |
1192 | struct new_utsname *a __attribute__ ((unused)); |
1193 | a = init_utsname(); | |
3d061e9d | 1194 | ],[ |
1195 | AC_MSG_RESULT(yes) | |
1196 | AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available]) | |
1197 | ],[ | |
1198 | AC_MSG_RESULT(no) | |
1199 | ]) | |
1200 | ]) | |
1201 | ||
3d061e9d | 1202 | dnl # |
1203 | dnl # 2.6.18 API change, | |
1204 | dnl # added linux/uaccess.h | |
322640b7 | 1205 | dnl # |
1206 | AC_DEFUN([SPL_AC_UACCESS_HEADER], [ | |
1207 | SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], []) | |
1208 | ]) | |
3d061e9d | 1209 | |
1210 | dnl # | |
1211 | dnl # 2.6.12 API change, | |
1212 | dnl # check whether 'kmalloc_node()' is available. | |
1213 | dnl # | |
1214 | AC_DEFUN([SPL_AC_KMALLOC_NODE], [ | |
1215 | AC_MSG_CHECKING([whether kmalloc_node() is available]) | |
1216 | SPL_LINUX_TRY_COMPILE([ | |
1217 | #include <linux/slab.h> | |
1218 | ],[ | |
03318641 BB |
1219 | void *a __attribute__ ((unused)); |
1220 | a = kmalloc_node(1, GFP_KERNEL, 0); | |
3d061e9d | 1221 | ],[ |
1222 | AC_MSG_RESULT(yes) | |
1223 | AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available]) | |
1224 | ],[ | |
1225 | AC_MSG_RESULT(no) | |
1226 | ]) | |
1227 | ]) | |
1228 | ||
1229 | dnl # | |
1230 | dnl # 2.6.9 API change, | |
1231 | dnl # check whether 'monotonic_clock()' is available it may | |
1232 | dnl # be available for some archs but not others. | |
1233 | dnl # | |
723aa3b0 ED |
1234 | AC_DEFUN([SPL_AC_MONOTONIC_CLOCK], |
1235 | [AC_MSG_CHECKING([whether monotonic_clock() is available]) | |
1236 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1237 | #include <linux/timex.h> | |
1238 | ], [ | |
1239 | monotonic_clock(); | |
1240 | ], [monotonic_clock], [], [ | |
1241 | AC_MSG_RESULT(yes) | |
1242 | AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, | |
1243 | [monotonic_clock() is available]) | |
1244 | ], [ | |
1245 | AC_MSG_RESULT(no) | |
1246 | ]) | |
3d061e9d | 1247 | ]) |
1248 | ||
1249 | dnl # | |
1250 | dnl # 2.6.16 API change, | |
1251 | dnl # check whether 'struct inode' has i_mutex | |
1252 | dnl # | |
1253 | AC_DEFUN([SPL_AC_INODE_I_MUTEX], [ | |
1254 | AC_MSG_CHECKING([whether struct inode has i_mutex]) | |
1255 | SPL_LINUX_TRY_COMPILE([ | |
1256 | #include <linux/fs.h> | |
1257 | #include <linux/mutex.h> | |
1258 | ],[ | |
1259 | struct inode i; | |
1260 | mutex_init(&i.i_mutex); | |
1261 | ],[ | |
1262 | AC_MSG_RESULT(yes) | |
1263 | AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex]) | |
1264 | ],[ | |
1265 | AC_MSG_RESULT(no) | |
1266 | ]) | |
1267 | ]) | |
b61a6e8b | 1268 | |
4d54fdee BB |
1269 | dnl # |
1270 | dnl # 2.6.29 API change, | |
1271 | dnl # Adaptive mutexs introduced. | |
1272 | dnl # | |
1273 | AC_DEFUN([SPL_AC_MUTEX_OWNER], [ | |
1274 | AC_MSG_CHECKING([whether struct mutex has owner]) | |
1275 | SPL_LINUX_TRY_COMPILE([ | |
1276 | #include <linux/mutex.h> | |
1277 | ],[ | |
03318641 | 1278 | struct mutex mtx __attribute__ ((unused)); |
4d54fdee BB |
1279 | mtx.owner = NULL; |
1280 | ],[ | |
1281 | AC_MSG_RESULT(yes) | |
1282 | AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner]) | |
1283 | ],[ | |
1284 | AC_MSG_RESULT(no) | |
1285 | ]) | |
1286 | ]) | |
1287 | ||
86fd39f3 BB |
1288 | dnl # |
1289 | dnl # 2.6.39 API change, | |
1290 | dnl # Owner type change. A Linux mutex prior to 2.6.39 would store | |
1291 | dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES | |
1292 | dnl # was defined. As of 2.6.39 this was changed to a task_struct | |
1293 | dnl # pointer which frankly makes a lot more sense. | |
1294 | dnl # | |
1295 | AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [ | |
1296 | AC_MSG_CHECKING([whether struct mutex owner is a task_struct]) | |
1297 | tmp_flags="$EXTRA_KCFLAGS" | |
1298 | EXTRA_KCFLAGS="-Werror" | |
1299 | SPL_LINUX_TRY_COMPILE([ | |
1300 | #include <linux/mutex.h> | |
a0625691 | 1301 | #include <linux/sched.h> |
86fd39f3 BB |
1302 | ],[ |
1303 | struct mutex mtx __attribute__ ((unused)); | |
1304 | mtx.owner = current; | |
1305 | ],[ | |
1306 | AC_MSG_RESULT(yes) | |
1307 | AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1, | |
1308 | [struct mutex owner is a task_struct]) | |
1309 | ],[ | |
1310 | AC_MSG_RESULT(no) | |
1311 | ]) | |
1312 | EXTRA_KCFLAGS="$tmp_flags" | |
1313 | ]) | |
1314 | ||
6c9433c1 BB |
1315 | dnl # |
1316 | dnl # 2.6.18 API change, | |
1317 | dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h, | |
1318 | dnl # as part of the mutex validator. Fallback to using 'mutex_lock()' | |
1319 | dnl # if the mutex validator is disabled or otherwise unavailable. | |
1320 | dnl # | |
1321 | AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [ | |
1322 | AC_MSG_CHECKING([whether mutex_lock_nested() is available]) | |
1323 | SPL_LINUX_TRY_COMPILE([ | |
1324 | #include <linux/mutex.h> | |
1325 | ],[ | |
1326 | struct mutex mutex; | |
1327 | mutex_init(&mutex); | |
1328 | mutex_lock_nested(&mutex, 0); | |
1329 | ],[ | |
1330 | AC_MSG_RESULT(yes) | |
1331 | AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1, | |
1332 | [mutex_lock_nested() is available]) | |
1333 | ],[ | |
1334 | AC_MSG_RESULT(no) | |
1335 | ]) | |
1336 | ]) | |
1337 | ||
31a033ec BB |
1338 | dnl # |
1339 | dnl # 2.6.27 API change, | |
1340 | dnl # on_each_cpu() uses 3 args, no 'retry' argument | |
1341 | dnl # | |
1342 | AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [ | |
1343 | AC_MSG_CHECKING([whether on_each_cpu() wants 3 args]) | |
1344 | SPL_LINUX_TRY_COMPILE([ | |
050cd84e | 1345 | #include <linux/interrupt.h> |
31a033ec | 1346 | #include <linux/smp.h> |
050cd84e BB |
1347 | |
1348 | void on_each_cpu_func(void *data) { return; } | |
31a033ec | 1349 | ],[ |
050cd84e | 1350 | on_each_cpu(on_each_cpu_func, NULL, 0); |
31a033ec BB |
1351 | ],[ |
1352 | AC_MSG_RESULT(yes) | |
1353 | AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1, | |
1354 | [on_each_cpu wants 3 args]) | |
1355 | ],[ | |
1356 | AC_MSG_RESULT(no) | |
1357 | ]) | |
1358 | ]) | |
36b313da BB |
1359 | |
1360 | dnl # | |
d1ff2312 BB |
1361 | dnl # 2.6.18 API change, |
1362 | dnl # kallsyms_lookup_name no longer exported | |
1363 | dnl # | |
723aa3b0 ED |
1364 | AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME], |
1365 | [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available]) | |
1366 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1367 | #include <linux/kallsyms.h> | |
1368 | ], [ | |
1369 | kallsyms_lookup_name(NULL); | |
1370 | ], [kallsyms_lookup_name], [], [ | |
1371 | AC_MSG_RESULT(yes) | |
1372 | AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1, | |
1373 | [kallsyms_lookup_name() is available]) | |
1374 | ], [ | |
1375 | AC_MSG_RESULT(no) | |
1376 | ]) | |
d1ff2312 BB |
1377 | ]) |
1378 | ||
1379 | dnl # | |
e11d6c5f BB |
1380 | dnl # Proposed API change, |
1381 | dnl # This symbol is not available in stock kernels. You may build a | |
1382 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1383 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1384 | dnl # your environment this is recommended. | |
d1ff2312 | 1385 | dnl # |
723aa3b0 ED |
1386 | AC_DEFUN([SPL_AC_GET_VMALLOC_INFO], |
1387 | [AC_MSG_CHECKING([whether get_vmalloc_info() is available]) | |
1388 | SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [ | |
1389 | AC_MSG_RESULT(yes) | |
1390 | AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1, | |
1391 | [get_vmalloc_info() is available]) | |
1392 | ], [ | |
1393 | AC_MSG_RESULT(no) | |
1394 | ]) | |
d1ff2312 BB |
1395 | ]) |
1396 | ||
c02ab72f YS |
1397 | dnl # |
1398 | dnl # 3.10 API change, | |
1399 | dnl # struct vmalloc_info is now declared in linux/vmalloc.h | |
1400 | dnl # | |
1401 | AC_DEFUN([SPL_AC_VMALLOC_INFO], [ | |
1402 | AC_MSG_CHECKING([whether struct vmalloc_info is declared]) | |
1403 | SPL_LINUX_TRY_COMPILE([ | |
1404 | #include <linux/vmalloc.h> | |
1405 | struct vmalloc_info { void *a; }; | |
1406 | ],[ | |
1407 | return 0; | |
1408 | ],[ | |
1409 | AC_MSG_RESULT(no) | |
1410 | ],[ | |
1411 | AC_MSG_RESULT(yes) | |
1412 | AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes]) | |
1413 | ]) | |
1414 | ]) | |
1415 | ||
1ddf9722 YS |
1416 | dnl # |
1417 | dnl # 3.10 API change, | |
1418 | dnl # PDE is replaced by PDE_DATA | |
1419 | dnl # | |
1420 | AC_DEFUN([SPL_AC_PDE_DATA], [ | |
1421 | AC_MSG_CHECKING([whether PDE_DATA() is available]) | |
1422 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1423 | #include <linux/proc_fs.h> | |
1424 | ], [ | |
1425 | PDE_DATA(NULL); | |
1426 | ], [PDE_DATA], [], [ | |
1427 | AC_MSG_RESULT(yes) | |
1428 | AC_DEFINE(HAVE_PDE_DATA, 1, [yes]) | |
1429 | ],[ | |
1430 | AC_MSG_RESULT(no) | |
1431 | ]) | |
1432 | ]) | |
1433 | ||
5232d256 BB |
1434 | dnl # |
1435 | dnl # 2.6.17 API change | |
1436 | dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and | |
1437 | dnl # next_zone() are introduced to simplify for_each_zone(). These symbols | |
1438 | dnl # were exported in 2.6.17 for use by modules which was consistent with | |
1439 | dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19 | |
1440 | dnl # the symbols were exported as 'unused', and by 2.6.20 they exports | |
1441 | dnl # were dropped entirely leaving modules no way to directly iterate over | |
1442 | dnl # the zone list. Because we need access to the zone helpers we check | |
1443 | dnl # if the kernel contains the old or new implementation. Then we check | |
1444 | dnl # to see if the symbols we need for each version are available. If they | |
1445 | dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name(). | |
1446 | dnl # | |
1447 | AC_DEFUN([SPL_AC_PGDAT_HELPERS], [ | |
1448 | AC_MSG_CHECKING([whether symbol *_pgdat exist]) | |
1449 | grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null | |
1450 | rc=$? | |
1451 | if test $rc -eq 0; then | |
1452 | AC_MSG_RESULT([yes]) | |
723aa3b0 | 1453 | AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available]) |
5232d256 BB |
1454 | else |
1455 | AC_MSG_RESULT([no]) | |
1456 | fi | |
1457 | ]) | |
1458 | ||
d1ff2312 | 1459 | dnl # |
e11d6c5f BB |
1460 | dnl # Proposed API change, |
1461 | dnl # This symbol is not available in stock kernels. You may build a | |
1462 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1463 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1464 | dnl # your environment this is recommended. | |
36b313da | 1465 | dnl # |
723aa3b0 ED |
1466 | AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT], |
1467 | [AC_MSG_CHECKING([whether first_online_pgdat() is available]) | |
1468 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1469 | #include <linux/mmzone.h> | |
1470 | ], [ | |
1471 | first_online_pgdat(); | |
1472 | ], [first_online_pgdat], [], [ | |
1473 | AC_MSG_RESULT(yes) | |
1474 | AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1, | |
1475 | [first_online_pgdat() is available]) | |
1476 | ], [ | |
1477 | AC_MSG_RESULT(no) | |
1478 | ]) | |
36b313da BB |
1479 | ]) |
1480 | ||
1481 | dnl # | |
e11d6c5f BB |
1482 | dnl # Proposed API change, |
1483 | dnl # This symbol is not available in stock kernels. You may build a | |
1484 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1485 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1486 | dnl # your environment this is recommended. | |
36b313da | 1487 | dnl # |
723aa3b0 ED |
1488 | AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT], |
1489 | [AC_MSG_CHECKING([whether next_online_pgdat() is available]) | |
1490 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1491 | #include <linux/mmzone.h> | |
1492 | ], [ | |
1493 | next_online_pgdat(NULL); | |
1494 | ], [next_online_pgdat], [], [ | |
1495 | AC_MSG_RESULT(yes) | |
1496 | AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1, | |
1497 | [next_online_pgdat() is available]) | |
1498 | ], [ | |
1499 | AC_MSG_RESULT(no) | |
1500 | ]) | |
36b313da BB |
1501 | ]) |
1502 | ||
1503 | dnl # | |
e11d6c5f BB |
1504 | dnl # Proposed API change, |
1505 | dnl # This symbol is not available in stock kernels. You may build a | |
1506 | dnl # custom kernel with the *-spl-export-symbols.patch which will export | |
1507 | dnl # these symbols for use. If your already rolling a custom kernel for | |
1508 | dnl # your environment this is recommended. | |
36b313da | 1509 | dnl # |
723aa3b0 ED |
1510 | AC_DEFUN([SPL_AC_NEXT_ZONE], |
1511 | [AC_MSG_CHECKING([whether next_zone() is available]) | |
1512 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1513 | #include <linux/mmzone.h> | |
1514 | ], [ | |
1515 | next_zone(NULL); | |
1516 | ], [next_zone], [], [ | |
1517 | AC_MSG_RESULT(yes) | |
1518 | AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available]) | |
1519 | ], [ | |
1520 | AC_MSG_RESULT(no) | |
1521 | ]) | |
36b313da | 1522 | ]) |
4ab13d3b | 1523 | |
5232d256 BB |
1524 | dnl # |
1525 | dnl # 2.6.17 API change, | |
1526 | dnl # See SPL_AC_PGDAT_HELPERS for details. | |
1527 | dnl # | |
723aa3b0 ED |
1528 | AC_DEFUN([SPL_AC_PGDAT_LIST], |
1529 | [AC_MSG_CHECKING([whether pgdat_list is available]) | |
1530 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1531 | #include <linux/topology.h> | |
1532 | pg_data_t *tmp = pgdat_list; | |
1533 | ], [], [pgdat_list], [], [ | |
1534 | AC_MSG_RESULT(yes) | |
1535 | AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available]) | |
1536 | ], [ | |
1537 | AC_MSG_RESULT(no) | |
1538 | ]) | |
5232d256 BB |
1539 | ]) |
1540 | ||
96dded38 BB |
1541 | dnl # |
1542 | dnl # 2.6.18 API change, | |
1543 | dnl # First introduced global_page_state() support as an inline. | |
1544 | dnl # | |
1545 | AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [ | |
1546 | AC_MSG_CHECKING([whether global_page_state() is available]) | |
1547 | SPL_LINUX_TRY_COMPILE([ | |
6ae7fef5 | 1548 | #include <linux/mm.h> |
96dded38 | 1549 | ],[ |
03318641 | 1550 | unsigned long state __attribute__ ((unused)); |
6ae7fef5 | 1551 | state = global_page_state(0); |
96dded38 BB |
1552 | ],[ |
1553 | AC_MSG_RESULT(yes) | |
1554 | AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1, | |
1555 | [global_page_state() is available]) | |
1556 | ],[ | |
1557 | AC_MSG_RESULT(no) | |
1558 | ]) | |
1559 | ]) | |
1560 | ||
e11d6c5f | 1561 | dnl # |
6ae7fef5 BB |
1562 | dnl # 2.6.21 API change (plus subsequent naming convention changes), |
1563 | dnl # Public global zone stats now include a free page count. However | |
1564 | dnl # the enumerated names of the counters have changed since this API | |
1565 | dnl # was introduced. We need to deduce the corrent name to use. This | |
1566 | dnl # replaces the priviate get_zone_counts() interface. | |
1567 | dnl # | |
1568 | dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which | |
1569 | dnl # is 2.6.30 as of when this was written. | |
e11d6c5f | 1570 | dnl # |
6ae7fef5 BB |
1571 | AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [ |
1572 | AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available]) | |
e11d6c5f | 1573 | SPL_LINUX_TRY_COMPILE([ |
6ae7fef5 | 1574 | #include <linux/mm.h> |
e11d6c5f | 1575 | ],[ |
03318641 | 1576 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 | 1577 | zsi = NR_FREE_PAGES; |
e11d6c5f BB |
1578 | ],[ |
1579 | AC_MSG_RESULT(yes) | |
6ae7fef5 BB |
1580 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1, |
1581 | [Page state NR_FREE_PAGES is available]) | |
e11d6c5f BB |
1582 | ],[ |
1583 | AC_MSG_RESULT(no) | |
1584 | ]) | |
1585 | ]) | |
a093c6a4 | 1586 | |
6ae7fef5 BB |
1587 | dnl # |
1588 | dnl # 2.6.21 API change (plus subsequent naming convention changes), | |
1589 | dnl # Public global zone stats now include an inactive page count. However | |
1590 | dnl # the enumerated names of the counters have changed since this API | |
1591 | dnl # was introduced. We need to deduce the corrent name to use. This | |
1592 | dnl # replaces the priviate get_zone_counts() interface. | |
1593 | dnl # | |
1594 | dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both | |
1595 | dnl # anonymous and file inactive pages. As of 2.6.28 it was split in | |
1596 | dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE. | |
1597 | dnl # | |
1598 | AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [ | |
1599 | AC_MSG_CHECKING([whether page state NR_INACTIVE is available]) | |
1600 | SPL_LINUX_TRY_COMPILE([ | |
1601 | #include <linux/mm.h> | |
1602 | ],[ | |
03318641 | 1603 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1604 | zsi = NR_INACTIVE; |
1605 | ],[ | |
1606 | AC_MSG_RESULT(yes) | |
1607 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1, | |
1608 | [Page state NR_INACTIVE is available]) | |
1609 | ],[ | |
1610 | AC_MSG_RESULT(no) | |
1611 | ]) | |
1612 | ||
1613 | AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available]) | |
1614 | SPL_LINUX_TRY_COMPILE([ | |
1615 | #include <linux/mm.h> | |
1616 | ],[ | |
03318641 | 1617 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1618 | zsi = NR_INACTIVE_ANON; |
1619 | ],[ | |
1620 | AC_MSG_RESULT(yes) | |
1621 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1, | |
1622 | [Page state NR_INACTIVE_ANON is available]) | |
1623 | ],[ | |
1624 | AC_MSG_RESULT(no) | |
1625 | ]) | |
1626 | ||
1627 | AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available]) | |
1628 | SPL_LINUX_TRY_COMPILE([ | |
1629 | #include <linux/mm.h> | |
1630 | ],[ | |
03318641 | 1631 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1632 | zsi = NR_INACTIVE_FILE; |
1633 | ],[ | |
1634 | AC_MSG_RESULT(yes) | |
1635 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1, | |
1636 | [Page state NR_INACTIVE_FILE is available]) | |
1637 | ],[ | |
1638 | AC_MSG_RESULT(no) | |
1639 | ]) | |
1640 | ]) | |
1641 | ||
1642 | dnl # | |
1643 | dnl # 2.6.21 API change (plus subsequent naming convention changes), | |
1644 | dnl # Public global zone stats now include an active page count. However | |
1645 | dnl # the enumerated names of the counters have changed since this API | |
1646 | dnl # was introduced. We need to deduce the corrent name to use. This | |
1647 | dnl # replaces the priviate get_zone_counts() interface. | |
1648 | dnl # | |
1649 | dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both | |
1650 | dnl # anonymous and file active pages. As of 2.6.28 it was split in | |
1651 | dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE. | |
1652 | dnl # | |
1653 | AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [ | |
1654 | AC_MSG_CHECKING([whether page state NR_ACTIVE is available]) | |
1655 | SPL_LINUX_TRY_COMPILE([ | |
1656 | #include <linux/mm.h> | |
1657 | ],[ | |
03318641 | 1658 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1659 | zsi = NR_ACTIVE; |
1660 | ],[ | |
1661 | AC_MSG_RESULT(yes) | |
1662 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1, | |
1663 | [Page state NR_ACTIVE is available]) | |
1664 | ],[ | |
1665 | AC_MSG_RESULT(no) | |
1666 | ]) | |
1667 | ||
1668 | AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available]) | |
1669 | SPL_LINUX_TRY_COMPILE([ | |
1670 | #include <linux/mm.h> | |
1671 | ],[ | |
03318641 | 1672 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1673 | zsi = NR_ACTIVE_ANON; |
1674 | ],[ | |
1675 | AC_MSG_RESULT(yes) | |
1676 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1, | |
1677 | [Page state NR_ACTIVE_ANON is available]) | |
1678 | ],[ | |
1679 | AC_MSG_RESULT(no) | |
1680 | ]) | |
1681 | ||
1682 | AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available]) | |
1683 | SPL_LINUX_TRY_COMPILE([ | |
1684 | #include <linux/mm.h> | |
1685 | ],[ | |
03318641 | 1686 | enum zone_stat_item zsi __attribute__ ((unused)); |
6ae7fef5 BB |
1687 | zsi = NR_ACTIVE_FILE; |
1688 | ],[ | |
1689 | AC_MSG_RESULT(yes) | |
1690 | AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1, | |
1691 | [Page state NR_ACTIVE_FILE is available]) | |
1692 | ],[ | |
1693 | AC_MSG_RESULT(no) | |
1694 | ]) | |
1695 | ]) | |
1696 | ||
1697 | dnl # | |
1698 | dnl # Proposed API change for legacy kernels. | |
1699 | dnl # This symbol is not available in older kernels. For kernels post | |
1700 | dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active | |
1701 | dnl # page state information. This symbol is only used in legacy kernels | |
1702 | dnl # any only as a last resort. | |
1703 | dnl | |
1704 | AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [ | |
1705 | AC_MSG_CHECKING([whether symbol get_zone_counts is needed]) | |
1706 | SPL_LINUX_TRY_COMPILE([ | |
1707 | ],[ | |
1708 | #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES) | |
1709 | #error "global_page_state needs NR_FREE_PAGES" | |
1710 | #endif | |
1711 | ||
1712 | #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \ | |
1713 | !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \ | |
1714 | !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE) | |
1715 | #error "global_page_state needs NR_ACTIVE*" | |
1716 | #endif | |
1717 | ||
1718 | #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \ | |
1719 | !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \ | |
1720 | !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE) | |
1721 | #error "global_page_state needs NR_INACTIVE*" | |
1722 | #endif | |
1723 | ],[ | |
1724 | AC_MSG_RESULT(no) | |
1725 | ],[ | |
1726 | AC_MSG_RESULT(yes) | |
1727 | AC_DEFINE(NEED_GET_ZONE_COUNTS, 1, | |
1728 | [get_zone_counts() is needed]) | |
1729 | ||
723aa3b0 ED |
1730 | AC_MSG_CHECKING([whether get_zone_counts() is available]) |
1731 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1732 | #include <linux/mmzone.h> | |
1733 | ], [ | |
1734 | get_zone_counts(NULL, NULL, NULL); | |
1735 | ], [get_zone_counts], [], [ | |
1736 | AC_MSG_RESULT(yes) | |
1737 | AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1, | |
1738 | [get_zone_counts() is available]) | |
1739 | ], [ | |
1740 | AC_MSG_RESULT(no) | |
1741 | ]) | |
6ae7fef5 BB |
1742 | ]) |
1743 | ]) | |
1744 | ||
7119bf70 BB |
1745 | dnl # |
1746 | dnl # 2.6.27 API change, | |
1747 | dnl # The user_path_dir() replaces __user_walk() | |
1748 | dnl # | |
723aa3b0 ED |
1749 | AC_DEFUN([SPL_AC_USER_PATH_DIR], |
1750 | [AC_MSG_CHECKING([whether user_path_dir() is available]) | |
1751 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1752 | #include <linux/fcntl.h> | |
1753 | #include <linux/namei.h> | |
1754 | ], [ | |
1755 | user_path_dir(NULL, NULL); | |
1756 | ], [user_path_at], [], [ | |
1757 | AC_MSG_RESULT(yes) | |
1758 | AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available]) | |
1759 | ], [ | |
1760 | AC_MSG_RESULT(no) | |
1761 | ]) | |
7119bf70 BB |
1762 | ]) |
1763 | ||
51a727e9 BB |
1764 | dnl # |
1765 | dnl # Symbol available in RHEL kernels not in stock kernels. | |
1766 | dnl # | |
723aa3b0 ED |
1767 | AC_DEFUN([SPL_AC_SET_FS_PWD], |
1768 | [AC_MSG_CHECKING([whether set_fs_pwd() is available]) | |
1769 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1770 | #include <linux/spinlock.h> | |
1771 | #include <linux/fs_struct.h> | |
1772 | ], [ | |
1773 | (void) set_fs_pwd; | |
1774 | ], [set_fs_pwd], [], [ | |
1775 | AC_MSG_RESULT(yes) | |
1776 | AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available]) | |
1777 | ], [ | |
1778 | AC_MSG_RESULT(no) | |
1779 | ]) | |
51a727e9 BB |
1780 | ]) |
1781 | ||
a54718cf RY |
1782 | dnl # |
1783 | dnl # 3.9 API change | |
1784 | dnl # set_fs_pwd takes const struct path * | |
1785 | dnl # | |
1786 | AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST], | |
a54718cf RY |
1787 | tmp_flags="$EXTRA_KCFLAGS" |
1788 | EXTRA_KCFLAGS="-Werror" | |
1789 | [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *]) | |
1790 | SPL_LINUX_TRY_COMPILE([ | |
1791 | #include <linux/spinlock.h> | |
1792 | #include <linux/fs_struct.h> | |
1793 | #include <linux/path.h> | |
1794 | void (*const set_fs_pwd_func) | |
1795 | (struct fs_struct *, const struct path *) | |
1796 | = set_fs_pwd; | |
1797 | ],[ | |
1798 | return 0; | |
1799 | ],[ | |
1800 | AC_MSG_RESULT(yes) | |
1801 | AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1, | |
1802 | [set_fs_pwd() needs const path *]) | |
1803 | ],[ | |
1804 | SPL_LINUX_TRY_COMPILE([ | |
1805 | #include <linux/spinlock.h> | |
1806 | #include <linux/fs_struct.h> | |
1807 | #include <linux/path.h> | |
1808 | void (*const set_fs_pwd_func) | |
1809 | (struct fs_struct *, struct path *) | |
1810 | = set_fs_pwd; | |
1811 | ],[ | |
1812 | return 0; | |
1813 | ],[ | |
1814 | AC_MSG_RESULT(no) | |
1815 | ],[ | |
1816 | AC_MSG_ERROR(unknown) | |
1817 | ]) | |
1818 | ]) | |
1819 | EXTRA_KCFLAGS="$tmp_flags" | |
a54718cf RY |
1820 | ]) |
1821 | ||
a093c6a4 BB |
1822 | AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK], |
1823 | [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args]) | |
1824 | SPL_LINUX_TRY_COMPILE([ | |
1825 | #include <linux/fs.h> | |
1826 | ],[ | |
50a0749e | 1827 | vfs_unlink((struct inode *) NULL, (struct dentry *) NULL); |
a093c6a4 BB |
1828 | ],[ |
1829 | AC_MSG_RESULT(yes) | |
1830 | AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1, | |
1831 | [vfs_unlink() wants 2 args]) | |
1832 | ],[ | |
1833 | AC_MSG_RESULT(no) | |
50a0749e RY |
1834 | dnl # |
1835 | dnl # Linux 3.13 API change | |
1836 | dnl # Added delegated inode | |
1837 | dnl # | |
1838 | AC_MSG_CHECKING([whether vfs_unlink() wants 3 args]) | |
1839 | SPL_LINUX_TRY_COMPILE([ | |
1840 | #include <linux/fs.h> | |
1841 | ],[ | |
1842 | vfs_unlink((struct inode *) NULL, | |
1843 | (struct dentry *) NULL, | |
1844 | (struct inode **) NULL); | |
1845 | ],[ | |
1846 | AC_MSG_RESULT(yes) | |
1847 | AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1, | |
1848 | [vfs_unlink() wants 3 args]) | |
1849 | ],[ | |
1850 | AC_MSG_ERROR(no) | |
1851 | ]) | |
1852 | ||
a093c6a4 BB |
1853 | ]) |
1854 | ]) | |
1855 | ||
a093c6a4 BB |
1856 | AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME], |
1857 | [AC_MSG_CHECKING([whether vfs_rename() wants 4 args]) | |
1858 | SPL_LINUX_TRY_COMPILE([ | |
1859 | #include <linux/fs.h> | |
1860 | ],[ | |
50a0749e RY |
1861 | vfs_rename((struct inode *) NULL, (struct dentry *) NULL, |
1862 | (struct inode *) NULL, (struct dentry *) NULL); | |
a093c6a4 BB |
1863 | ],[ |
1864 | AC_MSG_RESULT(yes) | |
1865 | AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1, | |
1866 | [vfs_rename() wants 4 args]) | |
1867 | ],[ | |
1868 | AC_MSG_RESULT(no) | |
50a0749e RY |
1869 | dnl # |
1870 | dnl # Linux 3.13 API change | |
1871 | dnl # Added delegated inode | |
1872 | dnl # | |
1873 | AC_MSG_CHECKING([whether vfs_rename() wants 5 args]) | |
1874 | SPL_LINUX_TRY_COMPILE([ | |
1875 | #include <linux/fs.h> | |
1876 | ],[ | |
1877 | vfs_rename((struct inode *) NULL, | |
1878 | (struct dentry *) NULL, | |
1879 | (struct inode *) NULL, | |
1880 | (struct dentry *) NULL, | |
1881 | (struct inode **) NULL); | |
1882 | ],[ | |
1883 | AC_MSG_RESULT(yes) | |
1884 | AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1, | |
1885 | [vfs_rename() wants 5 args]) | |
1886 | ],[ | |
ad3412ef CC |
1887 | AC_MSG_RESULT(no) |
1888 | dnl # | |
1889 | dnl # Linux 3.15 API change | |
1890 | dnl # Added flags | |
1891 | dnl # | |
1892 | AC_MSG_CHECKING([whether vfs_rename() wants 6 args]) | |
1893 | SPL_LINUX_TRY_COMPILE([ | |
1894 | #include <linux/fs.h> | |
1895 | ],[ | |
1896 | vfs_rename((struct inode *) NULL, | |
1897 | (struct dentry *) NULL, | |
1898 | (struct inode *) NULL, | |
1899 | (struct dentry *) NULL, | |
1900 | (struct inode **) NULL, | |
1901 | (unsigned int) 0); | |
1902 | ],[ | |
1903 | AC_MSG_RESULT(yes) | |
1904 | AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1, | |
1905 | [vfs_rename() wants 6 args]) | |
1906 | ],[ | |
1907 | AC_MSG_ERROR(no) | |
1908 | ]) | |
50a0749e | 1909 | ]) |
a093c6a4 BB |
1910 | ]) |
1911 | ]) | |
ec7d53e9 | 1912 | |
9b2048c2 BB |
1913 | dnl # |
1914 | dnl # 2.6.36 API change, | |
1915 | dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to | |
1916 | dnl # a spinlock_t to improve the fastpath performance. | |
1917 | dnl # | |
1918 | AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [ | |
1919 | AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t]) | |
97fd6a07 BB |
1920 | tmp_flags="$EXTRA_KCFLAGS" |
1921 | EXTRA_KCFLAGS="-Werror" | |
9b2048c2 BB |
1922 | SPL_LINUX_TRY_COMPILE([ |
1923 | #include <linux/sched.h> | |
1924 | #include <linux/fs_struct.h> | |
1925 | ],[ | |
1926 | struct fs_struct fs; | |
1927 | spin_lock_init(&fs.lock); | |
1928 | ],[ | |
1929 | AC_MSG_RESULT(yes) | |
1930 | AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1, | |
1931 | [struct fs_struct uses spinlock_t]) | |
1932 | ],[ | |
1933 | AC_MSG_RESULT(no) | |
1934 | ]) | |
97fd6a07 | 1935 | EXTRA_KCFLAGS="$tmp_flags" |
9b2048c2 BB |
1936 | ]) |
1937 | ||
ec7d53e9 BB |
1938 | dnl # |
1939 | dnl # 2.6.29 API change, | |
1940 | dnl # check whether 'struct cred' exists | |
1941 | dnl # | |
1942 | AC_DEFUN([SPL_AC_CRED_STRUCT], [ | |
1943 | AC_MSG_CHECKING([whether struct cred exists]) | |
1944 | SPL_LINUX_TRY_COMPILE([ | |
1945 | #include <linux/cred.h> | |
1946 | ],[ | |
03318641 | 1947 | struct cred *cr __attribute__ ((unused)); |
ec7d53e9 BB |
1948 | cr = NULL; |
1949 | ],[ | |
1950 | AC_MSG_RESULT(yes) | |
1951 | AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists]) | |
1952 | ],[ | |
1953 | AC_MSG_RESULT(no) | |
1954 | ]) | |
1955 | ]) | |
1956 | ||
f7fd6ddd RY |
1957 | |
1958 | dnl # | |
1959 | dnl # User namespaces, use kuid_t in place of uid_t | |
1960 | dnl # where available. Not strictly a user namespaces thing | |
1961 | dnl # but it should prevent surprises | |
1962 | dnl # | |
1963 | AC_DEFUN([SPL_AC_KUIDGID_T], [ | |
1964 | AC_MSG_CHECKING([whether kuid_t/kgid_t is available]) | |
1965 | SPL_LINUX_TRY_COMPILE([ | |
1966 | #include <linux/uidgid.h> | |
1967 | ], [ | |
1968 | kuid_t userid = KUIDT_INIT(0); | |
1969 | kgid_t groupid = KGIDT_INIT(0); | |
1970 | ],[ | |
1971 | SPL_LINUX_TRY_COMPILE([ | |
1972 | #include <linux/uidgid.h> | |
1973 | ], [ | |
1974 | kuid_t userid = 0; | |
1975 | kgid_t groupid = 0; | |
1976 | ],[ | |
1977 | AC_MSG_RESULT(yes; optional) | |
1978 | ],[ | |
1979 | AC_MSG_RESULT(yes; mandatory) | |
1980 | AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use]) | |
1981 | ]) | |
1982 | ],[ | |
1983 | AC_MSG_RESULT(no) | |
1984 | ]) | |
1985 | ]) | |
1986 | ||
ec7d53e9 | 1987 | dnl # |
e811949a | 1988 | dnl # Custom SPL patch may export this symbol. |
ec7d53e9 | 1989 | dnl # |
723aa3b0 ED |
1990 | AC_DEFUN([SPL_AC_GROUPS_SEARCH], |
1991 | [AC_MSG_CHECKING([whether groups_search() is available]) | |
1992 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1993 | #include <linux/cred.h> | |
f7fd6ddd RY |
1994 | #ifdef HAVE_KUIDGID_T |
1995 | #include <linux/uidgid.h> | |
1996 | #endif | |
723aa3b0 | 1997 | ], [ |
f7fd6ddd RY |
1998 | #ifdef HAVE_KUIDGID_T |
1999 | groups_search(NULL, KGIDT_INIT(0)); | |
2000 | #else | |
723aa3b0 | 2001 | groups_search(NULL, 0); |
f7fd6ddd | 2002 | #endif |
723aa3b0 ED |
2003 | ], [groups_search], [], [ |
2004 | AC_MSG_RESULT(yes) | |
2005 | AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available]) | |
2006 | ], [ | |
2007 | AC_MSG_RESULT(no) | |
2008 | ]) | |
ec7d53e9 | 2009 | ]) |
e811949a BB |
2010 | |
2011 | dnl # | |
2012 | dnl # 2.6.x API change, | |
2013 | dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere. | |
2014 | dnl # | |
723aa3b0 ED |
2015 | AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], |
2016 | [AC_MSG_CHECKING([whether __put_task_struct() is available]) | |
2017 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
2018 | #include <linux/sched.h> | |
2019 | ], [ | |
2020 | __put_task_struct(NULL); | |
2021 | ], [__put_task_struct], [], [ | |
2022 | AC_MSG_RESULT(yes) | |
2023 | AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1, | |
2024 | [__put_task_struct() is available]) | |
2025 | ], [ | |
2026 | AC_MSG_RESULT(no) | |
2027 | ]) | |
e811949a | 2028 | ]) |
3977f837 BB |
2029 | |
2030 | dnl # | |
2031 | dnl # 2.6.32 API change, | |
2032 | dnl # Unused 'struct file *' removed from prototype. | |
2033 | dnl # | |
2034 | AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [ | |
2035 | AC_MSG_CHECKING([whether proc_handler() wants 5 args]) | |
2036 | SPL_LINUX_TRY_COMPILE([ | |
2037 | #include <linux/sysctl.h> | |
2038 | ],[ | |
2039 | proc_dostring(NULL, 0, NULL, NULL, NULL); | |
2040 | ],[ | |
2041 | AC_MSG_RESULT(yes) | |
2042 | AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1, | |
2043 | [proc_handler() wants 5 args]) | |
2044 | ],[ | |
2045 | AC_MSG_RESULT(no) | |
2046 | ]) | |
2047 | ]) | |
b868e22f BB |
2048 | |
2049 | dnl # | |
2050 | dnl # 2.6.x API change, | |
2051 | dnl # kvasprintf() function added. | |
2052 | dnl # | |
723aa3b0 ED |
2053 | AC_DEFUN([SPL_AC_KVASPRINTF], |
2054 | [AC_MSG_CHECKING([whether kvasprintf() is available]) | |
2055 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
2056 | #include <linux/kernel.h> | |
2057 | ], [ | |
2058 | kvasprintf(0, NULL, *((va_list*)NULL)); | |
2059 | ], [kvasprintf], [], [ | |
2060 | AC_MSG_RESULT(yes) | |
2061 | AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available]) | |
2062 | ], [ | |
2063 | AC_MSG_RESULT(no) | |
2064 | ]) | |
b868e22f | 2065 | ]) |
f0ff89fc | 2066 | |
0d0b5237 BB |
2067 | dnl # |
2068 | dnl # 2.6.29 API change, | |
2069 | dnl # vfs_fsync() funcation added, prior to this use file_fsync(). | |
2070 | dnl # | |
723aa3b0 ED |
2071 | AC_DEFUN([SPL_AC_VFS_FSYNC], |
2072 | [AC_MSG_CHECKING([whether vfs_fsync() is available]) | |
2073 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
2074 | #include <linux/fs.h> | |
2075 | ], [ | |
2076 | (void) vfs_fsync; | |
2077 | ], [vfs_fsync], [fs/sync.c], [ | |
2078 | AC_MSG_RESULT(yes) | |
2079 | AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available]) | |
2080 | ], [ | |
2081 | AC_MSG_RESULT(no) | |
2082 | ]) | |
0d0b5237 BB |
2083 | ]) |
2084 | ||
f0ff89fc BB |
2085 | dnl # |
2086 | dnl # 2.6.35 API change, | |
0d0b5237 | 2087 | dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype. |
f0ff89fc | 2088 | dnl # |
0d0b5237 BB |
2089 | AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [ |
2090 | AC_MSG_CHECKING([whether vfs_fsync() wants 2 args]) | |
f0ff89fc | 2091 | SPL_LINUX_TRY_COMPILE([ |
0d0b5237 | 2092 | #include <linux/fs.h> |
f0ff89fc | 2093 | ],[ |
0d0b5237 | 2094 | vfs_fsync(NULL, 0); |
f0ff89fc BB |
2095 | ],[ |
2096 | AC_MSG_RESULT(yes) | |
0d0b5237 | 2097 | AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args]) |
f0ff89fc BB |
2098 | ],[ |
2099 | AC_MSG_RESULT(no) | |
2100 | ]) | |
2101 | ]) | |
46aa7b39 | 2102 | |
bbdc6ae4 ED |
2103 | dnl # |
2104 | dnl # 3.5 API change, | |
2105 | dnl # inode_operations.truncate_range removed | |
bbdc6ae4 ED |
2106 | dnl # |
2107 | AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [ | |
2108 | AC_MSG_CHECKING([whether truncate_range() inode operation is available]) | |
2109 | SPL_LINUX_TRY_COMPILE([ | |
2110 | #include <linux/fs.h> | |
2111 | ],[ | |
2112 | struct inode_operations ops; | |
2113 | ops.truncate_range = NULL; | |
2114 | ],[ | |
2115 | AC_MSG_RESULT(yes) | |
2116 | AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1, | |
2117 | [truncate_range() inode operation is available]) | |
2118 | ],[ | |
2119 | AC_MSG_RESULT(no) | |
2120 | ]) | |
1c7b3eaf BB |
2121 | ]) |
2122 | ||
2123 | dnl # | |
2124 | dnl # Linux 2.6.38 - 3.x API | |
2125 | dnl # | |
2126 | AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [ | |
2127 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
2128 | SPL_LINUX_TRY_COMPILE([ | |
2129 | #include <linux/fs.h> | |
2130 | ],[ | |
2131 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
2132 | struct file_operations fops __attribute__ ((unused)) = { | |
2133 | .fallocate = fallocate, | |
2134 | }; | |
2135 | ],[ | |
2136 | AC_MSG_RESULT(yes) | |
2137 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
2138 | ],[ | |
2139 | AC_MSG_RESULT(no) | |
2140 | ]) | |
2141 | ]) | |
2142 | ||
2143 | dnl # | |
2144 | dnl # Linux 2.6.x - 2.6.37 API | |
2145 | dnl # | |
2146 | AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [ | |
2147 | AC_MSG_CHECKING([whether iops->fallocate() exists]) | |
2148 | SPL_LINUX_TRY_COMPILE([ | |
2149 | #include <linux/fs.h> | |
2150 | ],[ | |
2151 | long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL; | |
2152 | struct inode_operations fops __attribute__ ((unused)) = { | |
2153 | .fallocate = fallocate, | |
2154 | }; | |
2155 | ],[ | |
2156 | AC_MSG_RESULT(yes) | |
2157 | AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists]) | |
2158 | ],[ | |
2159 | AC_MSG_RESULT(no) | |
2160 | ]) | |
2161 | ]) | |
2162 | ||
2163 | dnl # | |
2164 | dnl # PaX Linux 2.6.38 - 3.x API | |
2165 | dnl # | |
2166 | AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [ | |
2167 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
2168 | SPL_LINUX_TRY_COMPILE([ | |
2169 | #include <linux/fs.h> | |
2170 | ],[ | |
2171 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
2172 | struct file_operations_no_const fops __attribute__ ((unused)) = { | |
2173 | .fallocate = fallocate, | |
2174 | }; | |
2175 | ],[ | |
2176 | AC_MSG_RESULT(yes) | |
2177 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
2178 | ],[ | |
2179 | AC_MSG_RESULT(no) | |
2180 | ]) | |
2181 | ]) | |
2182 | ||
2183 | dnl # | |
2184 | dnl # The fallocate callback was moved from the inode_operations | |
2185 | dnl # structure to the file_operations structure. | |
2186 | dnl # | |
2187 | AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [ | |
2188 | SPL_AC_KERNEL_FILE_FALLOCATE | |
2189 | SPL_AC_KERNEL_INODE_FALLOCATE | |
2190 | SPL_AC_PAX_KERNEL_FILE_FALLOCATE | |
2191 | ]) | |
bbdc6ae4 | 2192 | |
46aa7b39 NB |
2193 | dnl # |
2194 | dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5. | |
2195 | dnl # Earlier versions of rwsem_is_locked() were inline and had a race | |
2196 | dnl # condition. The fixed version is exported as a symbol. The race | |
2197 | dnl # condition is fixed by acquiring sem->wait_lock, so we must not | |
2198 | dnl # call that version while holding sem->wait_lock. | |
2199 | dnl # | |
723aa3b0 ED |
2200 | AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], |
2201 | [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock]) | |
2202 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
2203 | #include <linux/rwsem.h> | |
2204 | int rwsem_is_locked(struct rw_semaphore *sem) { return 0; } | |
2205 | ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [ | |
2206 | AC_MSG_RESULT(yes) | |
2207 | AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1, | |
2208 | [rwsem_is_locked() acquires sem->wait_lock]) | |
2209 | ], [ | |
2210 | AC_MSG_RESULT(no) | |
2211 | ]) | |
46aa7b39 | 2212 | ]) |
914b0631 | 2213 | |
e76f4bf1 BB |
2214 | dnl # |
2215 | dnl # 2.6.xx API compat, | |
2216 | dnl # There currently exists no exposed API to partially shrink the dcache. | |
2217 | dnl # The expected mechanism to shrink the cache is a registered shrinker | |
2218 | dnl # which is called during memory pressure. | |
2219 | dnl # | |
723aa3b0 ED |
2220 | AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY], |
2221 | [AC_MSG_CHECKING([whether shrink_dcache_memory() is available]) | |
2222 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
2223 | #include <linux/dcache.h> | |
2224 | ], [ | |
2225 | shrink_dcache_memory(0, 0); | |
2226 | ], [shrink_dcache_memory], [fs/dcache.c], [ | |
2227 | AC_MSG_RESULT(yes) | |
2228 | AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1, | |
2229 | [shrink_dcache_memory() is available]) | |
2230 | ], [ | |
2231 | AC_MSG_RESULT(no) | |
2232 | ]) | |
e76f4bf1 BB |
2233 | ]) |
2234 | ||
2235 | dnl # | |
2236 | dnl # 2.6.xx API compat, | |
2237 | dnl # There currently exists no exposed API to partially shrink the icache. | |
2238 | dnl # The expected mechanism to shrink the cache is a registered shrinker | |
2239 | dnl # which is called during memory pressure. | |
2240 | dnl # | |
723aa3b0 ED |
2241 | AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY], |
2242 | [AC_MSG_CHECKING([whether shrink_icache_memory() is available]) | |
2243 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
2244 | #include <linux/dcache.h> | |
2245 | ], [ | |
2246 | shrink_icache_memory(0, 0); | |
2247 | ], [shrink_icache_memory], [fs/inode.c], [ | |
2248 | AC_MSG_RESULT(yes) | |
2249 | AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1, | |
2250 | [shrink_icache_memory() is available]) | |
2251 | ], [ | |
2252 | AC_MSG_RESULT(no) | |
2253 | ]) | |
e76f4bf1 | 2254 | ]) |
b1cbc461 BB |
2255 | |
2256 | dnl # | |
ec18fe3c RY |
2257 | dnl # 2.6.28 API change |
2258 | dnl # The kern_path() function has been introduced. We adopt it as the new way | |
2259 | dnl # of looking up paths. When it is not available, we emulate it using the | |
2260 | dnl # older interfaces. | |
b1cbc461 | 2261 | dnl # |
ec18fe3c RY |
2262 | AC_DEFUN([SPL_AC_KERN_PATH], |
2263 | [AC_MSG_CHECKING([whether kern_path() is available]) | |
723aa3b0 ED |
2264 | SPL_LINUX_TRY_COMPILE_SYMBOL([ |
2265 | #include <linux/namei.h> | |
2266 | ], [ | |
ec18fe3c RY |
2267 | int r = kern_path(NULL, 0, NULL); |
2268 | ], [kern_path], [fs/namei.c], [ | |
723aa3b0 | 2269 | AC_MSG_RESULT(yes) |
ec18fe3c RY |
2270 | AC_DEFINE(HAVE_KERN_PATH, 1, |
2271 | [kern_path() is available]) | |
723aa3b0 ED |
2272 | ], [ |
2273 | AC_MSG_RESULT(no) | |
ec18fe3c RY |
2274 | AC_MSG_CHECKING([whether path_lookup() is available]) |
2275 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
2276 | #include <linux/namei.h> | |
2277 | ], [ | |
2278 | int r = path_lookup(NULL, 0, NULL); | |
2279 | ], [path_lookup], [fs/namei.c], [ | |
2280 | AC_MSG_RESULT(yes) | |
2281 | AC_DEFINE(HAVE_KERN_PATH, 1, | |
2282 | [kern_path() is available]) | |
2283 | ], [ | |
2284 | AC_MSG_RESULT(no) | |
2285 | AC_MSG_ERROR([ | |
2286 | *** Neither kern_path() nor path_lookup() is available. | |
2287 | *** Please file an issue: | |
2288 | *** https://github.com/zfsonlinux/spl/issues/new]) | |
3dfc591a | 2289 | |
ec18fe3c RY |
2290 | ]) |
2291 | ]) | |
bcb15891 YS |
2292 | ]) |
2293 | ||
de081a2a BB |
2294 | dnl # |
2295 | dnl # /proc/kallsyms support, | |
2296 | dnl # Verify the kernel has CONFIG_KALLSYMS support enabled. | |
2297 | dnl # | |
2298 | AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [ | |
2299 | AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined]) | |
2300 | SPL_LINUX_TRY_COMPILE([ | |
2301 | #if !defined(CONFIG_KALLSYMS) | |
2302 | #error CONFIG_KALLSYMS not defined | |
2303 | #endif | |
2304 | ],[ ],[ | |
2305 | AC_MSG_RESULT([yes]) | |
2306 | ],[ | |
2307 | AC_MSG_RESULT([no]) | |
2308 | AC_MSG_ERROR([ | |
2309 | *** This kernel does not include the required kallsyms support. | |
2310 | *** Rebuild the kernel with CONFIG_KALLSYMS=y set.]) | |
2311 | ]) | |
2312 | ]) | |
2313 | ||
42b3ce62 BB |
2314 | dnl # |
2315 | dnl # zlib inflate compat, | |
2316 | dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled. | |
2317 | dnl # | |
2318 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [ | |
2319 | AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined]) | |
2320 | SPL_LINUX_TRY_COMPILE([ | |
2321 | #if !defined(CONFIG_ZLIB_INFLATE) && \ | |
2322 | !defined(CONFIG_ZLIB_INFLATE_MODULE) | |
2323 | #error CONFIG_ZLIB_INFLATE not defined | |
2324 | #endif | |
2325 | ],[ ],[ | |
2326 | AC_MSG_RESULT([yes]) | |
2327 | ],[ | |
2328 | AC_MSG_RESULT([no]) | |
2329 | AC_MSG_ERROR([ | |
2330 | *** This kernel does not include the required zlib inflate support. | |
2331 | *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.]) | |
2332 | ]) | |
2333 | ]) | |
2334 | ||
2335 | dnl # | |
2336 | dnl # zlib deflate compat, | |
2337 | dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled. | |
2338 | dnl # | |
2339 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [ | |
2340 | AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined]) | |
2341 | SPL_LINUX_TRY_COMPILE([ | |
2342 | #if !defined(CONFIG_ZLIB_DEFLATE) && \ | |
2343 | !defined(CONFIG_ZLIB_DEFLATE_MODULE) | |
2344 | #error CONFIG_ZLIB_DEFLATE not defined | |
2345 | #endif | |
2346 | ],[ ],[ | |
2347 | AC_MSG_RESULT([yes]) | |
2348 | ],[ | |
2349 | AC_MSG_RESULT([no]) | |
2350 | AC_MSG_ERROR([ | |
2351 | *** This kernel does not include the required zlib deflate support. | |
2352 | *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.]) | |
2353 | ]) | |
2354 | ]) | |
2355 | ||
3dfc591a BB |
2356 | dnl # |
2357 | dnl # 2.6.39 API compat, | |
2358 | dnl # The function zlib_deflate_workspacesize() now take 2 arguments. | |
2359 | dnl # This was done to avoid always having to allocate the maximum size | |
2360 | dnl # workspace (268K). The caller can now specific the windowBits and | |
2361 | dnl # memLevel compression parameters to get a smaller workspace. | |
2362 | dnl # | |
2363 | AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE], | |
2364 | [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args]) | |
2365 | SPL_LINUX_TRY_COMPILE([ | |
2366 | #include <linux/zlib.h> | |
2367 | ],[ | |
2368 | return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL); | |
2369 | ],[ | |
2370 | AC_MSG_RESULT(yes) | |
2371 | AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1, | |
2372 | [zlib_deflate_workspacesize() wants 2 args]) | |
2373 | ],[ | |
2374 | AC_MSG_RESULT(no) | |
2375 | ]) | |
2376 | ]) | |
a55bcaad BB |
2377 | |
2378 | dnl # | |
2379 | dnl # 2.6.39 API change, | |
2380 | dnl # Shrinker adjust to use common shrink_control structure. | |
2381 | dnl # | |
2382 | AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [ | |
2383 | AC_MSG_CHECKING([whether struct shrink_control exists]) | |
2384 | SPL_LINUX_TRY_COMPILE([ | |
2385 | #include <linux/mm.h> | |
2386 | ],[ | |
2387 | struct shrink_control sc __attribute__ ((unused)); | |
2388 | ||
2389 | sc.nr_to_scan = 0; | |
2390 | sc.gfp_mask = GFP_KERNEL; | |
2391 | ],[ | |
2392 | AC_MSG_RESULT(yes) | |
2393 | AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1, | |
2394 | [struct shrink_control exists]) | |
2395 | ],[ | |
2396 | AC_MSG_RESULT(no) | |
2397 | ]) | |
2398 | ]) | |
588d9004 DH |
2399 | |
2400 | dnl # | |
2401 | dnl # 3.1 API Change | |
2402 | dnl # | |
2403 | dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to | |
2404 | dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1. | |
2405 | dnl # | |
2406 | AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [ | |
2407 | AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw]) | |
2408 | tmp_flags="$EXTRA_KCFLAGS" | |
2409 | EXTRA_KCFLAGS="-Werror" | |
2410 | SPL_LINUX_TRY_COMPILE([ | |
2411 | #include <linux/rwsem.h> | |
2412 | ],[ | |
2413 | struct rw_semaphore dummy_semaphore __attribute__ ((unused)); | |
2414 | raw_spinlock_t dummy_lock __attribute__ ((unused)); | |
2415 | dummy_semaphore.wait_lock = dummy_lock; | |
2416 | ],[ | |
2417 | AC_MSG_RESULT(yes) | |
2418 | AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1, | |
2419 | [struct rw_semaphore member wait_lock is raw_spinlock_t]) | |
2420 | ],[ | |
2421 | AC_MSG_RESULT(no) | |
2422 | ]) | |
2423 | EXTRA_KCFLAGS="$tmp_flags" | |
2424 | ]) | |
10087fe1 RY |
2425 | |
2426 | dnl # | |
2427 | dnl # 3.9 API change, | |
2428 | dnl # Moved things from linux/sched.h to linux/sched/rt.h | |
2429 | dnl # | |
2430 | AC_DEFUN([SPL_AC_SCHED_RT_HEADER], | |
2431 | [AC_MSG_CHECKING([whether header linux/sched/rt.h exists]) | |
2432 | SPL_LINUX_TRY_COMPILE([ | |
2433 | #include <linux/sched.h> | |
2434 | #include <linux/sched/rt.h> | |
2435 | ],[ | |
2436 | return 0; | |
2437 | ],[ | |
2438 | AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists]) | |
2439 | AC_MSG_RESULT(yes) | |
2440 | ],[ | |
2441 | AC_MSG_RESULT(no) | |
2442 | ]) | |
2443 | ]) | |
2a305c34 RY |
2444 | |
2445 | dnl # | |
2446 | dnl # 3.9 API change, | |
2447 | dnl # vfs_getattr() uses 2 args | |
2448 | dnl # It takes struct path * instead of struct vfsmount * and struct dentry * | |
2449 | dnl # | |
2450 | AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [ | |
2451 | AC_MSG_CHECKING([whether vfs_getattr() wants]) | |
2452 | SPL_LINUX_TRY_COMPILE([ | |
2453 | #include <linux/fs.h> | |
2454 | ],[ | |
2455 | vfs_getattr((struct path *) NULL, | |
2456 | (struct kstat *)NULL); | |
2457 | ],[ | |
2458 | AC_MSG_RESULT(2 args) | |
2459 | AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1, | |
2460 | [vfs_getattr wants 2 args]) | |
2461 | ],[ | |
2462 | SPL_LINUX_TRY_COMPILE([ | |
2463 | #include <linux/fs.h> | |
2464 | ],[ | |
2465 | vfs_getattr((struct vfsmount *)NULL, | |
2466 | (struct dentry *)NULL, | |
2467 | (struct kstat *)NULL); | |
2468 | ],[ | |
2469 | AC_MSG_RESULT(3 args) | |
2470 | ],[ | |
2471 | AC_MSG_ERROR(unknown) | |
2472 | ]) | |
2473 | ]) | |
2474 | ]) | |
184c6873 NB |
2475 | |
2476 | dnl # | |
2477 | dnl # 2.6.36 API compatibility. | |
2478 | dnl # Added usleep_range timer. | |
2479 | dnl # usleep_range is a finer precision implementation of msleep | |
2480 | dnl # designed to be a drop-in replacement for udelay where a precise | |
2481 | dnl # sleep / busy-wait is unnecessary. | |
2482 | dnl # | |
2483 | AC_DEFUN([SPL_AC_USLEEP_RANGE], [ | |
2484 | AC_MSG_CHECKING([whether usleep_range() is available]) | |
2485 | SPL_LINUX_TRY_COMPILE([ | |
2486 | #include <linux/delay.h> | |
2487 | ],[ | |
2488 | usleep_range(0, 0); | |
2489 | ],[ | |
2490 | AC_MSG_RESULT(yes) | |
2491 | AC_DEFINE(HAVE_USLEEP_RANGE, 1, | |
2492 | [usleep_range is available]) | |
2493 | ],[ | |
2494 | AC_MSG_RESULT(no) | |
2495 | ]) | |
2496 | ]) | |
a073aeb0 BB |
2497 | |
2498 | dnl # | |
2499 | dnl # 2.6.35 API change, | |
2500 | dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are | |
2501 | dnl # private allocation flags which are applied when allocating a new slab | |
2502 | dnl # in kmem_getpages(). Unfortunately there is no public API for setting | |
2503 | dnl # non-default flags. | |
2504 | dnl # | |
2505 | AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [ | |
2506 | AC_MSG_CHECKING([whether struct kmem_cache has allocflags]) | |
2507 | SPL_LINUX_TRY_COMPILE([ | |
2508 | #include <linux/slab.h> | |
2509 | ],[ | |
2510 | struct kmem_cache cachep __attribute__ ((unused)); | |
2511 | cachep.allocflags = GFP_KERNEL; | |
2512 | ],[ | |
2513 | AC_MSG_RESULT(yes) | |
2514 | AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1, | |
2515 | [struct kmem_cache has allocflags]) | |
2516 | ],[ | |
2517 | AC_MSG_RESULT(no) | |
2518 | ||
2519 | AC_MSG_CHECKING([whether struct kmem_cache has gfpflags]) | |
2520 | SPL_LINUX_TRY_COMPILE([ | |
2521 | #include <linux/slab.h> | |
2522 | ],[ | |
2523 | struct kmem_cache cachep __attribute__ ((unused)); | |
2524 | cachep.gfpflags = GFP_KERNEL; | |
2525 | ],[ | |
2526 | AC_MSG_RESULT(yes) | |
2527 | AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1, | |
2528 | [struct kmem_cache has gfpflags]) | |
2529 | ],[ | |
2530 | AC_MSG_RESULT(no) | |
2531 | ]) | |
2532 | ]) | |
2533 | ]) | |
2fc44f66 NB |
2534 | |
2535 | dnl # | |
2536 | dnl # 3.17 API change, | |
2537 | dnl # wait_on_bit() no longer requires an action argument. The former | |
2538 | dnl # "wait_on_bit" interface required an 'action' function to be provided | |
2539 | dnl # which does the actual waiting. There were over 20 such functions in the | |
2540 | dnl # kernel, many of them identical, though most cases can be satisfied by one | |
2541 | dnl # of just two functions: one which uses io_schedule() and one which just | |
2542 | dnl # uses schedule(). This API change was made to consolidate all of those | |
2543 | dnl # redundant wait functions. | |
2544 | dnl # | |
2545 | AC_DEFUN([SPL_AC_WAIT_ON_BIT], [ | |
2546 | AC_MSG_CHECKING([whether wait_on_bit() takes an action]) | |
2547 | SPL_LINUX_TRY_COMPILE([ | |
2548 | #include <linux/wait.h> | |
2549 | ],[ | |
2550 | int (*action)(void *) = NULL; | |
2551 | wait_on_bit(NULL, 0, action, 0); | |
2552 | ],[ | |
2553 | AC_MSG_RESULT(yes) | |
2554 | AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes]) | |
2555 | ],[ | |
2556 | AC_MSG_RESULT(no) | |
2557 | ]) | |
2558 | ]) |