4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
6 AC_DEFUN([LIBCFS_CONFIG_CDEBUG], [
7 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
8 AC_ARG_ENABLE([libcfs_cdebug],
9 AC_HELP_STRING([--disable-libcfs-cdebug],
10 [disable libcfs CDEBUG, CWARN]),
11 [], [enable_libcfs_cdebug="yes"])
12 AC_MSG_RESULT([$enable_libcfs_cdebug])
13 AS_IF([test "x$enable_libcfs_cdebug" = xyes],
14 [AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])])
16 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
17 AC_ARG_ENABLE([libcfs_trace],
18 AC_HELP_STRING([--disable-libcfs-trace],
19 [disable libcfs ENTRY/EXIT]),
20 [], [enable_libcfs_trace="yes"])
21 AC_MSG_RESULT([$enable_libcfs_trace])
22 AS_IF([test "x$enable_libcfs_trace" = xyes],
23 [AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])])
25 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
26 AC_ARG_ENABLE([libcfs_assert],
27 AC_HELP_STRING([--disable-libcfs-assert],
28 [disable libcfs LASSERT, LASSERTF]),
29 [], [enable_libcfs_assert="yes"])
30 AC_MSG_RESULT([$enable_libcfs_assert])
31 AS_IF([test x$enable_libcfs_assert = xyes],
32 [AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])])
33 ]) # LIBCFS_CONFIG_CDEBUG
36 # LIBCFS_CONFIG_PANIC_DUMPLOG
38 # check if tunable panic_dumplog is wanted
40 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG], [
41 AC_MSG_CHECKING([whether to use tunable 'panic_dumplog' support])
42 AC_ARG_ENABLE([panic_dumplog],
43 AC_HELP_STRING([--enable-panic_dumplog],
44 [enable panic_dumplog]),
45 [], [enable_panic_dumplog="no"])
46 AC_MSG_RESULT([$enable_panic_dumplog])
47 AS_IF([test "x$enable_panic_dumplog" = xyes],
48 [AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])])
49 ]) # LIBCFS_CONFIG_PANIC_DUMPLOG
52 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
54 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
56 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK], [
57 LB_CHECK_COMPILE([if 'struct stacktrace_ops' has 'walk_stack' field],
58 stacktrace_ops_walk_stack, [
59 #include <asm/stacktrace.h>
61 ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
63 AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1,
64 ['struct stacktrace_ops' has 'walk_stack' field])
66 ]) # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
69 # LIBCFS_STACKTRACE_WARNING
71 # 3.0 removes stacktrace_ops warning* functions
73 AC_DEFUN([LIBCFS_STACKTRACE_WARNING], [
74 LB_CHECK_COMPILE([if 'stacktrace_ops.warning' is exist],
75 stacktrace_ops_warning, [
78 #include <asm/stacktrace.h>
80 ((struct stacktrace_ops *)0)->warning(NULL, NULL);
82 AC_DEFINE(HAVE_STACKTRACE_WARNING, 1,
83 [stacktrace_ops.warning is exist])
85 ]) # LIBCFS_STACKTRACE_WARNING
88 # LIBCFS_REINIT_COMPLETION
90 AC_DEFUN([LIBCFS_REINIT_COMPLETION], [
91 LB_CHECK_COMPILE([if 'reinit_completion' exists],
93 #include <linux/completion.h>
96 reinit_completion(&x);
98 AC_DEFINE(HAVE_REINIT_COMPLETION, 1,
99 [reinit_completion is exist])
101 ]) # LIBCFS_REINIT_COMPLETION
104 # LC_SHRINKER_WANT_SHRINK_PTR
106 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
108 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR], [
109 LB_CHECK_COMPILE([if 'shrinker' want self pointer in handler],
110 shrink_self_pointer, [
111 #include <linux/mm.h>
113 struct shrinker *tmp = NULL;
114 tmp->shrink(tmp, 0, 0);
116 AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
117 [shrinker want self pointer in handler])
119 ]) # LC_SHRINKER_WANT_SHRINK_PTR
122 # LIBCFS_SYSCTL_CTLNAME
124 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
126 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME], [
127 LB_CHECK_COMPILE([if 'ctl_table' has a 'ctl_name' field],
128 ctl_table_ctl_name, [
129 #include <linux/sysctl.h>
132 ct.ctl_name = sizeof(ct);
134 AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
135 [ctl_table has ctl_name field])
137 ]) # LIBCFS_SYSCTL_CTLNAME
140 # LIBCFS_MODULE_LOCKING
142 # 2.6.36 introduced locking to module params. RHEL6 lacks this support
144 AC_DEFUN([LIBCFS_MODULE_LOCKING],[
145 LB_CHECK_COMPILE([does the kernel support module param locking],
146 module_param_locking, [
147 #include <linux/moduleparam.h>
149 __kernel_param_lock(NULL);
150 __kernel_param_unlock(NULL);
152 AC_DEFINE(HAVE_MODULE_PARAM_LOCKING, 1,
153 [locking module param is supported])
155 ]) # LIBCFS_MODULE_LOCKING
160 # 2.6.38 kstrtoul is added
162 AC_DEFUN([LIBCFS_KSTRTOUL], [
163 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
165 #include <linux/kernel.h>
167 unsigned long result;
168 return kstrtoul("12345", 0, &result);
170 AC_DEFINE(HAVE_KSTRTOUL, 1,
171 [kernel has kstrtoul])
176 # LIBCFS_DUMP_TRACE_ADDRESS
178 # 2.6.39 adds a base pointer address argument to dump_trace
180 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
181 LB_CHECK_COMPILE([if 'dump_trace' want address],
182 dump_trace_address, [
185 #include <asm/stacktrace.h>
187 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
189 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
190 [dump_trace want address argument])
192 ]) # LIBCFS_DUMP_TRACE_ADDRESS
197 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
198 # pressure shrinker from Linux 3.0
200 AC_DEFUN([LC_SHRINK_CONTROL], [
201 LB_CHECK_COMPILE([if 'shrink_control' is present],
203 #include <linux/atomic.h>
204 #include <linux/mm.h>
206 struct shrink_control tmp = {0};
207 tmp.nr_to_scan = sizeof(tmp);
209 AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
210 [shrink_control is present])
212 ]) # LC_SHRINK_CONTROL
215 # LIBCFS_PROCESS_NAMESPACE
217 # 3.5 introduced process namespace
218 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
219 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
220 AC_DEFINE(HAVE_UIDGID_HEADER, 1,
221 [uidgid.h is present])])
222 ]) # LIBCFS_PROCESS_NAMESPACE
227 # 3.5 added helpers to read the new uid/gid types from VFS structures
228 # SLE11 SP3 has uidgid.h but not the helpers
230 AC_DEFUN([LIBCFS_I_UID_READ], [
231 LB_CHECK_COMPILE([if 'i_uid_read' is present],
233 #include <linux/fs.h>
237 AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
239 ]) # LIBCFS_I_UID_READ
244 AC_DEFUN([LIBCFS_HAVE_CRC32], [
245 LB_CHECK_CONFIG_IM([CRC32],
246 [have_crc32="yes"], [have_crc32="no"])
247 AS_IF([test "x$have_crc32" = xyes],
248 [AC_DEFINE(HAVE_CRC32, 1,
249 [kernel compiled with CRC32 functions])])
250 ]) # LIBCFS_HAVE_CRC32
253 # LIBCFS_ENABLE_CRC32_ACCEL
255 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
256 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
257 [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
258 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
259 AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
260 AC_MSG_WARN([No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32])])
261 ]) # LIBCFS_ENABLE_CRC32_ACCEL
264 # LIBCFS_ENABLE_CRC32C_ACCEL
266 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
267 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
268 [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
269 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
270 AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
271 AC_MSG_WARN([No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c])])
272 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
275 # Kernel version 3.11 introduced ktime_get_ts64
277 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
278 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
280 #include <linux/hrtimer.h>
281 #include <linux/ktime.h>
283 struct timespec64 *ts = NULL;
287 AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
288 ['ktime_get_ts64' is available])
290 ]) # LIBCFS_KTIME_GET_TS64
293 # Linux kernel 3.12 introduced struct kernel_param_ops
294 # This has been backported to all lustre supported
295 # clients except RHEL6. We have to handle the differences.
297 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
298 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
300 #include <linux/module.h>
302 struct kernel_param_ops ops;
306 AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
307 ['struct kernel_param_ops' is available])
309 ]) # LIBCFS_KERNEL_PARAM_OPS
312 # Kernel version 3.12 introduced ktime_add
314 AC_DEFUN([LIBCFS_KTIME_ADD],[
315 LB_CHECK_COMPILE([does function 'ktime_add' exist],
317 #include <linux/hrtimer.h>
318 #include <linux/ktime.h>
320 ktime_t start = ktime_set(0, 0);
324 total = ktime_add(start, end);
326 AC_DEFINE(HAVE_KTIME_ADD, 1,
327 [ktime_add is available])
329 ]) # LIBCFS_KTIME_ADD
332 # Kernel version 3.12 introduced ktime_after
334 AC_DEFUN([LIBCFS_KTIME_AFTER],[
335 LB_CHECK_COMPILE([does function 'ktime_after' exist],
337 #include <linux/hrtimer.h>
338 #include <linux/ktime.h>
340 ktime_t start = ktime_set(0, 0);
343 ktime_after(start, end);
345 AC_DEFINE(HAVE_KTIME_AFTER, 1,
346 [ktime_after is available])
348 ]) # LIBCFS_KTIME_AFTER
351 # Kernel version 3.12 introduced ktime_before
352 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
354 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
355 LB_CHECK_COMPILE([does function 'ktime_before' exist],
357 #include <linux/hrtimer.h>
358 #include <linux/ktime.h>
360 ktime_t start = ktime_set(0, 0);
363 ktime_before(start, end);
365 AC_DEFINE(HAVE_KTIME_BEFORE, 1,
366 [ktime_before is available])
368 ]) # LIBCFS_KTIME_BEFORE
371 # Kernel version 3.12 introduced ktime_compare
373 AC_DEFUN([LIBCFS_KTIME_COMPARE],[
374 LB_CHECK_COMPILE([does function 'ktime_compare' exist],
376 #include <linux/hrtimer.h>
377 #include <linux/ktime.h>
379 ktime_t start = ktime_set(0, 0);
382 ktime_compare(start, end);
384 AC_DEFINE(HAVE_KTIME_COMPARE, 1,
385 [ktime_compare is available])
387 ]) # LIBCFS_KTIME_COMPARE
390 # FC19 3.12 kernel struct shrinker change
392 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
393 LB_CHECK_COMPILE([shrinker has 'count_objects'],
394 shrinker_count_objects, [
395 #include <linux/mmzone.h>
396 #include <linux/shrinker.h>
398 struct shrinker shrinker;
400 shrinker.count_objects = NULL;
402 AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
403 [shrinker has count_objects member])
405 ]) # LIBCFS_SHRINKER_COUNT
408 # Kernel version 3.17 changed hlist_add_after to
411 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
412 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
414 #include <linux/list.h>
416 hlist_add_after(NULL, NULL);
418 AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
419 [hlist_add_after is available])
421 ]) # LIBCFS_HLIST_ADD_AFTER
424 # Kernel version 3.17 introduced struct timespec64
426 AC_DEFUN([LIBCFS_TIMESPEC64],[
427 LB_CHECK_COMPILE([does 'struct timespec64' exist],
429 #include <linux/time.h>
431 struct timespec64 ts;
436 AC_DEFINE(HAVE_TIMESPEC64, 1,
437 ['struct timespec64' is available])
439 ]) # LIBCFS_TIMESPEC64
442 # Kernel version 3.17 introduced ktime_get_real_ts64
444 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
445 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
446 ktime_get_real_ts64, [
447 #include <linux/ktime.h>
449 struct timespec64 *ts = NULL;
451 ktime_get_real_ts64(ts);
453 AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
454 ['ktime_get_real_ts64' is available])
456 ]) # LIBCFS_KTIME_GET_REAL_TS64
459 # Kernel version 3.17 introduced ktime_get_real_seconds
461 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
462 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
463 ktime_get_real_seconds, [
464 #include <linux/hrtimer.h>
465 #include <linux/ktime.h>
469 now = ktime_get_real_seconds();
471 AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
472 ['ktime_get_real_seconds' is available])
474 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
477 # Kernel version 3.17 created ktime_get_ns wrapper
479 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
480 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
482 #include <linux/hrtimer.h>
483 #include <linux/ktime.h>
487 nanoseconds = ktime_get_ns();
489 AC_DEFINE(NEED_KTIME_GET_NS, 1,
490 ['ktime_get_ns' is not available])
492 ]) # LIBCFS_KTIME_GET_NS
495 # Kernel version 3.17 created ktime_get_real_ns wrapper
497 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
498 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
500 #include <linux/hrtimer.h>
501 #include <linux/ktime.h>
505 nanoseconds = ktime_get_real_ns();
507 AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
508 ['ktime_get_real_ns' is not available])
510 ]) # LIBCFS_KTIME_GET_REAL_NS
513 # Kernel version 3.17 introduced ktime_to_timespec64
515 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
516 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
517 ktime_to_timespec64, [
518 #include <linux/hrtimer.h>
519 #include <linux/ktime.h>
521 ktime_t now = ktime_set(0, 0);
522 struct timespec64 ts;
524 ts = ktime_to_timespec64(now);
526 AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
527 ['ktime_to_timespec64' is available])
529 ]) # LIBCFS_KTIME_TO_TIMESPEC64
532 # Kernel version 3.17 introduced timespec64_sub
534 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
535 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
537 #include <linux/time.h>
539 struct timespec64 later = { }, earlier = { }, diff;
541 diff = timespec64_sub(later, earlier);
543 AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
544 ['timespec64_sub' is available])
546 ]) # LIBCFS_TIMESPEC64_SUB
549 # Kernel version 3.17 introduced timespec64_to_ktime
551 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
552 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
553 timespec64_to_ktime, [
554 #include <linux/ktime.h>
556 struct timespec64 ts;
559 now = timespec64_to_ktime(ts);
561 AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
562 ['timespec64_to_ktime' is available])
564 ]) # LIBCFS_TIMESPEC64_TO_KTIME
567 # Kernel version 3.19 introduced ktime_get_seconds
569 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
570 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
572 #include <linux/ktime.h>
576 now = ktime_get_seconds();
578 AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
579 ['ktime_get_seconds' is available])
581 ]) # LIBCFS_KTIME_GET_SECONDS
584 # Kernel version 3.19 commit 5aaba36318e5995e8c95d077a46d9a4d00fcc1cd
585 # This patch creates a new helper function cpumap_print_to_pagebuf in
586 # cpumask.h using newly added bitmap_print_to_pagebuf and consolidates
587 # most of those sysfs functions using the new helper function.
589 AC_DEFUN([LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF],[
590 LB_CHECK_COMPILE([does function 'cpumap_print_to_pagebuf' exist],
591 cpumap_print_to_pagebuf, [
592 #include <linux/topology.h>
596 const struct cpumask *mask = NULL;
597 n = cpumap_print_to_pagebuf(true, buf, mask);
599 AC_DEFINE(HAVE_CPUMASK_PRINT_TO_PAGEBUF, 1,
600 [cpumap_print_to_pagebuf is available])
602 ]) # LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
605 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
606 # introduced the helper function ktime_ms_delta.
608 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
609 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
611 #include <linux/ktime.h>
613 ktime_t start = ktime_set(0, 0);
616 ktime_ms_delta(start, end);
618 AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
619 ['ktime_ms_delta' is available])
621 ]) # LIBCFS_KTIME_MS_DELTA
624 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
625 # create per module locks which added kernel_param_[un]lock(). Older
626 # kernels you have to use __kernel_param_[un]lock(). In that case its
627 # a global lock for all modules but that is okay since its a rare event.
629 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
630 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
632 #include <linux/moduleparam.h>
634 kernel_param_lock(NULL);
635 kernel_param_unlock(NULL);
637 AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
638 ['kernel_param_[un]lock' is available])
640 ]) # LIBCFS_KERNEL_PARAM_LOCK
643 # Kernel version 4.2 changed topology_thread_cpumask
644 # to topology_sibling_cpumask
646 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
647 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
648 topology_sibling_cpumask, [
649 #include <linux/topology.h>
651 const struct cpumask *mask;
653 mask = topology_sibling_cpumask(0);
655 AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
656 [topology_sibling_cpumask is available])
658 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
661 # Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
662 # header file i387.h was renamed to fpu/api.h
664 AC_DEFUN([LIBCFS_FPU_API], [
665 LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
666 AC_DEFINE(HAVE_FPU_API_HEADER, 1,
667 [fpu/api.h is present])])
671 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
672 # introduced kstrtobool and kstrtobool_from_user.
674 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
675 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
676 kstrtobool_from_user, [
677 #include <linux/kernel.h>
680 return kstrtobool_from_user(NULL, 0, &result);
682 AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
683 [kernel has kstrtobool_from_user])
685 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
688 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
689 # added crypto hash helpers
691 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
692 LB_CHECK_COMPILE([does crypto hash helper functions exist],
693 crypto_hash_helpers, [
694 #include <crypto/hash.h>
696 crypto_ahash_alg_name(NULL);
697 crypto_ahash_driver_name(NULL);
699 AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
700 [crypto hash helper functions are available])
702 ]) # LIBCFS_CRYPTO_HASH_HELPERS
705 # Kernerl version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
706 # made kset_find_obj() exportable to modules
708 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
709 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
710 [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
711 [kset_find_obj is exported by the kernel])])
712 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
715 # Kernel version 4.6+ commit ef703f49a6c5b909a85149bb6625c4ed0d697186
716 # fixed the brokenness of hash_64(). The fix removed GOLDEN_RATIO_PRIME_64
717 # since it was a poor prime value.
719 AC_DEFUN([LIBCFS_BROKEN_HASH_64], [
720 LB_CHECK_COMPILE([kernel has fixed hash_64()],
722 #include <linux/hash.h>
724 int tmp = GOLDEN_RATIO_PRIME_64;
726 AC_DEFINE(HAVE_BROKEN_HASH_64, 1, [kernel hash_64() is broken])
728 ]) # LIBCFS_BROKEN_HASH_64
731 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
733 # linux 4.6 kernel changed stacktrace_ops address to return an int
735 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
736 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
737 stacktrace_ops_address_return_int, [
738 #include <asm/stacktrace.h>
742 rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
744 AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
745 ['struct stacktrace_ops' address function returns an int])
747 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
750 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
751 # arguments to get_user_pages
753 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
754 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
755 get_user_pages_6arg, [
756 #include <linux/mm.h>
760 rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
762 AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
763 [get_user_pages takes 6 arguments])
765 ]) # LIBCFS_GET_USER_PAGES_6ARG
770 # 4.6 kernel created stringhash.h which moved stuff out of dcache.h
771 # commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
773 AC_DEFUN([LIBCFS_STRINGHASH], [
774 LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
775 AC_DEFINE(HAVE_STRINGHASH, 1,
776 [stringhash.h is present])])
777 ]) # LIBCFS_STRINGHASH
780 # LIBCFS_STACKTRACE_OPS
782 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
783 # removed both struct stacktrace_ops and dump_trace() function
785 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
786 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
790 #include <asm/stacktrace.h>
792 struct stacktrace_ops ops;
795 AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
796 [struct stacktrace_ops exists])
798 ]) # LIBCFS_STACKTRACE_OPS
801 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
802 # mm: replace get_user_pages() write/force parameters with gup_flags
804 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
805 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
806 get_user_pages_gup_flags, [
807 #include <linux/mm.h>
810 rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
812 AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
813 [get_user_pages takes gup_flags in arguments])
815 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
818 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
819 # libcfs: Convert to hotplug state machine
821 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
822 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
823 cpu_hotplug_state_machine, [
824 #include <linux/cpuhotplug.h>
826 cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
828 AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
829 [hotplug state machine is supported])
831 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
834 # LIBCFS_SCHED_HEADERS
836 # 4.11 has broken up sched.h into more headers.
838 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
839 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
840 AC_DEFINE(HAVE_SCHED_HEADERS, 1,
841 [linux/sched header directory exist])])
842 ]) # LIBCFS_SCHED_HEADERS
845 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
846 # introduced rhashtable_lookup_get_insert_fast
848 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
849 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
850 rhashtable_lookup_get_insert_fast, [
851 #include <linux/rhashtable.h>
853 const struct rhashtable_params params = { 0 };
856 ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
858 AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
859 [rhashtable_lookup_get_insert_fast() is available])
861 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
864 # LIBCFS_WAIT_QUEUE_ENTRY
866 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
867 # Rename wait_queue_t => wait_queue_entry_t
869 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
870 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
872 #include <linux/wait.h>
874 wait_queue_entry_t e;
878 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
879 ['wait_queue_entry_t' is available])
881 ]) # LIBCFS_WAIT_QUEUE_ENTRY
884 # LIBCFS_NEW_KERNEL_WRITE
886 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
887 # changed kernel_write prototype to make is plug compatible
888 # with the unexported vfs_write()
890 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
891 tmp_flags="$EXTRA_KCFLAGS"
892 EXTRA_KCFLAGS="-Werror"
893 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
894 kernel_write_match, [
895 #include <linux/fs.h>
897 const void *buf = NULL;
899 return kernel_write(NULL, buf, 0, &pos);
901 AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
902 ['kernel_write' aligns with read/write helpers])
904 EXTRA_KCFLAGS="$tmp_flags"
905 ]) # LIBCFS_NEW_KERNEL_WRITE
908 # LIBCFS_DEFINE_TIMER
910 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
911 # remove expires and data arguments from DEFINE_TIMER. Also the callback
912 # when from using unsigned long argument to using struct timer_list pointer.
914 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
915 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
917 #include <linux/timer.h>
919 static DEFINE_TIMER(my_timer, NULL);
921 AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
922 [DEFINE_TIMER uses only 2 arguements])
924 ]) # LIBCFS_DEFINE_TIMER
929 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
930 # setup_timer() was replaced by timer_setup(), where the callback
931 # argument is the structure already holding the struct timer_list.
933 AC_DEFUN([LIBCFS_TIMER_SETUP], [
934 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
936 #include <linux/timer.h>
938 timer_setup(NULL, NULL, 0);
940 AC_DEFINE(HAVE_TIMER_SETUP, 1,
941 [timer_setup has replaced setup_timer])
943 ]) # LIBCFS_TIMER_SETUP
948 # LibCFS linux kernel checks
950 AC_DEFUN([LIBCFS_PROG_LINUX], [
951 AC_MSG_NOTICE([LibCFS kernel checks
952 ==============================================================================])
953 LIBCFS_CONFIG_PANIC_DUMPLOG
956 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
957 LC_SHRINKER_WANT_SHRINK_PTR
959 LIBCFS_SYSCTL_CTLNAME
961 LIBCFS_MODULE_LOCKING
965 LIBCFS_DUMP_TRACE_ADDRESS
969 LIBCFS_STACKTRACE_WARNING
970 LIBCFS_REINIT_COMPLETION
972 LIBCFS_PROCESS_NAMESPACE
976 LIBCFS_ENABLE_CRC32_ACCEL
978 LIBCFS_ENABLE_CRC32C_ACCEL
980 LIBCFS_KTIME_GET_TS64
982 LIBCFS_KERNEL_PARAM_OPS
987 LIBCFS_SHRINKER_COUNT
989 LIBCFS_HLIST_ADD_AFTER
992 LIBCFS_KTIME_GET_REAL_TS64
993 LIBCFS_KTIME_GET_REAL_SECONDS
994 LIBCFS_KTIME_GET_REAL_NS
995 LIBCFS_KTIME_TO_TIMESPEC64
996 LIBCFS_TIMESPEC64_SUB
997 LIBCFS_TIMESPEC64_TO_KTIME
999 LIBCFS_KTIME_GET_SECONDS
1000 LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
1002 LIBCFS_KTIME_MS_DELTA
1004 LIBCFS_KERNEL_PARAM_LOCK
1006 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
1009 LIBCFS_KSTRTOBOOL_FROM_USER
1011 LIBCFS_CRYPTO_HASH_HELPERS
1012 LIBCFS_EXPORT_KSET_FIND_OBJ
1014 LIBCFS_BROKEN_HASH_64
1015 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
1016 LIBCFS_GET_USER_PAGES_6ARG
1019 LIBCFS_STACKTRACE_OPS
1021 LIBCFS_GET_USER_PAGES_GUP_FLAGS
1023 LIBCFS_HOTPLUG_STATE_MACHINE
1025 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
1026 LIBCFS_SCHED_HEADERS
1028 LIBCFS_WAIT_QUEUE_ENTRY
1031 LIBCFS_NEW_KERNEL_WRITE
1034 ]) # LIBCFS_PROG_LINUX
1037 # LIBCFS_PATH_DEFAULTS
1039 # default paths for installed files
1041 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
1042 ]) # LIBCFS_PATH_DEFAULTS
1047 # other configure checks
1049 AC_DEFUN([LIBCFS_CONFIGURE], [
1050 AC_MSG_NOTICE([LibCFS core checks
1051 ==============================================================================])
1053 # libcfs/libcfs/util/nidstrings.c
1054 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
1055 AC_CHECK_FUNCS([gethostbyname])
1057 # -------- Check for required packages --------------
1059 AC_MSG_NOTICE([LibCFS required packages checks
1060 ==============================================================================])
1062 AC_MSG_CHECKING([whether to enable readline support])
1063 AC_ARG_ENABLE(readline,
1064 AC_HELP_STRING([--disable-readline],
1065 [disable readline support]),
1066 [], [enable_readline="yes"])
1067 AC_MSG_RESULT([$enable_readline])
1070 AS_IF([test "x$enable_readline" = xyes], [
1071 AC_CHECK_LIB([readline], [readline], [
1072 LIBREADLINE="-lreadline"
1073 AC_DEFINE(HAVE_LIBREADLINE, 1,
1074 [readline library is available])
1077 AC_SUBST(LIBREADLINE)
1079 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1080 AC_ARG_ENABLE([libpthread],
1081 AC_HELP_STRING([--disable-libpthread],
1082 [disable libpthread]),
1083 [], [enable_libpthread="yes"])
1084 AC_MSG_RESULT([$enable_libpthread])
1087 AS_IF([test "x$enable_libpthread" = xyes], [
1088 AC_CHECK_LIB([pthread], [pthread_create], [
1089 PTHREAD_LIBS="-lpthread"
1090 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1091 [use libpthread for libcfs library])
1094 AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1096 AC_SUBST(PTHREAD_LIBS)
1097 ]) # LIBCFS_CONFIGURE
1100 # LIBCFS_CONDITIONALS
1102 AC_DEFUN([LIBCFS_CONDITIONALS], [
1103 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
1104 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
1105 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
1106 ]) # LIBCFS_CONDITIONALS
1109 # LIBCFS_CONFIG_FILES
1111 # files that should be generated with AC_OUTPUT
1113 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1117 libcfs/autoconf/Makefile
1118 libcfs/include/Makefile
1119 libcfs/include/libcfs/Makefile
1120 libcfs/include/libcfs/linux/Makefile
1121 libcfs/include/libcfs/util/Makefile
1122 libcfs/libcfs/Makefile
1123 libcfs/libcfs/autoMakefile
1124 libcfs/libcfs/linux/Makefile
1125 libcfs/libcfs/util/Makefile
1127 ]) # LIBCFS_CONFIG_FILES