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