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