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