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_STACKTRACE_OPS
745 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
746 # removed both struct stacktrace_ops and dump_trace() function
748 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
749 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
753 #include <asm/stacktrace.h>
755 struct stacktrace_ops ops;
758 AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
759 [struct stacktrace_ops exists])
761 ]) # LIBCFS_STACKTRACE_OPS
764 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
765 # mm: replace get_user_pages() write/force parameters with gup_flags
767 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
768 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
769 get_user_pages_gup_flags, [
770 #include <linux/mm.h>
773 rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
775 AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
776 [get_user_pages takes gup_flags in arguments])
778 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
781 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
782 # libcfs: Convert to hotplug state machine
784 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
785 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
786 cpu_hotplug_state_machine, [
787 #include <linux/cpuhotplug.h>
789 cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
791 AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
792 [hotplug state machine is supported])
794 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
797 # LIBCFS_SCHED_HEADERS
799 # 4.11 has broken up sched.h into more headers.
801 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
802 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
803 AC_DEFINE(HAVE_SCHED_HEADERS, 1,
804 [linux/sched header directory exist])])
805 ]) # LIBCFS_SCHED_HEADERS
808 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
809 # introduced rhashtable_lookup_get_insert_fast
811 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
812 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
813 rhashtable_lookup_get_insert_fast, [
814 #include <linux/rhashtable.h>
816 const struct rhashtable_params params = { 0 };
819 ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
821 AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
822 [rhashtable_lookup_get_insert_fast() is available])
824 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
827 # LIBCFS_WAIT_QUEUE_ENTRY
829 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
830 # Rename wait_queue_t => wait_queue_entry_t
832 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
833 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
835 #include <linux/wait.h>
837 wait_queue_entry_t e;
841 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
842 ['wait_queue_entry_t' is available])
844 ]) # LIBCFS_WAIT_QUEUE_ENTRY
847 # LIBCFS_NEW_KERNEL_WRITE
849 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
850 # changed kernel_write prototype to make is plug compatible
851 # with the unexported vfs_write()
853 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
854 tmp_flags="$EXTRA_KCFLAGS"
855 EXTRA_KCFLAGS="-Werror"
856 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
857 kernel_write_match, [
858 #include <linux/fs.h>
860 const void *buf = NULL;
862 return kernel_write(NULL, buf, 0, &pos);
864 AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
865 ['kernel_write' aligns with read/write helpers])
867 EXTRA_KCFLAGS="$tmp_flags"
868 ]) # LIBCFS_NEW_KERNEL_WRITE
871 # LIBCFS_DEFINE_TIMER
873 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
874 # remove expires and data arguments from DEFINE_TIMER. Also the callback
875 # when from using unsigned long argument to using struct timer_list pointer.
877 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
878 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
880 #include <linux/timer.h>
882 static DEFINE_TIMER(my_timer, NULL);
884 AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
885 [DEFINE_TIMER uses only 2 arguements])
887 ]) # LIBCFS_DEFINE_TIMER
892 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
893 # setup_timer() was replaced by timer_setup(), where the callback
894 # argument is the structure already holding the struct timer_list.
896 AC_DEFUN([LIBCFS_TIMER_SETUP], [
897 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
899 #include <linux/timer.h>
901 timer_setup(NULL, NULL, 0);
903 AC_DEFINE(HAVE_TIMER_SETUP, 1,
904 [timer_setup has replaced setup_timer])
906 ]) # LIBCFS_TIMER_SETUP
911 # LibCFS linux kernel checks
913 AC_DEFUN([LIBCFS_PROG_LINUX], [
914 AC_MSG_NOTICE([LibCFS kernel checks
915 ==============================================================================])
916 LIBCFS_CONFIG_PANIC_DUMPLOG
919 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
920 LC_SHRINKER_WANT_SHRINK_PTR
922 LIBCFS_SYSCTL_CTLNAME
924 LIBCFS_MODULE_LOCKING
928 LIBCFS_DUMP_TRACE_ADDRESS
932 LIBCFS_STACKTRACE_WARNING
934 LIBCFS_PROCESS_NAMESPACE
938 LIBCFS_ENABLE_CRC32_ACCEL
940 LIBCFS_ENABLE_CRC32C_ACCEL
942 LIBCFS_KTIME_GET_TS64
944 LIBCFS_KERNEL_PARAM_OPS
949 LIBCFS_SHRINKER_COUNT
951 LIBCFS_HLIST_ADD_AFTER
954 LIBCFS_KTIME_GET_REAL_TS64
955 LIBCFS_KTIME_GET_REAL_SECONDS
956 LIBCFS_KTIME_GET_REAL_NS
957 LIBCFS_KTIME_TO_TIMESPEC64
958 LIBCFS_TIMESPEC64_SUB
959 LIBCFS_TIMESPEC64_TO_KTIME
961 LIBCFS_KTIME_GET_SECONDS
963 LIBCFS_KTIME_MS_DELTA
965 LIBCFS_KERNEL_PARAM_LOCK
967 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
970 LIBCFS_KSTRTOBOOL_FROM_USER
972 LIBCFS_CRYPTO_HASH_HELPERS
973 LIBCFS_EXPORT_KSET_FIND_OBJ
975 LIBCFS_BROKEN_HASH_64
976 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
977 LIBCFS_GET_USER_PAGES_6ARG
980 LIBCFS_STACKTRACE_OPS
982 LIBCFS_GET_USER_PAGES_GUP_FLAGS
984 LIBCFS_HOTPLUG_STATE_MACHINE
986 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
989 LIBCFS_WAIT_QUEUE_ENTRY
992 LIBCFS_NEW_KERNEL_WRITE
995 ]) # LIBCFS_PROG_LINUX
998 # LIBCFS_PATH_DEFAULTS
1000 # default paths for installed files
1002 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
1003 ]) # LIBCFS_PATH_DEFAULTS
1008 # other configure checks
1010 AC_DEFUN([LIBCFS_CONFIGURE], [
1011 AC_MSG_NOTICE([LibCFS core checks
1012 ==============================================================================])
1014 # libcfs/libcfs/util/nidstrings.c
1015 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
1016 AC_CHECK_FUNCS([gethostbyname])
1018 # -------- Check for required packages --------------
1020 AC_MSG_NOTICE([LibCFS required packages checks
1021 ==============================================================================])
1023 AC_MSG_CHECKING([whether to enable readline support])
1024 AC_ARG_ENABLE(readline,
1025 AC_HELP_STRING([--disable-readline],
1026 [disable readline support]),
1027 [], [enable_readline="yes"])
1028 AC_MSG_RESULT([$enable_readline])
1031 AS_IF([test "x$enable_readline" = xyes], [
1032 AC_CHECK_LIB([readline], [readline], [
1033 LIBREADLINE="-lreadline"
1034 AC_DEFINE(HAVE_LIBREADLINE, 1,
1035 [readline library is available])
1038 AC_SUBST(LIBREADLINE)
1040 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1041 AC_ARG_ENABLE([libpthread],
1042 AC_HELP_STRING([--disable-libpthread],
1043 [disable libpthread]),
1044 [], [enable_libpthread="yes"])
1045 AC_MSG_RESULT([$enable_libpthread])
1048 AS_IF([test "x$enable_libpthread" = xyes], [
1049 AC_CHECK_LIB([pthread], [pthread_create], [
1050 PTHREAD_LIBS="-lpthread"
1051 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1052 [use libpthread for libcfs library])
1055 AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1057 AC_SUBST(PTHREAD_LIBS)
1058 ]) # LIBCFS_CONFIGURE
1061 # LIBCFS_CONDITIONALS
1063 AC_DEFUN([LIBCFS_CONDITIONALS], [
1064 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
1065 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
1066 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
1067 ]) # LIBCFS_CONDITIONALS
1070 # LIBCFS_CONFIG_FILES
1072 # files that should be generated with AC_OUTPUT
1074 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1078 libcfs/autoconf/Makefile
1079 libcfs/include/Makefile
1080 libcfs/include/libcfs/Makefile
1081 libcfs/include/libcfs/linux/Makefile
1082 libcfs/include/libcfs/util/Makefile
1083 libcfs/libcfs/Makefile
1084 libcfs/libcfs/autoMakefile
1085 libcfs/libcfs/linux/Makefile
1086 libcfs/libcfs/util/Makefile
1088 ]) # LIBCFS_CONFIG_FILES