]>
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 |
c3d9c0df | 26 | SPL_AC_SHRINKER_CALLBACK |
79a3bf13 | 27 | SPL_AC_CTL_NAME |
1ddf9722 | 28 | SPL_AC_PDE_DATA |
4d54fdee | 29 | SPL_AC_MUTEX_OWNER |
86fd39f3 | 30 | SPL_AC_MUTEX_OWNER_TASK_STRUCT |
a54718cf | 31 | SPL_AC_SET_FS_PWD_WITH_CONST |
86933a6e BB |
32 | SPL_AC_2ARGS_VFS_UNLINK |
33 | SPL_AC_4ARGS_VFS_RENAME | |
0d0b5237 BB |
34 | SPL_AC_VFS_FSYNC |
35 | SPL_AC_2ARGS_VFS_FSYNC | |
bbdc6ae4 | 36 | SPL_AC_INODE_TRUNCATE_RANGE |
9b2048c2 | 37 | SPL_AC_FS_STRUCT_SPINLOCK |
f7fd6ddd | 38 | SPL_AC_KUIDGID_T |
e811949a | 39 | SPL_AC_PUT_TASK_STRUCT |
b868e22f | 40 | SPL_AC_KVASPRINTF |
46aa7b39 | 41 | SPL_AC_EXPORTED_RWSEM_IS_LOCKED |
1c7b3eaf | 42 | SPL_AC_KERNEL_FALLOCATE |
ec18fe3c | 43 | SPL_AC_KERN_PATH |
42b3ce62 BB |
44 | SPL_AC_CONFIG_ZLIB_INFLATE |
45 | SPL_AC_CONFIG_ZLIB_DEFLATE | |
3dfc591a | 46 | SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE |
a55bcaad | 47 | SPL_AC_SHRINK_CONTROL_STRUCT |
588d9004 | 48 | SPL_AC_RWSEM_SPINLOCK_IS_RAW |
10087fe1 | 49 | SPL_AC_SCHED_RT_HEADER |
2a305c34 | 50 | SPL_AC_2ARGS_VFS_GETATTR |
184c6873 | 51 | SPL_AC_USLEEP_RANGE |
a073aeb0 | 52 | SPL_AC_KMEM_CACHE_ALLOCFLAGS |
2fc44f66 | 53 | SPL_AC_WAIT_ON_BIT |
86933a6e BB |
54 | ]) |
55 | ||
56 | AC_DEFUN([SPL_AC_MODULE_SYMVERS], [ | |
bb339d06 | 57 | modpost=$LINUX/scripts/Makefile.modpost |
86933a6e | 58 | AC_MSG_CHECKING([kernel file name for module symbols]) |
0408008b | 59 | if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then |
bb339d06 BB |
60 | if grep -q Modules.symvers $modpost; then |
61 | LINUX_SYMBOLS=Modules.symvers | |
62 | else | |
63 | LINUX_SYMBOLS=Module.symvers | |
64 | fi | |
912fd84d BB |
65 | |
66 | if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then | |
67 | AC_MSG_ERROR([ | |
68 | *** Please make sure the kernel devel package for your distribution | |
7a8a6393 | 69 | *** is installed. If you are building with a custom kernel, make sure the |
912fd84d BB |
70 | *** kernel is configured, built, and the '--with-linux=PATH' configure |
71 | *** option refers to the location of the kernel source.]) | |
72 | fi | |
86933a6e | 73 | else |
bb339d06 | 74 | LINUX_SYMBOLS=NONE |
86933a6e BB |
75 | fi |
76 | AC_MSG_RESULT($LINUX_SYMBOLS) | |
77 | AC_SUBST(LINUX_SYMBOLS) | |
78 | ]) | |
79 | ||
57d86234 | 80 | AC_DEFUN([SPL_AC_KERNEL], [ |
57d86234 | 81 | AC_ARG_WITH([linux], |
82 | AS_HELP_STRING([--with-linux=PATH], | |
83 | [Path to kernel source]), | |
39a3d2a4 | 84 | [kernelsrc="$withval"]) |
57d86234 | 85 | |
86 | AC_ARG_WITH([linux-obj], | |
87 | AS_HELP_STRING([--with-linux-obj=PATH], | |
88 | [Path to kernel build objects]), | |
89 | [kernelbuild="$withval"]) | |
90 | ||
91 | AC_MSG_CHECKING([kernel source directory]) | |
92 | if test -z "$kernelsrc"; then | |
22ccfaa8 BB |
93 | if test -e "/lib/modules/$(uname -r)/source"; then |
94 | headersdir="/lib/modules/$(uname -r)/source" | |
95 | sourcelink=$(readlink -f "$headersdir") | |
96 | elif test -e "/lib/modules/$(uname -r)/build"; then | |
97 | headersdir="/lib/modules/$(uname -r)/build" | |
534c4e38 BM |
98 | sourcelink=$(readlink -f "$headersdir") |
99 | else | |
100 | sourcelink=$(ls -1d /usr/src/kernels/* \ | |
723aa3b0 | 101 | /usr/src/linux-* \ |
534c4e38 BM |
102 | 2>/dev/null | grep -v obj | tail -1) |
103 | fi | |
57d86234 | 104 | |
8fd4e3af | 105 | if test -n "$sourcelink" && test -e ${sourcelink}; then |
d4326403 | 106 | kernelsrc=`readlink -f ${sourcelink}` |
d4326403 | 107 | else |
251677e9 | 108 | kernelsrc="[Not found]" |
57d86234 | 109 | fi |
c5f70460 BB |
110 | else |
111 | if test "$kernelsrc" = "NONE"; then | |
112 | kernsrcver=NONE | |
113 | fi | |
57d86234 | 114 | fi |
115 | ||
116 | AC_MSG_RESULT([$kernelsrc]) | |
251677e9 BB |
117 | if test ! -d "$kernelsrc"; then |
118 | AC_MSG_ERROR([ | |
119 | *** Please make sure the kernel devel package for your distribution | |
7a8a6393 | 120 | *** is installed and then try again. If that fails, you can specify the |
251677e9 BB |
121 | *** location of the kernel source with the '--with-linux=PATH' option.]) |
122 | fi | |
123 | ||
57d86234 | 124 | AC_MSG_CHECKING([kernel build directory]) |
39a3d2a4 | 125 | if test -z "$kernelbuild"; then |
22ccfaa8 BB |
126 | if test -e "/lib/modules/$(uname -r)/build"; then |
127 | kernelbuild=`readlink -f /lib/modules/$(uname -r)/build` | |
128 | elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then | |
e2d28a37 BB |
129 | kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu} |
130 | elif test -d ${kernelsrc}-obj/${target_cpu}/default; then | |
131 | kernelbuild=${kernelsrc}-obj/${target_cpu}/default | |
132 | elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then | |
133 | kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu} | |
39a3d2a4 BB |
134 | else |
135 | kernelbuild=${kernelsrc} | |
136 | fi | |
bf338d8d | 137 | fi |
57d86234 | 138 | AC_MSG_RESULT([$kernelbuild]) |
139 | ||
140 | AC_MSG_CHECKING([kernel source version]) | |
fd921c2e BB |
141 | utsrelease1=$kernelbuild/include/linux/version.h |
142 | utsrelease2=$kernelbuild/include/linux/utsrelease.h | |
143 | utsrelease3=$kernelbuild/include/generated/utsrelease.h | |
144 | if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then | |
145 | utsrelease=linux/version.h | |
146 | elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then | |
147 | utsrelease=linux/utsrelease.h | |
148 | elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then | |
149 | utsrelease=generated/utsrelease.h | |
150 | fi | |
57d86234 | 151 | |
fd921c2e BB |
152 | if test "$utsrelease"; then |
153 | kernsrcver=`(echo "#include <$utsrelease>"; | |
57d86234 | 154 | echo "kernsrcver=UTS_RELEASE") | |
d4326403 | 155 | cpp -I $kernelbuild/include | |
57d86234 | 156 | grep "^kernsrcver=" | cut -d \" -f 2` |
57d86234 | 157 | |
fd921c2e BB |
158 | if test -z "$kernsrcver"; then |
159 | AC_MSG_RESULT([Not found]) | |
160 | AC_MSG_ERROR([*** Cannot determine kernel version.]) | |
161 | fi | |
162 | else | |
57d86234 | 163 | AC_MSG_RESULT([Not found]) |
0408008b ED |
164 | if test "x$enable_linux_builtin" != xyes; then |
165 | AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.]) | |
166 | else | |
167 | AC_MSG_ERROR([ | |
168 | *** Cannot find UTS_RELEASE definition. | |
169 | *** Please run 'make prepare' inside the kernel source tree.]) | |
170 | fi | |
57d86234 | 171 | fi |
172 | ||
173 | AC_MSG_RESULT([$kernsrcver]) | |
174 | ||
57d86234 | 175 | LINUX=${kernelsrc} |
176 | LINUX_OBJ=${kernelbuild} | |
c5f70460 BB |
177 | LINUX_VERSION=${kernsrcver} |
178 | ||
57d86234 | 179 | AC_SUBST(LINUX) |
180 | AC_SUBST(LINUX_OBJ) | |
c5f70460 | 181 | AC_SUBST(LINUX_VERSION) |
57d86234 | 182 | |
86933a6e | 183 | SPL_AC_MODULE_SYMVERS |
2e0e7e69 BB |
184 | ]) |
185 | ||
287b2fb1 BB |
186 | dnl # |
187 | dnl # Default SPL user configuration | |
188 | dnl # | |
ad35b6a6 | 189 | AC_DEFUN([SPL_AC_CONFIG_USER], []) |
287b2fb1 BB |
190 | |
191 | dnl # | |
192 | dnl # Check for rpm+rpmbuild to build RPM packages. If these tools | |
7a8a6393 | 193 | dnl # are missing, it is non-fatal, but you will not be able to build |
287b2fb1 BB |
194 | dnl # RPM packages and will be warned if you try too. |
195 | dnl # | |
7a8a6393 | 196 | dnl # By default, the generic spec file will be used because it requires |
493972c8 BB |
197 | dnl # minimal dependencies. Distribution specific spec files can be |
198 | dnl # placed under the 'rpm/<distribution>' directory and enabled using | |
199 | dnl # the --with-spec=<distribution> configure option. | |
200 | dnl # | |
287b2fb1 BB |
201 | AC_DEFUN([SPL_AC_RPM], [ |
202 | RPM=rpm | |
203 | RPMBUILD=rpmbuild | |
204 | ||
205 | AC_MSG_CHECKING([whether $RPM is available]) | |
206 | AS_IF([tmp=$($RPM --version 2>/dev/null)], [ | |
207 | RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
208 | HAVE_RPM=yes | |
209 | AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)]) | |
210 | ],[ | |
211 | HAVE_RPM=no | |
212 | AC_MSG_RESULT([$HAVE_RPM]) | |
213 | ]) | |
214 | ||
215 | AC_MSG_CHECKING([whether $RPMBUILD is available]) | |
216 | AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [ | |
217 | RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }') | |
218 | HAVE_RPMBUILD=yes | |
219 | AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)]) | |
220 | ],[ | |
221 | HAVE_RPMBUILD=no | |
222 | AC_MSG_RESULT([$HAVE_RPMBUILD]) | |
223 | ]) | |
224 | ||
493972c8 BB |
225 | RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"' |
226 | RPM_DEFINE_UTIL= | |
227 | RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"' | |
228 | RPM_DEFINE_DKMS= | |
229 | ||
230 | SRPM_DEFINE_COMMON='--define "build_src_rpm 1"' | |
231 | SRPM_DEFINE_UTIL= | |
232 | SRPM_DEFINE_KMOD= | |
233 | SRPM_DEFINE_DKMS= | |
234 | ||
235 | RPM_SPEC_DIR="rpm/generic" | |
236 | AC_ARG_WITH([spec], | |
237 | AS_HELP_STRING([--with-spec=SPEC], | |
238 | [Spec files 'generic|fedora']), | |
239 | [RPM_SPEC_DIR="rpm/$withval"]) | |
240 | ||
241 | AC_MSG_CHECKING([whether spec files are available]) | |
242 | AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)]) | |
243 | ||
287b2fb1 BB |
244 | AC_SUBST(HAVE_RPM) |
245 | AC_SUBST(RPM) | |
246 | AC_SUBST(RPM_VERSION) | |
247 | ||
248 | AC_SUBST(HAVE_RPMBUILD) | |
249 | AC_SUBST(RPMBUILD) | |
250 | AC_SUBST(RPMBUILD_VERSION) | |
493972c8 BB |
251 | |
252 | AC_SUBST(RPM_SPEC_DIR) | |
253 | AC_SUBST(RPM_DEFINE_UTIL) | |
254 | AC_SUBST(RPM_DEFINE_KMOD) | |
255 | AC_SUBST(RPM_DEFINE_DKMS) | |
256 | AC_SUBST(RPM_DEFINE_COMMON) | |
257 | AC_SUBST(SRPM_DEFINE_UTIL) | |
258 | AC_SUBST(SRPM_DEFINE_KMOD) | |
259 | AC_SUBST(SRPM_DEFINE_DKMS) | |
260 | AC_SUBST(SRPM_DEFINE_COMMON) | |
287b2fb1 BB |
261 | ]) |
262 | ||
263 | dnl # | |
264 | dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these | |
265 | dnl # tools are missing it is non-fatal but you will not be able to build | |
266 | dnl # DEB packages and will be warned if you try too. | |
267 | dnl # | |
268 | AC_DEFUN([SPL_AC_DPKG], [ | |
269 | DPKG=dpkg | |
270 | DPKGBUILD=dpkg-buildpackage | |
271 | ||
272 | AC_MSG_CHECKING([whether $DPKG is available]) | |
273 | AS_IF([tmp=$($DPKG --version 2>/dev/null)], [ | |
274 | DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }') | |
275 | HAVE_DPKG=yes | |
276 | AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)]) | |
277 | ],[ | |
278 | HAVE_DPKG=no | |
279 | AC_MSG_RESULT([$HAVE_DPKG]) | |
280 | ]) | |
281 | ||
282 | AC_MSG_CHECKING([whether $DPKGBUILD is available]) | |
283 | AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [ | |
284 | DPKGBUILD_VERSION=$(echo $tmp | \ | |
285 | $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.') | |
286 | HAVE_DPKGBUILD=yes | |
287 | AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)]) | |
288 | ],[ | |
289 | HAVE_DPKGBUILD=no | |
290 | AC_MSG_RESULT([$HAVE_DPKGBUILD]) | |
291 | ]) | |
292 | ||
293 | AC_SUBST(HAVE_DPKG) | |
294 | AC_SUBST(DPKG) | |
295 | AC_SUBST(DPKG_VERSION) | |
296 | ||
297 | AC_SUBST(HAVE_DPKGBUILD) | |
298 | AC_SUBST(DPKGBUILD) | |
299 | AC_SUBST(DPKGBUILD_VERSION) | |
300 | ]) | |
301 | ||
302 | dnl # | |
303 | dnl # Until native packaging for various different packing systems | |
304 | dnl # can be added the least we can do is attempt to use alien to | |
305 | dnl # convert the RPM packages to the needed package type. This is | |
306 | dnl # a hack but so far it has worked reasonable well. | |
307 | dnl # | |
308 | AC_DEFUN([SPL_AC_ALIEN], [ | |
309 | ALIEN=alien | |
310 | ||
311 | AC_MSG_CHECKING([whether $ALIEN is available]) | |
312 | AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [ | |
313 | ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }') | |
314 | HAVE_ALIEN=yes | |
315 | AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)]) | |
316 | ],[ | |
317 | HAVE_ALIEN=no | |
318 | AC_MSG_RESULT([$HAVE_ALIEN]) | |
319 | ]) | |
320 | ||
321 | AC_SUBST(HAVE_ALIEN) | |
322 | AC_SUBST(ALIEN) | |
323 | AC_SUBST(ALIEN_VERSION) | |
324 | ]) | |
325 | ||
326 | dnl # | |
327 | dnl # Using the VENDOR tag from config.guess set the default | |
328 | dnl # package type for 'make pkg': (rpm | deb | tgz) | |
329 | dnl # | |
330 | AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [ | |
73fc084e | 331 | AC_MSG_CHECKING([linux distribution]) |
a3a69b74 BB |
332 | if test -f /etc/toss-release ; then |
333 | VENDOR=toss ; | |
73fc084e BB |
334 | elif test -f /etc/fedora-release ; then |
335 | VENDOR=fedora ; | |
a3a69b74 BB |
336 | elif test -f /etc/redhat-release ; then |
337 | VENDOR=redhat ; | |
338 | elif test -f /etc/gentoo-release ; then | |
339 | VENDOR=gentoo ; | |
cd2817f8 PS |
340 | elif test -f /etc/arch-release ; then |
341 | VENDOR=arch ; | |
73fc084e BB |
342 | elif test -f /etc/SuSE-release ; then |
343 | VENDOR=sles ; | |
344 | elif test -f /etc/slackware-version ; then | |
345 | VENDOR=slackware ; | |
a3a69b74 BB |
346 | elif test -f /etc/lunar.release ; then |
347 | VENDOR=lunar ; | |
348 | elif test -f /etc/lsb-release ; then | |
349 | VENDOR=ubuntu ; | |
350 | elif test -f /etc/debian_version ; then | |
351 | VENDOR=debian ; | |
73fc084e BB |
352 | else |
353 | VENDOR= ; | |
354 | fi | |
355 | AC_MSG_RESULT([$VENDOR]) | |
356 | AC_SUBST(VENDOR) | |
287b2fb1 BB |
357 | |
358 | AC_MSG_CHECKING([default package type]) | |
359 | case "$VENDOR" in | |
a3a69b74 BB |
360 | toss) DEFAULT_PACKAGE=rpm ;; |
361 | redhat) DEFAULT_PACKAGE=rpm ;; | |
362 | fedora) DEFAULT_PACKAGE=rpm ;; | |
363 | gentoo) DEFAULT_PACKAGE=tgz ;; | |
5f0a4b08 | 364 | arch) DEFAULT_PACKAGE=tgz ;; |
a3a69b74 BB |
365 | sles) DEFAULT_PACKAGE=rpm ;; |
366 | slackware) DEFAULT_PACKAGE=tgz ;; | |
367 | lunar) DEFAULT_PACKAGE=tgz ;; | |
368 | ubuntu) DEFAULT_PACKAGE=deb ;; | |
369 | debian) DEFAULT_PACKAGE=deb ;; | |
370 | *) DEFAULT_PACKAGE=rpm ;; | |
287b2fb1 BB |
371 | esac |
372 | ||
373 | AC_MSG_RESULT([$DEFAULT_PACKAGE]) | |
374 | AC_SUBST(DEFAULT_PACKAGE) | |
375 | ]) | |
376 | ||
377 | dnl # | |
378 | dnl # Default SPL user configuration | |
379 | dnl # | |
380 | AC_DEFUN([SPL_AC_PACKAGE], [ | |
0b14b9f3 | 381 | SPL_AC_DEFAULT_PACKAGE |
287b2fb1 BB |
382 | SPL_AC_RPM |
383 | SPL_AC_DPKG | |
384 | SPL_AC_ALIEN | |
287b2fb1 BB |
385 | ]) |
386 | ||
6a1c3d41 | 387 | AC_DEFUN([SPL_AC_LICENSE], [ |
62032954 BB |
388 | AC_MSG_CHECKING([spl author]) |
389 | AC_MSG_RESULT([$SPL_META_AUTHOR]) | |
390 | ||
86933a6e | 391 | AC_MSG_CHECKING([spl license]) |
62032954 | 392 | AC_MSG_RESULT([$SPL_META_LICENSE]) |
86933a6e BB |
393 | ]) |
394 | ||
395 | AC_DEFUN([SPL_AC_CONFIG], [ | |
0408008b ED |
396 | SPL_CONFIG=all |
397 | AC_ARG_WITH([config], | |
398 | AS_HELP_STRING([--with-config=CONFIG], | |
399 | [Config file 'kernel|user|all|srpm']), | |
400 | [SPL_CONFIG="$withval"]) | |
401 | AC_ARG_ENABLE([linux-builtin], | |
402 | [AC_HELP_STRING([--enable-linux-builtin], | |
403 | [Configure for builtin in-tree kernel modules @<:@default=no@:>@])], | |
404 | [], | |
405 | [enable_linux_builtin=no]) | |
406 | ||
407 | AC_MSG_CHECKING([spl config]) | |
408 | AC_MSG_RESULT([$SPL_CONFIG]); | |
409 | AC_SUBST(SPL_CONFIG) | |
410 | ||
411 | case "$SPL_CONFIG" in | |
412 | kernel) SPL_AC_CONFIG_KERNEL ;; | |
413 | user) SPL_AC_CONFIG_USER ;; | |
414 | all) SPL_AC_CONFIG_KERNEL | |
415 | SPL_AC_CONFIG_USER ;; | |
c1541dfe | 416 | srpm) ;; |
0408008b ED |
417 | *) |
418 | AC_MSG_RESULT([Error!]) | |
419 | AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config, | |
420 | user kernel|user|all|srpm]) ;; | |
421 | esac | |
422 | ||
423 | AM_CONDITIONAL([CONFIG_USER], | |
424 | [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all]) | |
425 | AM_CONDITIONAL([CONFIG_KERNEL], | |
426 | [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] && | |
427 | [test "x$enable_linux_builtin" != xyes ]) | |
6a1c3d41 | 428 | ]) |
429 | ||
055ffd98 BB |
430 | dnl # |
431 | dnl # Enable if the SPL should be compiled with internal debugging enabled. | |
432 | dnl # By default this support is disabled. | |
433 | dnl # | |
57d86234 | 434 | AC_DEFUN([SPL_AC_DEBUG], [ |
c950d148 | 435 | AC_MSG_CHECKING([whether debugging is enabled]) |
055ffd98 BB |
436 | AC_ARG_ENABLE([debug], |
437 | [AS_HELP_STRING([--enable-debug], | |
438 | [Enable generic debug support @<:@default=no@:>@])], | |
439 | [], | |
440 | [enable_debug=no]) | |
441 | ||
442 | AS_IF([test "x$enable_debug" = xyes], | |
c950d148 | 443 | [ |
c950d148 BB |
444 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" |
445 | DEBUG_CFLAGS="-DDEBUG -Werror" | |
3c208a54 BB |
446 | DEBUG_SPL="_with_debug" |
447 | ], [ | |
c950d148 BB |
448 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" |
449 | DEBUG_CFLAGS="-DNDEBUG" | |
3c208a54 | 450 | DEBUG_SPL="_without_debug" |
c950d148 | 451 | ]) |
055ffd98 | 452 | |
c950d148 | 453 | AC_SUBST(DEBUG_CFLAGS) |
3c208a54 | 454 | AC_SUBST(DEBUG_SPL) |
055ffd98 | 455 | AC_MSG_RESULT([$enable_debug]) |
57d86234 | 456 | ]) |
457 | ||
4b2220f0 BB |
458 | dnl # |
459 | dnl # Enabled by default it provides a basic debug log infrastructure. | |
460 | dnl # Each subsystem registers itself with a name and logs messages | |
461 | dnl # using predefined types. If the debug mask it set to allow the | |
462 | dnl # message type it will be written to the internal log. The log | |
463 | dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry, | |
464 | dnl # after dumping the log it must be decoded using the spl utility. | |
465 | dnl # | |
466 | dnl # echo 1 >/proc/sys/kernel/spl/debug/dump | |
467 | dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt | |
468 | dnl # | |
469 | AC_DEFUN([SPL_AC_DEBUG_LOG], [ | |
470 | AC_ARG_ENABLE([debug-log], | |
471 | [AS_HELP_STRING([--enable-debug-log], | |
472 | [Enable basic debug logging @<:@default=yes@:>@])], | |
473 | [], | |
474 | [enable_debug_log=yes]) | |
475 | ||
476 | AS_IF([test "x$enable_debug_log" = xyes], | |
3c208a54 BB |
477 | [ |
478 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG" | |
479 | DEBUG_LOG="_with_debug_log" | |
480 | AC_DEFINE([DEBUG_LOG], [1], | |
4b2220f0 | 481 | [Define to 1 to enable basic debug logging]) |
3c208a54 BB |
482 | ], [ |
483 | DEBUG_LOG="_without_debug_log" | |
484 | ]) | |
4b2220f0 | 485 | |
3c208a54 | 486 | AC_SUBST(DEBUG_LOG) |
4b2220f0 BB |
487 | AC_MSG_CHECKING([whether basic debug logging is enabled]) |
488 | AC_MSG_RESULT([$enable_debug_log]) | |
489 | ]) | |
490 | ||
055ffd98 BB |
491 | dnl # |
492 | dnl # Enabled by default it provides a minimal level of memory tracking. | |
493 | dnl # A total count of bytes allocated is kept for each alloc and free. | |
494 | dnl # Then at module unload time a report to the console will be printed | |
495 | dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist | |
496 | dnl # and provide an easy way to inspect the kmem based slab. | |
497 | dnl # | |
57d86234 | 498 | AC_DEFUN([SPL_AC_DEBUG_KMEM], [ |
055ffd98 BB |
499 | AC_ARG_ENABLE([debug-kmem], |
500 | [AS_HELP_STRING([--enable-debug-kmem], | |
501 | [Enable basic kmem accounting @<:@default=yes@:>@])], | |
502 | [], | |
503 | [enable_debug_kmem=yes]) | |
57d86234 | 504 | |
055ffd98 | 505 | AS_IF([test "x$enable_debug_kmem" = xyes], |
3c208a54 BB |
506 | [ |
507 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" | |
508 | DEBUG_KMEM="_with_debug_kmem" | |
509 | AC_DEFINE([DEBUG_KMEM], [1], | |
055ffd98 | 510 | [Define to 1 to enable basic kmem accounting]) |
3c208a54 BB |
511 | ], [ |
512 | DEBUG_KMEM="_without_debug_kmem" | |
513 | ]) | |
055ffd98 | 514 | |
3c208a54 | 515 | AC_SUBST(DEBUG_KMEM) |
055ffd98 BB |
516 | AC_MSG_CHECKING([whether basic kmem accounting is enabled]) |
517 | AC_MSG_RESULT([$enable_debug_kmem]) | |
57d86234 | 518 | ]) |
519 | ||
055ffd98 BB |
520 | dnl # |
521 | dnl # Disabled by default it provides detailed memory tracking. This | |
522 | dnl # feature also requires --enable-debug-kmem to be set. When enabled | |
523 | dnl # not only will total bytes be tracked but also the location of every | |
524 | dnl # alloc and free. When the SPL module is unloaded a list of all leaked | |
525 | dnl # addresses and where they were allocated will be dumped to the console. | |
526 | dnl # Enabling this feature has a significant impact on performance but it | |
527 | dnl # makes finding memory leaks pretty straight forward. | |
528 | dnl # | |
529 | AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [ | |
530 | AC_ARG_ENABLE([debug-kmem-tracking], | |
531 | [AS_HELP_STRING([--enable-debug-kmem-tracking], | |
532 | [Enable detailed kmem tracking @<:@default=no@:>@])], | |
533 | [], | |
534 | [enable_debug_kmem_tracking=no]) | |
535 | ||
536 | AS_IF([test "x$enable_debug_kmem_tracking" = xyes], | |
3c208a54 BB |
537 | [ |
538 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING" | |
539 | DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking" | |
540 | AC_DEFINE([DEBUG_KMEM_TRACKING], [1], | |
055ffd98 | 541 | [Define to 1 to enable detailed kmem tracking]) |
3c208a54 BB |
542 | ], [ |
543 | DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking" | |
544 | ]) | |
055ffd98 | 545 | |
3c208a54 | 546 | AC_SUBST(DEBUG_KMEM_TRACKING) |
055ffd98 BB |
547 | AC_MSG_CHECKING([whether detailed kmem tracking is enabled]) |
548 | AC_MSG_RESULT([$enable_debug_kmem_tracking]) | |
57d86234 | 549 | ]) |
550 | ||
551 | dnl # | |
552 | dnl # SPL_LINUX_CONFTEST | |
553 | dnl # | |
554 | AC_DEFUN([SPL_LINUX_CONFTEST], [ | |
dbe561d8 | 555 | cat confdefs.h - <<_ACEOF >conftest.c |
57d86234 | 556 | $1 |
557 | _ACEOF | |
558 | ]) | |
559 | ||
560 | dnl # | |
561 | dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY]) | |
562 | dnl # | |
563 | m4_define([SPL_LANG_PROGRAM], [ | |
564 | $1 | |
565 | int | |
566 | main (void) | |
567 | { | |
568 | dnl Do *not* indent the following line: there may be CPP directives. | |
569 | dnl Don't move the `;' right after for the same reason. | |
570 | $2 | |
571 | ; | |
572 | return 0; | |
573 | } | |
574 | ]) | |
575 | ||
576 | dnl # | |
577 | dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE | |
578 | dnl # | |
579 | AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [ | |
c5f70460 | 580 | m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])]) |
df7cc5bc | 581 | rm -Rf build && mkdir -p build && touch build/conftest.mod.c |
c5f70460 | 582 | echo "obj-m := conftest.o" >build/Makefile |
df7cc5bc ED |
583 | modpost_flag='' |
584 | test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage | |
c5f70460 | 585 | AS_IF( |
df7cc5bc ED |
586 | [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])], |
587 | [$4], | |
588 | [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])] | |
c5f70460 BB |
589 | ) |
590 | rm -Rf build | |
57d86234 | 591 | ]) |
592 | ||
593 | dnl # | |
594 | dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE | |
595 | dnl # | |
596 | AC_DEFUN([SPL_LINUX_TRY_COMPILE], | |
597 | [SPL_LINUX_COMPILE_IFELSE( | |
d50bd9e2 | 598 | [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])], |
599 | [modules], | |
600 | [test -s build/conftest.o], | |
601 | [$3], [$4]) | |
57d86234 | 602 | ]) |
603 | ||
57d86234 | 604 | dnl # |
605 | dnl # SPL_CHECK_SYMBOL_EXPORT | |
606 | dnl # check symbol exported or not | |
607 | dnl # | |
723aa3b0 | 608 | AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [ |
2e0e7e69 BB |
609 | grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ |
610 | $LINUX_OBJ/Module*.symvers 2>/dev/null | |
57d86234 | 611 | rc=$? |
612 | if test $rc -ne 0; then | |
613 | export=0 | |
614 | for file in $2; do | |
2e0e7e69 BB |
615 | grep -q -E "EXPORT_SYMBOL.*($1)" \ |
616 | "$LINUX_OBJ/$file" 2>/dev/null | |
57d86234 | 617 | rc=$? |
723aa3b0 ED |
618 | if test $rc -eq 0; then |
619 | export=1 | |
620 | break; | |
621 | fi | |
57d86234 | 622 | done |
723aa3b0 | 623 | if test $export -eq 0; then : |
57d86234 | 624 | $4 |
723aa3b0 | 625 | else : |
57d86234 | 626 | $3 |
627 | fi | |
723aa3b0 | 628 | else : |
57d86234 | 629 | $3 |
630 | fi | |
631 | ]) | |
632 | ||
723aa3b0 ED |
633 | dnl # |
634 | dnl # SPL_LINUX_TRY_COMPILE_SYMBOL | |
635 | dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT | |
636 | dnl # is called if not compiling for builtin | |
637 | dnl # | |
638 | AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [ | |
639 | SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1]) | |
640 | if test $rc -ne 0; then : | |
641 | $6 | |
642 | else | |
643 | if test "x$enable_linux_builtin" != xyes; then | |
644 | SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1]) | |
645 | fi | |
646 | if test $rc -ne 0; then : | |
647 | $6 | |
648 | else : | |
649 | $5 | |
650 | fi | |
651 | fi | |
652 | ]) | |
653 | ||
12ff95ff BB |
654 | dnl # |
655 | dnl # SPL_CHECK_SYMBOL_HEADER | |
656 | dnl # check if a symbol prototype is defined in listed headers. | |
657 | dnl # | |
658 | AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [ | |
659 | AC_MSG_CHECKING([whether symbol $1 exists in header]) | |
660 | header=0 | |
661 | for file in $3; do | |
662 | grep -q "$2" "$LINUX/$file" 2>/dev/null | |
663 | rc=$? | |
723aa3b0 ED |
664 | if test $rc -eq 0; then |
665 | header=1 | |
666 | break; | |
667 | fi | |
12ff95ff BB |
668 | done |
669 | if test $header -eq 0; then | |
670 | AC_MSG_RESULT([no]) | |
671 | $5 | |
672 | else | |
673 | AC_MSG_RESULT([yes]) | |
674 | $4 | |
675 | fi | |
676 | ]) | |
677 | ||
86de8532 | 678 | dnl # |
679 | dnl # SPL_CHECK_HEADER | |
680 | dnl # check whether header exists and define HAVE_$2_HEADER | |
681 | dnl # | |
682 | AC_DEFUN([SPL_CHECK_HEADER], | |
683 | [AC_MSG_CHECKING([whether header $1 exists]) | |
684 | SPL_LINUX_TRY_COMPILE([ | |
d50bd9e2 | 685 | #include <$1> |
86de8532 | 686 | ],[ |
687 | return 0; | |
688 | ],[ | |
689 | AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists]) | |
690 | AC_MSG_RESULT(yes) | |
691 | $3 | |
692 | ],[ | |
693 | AC_MSG_RESULT(no) | |
694 | $4 | |
695 | ]) | |
696 | ]) | |
6a6cafbe | 697 | |
0408008b | 698 | dnl # |
62032954 BB |
699 | dnl # Basic toolchain sanity check. Verify that kernel modules can |
700 | dnl # be built and which symbols can be used. | |
0408008b ED |
701 | dnl # |
702 | AC_DEFUN([SPL_AC_TEST_MODULE], | |
703 | [AC_MSG_CHECKING([whether modules can be built]) | |
704 | SPL_LINUX_TRY_COMPILE([],[],[ | |
705 | AC_MSG_RESULT([yes]) | |
706 | ],[ | |
707 | AC_MSG_RESULT([no]) | |
708 | if test "x$enable_linux_builtin" != xyes; then | |
709 | AC_MSG_ERROR([*** Unable to build an empty module.]) | |
710 | else | |
711 | AC_MSG_ERROR([ | |
712 | *** Unable to build an empty module. | |
713 | *** Please run 'make scripts' inside the kernel source tree.]) | |
714 | fi | |
715 | ]) | |
62032954 BB |
716 | |
717 | AC_RUN_IFELSE([ | |
718 | AC_LANG_PROGRAM([ | |
719 | #include "$LINUX/include/linux/license.h" | |
720 | ], [ | |
721 | return !license_is_gpl_compatible("$SPL_META_LICENSE"); | |
722 | ]) | |
723 | ], [ | |
724 | AC_DEFINE([SPL_IS_GPL_COMPATIBLE], [1], | |
725 | [Define to 1 if GPL-only symbols can be used]) | |
726 | ], [ | |
727 | ]) | |
0408008b ED |
728 | ]) |
729 | ||
57d86234 | 730 | dnl # |
d04c8a56 BB |
731 | dnl # Use the atomic implemenation based on global spinlocks. This |
732 | dnl # should only be needed by 32-bit kernels which do not provide | |
733 | dnl # the atomic64_* API. It may be optionally enabled as a fallback | |
734 | dnl # if problems are observed with the direct mapping to the native | |
735 | dnl # Linux atomic operations. You may not disable atomic spinlocks | |
736 | dnl # if you kernel does not an atomic64_* API. | |
57d86234 | 737 | dnl # |
d04c8a56 BB |
738 | AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ |
739 | AC_ARG_ENABLE([atomic-spinlocks], | |
740 | [AS_HELP_STRING([--enable-atomic-spinlocks], | |
741 | [Atomic types use spinlocks @<:@default=check@:>@])], | |
742 | [], | |
743 | [enable_atomic_spinlocks=check]) | |
57d86234 | 744 | |
a0f6da3d | 745 | SPL_LINUX_TRY_COMPILE([ |
dd3678fc | 746 | #include <linux/fs.h> |
a0f6da3d | 747 | ],[ |
03318641 | 748 | atomic64_t *ptr __attribute__ ((unused)); |
a0f6da3d | 749 | ],[ |
d04c8a56 | 750 | have_atomic64_t=yes |
a0f6da3d | 751 | AC_DEFINE(HAVE_ATOMIC64_T, 1, |
d04c8a56 | 752 | [kernel defines atomic64_t]) |
a0f6da3d | 753 | ],[ |
d04c8a56 BB |
754 | have_atomic64_t=no |
755 | ]) | |
756 | ||
757 | AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [ | |
758 | AS_IF([test "x$have_atomic64_t" = xyes], [ | |
759 | enable_atomic_spinlocks=no | |
760 | ],[ | |
761 | enable_atomic_spinlocks=yes | |
762 | ]) | |
a0f6da3d | 763 | ]) |
d04c8a56 BB |
764 | |
765 | AS_IF([test "x$enable_atomic_spinlocks" = xyes], [ | |
766 | AC_DEFINE([ATOMIC_SPINLOCK], [1], | |
767 | [Atomic types use spinlocks]) | |
768 | ],[ | |
769 | AS_IF([test "x$have_atomic64_t" = xno], [ | |
770 | AC_MSG_FAILURE( | |
771 | [--disable-atomic-spinlocks given but required atomic64 support is unavailable]) | |
772 | ]) | |
773 | ]) | |
774 | ||
775 | AC_MSG_CHECKING([whether atomic types use spinlocks]) | |
776 | AC_MSG_RESULT([$enable_atomic_spinlocks]) | |
777 | ||
778 | AC_MSG_CHECKING([whether kernel defines atomic64_t]) | |
779 | AC_MSG_RESULT([$have_atomic64_t]) | |
a0f6da3d | 780 | ]) |
781 | ||
c3d9c0df | 782 | AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[ |
23aa63cb BB |
783 | tmp_flags="$EXTRA_KCFLAGS" |
784 | EXTRA_KCFLAGS="-Werror" | |
c3d9c0df RY |
785 | dnl # |
786 | dnl # 2.6.23 to 2.6.34 API change | |
787 | dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask) | |
788 | dnl # | |
789 | AC_MSG_CHECKING([whether old 2-argument shrinker exists]) | |
23aa63cb BB |
790 | SPL_LINUX_TRY_COMPILE([ |
791 | #include <linux/mm.h> | |
792 | ||
c3d9c0df | 793 | int shrinker_cb(int nr_to_scan, gfp_t gfp_mask); |
23aa63cb BB |
794 | ],[ |
795 | struct shrinker cache_shrinker = { | |
796 | .shrink = shrinker_cb, | |
797 | .seeks = DEFAULT_SEEKS, | |
798 | }; | |
799 | register_shrinker(&cache_shrinker); | |
800 | ],[ | |
801 | AC_MSG_RESULT(yes) | |
c3d9c0df RY |
802 | AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1, |
803 | [old shrinker callback wants 2 args]) | |
23aa63cb BB |
804 | ],[ |
805 | AC_MSG_RESULT(no) | |
c3d9c0df RY |
806 | dnl # |
807 | dnl # 2.6.35 - 2.6.39 API change | |
808 | dnl # ->shrink(struct shrinker *, | |
809 | dnl # int nr_to_scan, gfp_t gfp_mask) | |
810 | dnl # | |
811 | AC_MSG_CHECKING([whether old 3-argument shrinker exists]) | |
812 | SPL_LINUX_TRY_COMPILE([ | |
813 | #include <linux/mm.h> | |
814 | ||
815 | int shrinker_cb(struct shrinker *, int nr_to_scan, | |
816 | gfp_t gfp_mask); | |
817 | ],[ | |
818 | struct shrinker cache_shrinker = { | |
819 | .shrink = shrinker_cb, | |
820 | .seeks = DEFAULT_SEEKS, | |
821 | }; | |
822 | register_shrinker(&cache_shrinker); | |
823 | ],[ | |
824 | AC_MSG_RESULT(yes) | |
825 | AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1, | |
826 | [old shrinker callback wants 3 args]) | |
827 | ],[ | |
828 | AC_MSG_RESULT(no) | |
829 | dnl # | |
830 | dnl # 3.0 - 3.11 API change | |
831 | dnl # ->shrink(struct shrinker *, | |
832 | dnl # struct shrink_control *sc) | |
833 | dnl # | |
834 | AC_MSG_CHECKING( | |
835 | [whether new 2-argument shrinker exists]) | |
836 | SPL_LINUX_TRY_COMPILE([ | |
837 | #include <linux/mm.h> | |
838 | ||
839 | int shrinker_cb(struct shrinker *, | |
840 | struct shrink_control *sc); | |
841 | ],[ | |
842 | struct shrinker cache_shrinker = { | |
843 | .shrink = shrinker_cb, | |
844 | .seeks = DEFAULT_SEEKS, | |
845 | }; | |
846 | register_shrinker(&cache_shrinker); | |
847 | ],[ | |
848 | AC_MSG_RESULT(yes) | |
849 | AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1, | |
850 | [new shrinker callback wants 2 args]) | |
851 | ],[ | |
852 | AC_MSG_RESULT(no) | |
853 | dnl # | |
854 | dnl # 3.12 API change, | |
855 | dnl # ->shrink() is logically split in to | |
856 | dnl # ->count_objects() and ->scan_objects() | |
857 | dnl # | |
858 | AC_MSG_CHECKING( | |
859 | [whether ->count_objects callback exists]) | |
860 | SPL_LINUX_TRY_COMPILE([ | |
861 | #include <linux/mm.h> | |
862 | ||
863 | unsigned long shrinker_cb( | |
864 | struct shrinker *, | |
865 | struct shrink_control *sc); | |
866 | ],[ | |
867 | struct shrinker cache_shrinker = { | |
868 | .count_objects = shrinker_cb, | |
869 | .scan_objects = shrinker_cb, | |
870 | .seeks = DEFAULT_SEEKS, | |
871 | }; | |
872 | register_shrinker(&cache_shrinker); | |
873 | ],[ | |
874 | AC_MSG_RESULT(yes) | |
875 | AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, | |
876 | 1, [->count_objects exists]) | |
877 | ],[ | |
878 | AC_MSG_ERROR(error) | |
879 | ]) | |
880 | ]) | |
881 | ]) | |
23aa63cb BB |
882 | ]) |
883 | EXTRA_KCFLAGS="$tmp_flags" | |
884 | ]) | |
885 | ||
79a3bf13 BB |
886 | dnl # |
887 | dnl # 2.6.33 API change, | |
888 | dnl # Removed .ctl_name from struct ctl_table. | |
889 | dnl # | |
890 | AC_DEFUN([SPL_AC_CTL_NAME], [ | |
891 | AC_MSG_CHECKING([whether struct ctl_table has ctl_name]) | |
892 | SPL_LINUX_TRY_COMPILE([ | |
893 | #include <linux/sysctl.h> | |
894 | ],[ | |
03318641 | 895 | struct ctl_table ctl __attribute__ ((unused)); |
79a3bf13 BB |
896 | ctl.ctl_name = 0; |
897 | ],[ | |
898 | AC_MSG_RESULT(yes) | |
899 | AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name]) | |
900 | ],[ | |
901 | AC_MSG_RESULT(no) | |
902 | ]) | |
903 | ]) | |
904 | ||
4d54fdee BB |
905 | dnl # |
906 | dnl # 2.6.29 API change, | |
a80d69ca BB |
907 | dnl # Adaptive mutexs were introduced which track the mutex owner. The |
908 | dnl # mutex wrappers leverage this functionality to avoid tracking the | |
909 | dnl # owner multipe times. | |
4d54fdee BB |
910 | dnl # |
911 | AC_DEFUN([SPL_AC_MUTEX_OWNER], [ | |
912 | AC_MSG_CHECKING([whether struct mutex has owner]) | |
913 | SPL_LINUX_TRY_COMPILE([ | |
914 | #include <linux/mutex.h> | |
915 | ],[ | |
03318641 | 916 | struct mutex mtx __attribute__ ((unused)); |
4d54fdee BB |
917 | mtx.owner = NULL; |
918 | ],[ | |
919 | AC_MSG_RESULT(yes) | |
920 | AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner]) | |
921 | ],[ | |
922 | AC_MSG_RESULT(no) | |
923 | ]) | |
924 | ]) | |
925 | ||
86fd39f3 BB |
926 | dnl # |
927 | dnl # 2.6.39 API change, | |
928 | dnl # Owner type change. A Linux mutex prior to 2.6.39 would store | |
929 | dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES | |
930 | dnl # was defined. As of 2.6.39 this was changed to a task_struct | |
931 | dnl # pointer which frankly makes a lot more sense. | |
932 | dnl # | |
933 | AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [ | |
934 | AC_MSG_CHECKING([whether struct mutex owner is a task_struct]) | |
935 | tmp_flags="$EXTRA_KCFLAGS" | |
936 | EXTRA_KCFLAGS="-Werror" | |
937 | SPL_LINUX_TRY_COMPILE([ | |
938 | #include <linux/mutex.h> | |
a0625691 | 939 | #include <linux/sched.h> |
86fd39f3 BB |
940 | ],[ |
941 | struct mutex mtx __attribute__ ((unused)); | |
942 | mtx.owner = current; | |
943 | ],[ | |
944 | AC_MSG_RESULT(yes) | |
945 | AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1, | |
946 | [struct mutex owner is a task_struct]) | |
947 | ],[ | |
948 | AC_MSG_RESULT(no) | |
949 | ]) | |
950 | EXTRA_KCFLAGS="$tmp_flags" | |
951 | ]) | |
952 | ||
1ddf9722 YS |
953 | dnl # |
954 | dnl # 3.10 API change, | |
955 | dnl # PDE is replaced by PDE_DATA | |
956 | dnl # | |
957 | AC_DEFUN([SPL_AC_PDE_DATA], [ | |
958 | AC_MSG_CHECKING([whether PDE_DATA() is available]) | |
959 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
960 | #include <linux/proc_fs.h> | |
961 | ], [ | |
962 | PDE_DATA(NULL); | |
963 | ], [PDE_DATA], [], [ | |
964 | AC_MSG_RESULT(yes) | |
965 | AC_DEFINE(HAVE_PDE_DATA, 1, [yes]) | |
966 | ],[ | |
967 | AC_MSG_RESULT(no) | |
968 | ]) | |
969 | ]) | |
970 | ||
a54718cf RY |
971 | dnl # |
972 | dnl # 3.9 API change | |
973 | dnl # set_fs_pwd takes const struct path * | |
974 | dnl # | |
975 | AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST], | |
a54718cf RY |
976 | tmp_flags="$EXTRA_KCFLAGS" |
977 | EXTRA_KCFLAGS="-Werror" | |
978 | [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *]) | |
979 | SPL_LINUX_TRY_COMPILE([ | |
980 | #include <linux/spinlock.h> | |
981 | #include <linux/fs_struct.h> | |
982 | #include <linux/path.h> | |
983 | void (*const set_fs_pwd_func) | |
984 | (struct fs_struct *, const struct path *) | |
985 | = set_fs_pwd; | |
986 | ],[ | |
987 | return 0; | |
988 | ],[ | |
989 | AC_MSG_RESULT(yes) | |
990 | AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1, | |
991 | [set_fs_pwd() needs const path *]) | |
992 | ],[ | |
993 | SPL_LINUX_TRY_COMPILE([ | |
994 | #include <linux/spinlock.h> | |
995 | #include <linux/fs_struct.h> | |
996 | #include <linux/path.h> | |
997 | void (*const set_fs_pwd_func) | |
998 | (struct fs_struct *, struct path *) | |
999 | = set_fs_pwd; | |
1000 | ],[ | |
1001 | return 0; | |
1002 | ],[ | |
1003 | AC_MSG_RESULT(no) | |
1004 | ],[ | |
1005 | AC_MSG_ERROR(unknown) | |
1006 | ]) | |
1007 | ]) | |
1008 | EXTRA_KCFLAGS="$tmp_flags" | |
a54718cf RY |
1009 | ]) |
1010 | ||
e39174ed BB |
1011 | dnl # |
1012 | dnl # 3.13 API change | |
1013 | dnl # vfs_unlink() updated to take a third delegated_inode argument. | |
1014 | dnl # | |
a093c6a4 BB |
1015 | AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK], |
1016 | [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args]) | |
1017 | SPL_LINUX_TRY_COMPILE([ | |
1018 | #include <linux/fs.h> | |
1019 | ],[ | |
50a0749e | 1020 | vfs_unlink((struct inode *) NULL, (struct dentry *) NULL); |
a093c6a4 BB |
1021 | ],[ |
1022 | AC_MSG_RESULT(yes) | |
1023 | AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1, | |
1024 | [vfs_unlink() wants 2 args]) | |
1025 | ],[ | |
1026 | AC_MSG_RESULT(no) | |
50a0749e RY |
1027 | dnl # |
1028 | dnl # Linux 3.13 API change | |
1029 | dnl # Added delegated inode | |
1030 | dnl # | |
1031 | AC_MSG_CHECKING([whether vfs_unlink() wants 3 args]) | |
1032 | SPL_LINUX_TRY_COMPILE([ | |
1033 | #include <linux/fs.h> | |
1034 | ],[ | |
1035 | vfs_unlink((struct inode *) NULL, | |
1036 | (struct dentry *) NULL, | |
1037 | (struct inode **) NULL); | |
1038 | ],[ | |
1039 | AC_MSG_RESULT(yes) | |
1040 | AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1, | |
1041 | [vfs_unlink() wants 3 args]) | |
1042 | ],[ | |
1043 | AC_MSG_ERROR(no) | |
1044 | ]) | |
1045 | ||
a093c6a4 BB |
1046 | ]) |
1047 | ]) | |
1048 | ||
e39174ed BB |
1049 | dnl # |
1050 | dnl # 3.13 and 3.15 API changes | |
1051 | dnl # Added delegated inode and flags argument. | |
1052 | dnl # | |
a093c6a4 BB |
1053 | AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME], |
1054 | [AC_MSG_CHECKING([whether vfs_rename() wants 4 args]) | |
1055 | SPL_LINUX_TRY_COMPILE([ | |
1056 | #include <linux/fs.h> | |
1057 | ],[ | |
50a0749e RY |
1058 | vfs_rename((struct inode *) NULL, (struct dentry *) NULL, |
1059 | (struct inode *) NULL, (struct dentry *) NULL); | |
a093c6a4 BB |
1060 | ],[ |
1061 | AC_MSG_RESULT(yes) | |
1062 | AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1, | |
1063 | [vfs_rename() wants 4 args]) | |
1064 | ],[ | |
1065 | AC_MSG_RESULT(no) | |
50a0749e RY |
1066 | dnl # |
1067 | dnl # Linux 3.13 API change | |
1068 | dnl # Added delegated inode | |
1069 | dnl # | |
1070 | AC_MSG_CHECKING([whether vfs_rename() wants 5 args]) | |
1071 | SPL_LINUX_TRY_COMPILE([ | |
1072 | #include <linux/fs.h> | |
1073 | ],[ | |
1074 | vfs_rename((struct inode *) NULL, | |
1075 | (struct dentry *) NULL, | |
1076 | (struct inode *) NULL, | |
1077 | (struct dentry *) NULL, | |
1078 | (struct inode **) NULL); | |
1079 | ],[ | |
1080 | AC_MSG_RESULT(yes) | |
1081 | AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1, | |
1082 | [vfs_rename() wants 5 args]) | |
1083 | ],[ | |
ad3412ef CC |
1084 | AC_MSG_RESULT(no) |
1085 | dnl # | |
1086 | dnl # Linux 3.15 API change | |
1087 | dnl # Added flags | |
1088 | dnl # | |
1089 | AC_MSG_CHECKING([whether vfs_rename() wants 6 args]) | |
1090 | SPL_LINUX_TRY_COMPILE([ | |
1091 | #include <linux/fs.h> | |
1092 | ],[ | |
1093 | vfs_rename((struct inode *) NULL, | |
1094 | (struct dentry *) NULL, | |
1095 | (struct inode *) NULL, | |
1096 | (struct dentry *) NULL, | |
1097 | (struct inode **) NULL, | |
1098 | (unsigned int) 0); | |
1099 | ],[ | |
1100 | AC_MSG_RESULT(yes) | |
1101 | AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1, | |
1102 | [vfs_rename() wants 6 args]) | |
1103 | ],[ | |
1104 | AC_MSG_ERROR(no) | |
1105 | ]) | |
50a0749e | 1106 | ]) |
a093c6a4 BB |
1107 | ]) |
1108 | ]) | |
ec7d53e9 | 1109 | |
9b2048c2 BB |
1110 | dnl # |
1111 | dnl # 2.6.36 API change, | |
1112 | dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to | |
1113 | dnl # a spinlock_t to improve the fastpath performance. | |
1114 | dnl # | |
1115 | AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [ | |
1116 | AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t]) | |
97fd6a07 BB |
1117 | tmp_flags="$EXTRA_KCFLAGS" |
1118 | EXTRA_KCFLAGS="-Werror" | |
9b2048c2 BB |
1119 | SPL_LINUX_TRY_COMPILE([ |
1120 | #include <linux/sched.h> | |
1121 | #include <linux/fs_struct.h> | |
1122 | ],[ | |
1123 | struct fs_struct fs; | |
1124 | spin_lock_init(&fs.lock); | |
1125 | ],[ | |
1126 | AC_MSG_RESULT(yes) | |
1127 | AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1, | |
1128 | [struct fs_struct uses spinlock_t]) | |
1129 | ],[ | |
1130 | AC_MSG_RESULT(no) | |
1131 | ]) | |
97fd6a07 | 1132 | EXTRA_KCFLAGS="$tmp_flags" |
9b2048c2 BB |
1133 | ]) |
1134 | ||
f7fd6ddd RY |
1135 | dnl # |
1136 | dnl # User namespaces, use kuid_t in place of uid_t | |
1137 | dnl # where available. Not strictly a user namespaces thing | |
1138 | dnl # but it should prevent surprises | |
1139 | dnl # | |
1140 | AC_DEFUN([SPL_AC_KUIDGID_T], [ | |
1141 | AC_MSG_CHECKING([whether kuid_t/kgid_t is available]) | |
1142 | SPL_LINUX_TRY_COMPILE([ | |
1143 | #include <linux/uidgid.h> | |
1144 | ], [ | |
1145 | kuid_t userid = KUIDT_INIT(0); | |
1146 | kgid_t groupid = KGIDT_INIT(0); | |
1147 | ],[ | |
1148 | SPL_LINUX_TRY_COMPILE([ | |
1149 | #include <linux/uidgid.h> | |
1150 | ], [ | |
1151 | kuid_t userid = 0; | |
1152 | kgid_t groupid = 0; | |
1153 | ],[ | |
1154 | AC_MSG_RESULT(yes; optional) | |
1155 | ],[ | |
1156 | AC_MSG_RESULT(yes; mandatory) | |
1157 | AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use]) | |
1158 | ]) | |
1159 | ],[ | |
1160 | AC_MSG_RESULT(no) | |
1161 | ]) | |
1162 | ]) | |
1163 | ||
e811949a | 1164 | dnl # |
e03119e8 BB |
1165 | dnl # 2.6.39 API change, |
1166 | dnl # __put_task_struct() was exported by the mainline kernel. | |
e811949a | 1167 | dnl # |
723aa3b0 ED |
1168 | AC_DEFUN([SPL_AC_PUT_TASK_STRUCT], |
1169 | [AC_MSG_CHECKING([whether __put_task_struct() is available]) | |
1170 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1171 | #include <linux/sched.h> | |
1172 | ], [ | |
1173 | __put_task_struct(NULL); | |
1174 | ], [__put_task_struct], [], [ | |
1175 | AC_MSG_RESULT(yes) | |
1176 | AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1, | |
1177 | [__put_task_struct() is available]) | |
1178 | ], [ | |
1179 | AC_MSG_RESULT(no) | |
1180 | ]) | |
e811949a | 1181 | ]) |
3977f837 | 1182 | |
b868e22f BB |
1183 | dnl # |
1184 | dnl # 2.6.x API change, | |
1185 | dnl # kvasprintf() function added. | |
1186 | dnl # | |
723aa3b0 ED |
1187 | AC_DEFUN([SPL_AC_KVASPRINTF], |
1188 | [AC_MSG_CHECKING([whether kvasprintf() is available]) | |
1189 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1190 | #include <linux/kernel.h> | |
1191 | ], [ | |
1192 | kvasprintf(0, NULL, *((va_list*)NULL)); | |
1193 | ], [kvasprintf], [], [ | |
1194 | AC_MSG_RESULT(yes) | |
1195 | AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available]) | |
1196 | ], [ | |
1197 | AC_MSG_RESULT(no) | |
1198 | ]) | |
b868e22f | 1199 | ]) |
f0ff89fc | 1200 | |
0d0b5237 BB |
1201 | dnl # |
1202 | dnl # 2.6.29 API change, | |
1203 | dnl # vfs_fsync() funcation added, prior to this use file_fsync(). | |
1204 | dnl # | |
723aa3b0 ED |
1205 | AC_DEFUN([SPL_AC_VFS_FSYNC], |
1206 | [AC_MSG_CHECKING([whether vfs_fsync() is available]) | |
1207 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1208 | #include <linux/fs.h> | |
1209 | ], [ | |
1210 | (void) vfs_fsync; | |
1211 | ], [vfs_fsync], [fs/sync.c], [ | |
1212 | AC_MSG_RESULT(yes) | |
1213 | AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available]) | |
1214 | ], [ | |
1215 | AC_MSG_RESULT(no) | |
1216 | ]) | |
0d0b5237 BB |
1217 | ]) |
1218 | ||
f0ff89fc BB |
1219 | dnl # |
1220 | dnl # 2.6.35 API change, | |
0d0b5237 | 1221 | dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype. |
f0ff89fc | 1222 | dnl # |
0d0b5237 BB |
1223 | AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [ |
1224 | AC_MSG_CHECKING([whether vfs_fsync() wants 2 args]) | |
f0ff89fc | 1225 | SPL_LINUX_TRY_COMPILE([ |
0d0b5237 | 1226 | #include <linux/fs.h> |
f0ff89fc | 1227 | ],[ |
0d0b5237 | 1228 | vfs_fsync(NULL, 0); |
f0ff89fc BB |
1229 | ],[ |
1230 | AC_MSG_RESULT(yes) | |
0d0b5237 | 1231 | AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args]) |
f0ff89fc BB |
1232 | ],[ |
1233 | AC_MSG_RESULT(no) | |
1234 | ]) | |
1235 | ]) | |
46aa7b39 | 1236 | |
bbdc6ae4 ED |
1237 | dnl # |
1238 | dnl # 3.5 API change, | |
1239 | dnl # inode_operations.truncate_range removed | |
bbdc6ae4 ED |
1240 | dnl # |
1241 | AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [ | |
1242 | AC_MSG_CHECKING([whether truncate_range() inode operation is available]) | |
1243 | SPL_LINUX_TRY_COMPILE([ | |
1244 | #include <linux/fs.h> | |
1245 | ],[ | |
1246 | struct inode_operations ops; | |
1247 | ops.truncate_range = NULL; | |
1248 | ],[ | |
1249 | AC_MSG_RESULT(yes) | |
1250 | AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1, | |
1251 | [truncate_range() inode operation is available]) | |
1252 | ],[ | |
1253 | AC_MSG_RESULT(no) | |
1254 | ]) | |
1c7b3eaf BB |
1255 | ]) |
1256 | ||
1257 | dnl # | |
1258 | dnl # Linux 2.6.38 - 3.x API | |
1259 | dnl # | |
1260 | AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [ | |
1261 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
1262 | SPL_LINUX_TRY_COMPILE([ | |
1263 | #include <linux/fs.h> | |
1264 | ],[ | |
1265 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
1266 | struct file_operations fops __attribute__ ((unused)) = { | |
1267 | .fallocate = fallocate, | |
1268 | }; | |
1269 | ],[ | |
1270 | AC_MSG_RESULT(yes) | |
1271 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1272 | ],[ | |
1273 | AC_MSG_RESULT(no) | |
1274 | ]) | |
1275 | ]) | |
1276 | ||
1277 | dnl # | |
1278 | dnl # Linux 2.6.x - 2.6.37 API | |
1279 | dnl # | |
1280 | AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [ | |
1281 | AC_MSG_CHECKING([whether iops->fallocate() exists]) | |
1282 | SPL_LINUX_TRY_COMPILE([ | |
1283 | #include <linux/fs.h> | |
1284 | ],[ | |
1285 | long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL; | |
1286 | struct inode_operations fops __attribute__ ((unused)) = { | |
1287 | .fallocate = fallocate, | |
1288 | }; | |
1289 | ],[ | |
1290 | AC_MSG_RESULT(yes) | |
1291 | AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1292 | ],[ | |
1293 | AC_MSG_RESULT(no) | |
1294 | ]) | |
1295 | ]) | |
1296 | ||
1297 | dnl # | |
1298 | dnl # PaX Linux 2.6.38 - 3.x API | |
1299 | dnl # | |
1300 | AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [ | |
1301 | AC_MSG_CHECKING([whether fops->fallocate() exists]) | |
1302 | SPL_LINUX_TRY_COMPILE([ | |
1303 | #include <linux/fs.h> | |
1304 | ],[ | |
1305 | long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL; | |
1306 | struct file_operations_no_const fops __attribute__ ((unused)) = { | |
1307 | .fallocate = fallocate, | |
1308 | }; | |
1309 | ],[ | |
1310 | AC_MSG_RESULT(yes) | |
1311 | AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists]) | |
1312 | ],[ | |
1313 | AC_MSG_RESULT(no) | |
1314 | ]) | |
1315 | ]) | |
1316 | ||
1317 | dnl # | |
1318 | dnl # The fallocate callback was moved from the inode_operations | |
1319 | dnl # structure to the file_operations structure. | |
1320 | dnl # | |
1321 | AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [ | |
1322 | SPL_AC_KERNEL_FILE_FALLOCATE | |
1323 | SPL_AC_KERNEL_INODE_FALLOCATE | |
1324 | SPL_AC_PAX_KERNEL_FILE_FALLOCATE | |
1325 | ]) | |
bbdc6ae4 | 1326 | |
46aa7b39 NB |
1327 | dnl # |
1328 | dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5. | |
1329 | dnl # Earlier versions of rwsem_is_locked() were inline and had a race | |
1330 | dnl # condition. The fixed version is exported as a symbol. The race | |
1331 | dnl # condition is fixed by acquiring sem->wait_lock, so we must not | |
1332 | dnl # call that version while holding sem->wait_lock. | |
1333 | dnl # | |
723aa3b0 ED |
1334 | AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED], |
1335 | [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock]) | |
1336 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1337 | #include <linux/rwsem.h> | |
1338 | int rwsem_is_locked(struct rw_semaphore *sem) { return 0; } | |
1339 | ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [ | |
1340 | AC_MSG_RESULT(yes) | |
1341 | AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1, | |
1342 | [rwsem_is_locked() acquires sem->wait_lock]) | |
1343 | ], [ | |
1344 | AC_MSG_RESULT(no) | |
723aa3b0 | 1345 | ]) |
e76f4bf1 | 1346 | ]) |
b1cbc461 BB |
1347 | |
1348 | dnl # | |
ec18fe3c RY |
1349 | dnl # 2.6.28 API change |
1350 | dnl # The kern_path() function has been introduced. We adopt it as the new way | |
1351 | dnl # of looking up paths. When it is not available, we emulate it using the | |
1352 | dnl # older interfaces. | |
b1cbc461 | 1353 | dnl # |
ec18fe3c RY |
1354 | AC_DEFUN([SPL_AC_KERN_PATH], |
1355 | [AC_MSG_CHECKING([whether kern_path() is available]) | |
723aa3b0 ED |
1356 | SPL_LINUX_TRY_COMPILE_SYMBOL([ |
1357 | #include <linux/namei.h> | |
1358 | ], [ | |
ec18fe3c RY |
1359 | int r = kern_path(NULL, 0, NULL); |
1360 | ], [kern_path], [fs/namei.c], [ | |
723aa3b0 | 1361 | AC_MSG_RESULT(yes) |
ec18fe3c RY |
1362 | AC_DEFINE(HAVE_KERN_PATH, 1, |
1363 | [kern_path() is available]) | |
723aa3b0 ED |
1364 | ], [ |
1365 | AC_MSG_RESULT(no) | |
ec18fe3c RY |
1366 | AC_MSG_CHECKING([whether path_lookup() is available]) |
1367 | SPL_LINUX_TRY_COMPILE_SYMBOL([ | |
1368 | #include <linux/namei.h> | |
1369 | ], [ | |
1370 | int r = path_lookup(NULL, 0, NULL); | |
1371 | ], [path_lookup], [fs/namei.c], [ | |
1372 | AC_MSG_RESULT(yes) | |
1373 | AC_DEFINE(HAVE_KERN_PATH, 1, | |
1374 | [kern_path() is available]) | |
1375 | ], [ | |
1376 | AC_MSG_RESULT(no) | |
1377 | AC_MSG_ERROR([ | |
1378 | *** Neither kern_path() nor path_lookup() is available. | |
1379 | *** Please file an issue: | |
1380 | *** https://github.com/zfsonlinux/spl/issues/new]) | |
3dfc591a | 1381 | |
ec18fe3c RY |
1382 | ]) |
1383 | ]) | |
bcb15891 YS |
1384 | ]) |
1385 | ||
42b3ce62 BB |
1386 | dnl # |
1387 | dnl # zlib inflate compat, | |
1388 | dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled. | |
1389 | dnl # | |
1390 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [ | |
1391 | AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined]) | |
1392 | SPL_LINUX_TRY_COMPILE([ | |
1393 | #if !defined(CONFIG_ZLIB_INFLATE) && \ | |
1394 | !defined(CONFIG_ZLIB_INFLATE_MODULE) | |
1395 | #error CONFIG_ZLIB_INFLATE not defined | |
1396 | #endif | |
1397 | ],[ ],[ | |
1398 | AC_MSG_RESULT([yes]) | |
1399 | ],[ | |
1400 | AC_MSG_RESULT([no]) | |
1401 | AC_MSG_ERROR([ | |
1402 | *** This kernel does not include the required zlib inflate support. | |
1403 | *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.]) | |
1404 | ]) | |
1405 | ]) | |
1406 | ||
1407 | dnl # | |
1408 | dnl # zlib deflate compat, | |
1409 | dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled. | |
1410 | dnl # | |
1411 | AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [ | |
1412 | AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined]) | |
1413 | SPL_LINUX_TRY_COMPILE([ | |
1414 | #if !defined(CONFIG_ZLIB_DEFLATE) && \ | |
1415 | !defined(CONFIG_ZLIB_DEFLATE_MODULE) | |
1416 | #error CONFIG_ZLIB_DEFLATE not defined | |
1417 | #endif | |
1418 | ],[ ],[ | |
1419 | AC_MSG_RESULT([yes]) | |
1420 | ],[ | |
1421 | AC_MSG_RESULT([no]) | |
1422 | AC_MSG_ERROR([ | |
1423 | *** This kernel does not include the required zlib deflate support. | |
1424 | *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.]) | |
1425 | ]) | |
1426 | ]) | |
1427 | ||
3dfc591a BB |
1428 | dnl # |
1429 | dnl # 2.6.39 API compat, | |
1430 | dnl # The function zlib_deflate_workspacesize() now take 2 arguments. | |
1431 | dnl # This was done to avoid always having to allocate the maximum size | |
1432 | dnl # workspace (268K). The caller can now specific the windowBits and | |
1433 | dnl # memLevel compression parameters to get a smaller workspace. | |
1434 | dnl # | |
1435 | AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE], | |
1436 | [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args]) | |
1437 | SPL_LINUX_TRY_COMPILE([ | |
1438 | #include <linux/zlib.h> | |
1439 | ],[ | |
1440 | return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL); | |
1441 | ],[ | |
1442 | AC_MSG_RESULT(yes) | |
1443 | AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1, | |
1444 | [zlib_deflate_workspacesize() wants 2 args]) | |
1445 | ],[ | |
1446 | AC_MSG_RESULT(no) | |
1447 | ]) | |
1448 | ]) | |
a55bcaad BB |
1449 | |
1450 | dnl # | |
1451 | dnl # 2.6.39 API change, | |
1452 | dnl # Shrinker adjust to use common shrink_control structure. | |
1453 | dnl # | |
1454 | AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [ | |
1455 | AC_MSG_CHECKING([whether struct shrink_control exists]) | |
1456 | SPL_LINUX_TRY_COMPILE([ | |
1457 | #include <linux/mm.h> | |
1458 | ],[ | |
1459 | struct shrink_control sc __attribute__ ((unused)); | |
1460 | ||
1461 | sc.nr_to_scan = 0; | |
1462 | sc.gfp_mask = GFP_KERNEL; | |
1463 | ],[ | |
1464 | AC_MSG_RESULT(yes) | |
1465 | AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1, | |
1466 | [struct shrink_control exists]) | |
1467 | ],[ | |
1468 | AC_MSG_RESULT(no) | |
1469 | ]) | |
1470 | ]) | |
588d9004 DH |
1471 | |
1472 | dnl # | |
1473 | dnl # 3.1 API Change | |
1474 | dnl # | |
1475 | dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to | |
1476 | dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1. | |
1477 | dnl # | |
1478 | AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [ | |
1479 | AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw]) | |
1480 | tmp_flags="$EXTRA_KCFLAGS" | |
1481 | EXTRA_KCFLAGS="-Werror" | |
1482 | SPL_LINUX_TRY_COMPILE([ | |
1483 | #include <linux/rwsem.h> | |
1484 | ],[ | |
1485 | struct rw_semaphore dummy_semaphore __attribute__ ((unused)); | |
1486 | raw_spinlock_t dummy_lock __attribute__ ((unused)); | |
1487 | dummy_semaphore.wait_lock = dummy_lock; | |
1488 | ],[ | |
1489 | AC_MSG_RESULT(yes) | |
1490 | AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1, | |
1491 | [struct rw_semaphore member wait_lock is raw_spinlock_t]) | |
1492 | ],[ | |
1493 | AC_MSG_RESULT(no) | |
1494 | ]) | |
1495 | EXTRA_KCFLAGS="$tmp_flags" | |
1496 | ]) | |
10087fe1 RY |
1497 | |
1498 | dnl # | |
1499 | dnl # 3.9 API change, | |
1500 | dnl # Moved things from linux/sched.h to linux/sched/rt.h | |
1501 | dnl # | |
1502 | AC_DEFUN([SPL_AC_SCHED_RT_HEADER], | |
1503 | [AC_MSG_CHECKING([whether header linux/sched/rt.h exists]) | |
1504 | SPL_LINUX_TRY_COMPILE([ | |
1505 | #include <linux/sched.h> | |
1506 | #include <linux/sched/rt.h> | |
1507 | ],[ | |
1508 | return 0; | |
1509 | ],[ | |
1510 | AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists]) | |
1511 | AC_MSG_RESULT(yes) | |
1512 | ],[ | |
1513 | AC_MSG_RESULT(no) | |
1514 | ]) | |
1515 | ]) | |
2a305c34 RY |
1516 | |
1517 | dnl # | |
1518 | dnl # 3.9 API change, | |
1519 | dnl # vfs_getattr() uses 2 args | |
1520 | dnl # It takes struct path * instead of struct vfsmount * and struct dentry * | |
1521 | dnl # | |
1522 | AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [ | |
1523 | AC_MSG_CHECKING([whether vfs_getattr() wants]) | |
1524 | SPL_LINUX_TRY_COMPILE([ | |
1525 | #include <linux/fs.h> | |
1526 | ],[ | |
1527 | vfs_getattr((struct path *) NULL, | |
1528 | (struct kstat *)NULL); | |
1529 | ],[ | |
1530 | AC_MSG_RESULT(2 args) | |
1531 | AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1, | |
1532 | [vfs_getattr wants 2 args]) | |
1533 | ],[ | |
1534 | SPL_LINUX_TRY_COMPILE([ | |
1535 | #include <linux/fs.h> | |
1536 | ],[ | |
1537 | vfs_getattr((struct vfsmount *)NULL, | |
1538 | (struct dentry *)NULL, | |
1539 | (struct kstat *)NULL); | |
1540 | ],[ | |
1541 | AC_MSG_RESULT(3 args) | |
1542 | ],[ | |
1543 | AC_MSG_ERROR(unknown) | |
1544 | ]) | |
1545 | ]) | |
1546 | ]) | |
184c6873 NB |
1547 | |
1548 | dnl # | |
1549 | dnl # 2.6.36 API compatibility. | |
1550 | dnl # Added usleep_range timer. | |
1551 | dnl # usleep_range is a finer precision implementation of msleep | |
1552 | dnl # designed to be a drop-in replacement for udelay where a precise | |
1553 | dnl # sleep / busy-wait is unnecessary. | |
1554 | dnl # | |
1555 | AC_DEFUN([SPL_AC_USLEEP_RANGE], [ | |
1556 | AC_MSG_CHECKING([whether usleep_range() is available]) | |
1557 | SPL_LINUX_TRY_COMPILE([ | |
1558 | #include <linux/delay.h> | |
1559 | ],[ | |
1560 | usleep_range(0, 0); | |
1561 | ],[ | |
1562 | AC_MSG_RESULT(yes) | |
1563 | AC_DEFINE(HAVE_USLEEP_RANGE, 1, | |
1564 | [usleep_range is available]) | |
1565 | ],[ | |
1566 | AC_MSG_RESULT(no) | |
1567 | ]) | |
1568 | ]) | |
a073aeb0 BB |
1569 | |
1570 | dnl # | |
1571 | dnl # 2.6.35 API change, | |
1572 | dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are | |
1573 | dnl # private allocation flags which are applied when allocating a new slab | |
1574 | dnl # in kmem_getpages(). Unfortunately there is no public API for setting | |
1575 | dnl # non-default flags. | |
1576 | dnl # | |
1577 | AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [ | |
1578 | AC_MSG_CHECKING([whether struct kmem_cache has allocflags]) | |
1579 | SPL_LINUX_TRY_COMPILE([ | |
1580 | #include <linux/slab.h> | |
1581 | ],[ | |
1582 | struct kmem_cache cachep __attribute__ ((unused)); | |
1583 | cachep.allocflags = GFP_KERNEL; | |
1584 | ],[ | |
1585 | AC_MSG_RESULT(yes) | |
1586 | AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1, | |
1587 | [struct kmem_cache has allocflags]) | |
1588 | ],[ | |
1589 | AC_MSG_RESULT(no) | |
1590 | ||
1591 | AC_MSG_CHECKING([whether struct kmem_cache has gfpflags]) | |
1592 | SPL_LINUX_TRY_COMPILE([ | |
1593 | #include <linux/slab.h> | |
1594 | ],[ | |
1595 | struct kmem_cache cachep __attribute__ ((unused)); | |
1596 | cachep.gfpflags = GFP_KERNEL; | |
1597 | ],[ | |
1598 | AC_MSG_RESULT(yes) | |
1599 | AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1, | |
1600 | [struct kmem_cache has gfpflags]) | |
1601 | ],[ | |
1602 | AC_MSG_RESULT(no) | |
1603 | ]) | |
1604 | ]) | |
1605 | ]) | |
2fc44f66 NB |
1606 | |
1607 | dnl # | |
1608 | dnl # 3.17 API change, | |
1609 | dnl # wait_on_bit() no longer requires an action argument. The former | |
1610 | dnl # "wait_on_bit" interface required an 'action' function to be provided | |
1611 | dnl # which does the actual waiting. There were over 20 such functions in the | |
1612 | dnl # kernel, many of them identical, though most cases can be satisfied by one | |
1613 | dnl # of just two functions: one which uses io_schedule() and one which just | |
1614 | dnl # uses schedule(). This API change was made to consolidate all of those | |
1615 | dnl # redundant wait functions. | |
1616 | dnl # | |
1617 | AC_DEFUN([SPL_AC_WAIT_ON_BIT], [ | |
1618 | AC_MSG_CHECKING([whether wait_on_bit() takes an action]) | |
1619 | SPL_LINUX_TRY_COMPILE([ | |
1620 | #include <linux/wait.h> | |
1621 | ],[ | |
1622 | int (*action)(void *) = NULL; | |
1623 | wait_on_bit(NULL, 0, action, 0); | |
1624 | ],[ | |
1625 | AC_MSG_RESULT(yes) | |
1626 | AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes]) | |
1627 | ],[ | |
1628 | AC_MSG_RESULT(no) | |
1629 | ]) | |
1630 | ]) |