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