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