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