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