]> git.proxmox.com Git - mirror_spl.git/blob - config/spl-build.m4
Linux 3.17 compat: remove wait_on_bit action function
[mirror_spl.git] / config / spl-build.m4
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
9 AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
10 SPL_AC_KERNEL
11
12 if test "${LINUX_OBJ}" != "${LINUX}"; then
13 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
14 fi
15 AC_SUBST(KERNELMAKE_PARAMS)
16
17 KERNELCPPFLAGS="$KERNELCPPFLAGS -Wstrict-prototypes"
18 AC_SUBST(KERNELCPPFLAGS)
19
20 SPL_AC_DEBUG
21 SPL_AC_DEBUG_LOG
22 SPL_AC_DEBUG_KMEM
23 SPL_AC_DEBUG_KMEM_TRACKING
24 SPL_AC_TEST_MODULE
25 SPL_AC_ATOMIC_SPINLOCK
26 SPL_AC_TYPE_ATOMIC64_CMPXCHG
27 SPL_AC_TYPE_ATOMIC64_XCHG
28 SPL_AC_TYPE_UINTPTR_T
29 SPL_AC_2ARGS_REGISTER_SYSCTL
30 SPL_AC_SHRINKER_CALLBACK
31 SPL_AC_PATH_IN_NAMEIDATA
32 SPL_AC_TASK_CURR
33 SPL_AC_CTL_UNNUMBERED
34 SPL_AC_CTL_NAME
35 SPL_AC_VMALLOC_INFO
36 SPL_AC_PDE_DATA
37 SPL_AC_FLS64
38 SPL_AC_DEVICE_CREATE
39 SPL_AC_5ARGS_DEVICE_CREATE
40 SPL_AC_CLASS_DEVICE_CREATE
41 SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
42 SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
43 SPL_AC_TIMESPEC_SUB
44 SPL_AC_INIT_UTSNAME
45 SPL_AC_UACCESS_HEADER
46 SPL_AC_KMALLOC_NODE
47 SPL_AC_MONOTONIC_CLOCK
48 SPL_AC_INODE_I_MUTEX
49 SPL_AC_MUTEX_OWNER
50 SPL_AC_MUTEX_OWNER_TASK_STRUCT
51 SPL_AC_MUTEX_LOCK_NESTED
52 SPL_AC_3ARGS_ON_EACH_CPU
53 SPL_AC_KALLSYMS_LOOKUP_NAME
54 SPL_AC_GET_VMALLOC_INFO
55 SPL_AC_PGDAT_HELPERS
56 SPL_AC_FIRST_ONLINE_PGDAT
57 SPL_AC_NEXT_ONLINE_PGDAT
58 SPL_AC_NEXT_ZONE
59 SPL_AC_PGDAT_LIST
60 SPL_AC_GLOBAL_PAGE_STATE
61 SPL_AC_ZONE_STAT_ITEM_FREE
62 SPL_AC_ZONE_STAT_ITEM_INACTIVE
63 SPL_AC_ZONE_STAT_ITEM_ACTIVE
64 SPL_AC_GET_ZONE_COUNTS
65 SPL_AC_USER_PATH_DIR
66 SPL_AC_SET_FS_PWD
67 SPL_AC_SET_FS_PWD_WITH_CONST
68 SPL_AC_2ARGS_VFS_UNLINK
69 SPL_AC_4ARGS_VFS_RENAME
70 SPL_AC_VFS_FSYNC
71 SPL_AC_2ARGS_VFS_FSYNC
72 SPL_AC_INODE_TRUNCATE_RANGE
73 SPL_AC_FS_STRUCT_SPINLOCK
74 SPL_AC_CRED_STRUCT
75 SPL_AC_KUIDGID_T
76 SPL_AC_GROUPS_SEARCH
77 SPL_AC_PUT_TASK_STRUCT
78 SPL_AC_5ARGS_PROC_HANDLER
79 SPL_AC_KVASPRINTF
80 SPL_AC_EXPORTED_RWSEM_IS_LOCKED
81 SPL_AC_KERNEL_FALLOCATE
82 SPL_AC_SHRINK_DCACHE_MEMORY
83 SPL_AC_SHRINK_ICACHE_MEMORY
84 SPL_AC_KERN_PATH_PARENT_HEADER
85 SPL_AC_KERN_PATH_PARENT_SYMBOL
86 SPL_AC_KERN_PATH_LOCKED
87 SPL_AC_CONFIG_KALLSYMS
88 SPL_AC_CONFIG_ZLIB_INFLATE
89 SPL_AC_CONFIG_ZLIB_DEFLATE
90 SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
91 SPL_AC_SHRINK_CONTROL_STRUCT
92 SPL_AC_RWSEM_SPINLOCK_IS_RAW
93 SPL_AC_SCHED_RT_HEADER
94 SPL_AC_2ARGS_VFS_GETATTR
95 SPL_AC_USLEEP_RANGE
96 SPL_AC_KMEM_CACHE_ALLOCFLAGS
97 SPL_AC_WAIT_ON_BIT
98 ])
99
100 AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
101 modpost=$LINUX/scripts/Makefile.modpost
102 AC_MSG_CHECKING([kernel file name for module symbols])
103 if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
104 if grep -q Modules.symvers $modpost; then
105 LINUX_SYMBOLS=Modules.symvers
106 else
107 LINUX_SYMBOLS=Module.symvers
108 fi
109
110 if ! test -f "$LINUX_OBJ/$LINUX_SYMBOLS"; then
111 AC_MSG_ERROR([
112 *** Please make sure the kernel devel package for your distribution
113 *** is installed. If you are building with a custom kernel, make sure the
114 *** kernel is configured, built, and the '--with-linux=PATH' configure
115 *** option refers to the location of the kernel source.])
116 fi
117 else
118 LINUX_SYMBOLS=NONE
119 fi
120 AC_MSG_RESULT($LINUX_SYMBOLS)
121 AC_SUBST(LINUX_SYMBOLS)
122 ])
123
124 AC_DEFUN([SPL_AC_KERNEL], [
125 AC_ARG_WITH([linux],
126 AS_HELP_STRING([--with-linux=PATH],
127 [Path to kernel source]),
128 [kernelsrc="$withval"])
129
130 AC_ARG_WITH([linux-obj],
131 AS_HELP_STRING([--with-linux-obj=PATH],
132 [Path to kernel build objects]),
133 [kernelbuild="$withval"])
134
135 AC_MSG_CHECKING([kernel source directory])
136 if test -z "$kernelsrc"; then
137 if test -e "/lib/modules/$(uname -r)/source"; then
138 headersdir="/lib/modules/$(uname -r)/source"
139 sourcelink=$(readlink -f "$headersdir")
140 elif test -e "/lib/modules/$(uname -r)/build"; then
141 headersdir="/lib/modules/$(uname -r)/build"
142 sourcelink=$(readlink -f "$headersdir")
143 else
144 sourcelink=$(ls -1d /usr/src/kernels/* \
145 /usr/src/linux-* \
146 2>/dev/null | grep -v obj | tail -1)
147 fi
148
149 if test -n "$sourcelink" && test -e ${sourcelink}; then
150 kernelsrc=`readlink -f ${sourcelink}`
151 else
152 kernelsrc="[Not found]"
153 fi
154 else
155 if test "$kernelsrc" = "NONE"; then
156 kernsrcver=NONE
157 fi
158 fi
159
160 AC_MSG_RESULT([$kernelsrc])
161 if test ! -d "$kernelsrc"; then
162 AC_MSG_ERROR([
163 *** Please make sure the kernel devel package for your distribution
164 *** is installed and then try again. If that fails, you can specify the
165 *** location of the kernel source with the '--with-linux=PATH' option.])
166 fi
167
168 AC_MSG_CHECKING([kernel build directory])
169 if test -z "$kernelbuild"; then
170 if test -e "/lib/modules/$(uname -r)/build"; then
171 kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`
172 elif test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}; then
173 kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
174 elif test -d ${kernelsrc}-obj/${target_cpu}/default; then
175 kernelbuild=${kernelsrc}-obj/${target_cpu}/default
176 elif test -d `dirname ${kernelsrc}`/build-${target_cpu}; then
177 kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
178 else
179 kernelbuild=${kernelsrc}
180 fi
181 fi
182 AC_MSG_RESULT([$kernelbuild])
183
184 AC_MSG_CHECKING([kernel source version])
185 utsrelease1=$kernelbuild/include/linux/version.h
186 utsrelease2=$kernelbuild/include/linux/utsrelease.h
187 utsrelease3=$kernelbuild/include/generated/utsrelease.h
188 if test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1; then
189 utsrelease=linux/version.h
190 elif test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2; then
191 utsrelease=linux/utsrelease.h
192 elif test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3; then
193 utsrelease=generated/utsrelease.h
194 fi
195
196 if test "$utsrelease"; then
197 kernsrcver=`(echo "#include <$utsrelease>";
198 echo "kernsrcver=UTS_RELEASE") |
199 cpp -I $kernelbuild/include |
200 grep "^kernsrcver=" | cut -d \" -f 2`
201
202 if test -z "$kernsrcver"; then
203 AC_MSG_RESULT([Not found])
204 AC_MSG_ERROR([*** Cannot determine kernel version.])
205 fi
206 else
207 AC_MSG_RESULT([Not found])
208 if test "x$enable_linux_builtin" != xyes; then
209 AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
210 else
211 AC_MSG_ERROR([
212 *** Cannot find UTS_RELEASE definition.
213 *** Please run 'make prepare' inside the kernel source tree.])
214 fi
215 fi
216
217 AC_MSG_RESULT([$kernsrcver])
218
219 LINUX=${kernelsrc}
220 LINUX_OBJ=${kernelbuild}
221 LINUX_VERSION=${kernsrcver}
222
223 AC_SUBST(LINUX)
224 AC_SUBST(LINUX_OBJ)
225 AC_SUBST(LINUX_VERSION)
226
227 SPL_AC_MODULE_SYMVERS
228 ])
229
230 dnl #
231 dnl # Default SPL user configuration
232 dnl #
233 AC_DEFUN([SPL_AC_CONFIG_USER], [])
234
235 dnl #
236 dnl # Check for rpm+rpmbuild to build RPM packages. If these tools
237 dnl # are missing, it is non-fatal, but you will not be able to build
238 dnl # RPM packages and will be warned if you try too.
239 dnl #
240 dnl # By default, the generic spec file will be used because it requires
241 dnl # minimal dependencies. Distribution specific spec files can be
242 dnl # placed under the 'rpm/<distribution>' directory and enabled using
243 dnl # the --with-spec=<distribution> configure option.
244 dnl #
245 AC_DEFUN([SPL_AC_RPM], [
246 RPM=rpm
247 RPMBUILD=rpmbuild
248
249 AC_MSG_CHECKING([whether $RPM is available])
250 AS_IF([tmp=$($RPM --version 2>/dev/null)], [
251 RPM_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
252 HAVE_RPM=yes
253 AC_MSG_RESULT([$HAVE_RPM ($RPM_VERSION)])
254 ],[
255 HAVE_RPM=no
256 AC_MSG_RESULT([$HAVE_RPM])
257 ])
258
259 AC_MSG_CHECKING([whether $RPMBUILD is available])
260 AS_IF([tmp=$($RPMBUILD --version 2>/dev/null)], [
261 RPMBUILD_VERSION=$(echo $tmp | $AWK '/RPM/ { print $[3] }')
262 HAVE_RPMBUILD=yes
263 AC_MSG_RESULT([$HAVE_RPMBUILD ($RPMBUILD_VERSION)])
264 ],[
265 HAVE_RPMBUILD=no
266 AC_MSG_RESULT([$HAVE_RPMBUILD])
267 ])
268
269 RPM_DEFINE_COMMON='--define "$(DEBUG_SPL) 1" --define "$(DEBUG_LOG) 1" --define "$(DEBUG_KMEM) 1" --define "$(DEBUG_KMEM_TRACKING) 1"'
270 RPM_DEFINE_UTIL=
271 RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
272 RPM_DEFINE_DKMS=
273
274 SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
275 SRPM_DEFINE_UTIL=
276 SRPM_DEFINE_KMOD=
277 SRPM_DEFINE_DKMS=
278
279 RPM_SPEC_DIR="rpm/generic"
280 AC_ARG_WITH([spec],
281 AS_HELP_STRING([--with-spec=SPEC],
282 [Spec files 'generic|fedora']),
283 [RPM_SPEC_DIR="rpm/$withval"])
284
285 AC_MSG_CHECKING([whether spec files are available])
286 AC_MSG_RESULT([yes ($RPM_SPEC_DIR/*.spec.in)])
287
288 AC_SUBST(HAVE_RPM)
289 AC_SUBST(RPM)
290 AC_SUBST(RPM_VERSION)
291
292 AC_SUBST(HAVE_RPMBUILD)
293 AC_SUBST(RPMBUILD)
294 AC_SUBST(RPMBUILD_VERSION)
295
296 AC_SUBST(RPM_SPEC_DIR)
297 AC_SUBST(RPM_DEFINE_UTIL)
298 AC_SUBST(RPM_DEFINE_KMOD)
299 AC_SUBST(RPM_DEFINE_DKMS)
300 AC_SUBST(RPM_DEFINE_COMMON)
301 AC_SUBST(SRPM_DEFINE_UTIL)
302 AC_SUBST(SRPM_DEFINE_KMOD)
303 AC_SUBST(SRPM_DEFINE_DKMS)
304 AC_SUBST(SRPM_DEFINE_COMMON)
305 ])
306
307 dnl #
308 dnl # Check for dpkg+dpkg-buildpackage to build DEB packages. If these
309 dnl # tools are missing it is non-fatal but you will not be able to build
310 dnl # DEB packages and will be warned if you try too.
311 dnl #
312 AC_DEFUN([SPL_AC_DPKG], [
313 DPKG=dpkg
314 DPKGBUILD=dpkg-buildpackage
315
316 AC_MSG_CHECKING([whether $DPKG is available])
317 AS_IF([tmp=$($DPKG --version 2>/dev/null)], [
318 DPKG_VERSION=$(echo $tmp | $AWK '/Debian/ { print $[7] }')
319 HAVE_DPKG=yes
320 AC_MSG_RESULT([$HAVE_DPKG ($DPKG_VERSION)])
321 ],[
322 HAVE_DPKG=no
323 AC_MSG_RESULT([$HAVE_DPKG])
324 ])
325
326 AC_MSG_CHECKING([whether $DPKGBUILD is available])
327 AS_IF([tmp=$($DPKGBUILD --version 2>/dev/null)], [
328 DPKGBUILD_VERSION=$(echo $tmp | \
329 $AWK '/Debian/ { print $[4] }' | cut -f-4 -d'.')
330 HAVE_DPKGBUILD=yes
331 AC_MSG_RESULT([$HAVE_DPKGBUILD ($DPKGBUILD_VERSION)])
332 ],[
333 HAVE_DPKGBUILD=no
334 AC_MSG_RESULT([$HAVE_DPKGBUILD])
335 ])
336
337 AC_SUBST(HAVE_DPKG)
338 AC_SUBST(DPKG)
339 AC_SUBST(DPKG_VERSION)
340
341 AC_SUBST(HAVE_DPKGBUILD)
342 AC_SUBST(DPKGBUILD)
343 AC_SUBST(DPKGBUILD_VERSION)
344 ])
345
346 dnl #
347 dnl # Until native packaging for various different packing systems
348 dnl # can be added the least we can do is attempt to use alien to
349 dnl # convert the RPM packages to the needed package type. This is
350 dnl # a hack but so far it has worked reasonable well.
351 dnl #
352 AC_DEFUN([SPL_AC_ALIEN], [
353 ALIEN=alien
354
355 AC_MSG_CHECKING([whether $ALIEN is available])
356 AS_IF([tmp=$($ALIEN --version 2>/dev/null)], [
357 ALIEN_VERSION=$(echo $tmp | $AWK '{ print $[3] }')
358 HAVE_ALIEN=yes
359 AC_MSG_RESULT([$HAVE_ALIEN ($ALIEN_VERSION)])
360 ],[
361 HAVE_ALIEN=no
362 AC_MSG_RESULT([$HAVE_ALIEN])
363 ])
364
365 AC_SUBST(HAVE_ALIEN)
366 AC_SUBST(ALIEN)
367 AC_SUBST(ALIEN_VERSION)
368 ])
369
370 dnl #
371 dnl # Using the VENDOR tag from config.guess set the default
372 dnl # package type for 'make pkg': (rpm | deb | tgz)
373 dnl #
374 AC_DEFUN([SPL_AC_DEFAULT_PACKAGE], [
375 AC_MSG_CHECKING([linux distribution])
376 if test -f /etc/toss-release ; then
377 VENDOR=toss ;
378 elif test -f /etc/fedora-release ; then
379 VENDOR=fedora ;
380 elif test -f /etc/redhat-release ; then
381 VENDOR=redhat ;
382 elif test -f /etc/gentoo-release ; then
383 VENDOR=gentoo ;
384 elif test -f /etc/arch-release ; then
385 VENDOR=arch ;
386 elif test -f /etc/SuSE-release ; then
387 VENDOR=sles ;
388 elif test -f /etc/slackware-version ; then
389 VENDOR=slackware ;
390 elif test -f /etc/lunar.release ; then
391 VENDOR=lunar ;
392 elif test -f /etc/lsb-release ; then
393 VENDOR=ubuntu ;
394 elif test -f /etc/debian_version ; then
395 VENDOR=debian ;
396 else
397 VENDOR= ;
398 fi
399 AC_MSG_RESULT([$VENDOR])
400 AC_SUBST(VENDOR)
401
402 AC_MSG_CHECKING([default package type])
403 case "$VENDOR" in
404 toss) DEFAULT_PACKAGE=rpm ;;
405 redhat) DEFAULT_PACKAGE=rpm ;;
406 fedora) DEFAULT_PACKAGE=rpm ;;
407 gentoo) DEFAULT_PACKAGE=tgz ;;
408 arch) DEFAULT_PACKAGE=tgz ;;
409 sles) DEFAULT_PACKAGE=rpm ;;
410 slackware) DEFAULT_PACKAGE=tgz ;;
411 lunar) DEFAULT_PACKAGE=tgz ;;
412 ubuntu) DEFAULT_PACKAGE=deb ;;
413 debian) DEFAULT_PACKAGE=deb ;;
414 *) DEFAULT_PACKAGE=rpm ;;
415 esac
416
417 AC_MSG_RESULT([$DEFAULT_PACKAGE])
418 AC_SUBST(DEFAULT_PACKAGE)
419 ])
420
421 dnl #
422 dnl # Default SPL user configuration
423 dnl #
424 AC_DEFUN([SPL_AC_PACKAGE], [
425 SPL_AC_DEFAULT_PACKAGE
426 SPL_AC_RPM
427 SPL_AC_DPKG
428 SPL_AC_ALIEN
429 ])
430
431 AC_DEFUN([SPL_AC_LICENSE], [
432 AC_MSG_CHECKING([spl license])
433 LICENSE=GPL
434 AC_MSG_RESULT([$LICENSE])
435 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DHAVE_GPL_ONLY_SYMBOLS"
436 AC_SUBST(LICENSE)
437 ])
438
439 AC_DEFUN([SPL_AC_CONFIG], [
440 SPL_CONFIG=all
441 AC_ARG_WITH([config],
442 AS_HELP_STRING([--with-config=CONFIG],
443 [Config file 'kernel|user|all|srpm']),
444 [SPL_CONFIG="$withval"])
445 AC_ARG_ENABLE([linux-builtin],
446 [AC_HELP_STRING([--enable-linux-builtin],
447 [Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
448 [],
449 [enable_linux_builtin=no])
450
451 AC_MSG_CHECKING([spl config])
452 AC_MSG_RESULT([$SPL_CONFIG]);
453 AC_SUBST(SPL_CONFIG)
454
455 case "$SPL_CONFIG" in
456 kernel) SPL_AC_CONFIG_KERNEL ;;
457 user) SPL_AC_CONFIG_USER ;;
458 all) SPL_AC_CONFIG_KERNEL
459 SPL_AC_CONFIG_USER ;;
460 srpm) ;;
461 *)
462 AC_MSG_RESULT([Error!])
463 AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
464 user kernel|user|all|srpm]) ;;
465 esac
466
467 AM_CONDITIONAL([CONFIG_USER],
468 [test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
469 AM_CONDITIONAL([CONFIG_KERNEL],
470 [test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
471 [test "x$enable_linux_builtin" != xyes ])
472 ])
473
474 dnl #
475 dnl # Enable if the SPL should be compiled with internal debugging enabled.
476 dnl # By default this support is disabled.
477 dnl #
478 AC_DEFUN([SPL_AC_DEBUG], [
479 AC_MSG_CHECKING([whether debugging is enabled])
480 AC_ARG_ENABLE([debug],
481 [AS_HELP_STRING([--enable-debug],
482 [Enable generic debug support @<:@default=no@:>@])],
483 [],
484 [enable_debug=no])
485
486 AS_IF([test "x$enable_debug" = xyes],
487 [
488 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
489 DEBUG_CFLAGS="-DDEBUG -Werror"
490 DEBUG_SPL="_with_debug"
491 ], [
492 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
493 DEBUG_CFLAGS="-DNDEBUG"
494 DEBUG_SPL="_without_debug"
495 ])
496
497 AC_SUBST(DEBUG_CFLAGS)
498 AC_SUBST(DEBUG_SPL)
499 AC_MSG_RESULT([$enable_debug])
500 ])
501
502 dnl #
503 dnl # Enabled by default it provides a basic debug log infrastructure.
504 dnl # Each subsystem registers itself with a name and logs messages
505 dnl # using predefined types. If the debug mask it set to allow the
506 dnl # message type it will be written to the internal log. The log
507 dnl # can be dumped to a file by echoing 1 to the 'dump' proc entry,
508 dnl # after dumping the log it must be decoded using the spl utility.
509 dnl #
510 dnl # echo 1 >/proc/sys/kernel/spl/debug/dump
511 dnl # spl /tmp/spl-log.xxx.yyy /tmp/spl-log.xxx.yyy.txt
512 dnl #
513 AC_DEFUN([SPL_AC_DEBUG_LOG], [
514 AC_ARG_ENABLE([debug-log],
515 [AS_HELP_STRING([--enable-debug-log],
516 [Enable basic debug logging @<:@default=yes@:>@])],
517 [],
518 [enable_debug_log=yes])
519
520 AS_IF([test "x$enable_debug_log" = xyes],
521 [
522 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_LOG"
523 DEBUG_LOG="_with_debug_log"
524 AC_DEFINE([DEBUG_LOG], [1],
525 [Define to 1 to enable basic debug logging])
526 ], [
527 DEBUG_LOG="_without_debug_log"
528 ])
529
530 AC_SUBST(DEBUG_LOG)
531 AC_MSG_CHECKING([whether basic debug logging is enabled])
532 AC_MSG_RESULT([$enable_debug_log])
533 ])
534
535 dnl #
536 dnl # Enabled by default it provides a minimal level of memory tracking.
537 dnl # A total count of bytes allocated is kept for each alloc and free.
538 dnl # Then at module unload time a report to the console will be printed
539 dnl # if memory was leaked. Additionally, /proc/spl/kmem/slab will exist
540 dnl # and provide an easy way to inspect the kmem based slab.
541 dnl #
542 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
543 AC_ARG_ENABLE([debug-kmem],
544 [AS_HELP_STRING([--enable-debug-kmem],
545 [Enable basic kmem accounting @<:@default=yes@:>@])],
546 [],
547 [enable_debug_kmem=yes])
548
549 AS_IF([test "x$enable_debug_kmem" = xyes],
550 [
551 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
552 DEBUG_KMEM="_with_debug_kmem"
553 AC_DEFINE([DEBUG_KMEM], [1],
554 [Define to 1 to enable basic kmem accounting])
555 ], [
556 DEBUG_KMEM="_without_debug_kmem"
557 ])
558
559 AC_SUBST(DEBUG_KMEM)
560 AC_MSG_CHECKING([whether basic kmem accounting is enabled])
561 AC_MSG_RESULT([$enable_debug_kmem])
562 ])
563
564 dnl #
565 dnl # Disabled by default it provides detailed memory tracking. This
566 dnl # feature also requires --enable-debug-kmem to be set. When enabled
567 dnl # not only will total bytes be tracked but also the location of every
568 dnl # alloc and free. When the SPL module is unloaded a list of all leaked
569 dnl # addresses and where they were allocated will be dumped to the console.
570 dnl # Enabling this feature has a significant impact on performance but it
571 dnl # makes finding memory leaks pretty straight forward.
572 dnl #
573 AC_DEFUN([SPL_AC_DEBUG_KMEM_TRACKING], [
574 AC_ARG_ENABLE([debug-kmem-tracking],
575 [AS_HELP_STRING([--enable-debug-kmem-tracking],
576 [Enable detailed kmem tracking @<:@default=no@:>@])],
577 [],
578 [enable_debug_kmem_tracking=no])
579
580 AS_IF([test "x$enable_debug_kmem_tracking" = xyes],
581 [
582 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM_TRACKING"
583 DEBUG_KMEM_TRACKING="_with_debug_kmem_tracking"
584 AC_DEFINE([DEBUG_KMEM_TRACKING], [1],
585 [Define to 1 to enable detailed kmem tracking])
586 ], [
587 DEBUG_KMEM_TRACKING="_without_debug_kmem_tracking"
588 ])
589
590 AC_SUBST(DEBUG_KMEM_TRACKING)
591 AC_MSG_CHECKING([whether detailed kmem tracking is enabled])
592 AC_MSG_RESULT([$enable_debug_kmem_tracking])
593 ])
594
595 dnl #
596 dnl # SPL_LINUX_CONFTEST
597 dnl #
598 AC_DEFUN([SPL_LINUX_CONFTEST], [
599 cat confdefs.h - <<_ACEOF >conftest.c
600 $1
601 _ACEOF
602 ])
603
604 dnl #
605 dnl # SPL_LANG_PROGRAM(C)([PROLOGUE], [BODY])
606 dnl #
607 m4_define([SPL_LANG_PROGRAM], [
608 $1
609 int
610 main (void)
611 {
612 dnl Do *not* indent the following line: there may be CPP directives.
613 dnl Don't move the `;' right after for the same reason.
614 $2
615 ;
616 return 0;
617 }
618 ])
619
620 dnl #
621 dnl # SPL_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
622 dnl #
623 AC_DEFUN([SPL_LINUX_COMPILE_IFELSE], [
624 m4_ifvaln([$1], [SPL_LINUX_CONFTEST([$1])])
625 rm -Rf build && mkdir -p build && touch build/conftest.mod.c
626 echo "obj-m := conftest.o" >build/Makefile
627 modpost_flag=''
628 test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
629 AS_IF(
630 [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])],
631 [$4],
632 [_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
633 )
634 rm -Rf build
635 ])
636
637 dnl #
638 dnl # SPL_LINUX_TRY_COMPILE like AC_TRY_COMPILE
639 dnl #
640 AC_DEFUN([SPL_LINUX_TRY_COMPILE],
641 [SPL_LINUX_COMPILE_IFELSE(
642 [AC_LANG_SOURCE([SPL_LANG_PROGRAM([[$1]], [[$2]])])],
643 [modules],
644 [test -s build/conftest.o],
645 [$3], [$4])
646 ])
647
648 dnl #
649 dnl # SPL_CHECK_SYMBOL_EXPORT
650 dnl # check symbol exported or not
651 dnl #
652 AC_DEFUN([SPL_CHECK_SYMBOL_EXPORT], [
653 grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
654 $LINUX_OBJ/Module*.symvers 2>/dev/null
655 rc=$?
656 if test $rc -ne 0; then
657 export=0
658 for file in $2; do
659 grep -q -E "EXPORT_SYMBOL.*($1)" \
660 "$LINUX_OBJ/$file" 2>/dev/null
661 rc=$?
662 if test $rc -eq 0; then
663 export=1
664 break;
665 fi
666 done
667 if test $export -eq 0; then :
668 $4
669 else :
670 $3
671 fi
672 else :
673 $3
674 fi
675 ])
676
677 dnl #
678 dnl # SPL_LINUX_TRY_COMPILE_SYMBOL
679 dnl # like SPL_LINUX_TRY_COMPILE, except SPL_CHECK_SYMBOL_EXPORT
680 dnl # is called if not compiling for builtin
681 dnl #
682 AC_DEFUN([SPL_LINUX_TRY_COMPILE_SYMBOL], [
683 SPL_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
684 if test $rc -ne 0; then :
685 $6
686 else
687 if test "x$enable_linux_builtin" != xyes; then
688 SPL_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
689 fi
690 if test $rc -ne 0; then :
691 $6
692 else :
693 $5
694 fi
695 fi
696 ])
697
698 dnl #
699 dnl # SPL_CHECK_SYMBOL_HEADER
700 dnl # check if a symbol prototype is defined in listed headers.
701 dnl #
702 AC_DEFUN([SPL_CHECK_SYMBOL_HEADER], [
703 AC_MSG_CHECKING([whether symbol $1 exists in header])
704 header=0
705 for file in $3; do
706 grep -q "$2" "$LINUX/$file" 2>/dev/null
707 rc=$?
708 if test $rc -eq 0; then
709 header=1
710 break;
711 fi
712 done
713 if test $header -eq 0; then
714 AC_MSG_RESULT([no])
715 $5
716 else
717 AC_MSG_RESULT([yes])
718 $4
719 fi
720 ])
721
722 dnl #
723 dnl # SPL_CHECK_HEADER
724 dnl # check whether header exists and define HAVE_$2_HEADER
725 dnl #
726 AC_DEFUN([SPL_CHECK_HEADER],
727 [AC_MSG_CHECKING([whether header $1 exists])
728 SPL_LINUX_TRY_COMPILE([
729 #include <$1>
730 ],[
731 return 0;
732 ],[
733 AC_DEFINE(HAVE_$2_HEADER, 1, [$1 exists])
734 AC_MSG_RESULT(yes)
735 $3
736 ],[
737 AC_MSG_RESULT(no)
738 $4
739 ])
740 ])
741
742 dnl #
743 dnl # Basic toolchain sanity check.
744 dnl #
745 AC_DEFUN([SPL_AC_TEST_MODULE],
746 [AC_MSG_CHECKING([whether modules can be built])
747 SPL_LINUX_TRY_COMPILE([],[],[
748 AC_MSG_RESULT([yes])
749 ],[
750 AC_MSG_RESULT([no])
751 if test "x$enable_linux_builtin" != xyes; then
752 AC_MSG_ERROR([*** Unable to build an empty module.])
753 else
754 AC_MSG_ERROR([
755 *** Unable to build an empty module.
756 *** Please run 'make scripts' inside the kernel source tree.])
757 fi
758 ])
759 ])
760
761 dnl #
762 dnl # Use the atomic implemenation based on global spinlocks. This
763 dnl # should only be needed by 32-bit kernels which do not provide
764 dnl # the atomic64_* API. It may be optionally enabled as a fallback
765 dnl # if problems are observed with the direct mapping to the native
766 dnl # Linux atomic operations. You may not disable atomic spinlocks
767 dnl # if you kernel does not an atomic64_* API.
768 dnl #
769 AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [
770 AC_ARG_ENABLE([atomic-spinlocks],
771 [AS_HELP_STRING([--enable-atomic-spinlocks],
772 [Atomic types use spinlocks @<:@default=check@:>@])],
773 [],
774 [enable_atomic_spinlocks=check])
775
776 SPL_LINUX_TRY_COMPILE([
777 #include <linux/fs.h>
778 ],[
779 atomic64_t *ptr __attribute__ ((unused));
780 ],[
781 have_atomic64_t=yes
782 AC_DEFINE(HAVE_ATOMIC64_T, 1,
783 [kernel defines atomic64_t])
784 ],[
785 have_atomic64_t=no
786 ])
787
788 AS_IF([test "x$enable_atomic_spinlocks" = xcheck], [
789 AS_IF([test "x$have_atomic64_t" = xyes], [
790 enable_atomic_spinlocks=no
791 ],[
792 enable_atomic_spinlocks=yes
793 ])
794 ])
795
796 AS_IF([test "x$enable_atomic_spinlocks" = xyes], [
797 AC_DEFINE([ATOMIC_SPINLOCK], [1],
798 [Atomic types use spinlocks])
799 ],[
800 AS_IF([test "x$have_atomic64_t" = xno], [
801 AC_MSG_FAILURE(
802 [--disable-atomic-spinlocks given but required atomic64 support is unavailable])
803 ])
804 ])
805
806 AC_MSG_CHECKING([whether atomic types use spinlocks])
807 AC_MSG_RESULT([$enable_atomic_spinlocks])
808
809 AC_MSG_CHECKING([whether kernel defines atomic64_t])
810 AC_MSG_RESULT([$have_atomic64_t])
811 ])
812
813 dnl #
814 dnl # 2.6.24 API change,
815 dnl # check if atomic64_cmpxchg is defined
816 dnl #
817 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_CMPXCHG],
818 [AC_MSG_CHECKING([whether kernel defines atomic64_cmpxchg])
819 SPL_LINUX_TRY_COMPILE([
820 #include <linux/fs.h>
821 ],[
822 atomic64_cmpxchg((atomic64_t *)NULL, 0, 0);
823 ],[
824 AC_MSG_RESULT([yes])
825 AC_DEFINE(HAVE_ATOMIC64_CMPXCHG, 1,
826 [kernel defines atomic64_cmpxchg])
827 ],[
828 AC_MSG_RESULT([no])
829 ])
830 ])
831
832 dnl #
833 dnl # 2.6.24 API change,
834 dnl # check if atomic64_xchg is defined
835 dnl #
836 AC_DEFUN([SPL_AC_TYPE_ATOMIC64_XCHG],
837 [AC_MSG_CHECKING([whether kernel defines atomic64_xchg])
838 SPL_LINUX_TRY_COMPILE([
839 #include <linux/fs.h>
840 ],[
841 atomic64_xchg((atomic64_t *)NULL, 0);
842 ],[
843 AC_MSG_RESULT([yes])
844 AC_DEFINE(HAVE_ATOMIC64_XCHG, 1,
845 [kernel defines atomic64_xchg])
846 ],[
847 AC_MSG_RESULT([no])
848 ])
849 ])
850
851 dnl #
852 dnl # 2.6.24 API change,
853 dnl # check if uintptr_t typedef is defined
854 dnl #
855 AC_DEFUN([SPL_AC_TYPE_UINTPTR_T],
856 [AC_MSG_CHECKING([whether kernel defines uintptr_t])
857 SPL_LINUX_TRY_COMPILE([
858 #include <linux/types.h>
859 ],[
860 uintptr_t *ptr __attribute__ ((unused));
861 ],[
862 AC_MSG_RESULT([yes])
863 AC_DEFINE(HAVE_UINTPTR_T, 1,
864 [kernel defines uintptr_t])
865 ],[
866 AC_MSG_RESULT([no])
867 ])
868 ])
869
870 dnl #
871 dnl # 2.6.21 API change,
872 dnl # 'register_sysctl_table' use only one argument instead of two
873 dnl #
874 AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL],
875 [AC_MSG_CHECKING([whether register_sysctl_table() wants 2 args])
876 SPL_LINUX_TRY_COMPILE([
877 #include <linux/sysctl.h>
878 ],[
879 (void) register_sysctl_table(NULL, 0);
880 ],[
881 AC_MSG_RESULT(yes)
882 AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
883 [register_sysctl_table() wants 2 args])
884 ],[
885 AC_MSG_RESULT(no)
886 ])
887 ])
888
889 AC_DEFUN([SPL_AC_SHRINKER_CALLBACK],[
890 tmp_flags="$EXTRA_KCFLAGS"
891 EXTRA_KCFLAGS="-Werror"
892 dnl #
893 dnl # 2.6.23 to 2.6.34 API change
894 dnl # ->shrink(int nr_to_scan, gfp_t gfp_mask)
895 dnl #
896 AC_MSG_CHECKING([whether old 2-argument shrinker exists])
897 SPL_LINUX_TRY_COMPILE([
898 #include <linux/mm.h>
899
900 int shrinker_cb(int nr_to_scan, gfp_t gfp_mask);
901 ],[
902 struct shrinker cache_shrinker = {
903 .shrink = shrinker_cb,
904 .seeks = DEFAULT_SEEKS,
905 };
906 register_shrinker(&cache_shrinker);
907 ],[
908 AC_MSG_RESULT(yes)
909 AC_DEFINE(HAVE_2ARGS_OLD_SHRINKER_CALLBACK, 1,
910 [old shrinker callback wants 2 args])
911 ],[
912 AC_MSG_RESULT(no)
913 dnl #
914 dnl # 2.6.35 - 2.6.39 API change
915 dnl # ->shrink(struct shrinker *,
916 dnl # int nr_to_scan, gfp_t gfp_mask)
917 dnl #
918 AC_MSG_CHECKING([whether old 3-argument shrinker exists])
919 SPL_LINUX_TRY_COMPILE([
920 #include <linux/mm.h>
921
922 int shrinker_cb(struct shrinker *, int nr_to_scan,
923 gfp_t gfp_mask);
924 ],[
925 struct shrinker cache_shrinker = {
926 .shrink = shrinker_cb,
927 .seeks = DEFAULT_SEEKS,
928 };
929 register_shrinker(&cache_shrinker);
930 ],[
931 AC_MSG_RESULT(yes)
932 AC_DEFINE(HAVE_3ARGS_SHRINKER_CALLBACK, 1,
933 [old shrinker callback wants 3 args])
934 ],[
935 AC_MSG_RESULT(no)
936 dnl #
937 dnl # 3.0 - 3.11 API change
938 dnl # ->shrink(struct shrinker *,
939 dnl # struct shrink_control *sc)
940 dnl #
941 AC_MSG_CHECKING(
942 [whether new 2-argument shrinker exists])
943 SPL_LINUX_TRY_COMPILE([
944 #include <linux/mm.h>
945
946 int shrinker_cb(struct shrinker *,
947 struct shrink_control *sc);
948 ],[
949 struct shrinker cache_shrinker = {
950 .shrink = shrinker_cb,
951 .seeks = DEFAULT_SEEKS,
952 };
953 register_shrinker(&cache_shrinker);
954 ],[
955 AC_MSG_RESULT(yes)
956 AC_DEFINE(HAVE_2ARGS_NEW_SHRINKER_CALLBACK, 1,
957 [new shrinker callback wants 2 args])
958 ],[
959 AC_MSG_RESULT(no)
960 dnl #
961 dnl # 3.12 API change,
962 dnl # ->shrink() is logically split in to
963 dnl # ->count_objects() and ->scan_objects()
964 dnl #
965 AC_MSG_CHECKING(
966 [whether ->count_objects callback exists])
967 SPL_LINUX_TRY_COMPILE([
968 #include <linux/mm.h>
969
970 unsigned long shrinker_cb(
971 struct shrinker *,
972 struct shrink_control *sc);
973 ],[
974 struct shrinker cache_shrinker = {
975 .count_objects = shrinker_cb,
976 .scan_objects = shrinker_cb,
977 .seeks = DEFAULT_SEEKS,
978 };
979 register_shrinker(&cache_shrinker);
980 ],[
981 AC_MSG_RESULT(yes)
982 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
983 1, [->count_objects exists])
984 ],[
985 AC_MSG_ERROR(error)
986 ])
987 ])
988 ])
989 ])
990 EXTRA_KCFLAGS="$tmp_flags"
991 ])
992
993 dnl #
994 dnl # 2.6.25 API change,
995 dnl # struct path entry added to struct nameidata
996 dnl #
997 AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA],
998 [AC_MSG_CHECKING([whether struct path used in struct nameidata])
999 SPL_LINUX_TRY_COMPILE([
1000 #include <linux/namei.h>
1001 ],[
1002 struct nameidata nd __attribute__ ((unused));
1003
1004 nd.path.mnt = NULL;
1005 nd.path.dentry = NULL;
1006 ],[
1007 AC_MSG_RESULT(yes)
1008 AC_DEFINE(HAVE_PATH_IN_NAMEIDATA, 1,
1009 [struct path used in struct nameidata])
1010 ],[
1011 AC_MSG_RESULT(no)
1012 ])
1013 ])
1014
1015 dnl #
1016 dnl # Custom SPL patch may export this system it is not required
1017 dnl #
1018 AC_DEFUN([SPL_AC_TASK_CURR],
1019 [AC_MSG_CHECKING([whether task_curr() is available])
1020 SPL_LINUX_TRY_COMPILE_SYMBOL([
1021 #include <linux/sched.h>
1022 ], [
1023 task_curr(NULL);
1024 ], [task_curr], [kernel/sched.c], [
1025 AC_MSG_RESULT(yes)
1026 AC_DEFINE(HAVE_TASK_CURR, 1, [task_curr() is available])
1027 ], [
1028 AC_MSG_RESULT(no)
1029 ])
1030 ])
1031
1032 dnl #
1033 dnl # 2.6.19 API change,
1034 dnl # Use CTL_UNNUMBERED when binary sysctl is not required
1035 dnl #
1036 AC_DEFUN([SPL_AC_CTL_UNNUMBERED],
1037 [AC_MSG_CHECKING([whether unnumbered sysctl support exists])
1038 SPL_LINUX_TRY_COMPILE([
1039 #include <linux/sysctl.h>
1040 ],[
1041 #ifndef CTL_UNNUMBERED
1042 #error CTL_UNNUMBERED undefined
1043 #endif
1044 ],[
1045 AC_MSG_RESULT(yes)
1046 AC_DEFINE(HAVE_CTL_UNNUMBERED, 1,
1047 [unnumbered sysctl support exists])
1048 ],[
1049 AC_MSG_RESULT(no)
1050 ])
1051 ])
1052
1053 dnl #
1054 dnl # 2.6.33 API change,
1055 dnl # Removed .ctl_name from struct ctl_table.
1056 dnl #
1057 AC_DEFUN([SPL_AC_CTL_NAME], [
1058 AC_MSG_CHECKING([whether struct ctl_table has ctl_name])
1059 SPL_LINUX_TRY_COMPILE([
1060 #include <linux/sysctl.h>
1061 ],[
1062 struct ctl_table ctl __attribute__ ((unused));
1063 ctl.ctl_name = 0;
1064 ],[
1065 AC_MSG_RESULT(yes)
1066 AC_DEFINE(HAVE_CTL_NAME, 1, [struct ctl_table has ctl_name])
1067 ],[
1068 AC_MSG_RESULT(no)
1069 ])
1070 ])
1071
1072 dnl #
1073 dnl # 2.6.16 API change.
1074 dnl # Check if 'fls64()' is available
1075 dnl #
1076 AC_DEFUN([SPL_AC_FLS64],
1077 [AC_MSG_CHECKING([whether fls64() is available])
1078 SPL_LINUX_TRY_COMPILE([
1079 #include <linux/bitops.h>
1080 ],[
1081 return fls64(0);
1082 ],[
1083 AC_MSG_RESULT(yes)
1084 AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
1085 ],[
1086 AC_MSG_RESULT(no)
1087 ])
1088 ])
1089
1090 dnl #
1091 dnl # 2.6.18 API change, check whether device_create() is available.
1092 dnl # Device_create() was introduced in 2.6.18 and depricated
1093 dnl # class_device_create() which was fully removed in 2.6.26.
1094 dnl #
1095 AC_DEFUN([SPL_AC_DEVICE_CREATE],
1096 [AC_MSG_CHECKING([whether device_create() is available])
1097 SPL_CHECK_SYMBOL_EXPORT([device_create], [drivers/base/core.c], [
1098 AC_MSG_RESULT(yes)
1099 AC_DEFINE(HAVE_DEVICE_CREATE, 1,
1100 [device_create() is available])
1101 ], [
1102 AC_MSG_RESULT(no)
1103 ])
1104 ])
1105
1106 dnl #
1107 dnl # 2.6.27 API change,
1108 dnl # device_create() uses 5 args, new 'drvdata' argument.
1109 dnl #
1110 AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
1111 AC_MSG_CHECKING([whether device_create() wants 5 args])
1112 tmp_flags="$EXTRA_KCFLAGS"
1113 EXTRA_KCFLAGS="-Werror"
1114 SPL_LINUX_TRY_COMPILE([
1115 #include <linux/device.h>
1116 ],[
1117 device_create(NULL, NULL, 0, NULL, "%d", 1);
1118 ],[
1119 AC_MSG_RESULT(yes)
1120 AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
1121 [device_create wants 5 args])
1122 ],[
1123 AC_MSG_RESULT(no)
1124 ])
1125 EXTRA_KCFLAGS="$tmp_flags"
1126 ])
1127
1128 dnl #
1129 dnl # 2.6.13 API change, check whether class_device_create() is available.
1130 dnl # Class_device_create() was introduced in 2.6.13 and depricated
1131 dnl # class_simple_device_add() which was fully removed in 2.6.13.
1132 dnl #
1133 AC_DEFUN([SPL_AC_CLASS_DEVICE_CREATE],
1134 [AC_MSG_CHECKING([whether class_device_create() is available])
1135 SPL_LINUX_TRY_COMPILE_SYMBOL([
1136 #include <linux/device.h>
1137 ], [
1138 class_device_create(NULL, NULL, 0, NULL, NULL);
1139 ], [class_device_create], [drivers/base/class.c], [
1140 AC_MSG_RESULT(yes)
1141 AC_DEFINE(HAVE_CLASS_DEVICE_CREATE, 1,
1142 [class_device_create() is available])
1143 ], [
1144 AC_MSG_RESULT(no)
1145 ])
1146 ])
1147
1148 dnl #
1149 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
1150 dnl #
1151 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT],
1152 [AC_MSG_CHECKING([whether set_normalized_timespec() is available as export])
1153 SPL_LINUX_TRY_COMPILE_SYMBOL([
1154 #include <linux/time.h>
1155 ], [
1156 set_normalized_timespec(NULL, 0, 0);
1157 ], [set_normalized_timespec], [kernel/time.c], [
1158 AC_MSG_RESULT(yes)
1159 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_EXPORT, 1,
1160 [set_normalized_timespec() is available as export])
1161 ], [
1162 AC_MSG_RESULT(no)
1163 ])
1164 ])
1165
1166 dnl #
1167 dnl # 2.6.16 API change, set_normalize_timespec() moved to time.c
1168 dnl # previously it was available in time.h as an inline.
1169 dnl #
1170 AC_DEFUN([SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE], [
1171 AC_MSG_CHECKING([whether set_normalized_timespec() is an inline])
1172 SPL_LINUX_TRY_COMPILE([
1173 #include <linux/time.h>
1174 void set_normalized_timespec(struct timespec *ts,
1175 time_t sec, long nsec) { }
1176 ],
1177 [],
1178 [
1179 AC_MSG_RESULT(no)
1180 ],[
1181 AC_MSG_RESULT(yes)
1182 AC_DEFINE(HAVE_SET_NORMALIZED_TIMESPEC_INLINE, 1,
1183 [set_normalized_timespec() is available as inline])
1184 ])
1185 ])
1186
1187 dnl #
1188 dnl # 2.6.18 API change,
1189 dnl # timespec_sub() inline function available in linux/time.h
1190 dnl #
1191 AC_DEFUN([SPL_AC_TIMESPEC_SUB], [
1192 AC_MSG_CHECKING([whether timespec_sub() is available])
1193 SPL_LINUX_TRY_COMPILE([
1194 #include <linux/time.h>
1195 ],[
1196 struct timespec a = { 0 };
1197 struct timespec b = { 0 };
1198 struct timespec c __attribute__ ((unused));
1199 c = timespec_sub(a, b);
1200 ],[
1201 AC_MSG_RESULT(yes)
1202 AC_DEFINE(HAVE_TIMESPEC_SUB, 1, [timespec_sub() is available])
1203 ],[
1204 AC_MSG_RESULT(no)
1205 ])
1206 ])
1207
1208 dnl #
1209 dnl # 2.6.19 API change,
1210 dnl # check if init_utsname() is available in linux/utsname.h
1211 dnl #
1212 AC_DEFUN([SPL_AC_INIT_UTSNAME], [
1213 AC_MSG_CHECKING([whether init_utsname() is available])
1214 SPL_LINUX_TRY_COMPILE([
1215 #include <linux/utsname.h>
1216 ],[
1217 struct new_utsname *a __attribute__ ((unused));
1218 a = init_utsname();
1219 ],[
1220 AC_MSG_RESULT(yes)
1221 AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available])
1222 ],[
1223 AC_MSG_RESULT(no)
1224 ])
1225 ])
1226
1227 dnl #
1228 dnl # 2.6.18 API change,
1229 dnl # added linux/uaccess.h
1230 dnl #
1231 AC_DEFUN([SPL_AC_UACCESS_HEADER], [
1232 SPL_CHECK_HEADER([linux/uaccess.h], [UACCESS], [], [])
1233 ])
1234
1235 dnl #
1236 dnl # 2.6.12 API change,
1237 dnl # check whether 'kmalloc_node()' is available.
1238 dnl #
1239 AC_DEFUN([SPL_AC_KMALLOC_NODE], [
1240 AC_MSG_CHECKING([whether kmalloc_node() is available])
1241 SPL_LINUX_TRY_COMPILE([
1242 #include <linux/slab.h>
1243 ],[
1244 void *a __attribute__ ((unused));
1245 a = kmalloc_node(1, GFP_KERNEL, 0);
1246 ],[
1247 AC_MSG_RESULT(yes)
1248 AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available])
1249 ],[
1250 AC_MSG_RESULT(no)
1251 ])
1252 ])
1253
1254 dnl #
1255 dnl # 2.6.9 API change,
1256 dnl # check whether 'monotonic_clock()' is available it may
1257 dnl # be available for some archs but not others.
1258 dnl #
1259 AC_DEFUN([SPL_AC_MONOTONIC_CLOCK],
1260 [AC_MSG_CHECKING([whether monotonic_clock() is available])
1261 SPL_LINUX_TRY_COMPILE_SYMBOL([
1262 #include <linux/timex.h>
1263 ], [
1264 monotonic_clock();
1265 ], [monotonic_clock], [], [
1266 AC_MSG_RESULT(yes)
1267 AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1,
1268 [monotonic_clock() is available])
1269 ], [
1270 AC_MSG_RESULT(no)
1271 ])
1272 ])
1273
1274 dnl #
1275 dnl # 2.6.16 API change,
1276 dnl # check whether 'struct inode' has i_mutex
1277 dnl #
1278 AC_DEFUN([SPL_AC_INODE_I_MUTEX], [
1279 AC_MSG_CHECKING([whether struct inode has i_mutex])
1280 SPL_LINUX_TRY_COMPILE([
1281 #include <linux/fs.h>
1282 #include <linux/mutex.h>
1283 ],[
1284 struct inode i;
1285 mutex_init(&i.i_mutex);
1286 ],[
1287 AC_MSG_RESULT(yes)
1288 AC_DEFINE(HAVE_INODE_I_MUTEX, 1, [struct inode has i_mutex])
1289 ],[
1290 AC_MSG_RESULT(no)
1291 ])
1292 ])
1293
1294 dnl #
1295 dnl # 2.6.29 API change,
1296 dnl # Adaptive mutexs introduced.
1297 dnl #
1298 AC_DEFUN([SPL_AC_MUTEX_OWNER], [
1299 AC_MSG_CHECKING([whether struct mutex has owner])
1300 SPL_LINUX_TRY_COMPILE([
1301 #include <linux/mutex.h>
1302 ],[
1303 struct mutex mtx __attribute__ ((unused));
1304 mtx.owner = NULL;
1305 ],[
1306 AC_MSG_RESULT(yes)
1307 AC_DEFINE(HAVE_MUTEX_OWNER, 1, [struct mutex has owner])
1308 ],[
1309 AC_MSG_RESULT(no)
1310 ])
1311 ])
1312
1313 dnl #
1314 dnl # 2.6.39 API change,
1315 dnl # Owner type change. A Linux mutex prior to 2.6.39 would store
1316 dnl # the owner as a thread_info pointer when CONFIG_DEBUG_MUTEXES
1317 dnl # was defined. As of 2.6.39 this was changed to a task_struct
1318 dnl # pointer which frankly makes a lot more sense.
1319 dnl #
1320 AC_DEFUN([SPL_AC_MUTEX_OWNER_TASK_STRUCT], [
1321 AC_MSG_CHECKING([whether struct mutex owner is a task_struct])
1322 tmp_flags="$EXTRA_KCFLAGS"
1323 EXTRA_KCFLAGS="-Werror"
1324 SPL_LINUX_TRY_COMPILE([
1325 #include <linux/mutex.h>
1326 #include <linux/sched.h>
1327 ],[
1328 struct mutex mtx __attribute__ ((unused));
1329 mtx.owner = current;
1330 ],[
1331 AC_MSG_RESULT(yes)
1332 AC_DEFINE(HAVE_MUTEX_OWNER_TASK_STRUCT, 1,
1333 [struct mutex owner is a task_struct])
1334 ],[
1335 AC_MSG_RESULT(no)
1336 ])
1337 EXTRA_KCFLAGS="$tmp_flags"
1338 ])
1339
1340 dnl #
1341 dnl # 2.6.18 API change,
1342 dnl # First introduced 'mutex_lock_nested()' in include/linux/mutex.h,
1343 dnl # as part of the mutex validator. Fallback to using 'mutex_lock()'
1344 dnl # if the mutex validator is disabled or otherwise unavailable.
1345 dnl #
1346 AC_DEFUN([SPL_AC_MUTEX_LOCK_NESTED], [
1347 AC_MSG_CHECKING([whether mutex_lock_nested() is available])
1348 SPL_LINUX_TRY_COMPILE([
1349 #include <linux/mutex.h>
1350 ],[
1351 struct mutex mutex;
1352 mutex_init(&mutex);
1353 mutex_lock_nested(&mutex, 0);
1354 ],[
1355 AC_MSG_RESULT(yes)
1356 AC_DEFINE(HAVE_MUTEX_LOCK_NESTED, 1,
1357 [mutex_lock_nested() is available])
1358 ],[
1359 AC_MSG_RESULT(no)
1360 ])
1361 ])
1362
1363 dnl #
1364 dnl # 2.6.27 API change,
1365 dnl # on_each_cpu() uses 3 args, no 'retry' argument
1366 dnl #
1367 AC_DEFUN([SPL_AC_3ARGS_ON_EACH_CPU], [
1368 AC_MSG_CHECKING([whether on_each_cpu() wants 3 args])
1369 SPL_LINUX_TRY_COMPILE([
1370 #include <linux/interrupt.h>
1371 #include <linux/smp.h>
1372
1373 void on_each_cpu_func(void *data) { return; }
1374 ],[
1375 on_each_cpu(on_each_cpu_func, NULL, 0);
1376 ],[
1377 AC_MSG_RESULT(yes)
1378 AC_DEFINE(HAVE_3ARGS_ON_EACH_CPU, 1,
1379 [on_each_cpu wants 3 args])
1380 ],[
1381 AC_MSG_RESULT(no)
1382 ])
1383 ])
1384
1385 dnl #
1386 dnl # 2.6.18 API change,
1387 dnl # kallsyms_lookup_name no longer exported
1388 dnl #
1389 AC_DEFUN([SPL_AC_KALLSYMS_LOOKUP_NAME],
1390 [AC_MSG_CHECKING([whether kallsyms_lookup_name() is available])
1391 SPL_LINUX_TRY_COMPILE_SYMBOL([
1392 #include <linux/kallsyms.h>
1393 ], [
1394 kallsyms_lookup_name(NULL);
1395 ], [kallsyms_lookup_name], [], [
1396 AC_MSG_RESULT(yes)
1397 AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1398 [kallsyms_lookup_name() is available])
1399 ], [
1400 AC_MSG_RESULT(no)
1401 ])
1402 ])
1403
1404 dnl #
1405 dnl # Proposed API change,
1406 dnl # This symbol is not available in stock kernels. You may build a
1407 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1408 dnl # these symbols for use. If your already rolling a custom kernel for
1409 dnl # your environment this is recommended.
1410 dnl #
1411 AC_DEFUN([SPL_AC_GET_VMALLOC_INFO],
1412 [AC_MSG_CHECKING([whether get_vmalloc_info() is available])
1413 SPL_CHECK_SYMBOL_EXPORT([get_vmalloc_info], [], [
1414 AC_MSG_RESULT(yes)
1415 AC_DEFINE(HAVE_GET_VMALLOC_INFO, 1,
1416 [get_vmalloc_info() is available])
1417 ], [
1418 AC_MSG_RESULT(no)
1419 ])
1420 ])
1421
1422 dnl #
1423 dnl # 3.10 API change,
1424 dnl # struct vmalloc_info is now declared in linux/vmalloc.h
1425 dnl #
1426 AC_DEFUN([SPL_AC_VMALLOC_INFO], [
1427 AC_MSG_CHECKING([whether struct vmalloc_info is declared])
1428 SPL_LINUX_TRY_COMPILE([
1429 #include <linux/vmalloc.h>
1430 struct vmalloc_info { void *a; };
1431 ],[
1432 return 0;
1433 ],[
1434 AC_MSG_RESULT(no)
1435 ],[
1436 AC_MSG_RESULT(yes)
1437 AC_DEFINE(HAVE_VMALLOC_INFO, 1, [yes])
1438 ])
1439 ])
1440
1441 dnl #
1442 dnl # 3.10 API change,
1443 dnl # PDE is replaced by PDE_DATA
1444 dnl #
1445 AC_DEFUN([SPL_AC_PDE_DATA], [
1446 AC_MSG_CHECKING([whether PDE_DATA() is available])
1447 SPL_LINUX_TRY_COMPILE_SYMBOL([
1448 #include <linux/proc_fs.h>
1449 ], [
1450 PDE_DATA(NULL);
1451 ], [PDE_DATA], [], [
1452 AC_MSG_RESULT(yes)
1453 AC_DEFINE(HAVE_PDE_DATA, 1, [yes])
1454 ],[
1455 AC_MSG_RESULT(no)
1456 ])
1457 ])
1458
1459 dnl #
1460 dnl # 2.6.17 API change
1461 dnl # The helper functions first_online_pgdat(), next_online_pgdat(), and
1462 dnl # next_zone() are introduced to simplify for_each_zone(). These symbols
1463 dnl # were exported in 2.6.17 for use by modules which was consistent with
1464 dnl # the previous implementation of for_each_zone(). From 2.6.18 - 2.6.19
1465 dnl # the symbols were exported as 'unused', and by 2.6.20 they exports
1466 dnl # were dropped entirely leaving modules no way to directly iterate over
1467 dnl # the zone list. Because we need access to the zone helpers we check
1468 dnl # if the kernel contains the old or new implementation. Then we check
1469 dnl # to see if the symbols we need for each version are available. If they
1470 dnl # are not, dynamically aquire the addresses with kallsyms_lookup_name().
1471 dnl #
1472 AC_DEFUN([SPL_AC_PGDAT_HELPERS], [
1473 AC_MSG_CHECKING([whether symbol *_pgdat exist])
1474 grep -q -E 'first_online_pgdat' $LINUX/include/linux/mmzone.h 2>/dev/null
1475 rc=$?
1476 if test $rc -eq 0; then
1477 AC_MSG_RESULT([yes])
1478 AC_DEFINE(HAVE_PGDAT_HELPERS, 1, [pgdat helpers are available])
1479 else
1480 AC_MSG_RESULT([no])
1481 fi
1482 ])
1483
1484 dnl #
1485 dnl # Proposed API change,
1486 dnl # This symbol is not available in stock kernels. You may build a
1487 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1488 dnl # these symbols for use. If your already rolling a custom kernel for
1489 dnl # your environment this is recommended.
1490 dnl #
1491 AC_DEFUN([SPL_AC_FIRST_ONLINE_PGDAT],
1492 [AC_MSG_CHECKING([whether first_online_pgdat() is available])
1493 SPL_LINUX_TRY_COMPILE_SYMBOL([
1494 #include <linux/mmzone.h>
1495 ], [
1496 first_online_pgdat();
1497 ], [first_online_pgdat], [], [
1498 AC_MSG_RESULT(yes)
1499 AC_DEFINE(HAVE_FIRST_ONLINE_PGDAT, 1,
1500 [first_online_pgdat() is available])
1501 ], [
1502 AC_MSG_RESULT(no)
1503 ])
1504 ])
1505
1506 dnl #
1507 dnl # Proposed API change,
1508 dnl # This symbol is not available in stock kernels. You may build a
1509 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1510 dnl # these symbols for use. If your already rolling a custom kernel for
1511 dnl # your environment this is recommended.
1512 dnl #
1513 AC_DEFUN([SPL_AC_NEXT_ONLINE_PGDAT],
1514 [AC_MSG_CHECKING([whether next_online_pgdat() is available])
1515 SPL_LINUX_TRY_COMPILE_SYMBOL([
1516 #include <linux/mmzone.h>
1517 ], [
1518 next_online_pgdat(NULL);
1519 ], [next_online_pgdat], [], [
1520 AC_MSG_RESULT(yes)
1521 AC_DEFINE(HAVE_NEXT_ONLINE_PGDAT, 1,
1522 [next_online_pgdat() is available])
1523 ], [
1524 AC_MSG_RESULT(no)
1525 ])
1526 ])
1527
1528 dnl #
1529 dnl # Proposed API change,
1530 dnl # This symbol is not available in stock kernels. You may build a
1531 dnl # custom kernel with the *-spl-export-symbols.patch which will export
1532 dnl # these symbols for use. If your already rolling a custom kernel for
1533 dnl # your environment this is recommended.
1534 dnl #
1535 AC_DEFUN([SPL_AC_NEXT_ZONE],
1536 [AC_MSG_CHECKING([whether next_zone() is available])
1537 SPL_LINUX_TRY_COMPILE_SYMBOL([
1538 #include <linux/mmzone.h>
1539 ], [
1540 next_zone(NULL);
1541 ], [next_zone], [], [
1542 AC_MSG_RESULT(yes)
1543 AC_DEFINE(HAVE_NEXT_ZONE, 1, [next_zone() is available])
1544 ], [
1545 AC_MSG_RESULT(no)
1546 ])
1547 ])
1548
1549 dnl #
1550 dnl # 2.6.17 API change,
1551 dnl # See SPL_AC_PGDAT_HELPERS for details.
1552 dnl #
1553 AC_DEFUN([SPL_AC_PGDAT_LIST],
1554 [AC_MSG_CHECKING([whether pgdat_list is available])
1555 SPL_LINUX_TRY_COMPILE_SYMBOL([
1556 #include <linux/topology.h>
1557 pg_data_t *tmp = pgdat_list;
1558 ], [], [pgdat_list], [], [
1559 AC_MSG_RESULT(yes)
1560 AC_DEFINE(HAVE_PGDAT_LIST, 1, [pgdat_list is available])
1561 ], [
1562 AC_MSG_RESULT(no)
1563 ])
1564 ])
1565
1566 dnl #
1567 dnl # 2.6.18 API change,
1568 dnl # First introduced global_page_state() support as an inline.
1569 dnl #
1570 AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [
1571 AC_MSG_CHECKING([whether global_page_state() is available])
1572 SPL_LINUX_TRY_COMPILE([
1573 #include <linux/mm.h>
1574 ],[
1575 unsigned long state __attribute__ ((unused));
1576 state = global_page_state(0);
1577 ],[
1578 AC_MSG_RESULT(yes)
1579 AC_DEFINE(HAVE_GLOBAL_PAGE_STATE, 1,
1580 [global_page_state() is available])
1581 ],[
1582 AC_MSG_RESULT(no)
1583 ])
1584 ])
1585
1586 dnl #
1587 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1588 dnl # Public global zone stats now include a free page count. However
1589 dnl # the enumerated names of the counters have changed since this API
1590 dnl # was introduced. We need to deduce the corrent name to use. This
1591 dnl # replaces the priviate get_zone_counts() interface.
1592 dnl #
1593 dnl # NR_FREE_PAGES was available from 2.6.21 to current kernels, which
1594 dnl # is 2.6.30 as of when this was written.
1595 dnl #
1596 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [
1597 AC_MSG_CHECKING([whether page state NR_FREE_PAGES is available])
1598 SPL_LINUX_TRY_COMPILE([
1599 #include <linux/mm.h>
1600 ],[
1601 enum zone_stat_item zsi __attribute__ ((unused));
1602 zsi = NR_FREE_PAGES;
1603 ],[
1604 AC_MSG_RESULT(yes)
1605 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES, 1,
1606 [Page state NR_FREE_PAGES is available])
1607 ],[
1608 AC_MSG_RESULT(no)
1609 ])
1610 ])
1611
1612 dnl #
1613 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1614 dnl # Public global zone stats now include an inactive page count. However
1615 dnl # the enumerated names of the counters have changed since this API
1616 dnl # was introduced. We need to deduce the corrent name to use. This
1617 dnl # replaces the priviate get_zone_counts() interface.
1618 dnl #
1619 dnl # NR_INACTIVE was available from 2.6.21 to 2.6.27 and included both
1620 dnl # anonymous and file inactive pages. As of 2.6.28 it was split in
1621 dnl # to NR_INACTIVE_ANON and NR_INACTIVE_FILE.
1622 dnl #
1623 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [
1624 AC_MSG_CHECKING([whether page state NR_INACTIVE is available])
1625 SPL_LINUX_TRY_COMPILE([
1626 #include <linux/mm.h>
1627 ],[
1628 enum zone_stat_item zsi __attribute__ ((unused));
1629 zsi = NR_INACTIVE;
1630 ],[
1631 AC_MSG_RESULT(yes)
1632 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE, 1,
1633 [Page state NR_INACTIVE is available])
1634 ],[
1635 AC_MSG_RESULT(no)
1636 ])
1637
1638 AC_MSG_CHECKING([whether page state NR_INACTIVE_ANON is available])
1639 SPL_LINUX_TRY_COMPILE([
1640 #include <linux/mm.h>
1641 ],[
1642 enum zone_stat_item zsi __attribute__ ((unused));
1643 zsi = NR_INACTIVE_ANON;
1644 ],[
1645 AC_MSG_RESULT(yes)
1646 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON, 1,
1647 [Page state NR_INACTIVE_ANON is available])
1648 ],[
1649 AC_MSG_RESULT(no)
1650 ])
1651
1652 AC_MSG_CHECKING([whether page state NR_INACTIVE_FILE is available])
1653 SPL_LINUX_TRY_COMPILE([
1654 #include <linux/mm.h>
1655 ],[
1656 enum zone_stat_item zsi __attribute__ ((unused));
1657 zsi = NR_INACTIVE_FILE;
1658 ],[
1659 AC_MSG_RESULT(yes)
1660 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE, 1,
1661 [Page state NR_INACTIVE_FILE is available])
1662 ],[
1663 AC_MSG_RESULT(no)
1664 ])
1665 ])
1666
1667 dnl #
1668 dnl # 2.6.21 API change (plus subsequent naming convention changes),
1669 dnl # Public global zone stats now include an active page count. However
1670 dnl # the enumerated names of the counters have changed since this API
1671 dnl # was introduced. We need to deduce the corrent name to use. This
1672 dnl # replaces the priviate get_zone_counts() interface.
1673 dnl #
1674 dnl # NR_ACTIVE was available from 2.6.21 to 2.6.27 and included both
1675 dnl # anonymous and file active pages. As of 2.6.28 it was split in
1676 dnl # to NR_ACTIVE_ANON and NR_ACTIVE_FILE.
1677 dnl #
1678 AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [
1679 AC_MSG_CHECKING([whether page state NR_ACTIVE is available])
1680 SPL_LINUX_TRY_COMPILE([
1681 #include <linux/mm.h>
1682 ],[
1683 enum zone_stat_item zsi __attribute__ ((unused));
1684 zsi = NR_ACTIVE;
1685 ],[
1686 AC_MSG_RESULT(yes)
1687 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE, 1,
1688 [Page state NR_ACTIVE is available])
1689 ],[
1690 AC_MSG_RESULT(no)
1691 ])
1692
1693 AC_MSG_CHECKING([whether page state NR_ACTIVE_ANON is available])
1694 SPL_LINUX_TRY_COMPILE([
1695 #include <linux/mm.h>
1696 ],[
1697 enum zone_stat_item zsi __attribute__ ((unused));
1698 zsi = NR_ACTIVE_ANON;
1699 ],[
1700 AC_MSG_RESULT(yes)
1701 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON, 1,
1702 [Page state NR_ACTIVE_ANON is available])
1703 ],[
1704 AC_MSG_RESULT(no)
1705 ])
1706
1707 AC_MSG_CHECKING([whether page state NR_ACTIVE_FILE is available])
1708 SPL_LINUX_TRY_COMPILE([
1709 #include <linux/mm.h>
1710 ],[
1711 enum zone_stat_item zsi __attribute__ ((unused));
1712 zsi = NR_ACTIVE_FILE;
1713 ],[
1714 AC_MSG_RESULT(yes)
1715 AC_DEFINE(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE, 1,
1716 [Page state NR_ACTIVE_FILE is available])
1717 ],[
1718 AC_MSG_RESULT(no)
1719 ])
1720 ])
1721
1722 dnl #
1723 dnl # Proposed API change for legacy kernels.
1724 dnl # This symbol is not available in older kernels. For kernels post
1725 dnl # 2.6.21 the global_page_state() API is used to get free/inactive/active
1726 dnl # page state information. This symbol is only used in legacy kernels
1727 dnl # any only as a last resort.
1728 dnl
1729 AC_DEFUN([SPL_AC_GET_ZONE_COUNTS], [
1730 AC_MSG_CHECKING([whether symbol get_zone_counts is needed])
1731 SPL_LINUX_TRY_COMPILE([
1732 ],[
1733 #if !defined(HAVE_ZONE_STAT_ITEM_NR_FREE_PAGES)
1734 #error "global_page_state needs NR_FREE_PAGES"
1735 #endif
1736
1737 #if !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE) && \
1738 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_ANON) && \
1739 !defined(HAVE_ZONE_STAT_ITEM_NR_ACTIVE_FILE)
1740 #error "global_page_state needs NR_ACTIVE*"
1741 #endif
1742
1743 #if !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE) && \
1744 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_ANON) && \
1745 !defined(HAVE_ZONE_STAT_ITEM_NR_INACTIVE_FILE)
1746 #error "global_page_state needs NR_INACTIVE*"
1747 #endif
1748 ],[
1749 AC_MSG_RESULT(no)
1750 ],[
1751 AC_MSG_RESULT(yes)
1752 AC_DEFINE(NEED_GET_ZONE_COUNTS, 1,
1753 [get_zone_counts() is needed])
1754
1755 AC_MSG_CHECKING([whether get_zone_counts() is available])
1756 SPL_LINUX_TRY_COMPILE_SYMBOL([
1757 #include <linux/mmzone.h>
1758 ], [
1759 get_zone_counts(NULL, NULL, NULL);
1760 ], [get_zone_counts], [], [
1761 AC_MSG_RESULT(yes)
1762 AC_DEFINE(HAVE_GET_ZONE_COUNTS, 1,
1763 [get_zone_counts() is available])
1764 ], [
1765 AC_MSG_RESULT(no)
1766 ])
1767 ])
1768 ])
1769
1770 dnl #
1771 dnl # 2.6.27 API change,
1772 dnl # The user_path_dir() replaces __user_walk()
1773 dnl #
1774 AC_DEFUN([SPL_AC_USER_PATH_DIR],
1775 [AC_MSG_CHECKING([whether user_path_dir() is available])
1776 SPL_LINUX_TRY_COMPILE_SYMBOL([
1777 #include <linux/fcntl.h>
1778 #include <linux/namei.h>
1779 ], [
1780 user_path_dir(NULL, NULL);
1781 ], [user_path_at], [], [
1782 AC_MSG_RESULT(yes)
1783 AC_DEFINE(HAVE_USER_PATH_DIR, 1, [user_path_dir() is available])
1784 ], [
1785 AC_MSG_RESULT(no)
1786 ])
1787 ])
1788
1789 dnl #
1790 dnl # Symbol available in RHEL kernels not in stock kernels.
1791 dnl #
1792 AC_DEFUN([SPL_AC_SET_FS_PWD],
1793 [AC_MSG_CHECKING([whether set_fs_pwd() is available])
1794 SPL_LINUX_TRY_COMPILE_SYMBOL([
1795 #include <linux/spinlock.h>
1796 #include <linux/fs_struct.h>
1797 ], [
1798 (void) set_fs_pwd;
1799 ], [set_fs_pwd], [], [
1800 AC_MSG_RESULT(yes)
1801 AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd() is available])
1802 ], [
1803 AC_MSG_RESULT(no)
1804 ])
1805 ])
1806
1807 dnl #
1808 dnl # 3.9 API change
1809 dnl # set_fs_pwd takes const struct path *
1810 dnl #
1811 AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
1812 tmp_flags="$EXTRA_KCFLAGS"
1813 EXTRA_KCFLAGS="-Werror"
1814 [AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
1815 SPL_LINUX_TRY_COMPILE([
1816 #include <linux/spinlock.h>
1817 #include <linux/fs_struct.h>
1818 #include <linux/path.h>
1819 void (*const set_fs_pwd_func)
1820 (struct fs_struct *, const struct path *)
1821 = set_fs_pwd;
1822 ],[
1823 return 0;
1824 ],[
1825 AC_MSG_RESULT(yes)
1826 AC_DEFINE(HAVE_SET_FS_PWD_WITH_CONST, 1,
1827 [set_fs_pwd() needs const path *])
1828 ],[
1829 SPL_LINUX_TRY_COMPILE([
1830 #include <linux/spinlock.h>
1831 #include <linux/fs_struct.h>
1832 #include <linux/path.h>
1833 void (*const set_fs_pwd_func)
1834 (struct fs_struct *, struct path *)
1835 = set_fs_pwd;
1836 ],[
1837 return 0;
1838 ],[
1839 AC_MSG_RESULT(no)
1840 ],[
1841 AC_MSG_ERROR(unknown)
1842 ])
1843 ])
1844 EXTRA_KCFLAGS="$tmp_flags"
1845 ])
1846
1847 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
1848 [AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
1849 SPL_LINUX_TRY_COMPILE([
1850 #include <linux/fs.h>
1851 ],[
1852 vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
1853 ],[
1854 AC_MSG_RESULT(yes)
1855 AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
1856 [vfs_unlink() wants 2 args])
1857 ],[
1858 AC_MSG_RESULT(no)
1859 dnl #
1860 dnl # Linux 3.13 API change
1861 dnl # Added delegated inode
1862 dnl #
1863 AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
1864 SPL_LINUX_TRY_COMPILE([
1865 #include <linux/fs.h>
1866 ],[
1867 vfs_unlink((struct inode *) NULL,
1868 (struct dentry *) NULL,
1869 (struct inode **) NULL);
1870 ],[
1871 AC_MSG_RESULT(yes)
1872 AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
1873 [vfs_unlink() wants 3 args])
1874 ],[
1875 AC_MSG_ERROR(no)
1876 ])
1877
1878 ])
1879 ])
1880
1881 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
1882 [AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
1883 SPL_LINUX_TRY_COMPILE([
1884 #include <linux/fs.h>
1885 ],[
1886 vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
1887 (struct inode *) NULL, (struct dentry *) NULL);
1888 ],[
1889 AC_MSG_RESULT(yes)
1890 AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
1891 [vfs_rename() wants 4 args])
1892 ],[
1893 AC_MSG_RESULT(no)
1894 dnl #
1895 dnl # Linux 3.13 API change
1896 dnl # Added delegated inode
1897 dnl #
1898 AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
1899 SPL_LINUX_TRY_COMPILE([
1900 #include <linux/fs.h>
1901 ],[
1902 vfs_rename((struct inode *) NULL,
1903 (struct dentry *) NULL,
1904 (struct inode *) NULL,
1905 (struct dentry *) NULL,
1906 (struct inode **) NULL);
1907 ],[
1908 AC_MSG_RESULT(yes)
1909 AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
1910 [vfs_rename() wants 5 args])
1911 ],[
1912 AC_MSG_RESULT(no)
1913 dnl #
1914 dnl # Linux 3.15 API change
1915 dnl # Added flags
1916 dnl #
1917 AC_MSG_CHECKING([whether vfs_rename() wants 6 args])
1918 SPL_LINUX_TRY_COMPILE([
1919 #include <linux/fs.h>
1920 ],[
1921 vfs_rename((struct inode *) NULL,
1922 (struct dentry *) NULL,
1923 (struct inode *) NULL,
1924 (struct dentry *) NULL,
1925 (struct inode **) NULL,
1926 (unsigned int) 0);
1927 ],[
1928 AC_MSG_RESULT(yes)
1929 AC_DEFINE(HAVE_6ARGS_VFS_RENAME, 1,
1930 [vfs_rename() wants 6 args])
1931 ],[
1932 AC_MSG_ERROR(no)
1933 ])
1934 ])
1935 ])
1936 ])
1937
1938 dnl #
1939 dnl # 2.6.36 API change,
1940 dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
1941 dnl # a spinlock_t to improve the fastpath performance.
1942 dnl #
1943 AC_DEFUN([SPL_AC_FS_STRUCT_SPINLOCK], [
1944 AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
1945 tmp_flags="$EXTRA_KCFLAGS"
1946 EXTRA_KCFLAGS="-Werror"
1947 SPL_LINUX_TRY_COMPILE([
1948 #include <linux/sched.h>
1949 #include <linux/fs_struct.h>
1950 ],[
1951 struct fs_struct fs;
1952 spin_lock_init(&fs.lock);
1953 ],[
1954 AC_MSG_RESULT(yes)
1955 AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
1956 [struct fs_struct uses spinlock_t])
1957 ],[
1958 AC_MSG_RESULT(no)
1959 ])
1960 EXTRA_KCFLAGS="$tmp_flags"
1961 ])
1962
1963 dnl #
1964 dnl # 2.6.29 API change,
1965 dnl # check whether 'struct cred' exists
1966 dnl #
1967 AC_DEFUN([SPL_AC_CRED_STRUCT], [
1968 AC_MSG_CHECKING([whether struct cred exists])
1969 SPL_LINUX_TRY_COMPILE([
1970 #include <linux/cred.h>
1971 ],[
1972 struct cred *cr __attribute__ ((unused));
1973 cr = NULL;
1974 ],[
1975 AC_MSG_RESULT(yes)
1976 AC_DEFINE(HAVE_CRED_STRUCT, 1, [struct cred exists])
1977 ],[
1978 AC_MSG_RESULT(no)
1979 ])
1980 ])
1981
1982
1983 dnl #
1984 dnl # User namespaces, use kuid_t in place of uid_t
1985 dnl # where available. Not strictly a user namespaces thing
1986 dnl # but it should prevent surprises
1987 dnl #
1988 AC_DEFUN([SPL_AC_KUIDGID_T], [
1989 AC_MSG_CHECKING([whether kuid_t/kgid_t is available])
1990 SPL_LINUX_TRY_COMPILE([
1991 #include <linux/uidgid.h>
1992 ], [
1993 kuid_t userid = KUIDT_INIT(0);
1994 kgid_t groupid = KGIDT_INIT(0);
1995 ],[
1996 SPL_LINUX_TRY_COMPILE([
1997 #include <linux/uidgid.h>
1998 ], [
1999 kuid_t userid = 0;
2000 kgid_t groupid = 0;
2001 ],[
2002 AC_MSG_RESULT(yes; optional)
2003 ],[
2004 AC_MSG_RESULT(yes; mandatory)
2005 AC_DEFINE(HAVE_KUIDGID_T, 1, [kuid_t/kgid_t in use])
2006 ])
2007 ],[
2008 AC_MSG_RESULT(no)
2009 ])
2010 ])
2011
2012 dnl #
2013 dnl # Custom SPL patch may export this symbol.
2014 dnl #
2015 AC_DEFUN([SPL_AC_GROUPS_SEARCH],
2016 [AC_MSG_CHECKING([whether groups_search() is available])
2017 SPL_LINUX_TRY_COMPILE_SYMBOL([
2018 #include <linux/cred.h>
2019 #ifdef HAVE_KUIDGID_T
2020 #include <linux/uidgid.h>
2021 #endif
2022 ], [
2023 #ifdef HAVE_KUIDGID_T
2024 groups_search(NULL, KGIDT_INIT(0));
2025 #else
2026 groups_search(NULL, 0);
2027 #endif
2028 ], [groups_search], [], [
2029 AC_MSG_RESULT(yes)
2030 AC_DEFINE(HAVE_GROUPS_SEARCH, 1, [groups_search() is available])
2031 ], [
2032 AC_MSG_RESULT(no)
2033 ])
2034 ])
2035
2036 dnl #
2037 dnl # 2.6.x API change,
2038 dnl # __put_task_struct() was exported in RHEL5 but unavailable elsewhere.
2039 dnl #
2040 AC_DEFUN([SPL_AC_PUT_TASK_STRUCT],
2041 [AC_MSG_CHECKING([whether __put_task_struct() is available])
2042 SPL_LINUX_TRY_COMPILE_SYMBOL([
2043 #include <linux/sched.h>
2044 ], [
2045 __put_task_struct(NULL);
2046 ], [__put_task_struct], [], [
2047 AC_MSG_RESULT(yes)
2048 AC_DEFINE(HAVE_PUT_TASK_STRUCT, 1,
2049 [__put_task_struct() is available])
2050 ], [
2051 AC_MSG_RESULT(no)
2052 ])
2053 ])
2054
2055 dnl #
2056 dnl # 2.6.32 API change,
2057 dnl # Unused 'struct file *' removed from prototype.
2058 dnl #
2059 AC_DEFUN([SPL_AC_5ARGS_PROC_HANDLER], [
2060 AC_MSG_CHECKING([whether proc_handler() wants 5 args])
2061 SPL_LINUX_TRY_COMPILE([
2062 #include <linux/sysctl.h>
2063 ],[
2064 proc_dostring(NULL, 0, NULL, NULL, NULL);
2065 ],[
2066 AC_MSG_RESULT(yes)
2067 AC_DEFINE(HAVE_5ARGS_PROC_HANDLER, 1,
2068 [proc_handler() wants 5 args])
2069 ],[
2070 AC_MSG_RESULT(no)
2071 ])
2072 ])
2073
2074 dnl #
2075 dnl # 2.6.x API change,
2076 dnl # kvasprintf() function added.
2077 dnl #
2078 AC_DEFUN([SPL_AC_KVASPRINTF],
2079 [AC_MSG_CHECKING([whether kvasprintf() is available])
2080 SPL_LINUX_TRY_COMPILE_SYMBOL([
2081 #include <linux/kernel.h>
2082 ], [
2083 kvasprintf(0, NULL, *((va_list*)NULL));
2084 ], [kvasprintf], [], [
2085 AC_MSG_RESULT(yes)
2086 AC_DEFINE(HAVE_KVASPRINTF, 1, [kvasprintf() is available])
2087 ], [
2088 AC_MSG_RESULT(no)
2089 ])
2090 ])
2091
2092 dnl #
2093 dnl # 2.6.29 API change,
2094 dnl # vfs_fsync() funcation added, prior to this use file_fsync().
2095 dnl #
2096 AC_DEFUN([SPL_AC_VFS_FSYNC],
2097 [AC_MSG_CHECKING([whether vfs_fsync() is available])
2098 SPL_LINUX_TRY_COMPILE_SYMBOL([
2099 #include <linux/fs.h>
2100 ], [
2101 (void) vfs_fsync;
2102 ], [vfs_fsync], [fs/sync.c], [
2103 AC_MSG_RESULT(yes)
2104 AC_DEFINE(HAVE_VFS_FSYNC, 1, [vfs_fsync() is available])
2105 ], [
2106 AC_MSG_RESULT(no)
2107 ])
2108 ])
2109
2110 dnl #
2111 dnl # 2.6.35 API change,
2112 dnl # Unused 'struct dentry *' removed from vfs_fsync() prototype.
2113 dnl #
2114 AC_DEFUN([SPL_AC_2ARGS_VFS_FSYNC], [
2115 AC_MSG_CHECKING([whether vfs_fsync() wants 2 args])
2116 SPL_LINUX_TRY_COMPILE([
2117 #include <linux/fs.h>
2118 ],[
2119 vfs_fsync(NULL, 0);
2120 ],[
2121 AC_MSG_RESULT(yes)
2122 AC_DEFINE(HAVE_2ARGS_VFS_FSYNC, 1, [vfs_fsync() wants 2 args])
2123 ],[
2124 AC_MSG_RESULT(no)
2125 ])
2126 ])
2127
2128 dnl #
2129 dnl # 3.5 API change,
2130 dnl # inode_operations.truncate_range removed
2131 dnl #
2132 AC_DEFUN([SPL_AC_INODE_TRUNCATE_RANGE], [
2133 AC_MSG_CHECKING([whether truncate_range() inode operation is available])
2134 SPL_LINUX_TRY_COMPILE([
2135 #include <linux/fs.h>
2136 ],[
2137 struct inode_operations ops;
2138 ops.truncate_range = NULL;
2139 ],[
2140 AC_MSG_RESULT(yes)
2141 AC_DEFINE(HAVE_INODE_TRUNCATE_RANGE, 1,
2142 [truncate_range() inode operation is available])
2143 ],[
2144 AC_MSG_RESULT(no)
2145 ])
2146 ])
2147
2148 dnl #
2149 dnl # Linux 2.6.38 - 3.x API
2150 dnl #
2151 AC_DEFUN([SPL_AC_KERNEL_FILE_FALLOCATE], [
2152 AC_MSG_CHECKING([whether fops->fallocate() exists])
2153 SPL_LINUX_TRY_COMPILE([
2154 #include <linux/fs.h>
2155 ],[
2156 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2157 struct file_operations fops __attribute__ ((unused)) = {
2158 .fallocate = fallocate,
2159 };
2160 ],[
2161 AC_MSG_RESULT(yes)
2162 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2163 ],[
2164 AC_MSG_RESULT(no)
2165 ])
2166 ])
2167
2168 dnl #
2169 dnl # Linux 2.6.x - 2.6.37 API
2170 dnl #
2171 AC_DEFUN([SPL_AC_KERNEL_INODE_FALLOCATE], [
2172 AC_MSG_CHECKING([whether iops->fallocate() exists])
2173 SPL_LINUX_TRY_COMPILE([
2174 #include <linux/fs.h>
2175 ],[
2176 long (*fallocate) (struct inode *, int, loff_t, loff_t) = NULL;
2177 struct inode_operations fops __attribute__ ((unused)) = {
2178 .fallocate = fallocate,
2179 };
2180 ],[
2181 AC_MSG_RESULT(yes)
2182 AC_DEFINE(HAVE_INODE_FALLOCATE, 1, [fops->fallocate() exists])
2183 ],[
2184 AC_MSG_RESULT(no)
2185 ])
2186 ])
2187
2188 dnl #
2189 dnl # PaX Linux 2.6.38 - 3.x API
2190 dnl #
2191 AC_DEFUN([SPL_AC_PAX_KERNEL_FILE_FALLOCATE], [
2192 AC_MSG_CHECKING([whether fops->fallocate() exists])
2193 SPL_LINUX_TRY_COMPILE([
2194 #include <linux/fs.h>
2195 ],[
2196 long (*fallocate) (struct file *, int, loff_t, loff_t) = NULL;
2197 struct file_operations_no_const fops __attribute__ ((unused)) = {
2198 .fallocate = fallocate,
2199 };
2200 ],[
2201 AC_MSG_RESULT(yes)
2202 AC_DEFINE(HAVE_FILE_FALLOCATE, 1, [fops->fallocate() exists])
2203 ],[
2204 AC_MSG_RESULT(no)
2205 ])
2206 ])
2207
2208 dnl #
2209 dnl # The fallocate callback was moved from the inode_operations
2210 dnl # structure to the file_operations structure.
2211 dnl #
2212 AC_DEFUN([SPL_AC_KERNEL_FALLOCATE], [
2213 SPL_AC_KERNEL_FILE_FALLOCATE
2214 SPL_AC_KERNEL_INODE_FALLOCATE
2215 SPL_AC_PAX_KERNEL_FILE_FALLOCATE
2216 ])
2217
2218 dnl #
2219 dnl # 2.6.33 API change. Also backported in RHEL5 as of 2.6.18-190.el5.
2220 dnl # Earlier versions of rwsem_is_locked() were inline and had a race
2221 dnl # condition. The fixed version is exported as a symbol. The race
2222 dnl # condition is fixed by acquiring sem->wait_lock, so we must not
2223 dnl # call that version while holding sem->wait_lock.
2224 dnl #
2225 AC_DEFUN([SPL_AC_EXPORTED_RWSEM_IS_LOCKED],
2226 [AC_MSG_CHECKING([whether rwsem_is_locked() acquires sem->wait_lock])
2227 SPL_LINUX_TRY_COMPILE_SYMBOL([
2228 #include <linux/rwsem.h>
2229 int rwsem_is_locked(struct rw_semaphore *sem) { return 0; }
2230 ], [], [rwsem_is_locked], [lib/rwsem-spinlock.c], [
2231 AC_MSG_RESULT(yes)
2232 AC_DEFINE(RWSEM_IS_LOCKED_TAKES_WAIT_LOCK, 1,
2233 [rwsem_is_locked() acquires sem->wait_lock])
2234 ], [
2235 AC_MSG_RESULT(no)
2236 ])
2237 ])
2238
2239 dnl #
2240 dnl # 2.6.xx API compat,
2241 dnl # There currently exists no exposed API to partially shrink the dcache.
2242 dnl # The expected mechanism to shrink the cache is a registered shrinker
2243 dnl # which is called during memory pressure.
2244 dnl #
2245 AC_DEFUN([SPL_AC_SHRINK_DCACHE_MEMORY],
2246 [AC_MSG_CHECKING([whether shrink_dcache_memory() is available])
2247 SPL_LINUX_TRY_COMPILE_SYMBOL([
2248 #include <linux/dcache.h>
2249 ], [
2250 shrink_dcache_memory(0, 0);
2251 ], [shrink_dcache_memory], [fs/dcache.c], [
2252 AC_MSG_RESULT(yes)
2253 AC_DEFINE(HAVE_SHRINK_DCACHE_MEMORY, 1,
2254 [shrink_dcache_memory() is available])
2255 ], [
2256 AC_MSG_RESULT(no)
2257 ])
2258 ])
2259
2260 dnl #
2261 dnl # 2.6.xx API compat,
2262 dnl # There currently exists no exposed API to partially shrink the icache.
2263 dnl # The expected mechanism to shrink the cache is a registered shrinker
2264 dnl # which is called during memory pressure.
2265 dnl #
2266 AC_DEFUN([SPL_AC_SHRINK_ICACHE_MEMORY],
2267 [AC_MSG_CHECKING([whether shrink_icache_memory() is available])
2268 SPL_LINUX_TRY_COMPILE_SYMBOL([
2269 #include <linux/dcache.h>
2270 ], [
2271 shrink_icache_memory(0, 0);
2272 ], [shrink_icache_memory], [fs/inode.c], [
2273 AC_MSG_RESULT(yes)
2274 AC_DEFINE(HAVE_SHRINK_ICACHE_MEMORY, 1,
2275 [shrink_icache_memory() is available])
2276 ], [
2277 AC_MSG_RESULT(no)
2278 ])
2279 ])
2280
2281 dnl #
2282 dnl # 2.6.39 API compat,
2283 dnl # The path_lookup() function has been renamed to kern_path_parent()
2284 dnl # and the flags argument has been removed. The only behavior now
2285 dnl # offered is that of LOOKUP_PARENT. The spl already always passed
2286 dnl # this flag so dropping the flag does not impact us.
2287 dnl #
2288 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_HEADER], [
2289 SPL_CHECK_SYMBOL_HEADER(
2290 [kern_path_parent],
2291 [int kern_path_parent(const char \*, struct nameidata \*)],
2292 [include/linux/namei.h],
2293 [AC_DEFINE(HAVE_KERN_PATH_PARENT_HEADER, 1,
2294 [kern_path_parent() is available])],
2295 [])
2296 ])
2297
2298 dnl #
2299 dnl # 3.1 API compat,
2300 dnl # The kern_path_parent() symbol is no longer exported by the kernel.
2301 dnl # However, it remains the prefered interface and since we still have
2302 dnl # access to the prototype we dynamically lookup the required address.
2303 dnl #
2304 AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
2305 [AC_MSG_CHECKING([whether kern_path_parent() is available])
2306 SPL_LINUX_TRY_COMPILE_SYMBOL([
2307 #include <linux/namei.h>
2308 ], [
2309 kern_path_parent(NULL, NULL);
2310 ], [kern_path_parent], [fs/namei.c], [
2311 AC_MSG_RESULT(yes)
2312 AC_DEFINE(HAVE_KERN_PATH_PARENT_SYMBOL, 1,
2313 [kern_path_parent() is available])
2314 ], [
2315 AC_MSG_RESULT(no)
2316 ])
2317 ])
2318
2319 dnl #
2320 dnl # 3.6 API compat,
2321 dnl # The kern_path_parent() function was replaced by the kern_path_locked()
2322 dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
2323 dnl #
2324 AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
2325 SPL_CHECK_SYMBOL_HEADER(
2326 [kern_path_locked],
2327 [struct dentry \*kern_path_locked(const char \*, struct path \*)],
2328 [include/linux/namei.h],
2329 [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
2330 [kern_path_locked() is available])],
2331 [])
2332 ])
2333
2334 dnl #
2335 dnl # /proc/kallsyms support,
2336 dnl # Verify the kernel has CONFIG_KALLSYMS support enabled.
2337 dnl #
2338 AC_DEFUN([SPL_AC_CONFIG_KALLSYMS], [
2339 AC_MSG_CHECKING([whether CONFIG_KALLSYMS is defined])
2340 SPL_LINUX_TRY_COMPILE([
2341 #if !defined(CONFIG_KALLSYMS)
2342 #error CONFIG_KALLSYMS not defined
2343 #endif
2344 ],[ ],[
2345 AC_MSG_RESULT([yes])
2346 ],[
2347 AC_MSG_RESULT([no])
2348 AC_MSG_ERROR([
2349 *** This kernel does not include the required kallsyms support.
2350 *** Rebuild the kernel with CONFIG_KALLSYMS=y set.])
2351 ])
2352 ])
2353
2354 dnl #
2355 dnl # zlib inflate compat,
2356 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
2357 dnl #
2358 AC_DEFUN([SPL_AC_CONFIG_ZLIB_INFLATE], [
2359 AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
2360 SPL_LINUX_TRY_COMPILE([
2361 #if !defined(CONFIG_ZLIB_INFLATE) && \
2362 !defined(CONFIG_ZLIB_INFLATE_MODULE)
2363 #error CONFIG_ZLIB_INFLATE not defined
2364 #endif
2365 ],[ ],[
2366 AC_MSG_RESULT([yes])
2367 ],[
2368 AC_MSG_RESULT([no])
2369 AC_MSG_ERROR([
2370 *** This kernel does not include the required zlib inflate support.
2371 *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
2372 ])
2373 ])
2374
2375 dnl #
2376 dnl # zlib deflate compat,
2377 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
2378 dnl #
2379 AC_DEFUN([SPL_AC_CONFIG_ZLIB_DEFLATE], [
2380 AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
2381 SPL_LINUX_TRY_COMPILE([
2382 #if !defined(CONFIG_ZLIB_DEFLATE) && \
2383 !defined(CONFIG_ZLIB_DEFLATE_MODULE)
2384 #error CONFIG_ZLIB_DEFLATE not defined
2385 #endif
2386 ],[ ],[
2387 AC_MSG_RESULT([yes])
2388 ],[
2389 AC_MSG_RESULT([no])
2390 AC_MSG_ERROR([
2391 *** This kernel does not include the required zlib deflate support.
2392 *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
2393 ])
2394 ])
2395
2396 dnl #
2397 dnl # 2.6.39 API compat,
2398 dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
2399 dnl # This was done to avoid always having to allocate the maximum size
2400 dnl # workspace (268K). The caller can now specific the windowBits and
2401 dnl # memLevel compression parameters to get a smaller workspace.
2402 dnl #
2403 AC_DEFUN([SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE],
2404 [AC_MSG_CHECKING([whether zlib_deflate_workspacesize() wants 2 args])
2405 SPL_LINUX_TRY_COMPILE([
2406 #include <linux/zlib.h>
2407 ],[
2408 return zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL);
2409 ],[
2410 AC_MSG_RESULT(yes)
2411 AC_DEFINE(HAVE_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE, 1,
2412 [zlib_deflate_workspacesize() wants 2 args])
2413 ],[
2414 AC_MSG_RESULT(no)
2415 ])
2416 ])
2417
2418 dnl #
2419 dnl # 2.6.39 API change,
2420 dnl # Shrinker adjust to use common shrink_control structure.
2421 dnl #
2422 AC_DEFUN([SPL_AC_SHRINK_CONTROL_STRUCT], [
2423 AC_MSG_CHECKING([whether struct shrink_control exists])
2424 SPL_LINUX_TRY_COMPILE([
2425 #include <linux/mm.h>
2426 ],[
2427 struct shrink_control sc __attribute__ ((unused));
2428
2429 sc.nr_to_scan = 0;
2430 sc.gfp_mask = GFP_KERNEL;
2431 ],[
2432 AC_MSG_RESULT(yes)
2433 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
2434 [struct shrink_control exists])
2435 ],[
2436 AC_MSG_RESULT(no)
2437 ])
2438 ])
2439
2440 dnl #
2441 dnl # 3.1 API Change
2442 dnl #
2443 dnl # The rw_semaphore.wait_lock member was changed from spinlock_t to
2444 dnl # raw_spinlock_t at commit ddb6c9b58a19edcfac93ac670b066c836ff729f1.
2445 dnl #
2446 AC_DEFUN([SPL_AC_RWSEM_SPINLOCK_IS_RAW], [
2447 AC_MSG_CHECKING([whether struct rw_semaphore member wait_lock is raw])
2448 tmp_flags="$EXTRA_KCFLAGS"
2449 EXTRA_KCFLAGS="-Werror"
2450 SPL_LINUX_TRY_COMPILE([
2451 #include <linux/rwsem.h>
2452 ],[
2453 struct rw_semaphore dummy_semaphore __attribute__ ((unused));
2454 raw_spinlock_t dummy_lock __attribute__ ((unused));
2455 dummy_semaphore.wait_lock = dummy_lock;
2456 ],[
2457 AC_MSG_RESULT(yes)
2458 AC_DEFINE(RWSEM_SPINLOCK_IS_RAW, 1,
2459 [struct rw_semaphore member wait_lock is raw_spinlock_t])
2460 ],[
2461 AC_MSG_RESULT(no)
2462 ])
2463 EXTRA_KCFLAGS="$tmp_flags"
2464 ])
2465
2466 dnl #
2467 dnl # 3.9 API change,
2468 dnl # Moved things from linux/sched.h to linux/sched/rt.h
2469 dnl #
2470 AC_DEFUN([SPL_AC_SCHED_RT_HEADER],
2471 [AC_MSG_CHECKING([whether header linux/sched/rt.h exists])
2472 SPL_LINUX_TRY_COMPILE([
2473 #include <linux/sched.h>
2474 #include <linux/sched/rt.h>
2475 ],[
2476 return 0;
2477 ],[
2478 AC_DEFINE(HAVE_SCHED_RT_HEADER, 1, [linux/sched/rt.h exists])
2479 AC_MSG_RESULT(yes)
2480 ],[
2481 AC_MSG_RESULT(no)
2482 ])
2483 ])
2484
2485 dnl #
2486 dnl # 3.9 API change,
2487 dnl # vfs_getattr() uses 2 args
2488 dnl # It takes struct path * instead of struct vfsmount * and struct dentry *
2489 dnl #
2490 AC_DEFUN([SPL_AC_2ARGS_VFS_GETATTR], [
2491 AC_MSG_CHECKING([whether vfs_getattr() wants])
2492 SPL_LINUX_TRY_COMPILE([
2493 #include <linux/fs.h>
2494 ],[
2495 vfs_getattr((struct path *) NULL,
2496 (struct kstat *)NULL);
2497 ],[
2498 AC_MSG_RESULT(2 args)
2499 AC_DEFINE(HAVE_2ARGS_VFS_GETATTR, 1,
2500 [vfs_getattr wants 2 args])
2501 ],[
2502 SPL_LINUX_TRY_COMPILE([
2503 #include <linux/fs.h>
2504 ],[
2505 vfs_getattr((struct vfsmount *)NULL,
2506 (struct dentry *)NULL,
2507 (struct kstat *)NULL);
2508 ],[
2509 AC_MSG_RESULT(3 args)
2510 ],[
2511 AC_MSG_ERROR(unknown)
2512 ])
2513 ])
2514 ])
2515
2516 dnl #
2517 dnl # 2.6.36 API compatibility.
2518 dnl # Added usleep_range timer.
2519 dnl # usleep_range is a finer precision implementation of msleep
2520 dnl # designed to be a drop-in replacement for udelay where a precise
2521 dnl # sleep / busy-wait is unnecessary.
2522 dnl #
2523 AC_DEFUN([SPL_AC_USLEEP_RANGE], [
2524 AC_MSG_CHECKING([whether usleep_range() is available])
2525 SPL_LINUX_TRY_COMPILE([
2526 #include <linux/delay.h>
2527 ],[
2528 usleep_range(0, 0);
2529 ],[
2530 AC_MSG_RESULT(yes)
2531 AC_DEFINE(HAVE_USLEEP_RANGE, 1,
2532 [usleep_range is available])
2533 ],[
2534 AC_MSG_RESULT(no)
2535 ])
2536 ])
2537
2538 dnl #
2539 dnl # 2.6.35 API change,
2540 dnl # The cachep->gfpflags member was renamed cachep->allocflags. These are
2541 dnl # private allocation flags which are applied when allocating a new slab
2542 dnl # in kmem_getpages(). Unfortunately there is no public API for setting
2543 dnl # non-default flags.
2544 dnl #
2545 AC_DEFUN([SPL_AC_KMEM_CACHE_ALLOCFLAGS], [
2546 AC_MSG_CHECKING([whether struct kmem_cache has allocflags])
2547 SPL_LINUX_TRY_COMPILE([
2548 #include <linux/slab.h>
2549 ],[
2550 struct kmem_cache cachep __attribute__ ((unused));
2551 cachep.allocflags = GFP_KERNEL;
2552 ],[
2553 AC_MSG_RESULT(yes)
2554 AC_DEFINE(HAVE_KMEM_CACHE_ALLOCFLAGS, 1,
2555 [struct kmem_cache has allocflags])
2556 ],[
2557 AC_MSG_RESULT(no)
2558
2559 AC_MSG_CHECKING([whether struct kmem_cache has gfpflags])
2560 SPL_LINUX_TRY_COMPILE([
2561 #include <linux/slab.h>
2562 ],[
2563 struct kmem_cache cachep __attribute__ ((unused));
2564 cachep.gfpflags = GFP_KERNEL;
2565 ],[
2566 AC_MSG_RESULT(yes)
2567 AC_DEFINE(HAVE_KMEM_CACHE_GFPFLAGS, 1,
2568 [struct kmem_cache has gfpflags])
2569 ],[
2570 AC_MSG_RESULT(no)
2571 ])
2572 ])
2573 ])
2574
2575 dnl #
2576 dnl # 3.17 API change,
2577 dnl # wait_on_bit() no longer requires an action argument. The former
2578 dnl # "wait_on_bit" interface required an 'action' function to be provided
2579 dnl # which does the actual waiting. There were over 20 such functions in the
2580 dnl # kernel, many of them identical, though most cases can be satisfied by one
2581 dnl # of just two functions: one which uses io_schedule() and one which just
2582 dnl # uses schedule(). This API change was made to consolidate all of those
2583 dnl # redundant wait functions.
2584 dnl #
2585 AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
2586 AC_MSG_CHECKING([whether wait_on_bit() takes an action])
2587 SPL_LINUX_TRY_COMPILE([
2588 #include <linux/wait.h>
2589 ],[
2590 int (*action)(void *) = NULL;
2591 wait_on_bit(NULL, 0, action, 0);
2592 ],[
2593 AC_MSG_RESULT(yes)
2594 AC_DEFINE(HAVE_WAIT_ON_BIT_ACTION, 1, [yes])
2595 ],[
2596 AC_MSG_RESULT(no)
2597 ])
2598 ])