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 # LC_SHRINKER_WANT_SHRINK_PTR
90 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
92 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR], [
93 LB_CHECK_COMPILE([if 'shrinker' want self pointer in handler],
94 shrink_self_pointer, [
97 struct shrinker *tmp = NULL;
98 tmp->shrink(tmp, 0, 0);
100 AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
101 [shrinker want self pointer in handler])
103 ]) # LC_SHRINKER_WANT_SHRINK_PTR
106 # LIBCFS_SYSCTL_CTLNAME
108 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
110 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME], [
111 LB_CHECK_COMPILE([if 'ctl_table' has a 'ctl_name' field],
112 ctl_table_ctl_name, [
113 #include <linux/sysctl.h>
116 ct.ctl_name = sizeof(ct);
118 AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
119 [ctl_table has ctl_name field])
121 ]) # LIBCFS_SYSCTL_CTLNAME
124 # LIBCFS_MODULE_LOCKING
126 # 2.6.36 introduced locking to module params. RHEL6 lacks this support
128 AC_DEFUN([LIBCFS_MODULE_LOCKING],[
129 LB_CHECK_COMPILE([does the kernel support module param locking],
130 module_param_locking, [
131 #include <linux/moduleparam.h>
133 __kernel_param_lock(NULL);
134 __kernel_param_unlock(NULL);
136 AC_DEFINE(HAVE_MODULE_PARAM_LOCKING, 1,
137 [locking module param is supported])
139 ]) # LIBCFS_MODULE_LOCKING
144 # 2.6.38 kstrtoul is added
146 AC_DEFUN([LIBCFS_KSTRTOUL], [
147 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
149 #include <linux/kernel.h>
151 unsigned long result;
152 return kstrtoul("12345", 0, &result);
154 AC_DEFINE(HAVE_KSTRTOUL, 1,
155 [kernel has kstrtoul])
160 # LIBCFS_DUMP_TRACE_ADDRESS
162 # 2.6.39 adds a base pointer address argument to dump_trace
164 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
165 LB_CHECK_COMPILE([if 'dump_trace' want address],
166 dump_trace_address, [
169 #include <asm/stacktrace.h>
171 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
173 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
174 [dump_trace want address argument])
176 ]) # LIBCFS_DUMP_TRACE_ADDRESS
181 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
182 # pressure shrinker from Linux 3.0
184 AC_DEFUN([LC_SHRINK_CONTROL], [
185 LB_CHECK_COMPILE([if 'shrink_control' is present],
187 #include <linux/atomic.h>
188 #include <linux/mm.h>
190 struct shrink_control tmp = {0};
191 tmp.nr_to_scan = sizeof(tmp);
193 AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
194 [shrink_control is present])
196 ]) # LC_SHRINK_CONTROL
199 # LIBCFS_PROCESS_NAMESPACE
201 # 3.5 introduced process namespace
202 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
203 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
204 AC_DEFINE(HAVE_UIDGID_HEADER, 1,
205 [uidgid.h is present])])
206 ]) # LIBCFS_PROCESS_NAMESPACE
211 # 3.5 added helpers to read the new uid/gid types from VFS structures
212 # SLE11 SP3 has uidgid.h but not the helpers
214 AC_DEFUN([LIBCFS_I_UID_READ], [
215 LB_CHECK_COMPILE([if 'i_uid_read' is present],
217 #include <linux/fs.h>
221 AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
223 ]) # LIBCFS_I_UID_READ
228 AC_DEFUN([LIBCFS_HAVE_CRC32], [
229 LB_CHECK_CONFIG_IM([CRC32],
230 [have_crc32="yes"], [have_crc32="no"])
231 AS_IF([test "x$have_crc32" = xyes],
232 [AC_DEFINE(HAVE_CRC32, 1,
233 [kernel compiled with CRC32 functions])])
234 ]) # LIBCFS_HAVE_CRC32
237 # LIBCFS_ENABLE_CRC32_ACCEL
239 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
240 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
241 [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
242 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
243 AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
244 AC_MSG_WARN([No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32])])
245 ]) # LIBCFS_ENABLE_CRC32_ACCEL
248 # LIBCFS_ENABLE_CRC32C_ACCEL
250 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
251 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
252 [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
253 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
254 AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
255 AC_MSG_WARN([No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c])])
256 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
259 # Kernel version 3.11 introduced ktime_get_ts64
261 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
262 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
264 #include <linux/hrtimer.h>
265 #include <linux/ktime.h>
267 struct timespec64 *ts = NULL;
271 AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
272 ['ktime_get_ts64' is available])
274 ]) # LIBCFS_KTIME_GET_TS64
277 # Linux kernel 3.12 introduced struct kernel_param_ops
278 # This has been backported to all lustre supported
279 # clients except RHEL6. We have to handle the differences.
281 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
282 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
284 #include <linux/module.h>
286 struct kernel_param_ops ops;
290 AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
291 ['struct kernel_param_ops' is available])
293 ]) # LIBCFS_KERNEL_PARAM_OPS
296 # Kernel version 3.12 introduced ktime_add
298 AC_DEFUN([LIBCFS_KTIME_ADD],[
299 LB_CHECK_COMPILE([does function 'ktime_add' exist],
301 #include <linux/hrtimer.h>
302 #include <linux/ktime.h>
304 ktime_t start = ktime_set(0, 0);
308 total = ktime_add(start, end);
310 AC_DEFINE(HAVE_KTIME_ADD, 1,
311 [ktime_add is available])
313 ]) # LIBCFS_KTIME_ADD
316 # Kernel version 3.12 introduced ktime_after
318 AC_DEFUN([LIBCFS_KTIME_AFTER],[
319 LB_CHECK_COMPILE([does function 'ktime_after' exist],
321 #include <linux/hrtimer.h>
322 #include <linux/ktime.h>
324 ktime_t start = ktime_set(0, 0);
327 ktime_after(start, end);
329 AC_DEFINE(HAVE_KTIME_AFTER, 1,
330 [ktime_after is available])
332 ]) # LIBCFS_KTIME_AFTER
335 # Kernel version 3.12 introduced ktime_before
336 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
338 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
339 LB_CHECK_COMPILE([does function 'ktime_before' exist],
341 #include <linux/hrtimer.h>
342 #include <linux/ktime.h>
344 ktime_t start = ktime_set(0, 0);
347 ktime_before(start, end);
349 AC_DEFINE(HAVE_KTIME_BEFORE, 1,
350 [ktime_before is available])
352 ]) # LIBCFS_KTIME_BEFORE
355 # Kernel version 3.12 introduced ktime_compare
357 AC_DEFUN([LIBCFS_KTIME_COMPARE],[
358 LB_CHECK_COMPILE([does function 'ktime_compare' exist],
360 #include <linux/hrtimer.h>
361 #include <linux/ktime.h>
363 ktime_t start = ktime_set(0, 0);
366 ktime_compare(start, end);
368 AC_DEFINE(HAVE_KTIME_COMPARE, 1,
369 [ktime_compare is available])
371 ]) # LIBCFS_KTIME_COMPARE
374 # FC19 3.12 kernel struct shrinker change
376 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
377 LB_CHECK_COMPILE([shrinker has 'count_objects'],
378 shrinker_count_objects, [
379 #include <linux/mmzone.h>
380 #include <linux/shrinker.h>
382 struct shrinker shrinker;
384 shrinker.count_objects = NULL;
386 AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
387 [shrinker has count_objects member])
389 ]) # LIBCFS_SHRINKER_COUNT
392 # Kernel version 3.17 changed hlist_add_after to
395 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
396 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
398 #include <linux/list.h>
400 hlist_add_after(NULL, NULL);
402 AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
403 [hlist_add_after is available])
405 ]) # LIBCFS_HLIST_ADD_AFTER
408 # Kernel version 3.17 introduced struct timespec64
410 AC_DEFUN([LIBCFS_TIMESPEC64],[
411 LB_CHECK_COMPILE([does 'struct timespec64' exist],
413 #include <linux/time.h>
415 struct timespec64 ts;
420 AC_DEFINE(HAVE_TIMESPEC64, 1,
421 ['struct timespec64' is available])
423 ]) # LIBCFS_TIMESPEC64
426 # Kernel version 3.17 introduced ktime_get_real_ts64
428 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
429 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
430 ktime_get_real_ts64, [
431 #include <linux/ktime.h>
433 struct timespec64 *ts = NULL;
435 ktime_get_real_ts64(ts);
437 AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
438 ['ktime_get_real_ts64' is available])
440 ]) # LIBCFS_KTIME_GET_REAL_TS64
443 # Kernel version 3.17 introduced ktime_get_real_seconds
445 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
446 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
447 ktime_get_real_seconds, [
448 #include <linux/hrtimer.h>
449 #include <linux/ktime.h>
453 now = ktime_get_real_seconds();
455 AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
456 ['ktime_get_real_seconds' is available])
458 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
461 # Kernel version 3.17 created ktime_get_ns wrapper
463 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
464 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
466 #include <linux/hrtimer.h>
467 #include <linux/ktime.h>
471 nanoseconds = ktime_get_ns();
473 AC_DEFINE(NEED_KTIME_GET_NS, 1,
474 ['ktime_get_ns' is not available])
476 ]) # LIBCFS_KTIME_GET_NS
479 # Kernel version 3.17 created ktime_get_real_ns wrapper
481 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
482 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
484 #include <linux/hrtimer.h>
485 #include <linux/ktime.h>
489 nanoseconds = ktime_get_real_ns();
491 AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
492 ['ktime_get_real_ns' is not available])
494 ]) # LIBCFS_KTIME_GET_REAL_NS
497 # Kernel version 3.17 introduced ktime_to_timespec64
499 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
500 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
501 ktime_to_timespec64, [
502 #include <linux/hrtimer.h>
503 #include <linux/ktime.h>
505 ktime_t now = ktime_set(0, 0);
506 struct timespec64 ts;
508 ts = ktime_to_timespec64(now);
510 AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
511 ['ktime_to_timespec64' is available])
513 ]) # LIBCFS_KTIME_TO_TIMESPEC64
516 # Kernel version 3.17 introduced timespec64_sub
518 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
519 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
521 #include <linux/time.h>
523 struct timespec64 later = { }, earlier = { }, diff;
525 diff = timespec64_sub(later, earlier);
527 AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
528 ['timespec64_sub' is available])
530 ]) # LIBCFS_TIMESPEC64_SUB
533 # Kernel version 3.17 introduced timespec64_to_ktime
535 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
536 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
537 timespec64_to_ktime, [
538 #include <linux/ktime.h>
540 struct timespec64 ts;
543 now = timespec64_to_ktime(ts);
545 AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
546 ['timespec64_to_ktime' is available])
548 ]) # LIBCFS_TIMESPEC64_TO_KTIME
551 # Kernel version 3.19 introduced ktime_get_seconds
553 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
554 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
556 #include <linux/ktime.h>
560 now = ktime_get_seconds();
562 AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
563 ['ktime_get_seconds' is available])
565 ]) # LIBCFS_KTIME_GET_SECONDS
568 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
569 # introduced the helper function ktime_ms_delta.
571 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
572 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
574 #include <linux/ktime.h>
576 ktime_t start = ktime_set(0, 0);
579 ktime_ms_delta(start, end);
581 AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
582 ['ktime_ms_delta' is available])
584 ]) # LIBCFS_KTIME_MS_DELTA
587 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
588 # create per module locks which added kernel_param_[un]lock(). Older
589 # kernels you have to use __kernel_param_[un]lock(). In that case its
590 # a global lock for all modules but that is okay since its a rare event.
592 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
593 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
595 #include <linux/moduleparam.h>
597 kernel_param_lock(NULL);
598 kernel_param_unlock(NULL);
600 AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
601 ['kernel_param_[un]lock' is available])
603 ]) # LIBCFS_KERNEL_PARAM_LOCK
606 # Kernel version 4.2 changed topology_thread_cpumask
607 # to topology_sibling_cpumask
609 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
610 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
611 topology_sibling_cpumask, [
612 #include <linux/topology.h>
614 const struct cpumask *mask;
616 mask = topology_sibling_cpumask(0);
618 AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
619 [topology_sibling_cpumask is available])
621 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
624 # Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
625 # header file i387.h was renamed to fpu/api.h
627 AC_DEFUN([LIBCFS_FPU_API], [
628 LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
629 AC_DEFINE(HAVE_FPU_API_HEADER, 1,
630 [fpu/api.h is present])])
634 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
635 # introduced kstrtobool and kstrtobool_from_user.
637 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
638 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
639 kstrtobool_from_user, [
640 #include <linux/kernel.h>
643 return kstrtobool_from_user(NULL, 0, &result);
645 AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
646 [kernel has kstrtobool_from_user])
648 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
651 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
652 # added crypto hash helpers
654 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
655 LB_CHECK_COMPILE([does crypto hash helper functions exist],
656 crypto_hash_helpers, [
657 #include <crypto/hash.h>
659 crypto_ahash_alg_name(NULL);
660 crypto_ahash_driver_name(NULL);
662 AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
663 [crypto hash helper functions are available])
665 ]) # LIBCFS_CRYPTO_HASH_HELPERS
668 # Kernerl version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
669 # made kset_find_obj() exportable to modules
671 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
672 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
673 [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
674 [kset_find_obj is exported by the kernel])])
675 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
678 # Kernel version 4.6+ commit ef703f49a6c5b909a85149bb6625c4ed0d697186
679 # fixed the brokenness of hash_64(). The fix removed GOLDEN_RATIO_PRIME_64
680 # since it was a poor prime value.
682 AC_DEFUN([LIBCFS_BROKEN_HASH_64], [
683 LB_CHECK_COMPILE([kernel has fixed hash_64()],
685 #include <linux/hash.h>
687 int tmp = GOLDEN_RATIO_PRIME_64;
689 AC_DEFINE(HAVE_BROKEN_HASH_64, 1, [kernel hash_64() is broken])
691 ]) # LIBCFS_BROKEN_HASH_64
694 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
696 # linux 4.6 kernel changed stacktrace_ops address to return an int
698 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
699 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
700 stacktrace_ops_address_return_int, [
701 #include <asm/stacktrace.h>
705 rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
707 AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
708 ['struct stacktrace_ops' address function returns an int])
710 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
713 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
714 # arguments to get_user_pages
716 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
717 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
718 get_user_pages_6arg, [
719 #include <linux/mm.h>
723 rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
725 AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
726 [get_user_pages takes 6 arguments])
728 ]) # LIBCFS_GET_USER_PAGES_6ARG
733 # 4.6 kernel created stringhash.h which moved stuff out of dcache.h
734 # commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
736 AC_DEFUN([LIBCFS_STRINGHASH], [
737 LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
738 AC_DEFINE(HAVE_STRINGHASH, 1,
739 [stringhash.h is present])])
740 ]) # LIBCFS_STRINGHASH
743 # LIBCFS_RHASHTABLE_INSERT_FAST
745 # 4.7+ kernel commit 5ca8cc5bf11faed257c762018aea9106d529232f
746 # changed __rhashtable_insert_fast to support the new function
747 # rhashtable_lookup_get_insert_key().
749 AC_DEFUN([LIBCFS_RHASHTABLE_INSERT_FAST], [
750 tmp_flags="$EXTRA_KCFLAGS"
751 EXTRA_KCFLAGS="-Werror"
752 LB_CHECK_COMPILE([if internal '__rhashtable_insert_fast()' returns int],
753 rhashtable_insert_fast, [
754 #include <linux/rhashtable.h>
756 const struct rhashtable_params params = { 0 };
759 rc = __rhashtable_insert_fast(NULL, NULL, NULL, params);
761 AC_DEFINE(HAVE_HASHTABLE_INSERT_FAST_RETURN_INT, 1,
762 ['__rhashtable_insert_fast()' returns int])
764 EXTRA_KCFLAGS="$tmp_flags"
765 ]) # LIBCFS_RHASHTABLE_INSERT_FAST
768 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
769 # introduced rhashtable_lookup
771 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP], [
772 LB_CHECK_COMPILE([if 'rhashtable_lookup' exist],
774 #include <linux/rhashtable.h>
776 const struct rhashtable_params params = { 0 };
779 ret = rhashtable_lookup(NULL, NULL, params);
781 AC_DEFINE(HAVE_RHASHTABLE_LOOKUP, 1,
782 [rhashtable_lookup() is available])
784 ]) # LIBCFS_RHASHTABLE_LOOKUP
788 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
789 # created the rhlist interface to allow inserting duplicate objects
790 # into the same table.
792 AC_DEFUN([LIBCFS_RHLTABLE], [
793 LB_CHECK_COMPILE([does 'struct rhltable' exist],
795 #include <linux/rhashtable.h>
797 struct rhltable *hlt;
799 rhltable_destroy(hlt);
801 AC_DEFINE(HAVE_RHLTABLE, 1,
802 [struct rhltable exist])
807 # LIBCFS_STACKTRACE_OPS
809 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
810 # removed both struct stacktrace_ops and dump_trace() function
812 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
813 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
817 #include <asm/stacktrace.h>
819 struct stacktrace_ops ops;
822 AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
823 [struct stacktrace_ops exists])
825 ]) # LIBCFS_STACKTRACE_OPS
828 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
829 # mm: replace get_user_pages() write/force parameters with gup_flags
831 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
832 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
833 get_user_pages_gup_flags, [
834 #include <linux/mm.h>
837 rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
839 AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
840 [get_user_pages takes gup_flags in arguments])
842 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
845 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
846 # libcfs: Convert to hotplug state machine
848 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
849 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
850 cpu_hotplug_state_machine, [
851 #include <linux/cpuhotplug.h>
853 cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
855 AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
856 [hotplug state machine is supported])
858 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
861 # LIBCFS_SCHED_HEADERS
863 # 4.11 has broken up sched.h into more headers.
865 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
866 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
867 AC_DEFINE(HAVE_SCHED_HEADERS, 1,
868 [linux/sched header directory exist])])
869 ]) # LIBCFS_SCHED_HEADERS
872 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
873 # introduced rhashtable_lookup_get_insert_fast
875 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
876 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
877 rhashtable_lookup_get_insert_fast, [
878 #include <linux/rhashtable.h>
880 const struct rhashtable_params params = { 0 };
883 ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
885 AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
886 [rhashtable_lookup_get_insert_fast() is available])
888 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
891 # Kernel version 4.12-rc3 f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
892 # renamed uuid_be to uuid_t
894 AC_DEFUN([LIBCFS_UUID_T], [
895 LB_CHECK_COMPILE([if 'uuid_t' exist],
897 #include <linux/uuid.h>
901 memset(uuid.b, 0, 16);
903 AC_DEFINE(HAVE_UUID_T, 1, ['uuid_t' exist])
908 # Kernel version 4.12-rc3 commit fd851a3cdc196bfc1d229b5f22369069af532bf8
909 # introduce processor.h
911 AC_DEFUN([LIBCFS_HAVE_PROCESSOR_HEADER], [
912 LB_CHECK_LINUX_HEADER([linux/processor.h], [
913 AC_DEFINE(HAVE_PROCESSOR_H, 1,
914 [processor.h is present])])
915 ]) # LIBCFS_HAVE_PROCESSOR_HEADER
919 # LIBCFS_WAIT_QUEUE_ENTRY
921 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
922 # Rename wait_queue_t => wait_queue_entry_t
924 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
925 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
927 #include <linux/wait.h>
929 wait_queue_entry_t e;
933 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
934 ['wait_queue_entry_t' is available])
936 ]) # LIBCFS_WAIT_QUEUE_ENTRY
939 # LIBCFS_NEW_KERNEL_WRITE
941 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
942 # changed kernel_write prototype to make is plug compatible
943 # with the unexported vfs_write()
945 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
946 tmp_flags="$EXTRA_KCFLAGS"
947 EXTRA_KCFLAGS="-Werror"
948 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
949 kernel_write_match, [
950 #include <linux/fs.h>
952 const void *buf = NULL;
954 return kernel_write(NULL, buf, 0, &pos);
956 AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
957 ['kernel_write' aligns with read/write helpers])
959 EXTRA_KCFLAGS="$tmp_flags"
960 ]) # LIBCFS_NEW_KERNEL_WRITE
963 # LIBCFS_DEFINE_TIMER
965 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
966 # remove expires and data arguments from DEFINE_TIMER. Also the callback
967 # when from using unsigned long argument to using struct timer_list pointer.
969 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
970 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
972 #include <linux/timer.h>
974 static DEFINE_TIMER(my_timer, NULL);
976 AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
977 [DEFINE_TIMER uses only 2 arguements])
979 ]) # LIBCFS_DEFINE_TIMER
984 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
985 # setup_timer() was replaced by timer_setup(), where the callback
986 # argument is the structure already holding the struct timer_list.
988 AC_DEFUN([LIBCFS_TIMER_SETUP], [
989 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
991 #include <linux/timer.h>
993 timer_setup(NULL, NULL, 0);
995 AC_DEFINE(HAVE_TIMER_SETUP, 1,
996 [timer_setup has replaced setup_timer])
998 ]) # LIBCFS_TIMER_SETUP
1003 # LibCFS linux kernel checks
1005 AC_DEFUN([LIBCFS_PROG_LINUX], [
1006 AC_MSG_NOTICE([LibCFS kernel checks
1007 ==============================================================================])
1008 LIBCFS_CONFIG_PANIC_DUMPLOG
1011 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
1012 LC_SHRINKER_WANT_SHRINK_PTR
1014 LIBCFS_SYSCTL_CTLNAME
1016 LIBCFS_MODULE_LOCKING
1020 LIBCFS_DUMP_TRACE_ADDRESS
1024 LIBCFS_STACKTRACE_WARNING
1026 LIBCFS_PROCESS_NAMESPACE
1030 LIBCFS_ENABLE_CRC32_ACCEL
1032 LIBCFS_ENABLE_CRC32C_ACCEL
1034 LIBCFS_KTIME_GET_TS64
1036 LIBCFS_KERNEL_PARAM_OPS
1040 LIBCFS_KTIME_COMPARE
1041 LIBCFS_SHRINKER_COUNT
1043 LIBCFS_HLIST_ADD_AFTER
1046 LIBCFS_KTIME_GET_REAL_TS64
1047 LIBCFS_KTIME_GET_REAL_SECONDS
1048 LIBCFS_KTIME_GET_REAL_NS
1049 LIBCFS_KTIME_TO_TIMESPEC64
1050 LIBCFS_TIMESPEC64_SUB
1051 LIBCFS_TIMESPEC64_TO_KTIME
1053 LIBCFS_KTIME_GET_SECONDS
1055 LIBCFS_KTIME_MS_DELTA
1057 LIBCFS_KERNEL_PARAM_LOCK
1059 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
1062 LIBCFS_KSTRTOBOOL_FROM_USER
1064 LIBCFS_CRYPTO_HASH_HELPERS
1065 LIBCFS_EXPORT_KSET_FIND_OBJ
1067 LIBCFS_BROKEN_HASH_64
1068 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
1069 LIBCFS_GET_USER_PAGES_6ARG
1072 LIBCFS_RHASHTABLE_INSERT_FAST
1074 LIBCFS_RHASHTABLE_LOOKUP
1076 LIBCFS_STACKTRACE_OPS
1078 LIBCFS_GET_USER_PAGES_GUP_FLAGS
1080 LIBCFS_HOTPLUG_STATE_MACHINE
1082 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
1083 LIBCFS_SCHED_HEADERS
1085 LIBCFS_HAVE_PROCESSOR_HEADER
1088 LIBCFS_WAIT_QUEUE_ENTRY
1091 LIBCFS_NEW_KERNEL_WRITE
1094 ]) # LIBCFS_PROG_LINUX
1097 # LIBCFS_PATH_DEFAULTS
1099 # default paths for installed files
1101 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
1102 ]) # LIBCFS_PATH_DEFAULTS
1107 # other configure checks
1109 AC_DEFUN([LIBCFS_CONFIGURE], [
1110 AC_MSG_NOTICE([LibCFS core checks
1111 ==============================================================================])
1113 # libcfs/libcfs/util/nidstrings.c
1114 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
1115 AC_CHECK_FUNCS([gethostbyname])
1117 # -------- Check for required packages --------------
1119 AC_MSG_NOTICE([LibCFS required packages checks
1120 ==============================================================================])
1122 AC_MSG_CHECKING([whether to enable readline support])
1123 AC_ARG_ENABLE(readline,
1124 AC_HELP_STRING([--disable-readline],
1125 [disable readline support]),
1126 [], [enable_readline="yes"])
1127 AC_MSG_RESULT([$enable_readline])
1130 AS_IF([test "x$enable_readline" = xyes], [
1131 AC_CHECK_LIB([readline], [readline], [
1132 LIBREADLINE="-lreadline"
1133 AC_DEFINE(HAVE_LIBREADLINE, 1,
1134 [readline library is available])
1137 AC_SUBST(LIBREADLINE)
1139 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1140 AC_ARG_ENABLE([libpthread],
1141 AC_HELP_STRING([--disable-libpthread],
1142 [disable libpthread]),
1143 [], [enable_libpthread="yes"])
1144 AC_MSG_RESULT([$enable_libpthread])
1147 AS_IF([test "x$enable_libpthread" = xyes], [
1148 AC_CHECK_LIB([pthread], [pthread_create], [
1149 PTHREAD_LIBS="-lpthread"
1150 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1151 [use libpthread for libcfs library])
1154 AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1156 AC_SUBST(PTHREAD_LIBS)
1157 ]) # LIBCFS_CONFIGURE
1160 # LIBCFS_CONDITIONALS
1162 AC_DEFUN([LIBCFS_CONDITIONALS], [
1163 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
1164 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
1165 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
1166 ]) # LIBCFS_CONDITIONALS
1169 # LIBCFS_CONFIG_FILES
1171 # files that should be generated with AC_OUTPUT
1173 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1177 libcfs/autoconf/Makefile
1178 libcfs/include/Makefile
1179 libcfs/include/libcfs/Makefile
1180 libcfs/include/libcfs/linux/Makefile
1181 libcfs/include/libcfs/util/Makefile
1182 libcfs/libcfs/Makefile
1183 libcfs/libcfs/autoMakefile
1184 libcfs/libcfs/linux/Makefile
1185 libcfs/libcfs/util/Makefile
1187 ]) # LIBCFS_CONFIG_FILES