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
242 # LIBCFS_SOCK_ALLOC_FILE
244 # FC18 3.7.2-201 unexport sock_map_fd() change to
245 # use sock_alloc_file().
246 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
248 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE], [
249 LB_CHECK_EXPORT([sock_alloc_file], [net/socket.c], [
250 LB_CHECK_COMPILE([if 'sock_alloc_file' takes 3 arguments],
251 sock_alloc_file_3args, [
252 #include <linux/net.h>
254 sock_alloc_file(NULL, 0, NULL);
256 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
257 [sock_alloc_file takes 3 arguments])
259 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
260 [sock_alloc_file is exported])
263 ]) # LIBCFS_SOCK_ALLOC_FILE
268 AC_DEFUN([LIBCFS_HAVE_CRC32], [
269 LB_CHECK_CONFIG_IM([CRC32],
270 [have_crc32="yes"], [have_crc32="no"])
271 AS_IF([test "x$have_crc32" = xyes],
272 [AC_DEFINE(HAVE_CRC32, 1,
273 [kernel compiled with CRC32 functions])])
274 ]) # LIBCFS_HAVE_CRC32
277 # LIBCFS_ENABLE_CRC32_ACCEL
279 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
280 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
281 [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
282 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
283 AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
284 AC_MSG_WARN([No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32])])
285 ]) # LIBCFS_ENABLE_CRC32_ACCEL
288 # LIBCFS_ENABLE_CRC32C_ACCEL
290 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
291 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
292 [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
293 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
294 AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
295 AC_MSG_WARN([No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c])])
296 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
299 # Kernel version 3.11 introduced ktime_get_ts64
301 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
302 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
304 #include <linux/hrtimer.h>
305 #include <linux/ktime.h>
307 struct timespec64 *ts = NULL;
311 AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
312 ['ktime_get_ts64' is available])
314 ]) # LIBCFS_KTIME_GET_TS64
317 # Linux kernel 3.12 introduced struct kernel_param_ops
318 # This has been backported to all lustre supported
319 # clients except RHEL6. We have to handle the differences.
321 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
322 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
324 #include <linux/module.h>
326 struct kernel_param_ops ops;
330 AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
331 ['struct kernel_param_ops' is available])
333 ]) # LIBCFS_KERNEL_PARAM_OPS
336 # Kernel version 3.12 introduced ktime_add
338 AC_DEFUN([LIBCFS_KTIME_ADD],[
339 LB_CHECK_COMPILE([does function 'ktime_add' exist],
341 #include <linux/hrtimer.h>
342 #include <linux/ktime.h>
344 ktime_t start = ktime_set(0, 0);
348 total = ktime_add(start, end);
350 AC_DEFINE(HAVE_KTIME_ADD, 1,
351 [ktime_add is available])
353 ]) # LIBCFS_KTIME_ADD
356 # Kernel version 3.12 introduced ktime_after
358 AC_DEFUN([LIBCFS_KTIME_AFTER],[
359 LB_CHECK_COMPILE([does function 'ktime_after' exist],
361 #include <linux/hrtimer.h>
362 #include <linux/ktime.h>
364 ktime_t start = ktime_set(0, 0);
367 ktime_after(start, end);
369 AC_DEFINE(HAVE_KTIME_AFTER, 1,
370 [ktime_after is available])
372 ]) # LIBCFS_KTIME_AFTER
375 # Kernel version 3.12 introduced ktime_before
376 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
378 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
379 LB_CHECK_COMPILE([does function 'ktime_before' exist],
381 #include <linux/hrtimer.h>
382 #include <linux/ktime.h>
384 ktime_t start = ktime_set(0, 0);
387 ktime_before(start, end);
389 AC_DEFINE(HAVE_KTIME_BEFORE, 1,
390 [ktime_before is available])
392 ]) # LIBCFS_KTIME_BEFORE
395 # Kernel version 3.12 introduced ktime_compare
397 AC_DEFUN([LIBCFS_KTIME_COMPARE],[
398 LB_CHECK_COMPILE([does function 'ktime_compare' exist],
400 #include <linux/hrtimer.h>
401 #include <linux/ktime.h>
403 ktime_t start = ktime_set(0, 0);
406 ktime_compare(start, end);
408 AC_DEFINE(HAVE_KTIME_COMPARE, 1,
409 [ktime_compare is available])
411 ]) # LIBCFS_KTIME_COMPARE
414 # FC19 3.12 kernel struct shrinker change
416 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
417 LB_CHECK_COMPILE([shrinker has 'count_objects'],
418 shrinker_count_objects, [
419 #include <linux/mmzone.h>
420 #include <linux/shrinker.h>
422 struct shrinker shrinker;
424 shrinker.count_objects = NULL;
426 AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
427 [shrinker has count_objects member])
429 ]) # LIBCFS_SHRINKER_COUNT
432 # Kernel version 3.17 changed hlist_add_after to
435 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
436 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
438 #include <linux/list.h>
440 hlist_add_after(NULL, NULL);
442 AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
443 [hlist_add_after is available])
445 ]) # LIBCFS_HLIST_ADD_AFTER
448 # Kernel version 3.17 introduced struct timespec64
450 AC_DEFUN([LIBCFS_TIMESPEC64],[
451 LB_CHECK_COMPILE([does 'struct timespec64' exist],
453 #include <linux/time.h>
455 struct timespec64 ts;
460 AC_DEFINE(HAVE_TIMESPEC64, 1,
461 ['struct timespec64' is available])
463 ]) # LIBCFS_TIMESPEC64
466 # Kernel version 3.17 introduced ktime_get_real_ts64
468 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
469 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
470 ktime_get_real_ts64, [
471 #include <linux/ktime.h>
473 struct timespec64 *ts = NULL;
475 ktime_get_real_ts64(ts);
477 AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
478 ['ktime_get_real_ts64' is available])
480 ]) # LIBCFS_KTIME_GET_REAL_TS64
483 # Kernel version 3.17 introduced ktime_get_real_seconds
485 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
486 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
487 ktime_get_real_seconds, [
488 #include <linux/hrtimer.h>
489 #include <linux/ktime.h>
493 now = ktime_get_real_seconds();
495 AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
496 ['ktime_get_real_seconds' is available])
498 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
501 # Kernel version 3.17 created ktime_get_ns wrapper
503 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
504 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
506 #include <linux/hrtimer.h>
507 #include <linux/ktime.h>
511 nanoseconds = ktime_get_ns();
513 AC_DEFINE(NEED_KTIME_GET_NS, 1,
514 ['ktime_get_ns' is not available])
516 ]) # LIBCFS_KTIME_GET_NS
519 # Kernel version 3.17 created ktime_get_real_ns wrapper
521 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
522 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
524 #include <linux/hrtimer.h>
525 #include <linux/ktime.h>
529 nanoseconds = ktime_get_real_ns();
531 AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
532 ['ktime_get_real_ns' is not available])
534 ]) # LIBCFS_KTIME_GET_REAL_NS
537 # Kernel version 3.17 introduced ktime_to_timespec64
539 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
540 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
541 ktime_to_timespec64, [
542 #include <linux/hrtimer.h>
543 #include <linux/ktime.h>
545 struct timespec64 ts;
548 ts = ktime_to_timespec64(now);
550 AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
551 ['ktime_to_timespec64' is available])
553 ]) # LIBCFS_KTIME_TO_TIMESPEC64
556 # Kernel version 3.17 introduced timespec64_sub
558 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
559 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
561 #include <linux/time.h>
563 struct timespec64 later = { }, earlier = { }, diff;
565 diff = timespec64_sub(later, earlier);
567 AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
568 ['timespec64_sub' is available])
570 ]) # LIBCFS_TIMESPEC64_SUB
573 # Kernel version 3.17 introduced timespec64_to_ktime
575 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
576 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
577 timespec64_to_ktime, [
578 #include <linux/ktime.h>
580 struct timespec64 ts;
583 now = timespec64_to_ktime(ts);
585 AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
586 ['timespec64_to_ktime' is available])
588 ]) # LIBCFS_TIMESPEC64_TO_KTIME
591 # Kernel version 3.19 introduced ktime_get_seconds
593 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
594 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
596 #include <linux/ktime.h>
600 now = ktime_get_seconds();
602 AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
603 ['ktime_get_seconds' is available])
605 ]) # LIBCFS_KTIME_GET_SECONDS
608 # Kernel version 3.19 commit 5aaba36318e5995e8c95d077a46d9a4d00fcc1cd
609 # This patch creates a new helper function cpumap_print_to_pagebuf in
610 # cpumask.h using newly added bitmap_print_to_pagebuf and consolidates
611 # most of those sysfs functions using the new helper function.
613 AC_DEFUN([LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF],[
614 LB_CHECK_COMPILE([does function 'cpumap_print_to_pagebuf' exist],
615 cpumap_print_to_pagebuf, [
616 #include <linux/topology.h>
620 const struct cpumask *mask = NULL;
621 n = cpumap_print_to_pagebuf(true, buf, mask);
623 AC_DEFINE(HAVE_CPUMASK_PRINT_TO_PAGEBUF, 1,
624 [cpumap_print_to_pagebuf is available])
626 ]) # LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
629 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
630 # introduced the helper function ktime_ms_delta.
632 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
633 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
635 #include <linux/ktime.h>
637 ktime_t start = ktime_set(0, 0);
640 ktime_ms_delta(start, end);
642 AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
643 ['ktime_ms_delta' is available])
645 ]) # LIBCFS_KTIME_MS_DELTA
648 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
649 # create per module locks which added kernel_param_[un]lock(). Older
650 # kernels you have to use __kernel_param_[un]lock(). In that case its
651 # a global lock for all modules but that is okay since its a rare event.
653 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
654 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
656 #include <linux/moduleparam.h>
658 kernel_param_lock(NULL);
659 kernel_param_unlock(NULL);
661 AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
662 ['kernel_param_[un]lock' is available])
664 ]) # LIBCFS_KERNEL_PARAM_LOCK
667 # Kernel version 4.2 changed topology_thread_cpumask
668 # to topology_sibling_cpumask
670 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
671 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
672 topology_sibling_cpumask, [
673 #include <linux/topology.h>
675 const struct cpumask *mask;
677 mask = topology_sibling_cpumask(0);
679 AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
680 [topology_sibling_cpumask is available])
682 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
685 # Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
686 # header file i387.h was renamed to fpu/api.h
688 AC_DEFUN([LIBCFS_FPU_API], [
689 LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
690 AC_DEFINE(HAVE_FPU_API_HEADER, 1,
691 [fpu/api.h is present])])
695 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
696 # introduced kstrtobool and kstrtobool_from_user.
698 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
699 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
700 kstrtobool_from_user, [
701 #include <linux/kernel.h>
704 return kstrtobool_from_user(NULL, 0, &result);
706 AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
707 [kernel has kstrtobool_from_user])
709 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
712 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
713 # added crypto hash helpers
715 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
716 LB_CHECK_COMPILE([does crypto hash helper functions exist],
717 crypto_hash_helpers, [
718 #include <crypto/hash.h>
720 crypto_ahash_alg_name(NULL);
721 crypto_ahash_driver_name(NULL);
723 AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
724 [crypto hash helper functions are available])
726 ]) # LIBCFS_CRYPTO_HASH_HELPERS
729 # Kernerl version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
730 # made kset_find_obj() exportable to modules
732 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
733 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
734 [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
735 [kset_find_obj is exported by the kernel])])
736 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
739 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
741 # linux 4.6 kernel changed stacktrace_ops address to return an int
743 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
744 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
745 stacktrace_ops_address_return_int, [
746 #include <asm/stacktrace.h>
750 rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
752 AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
753 ['struct stacktrace_ops' address function returns an int])
755 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
758 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
759 # arguments to get_user_pages
761 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
762 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
763 get_user_pages_6arg, [
764 #include <linux/mm.h>
768 rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
770 AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
771 [get_user_pages takes 6 arguments])
773 ]) # LIBCFS_GET_USER_PAGES_6ARG
776 # LIBCFS_STACKTRACE_OPS
778 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
779 # removed both struct stacktrace_ops and dump_trace() function
781 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
782 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
786 #include <asm/stacktrace.h>
788 struct stacktrace_ops ops;
791 AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
792 [struct stacktrace_ops exists])
794 ]) # LIBCFS_STACKTRACE_OPS
797 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
798 # mm: replace get_user_pages() write/force parameters with gup_flags
800 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
801 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
802 get_user_pages_gup_flags, [
803 #include <linux/mm.h>
806 rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
808 AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
809 [get_user_pages takes gup_flags in arguments])
811 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
814 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
815 # libcfs: Convert to hotplug state machine
817 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
818 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
819 cpu_hotplug_state_machine, [
820 #include <linux/cpuhotplug.h>
822 cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
824 AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
825 [hotplug state machine is supported])
827 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
830 # LIBCFS_SCHED_HEADERS
832 # 4.11 has broken up sched.h into more headers.
834 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
835 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
836 AC_DEFINE(HAVE_SCHED_HEADERS, 1,
837 [linux/sched header directory exist])])
838 ]) # LIBCFS_SCHED_HEADERS
841 # LIBCFS_WAIT_QUEUE_ENTRY
843 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
844 # Rename wait_queue_t => wait_queue_entry_t
846 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
847 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
849 #include <linux/wait.h>
851 wait_queue_entry_t e;
855 AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
856 ['wait_queue_entry_t' is available])
858 ]) # LIBCFS_WAIT_QUEUE_ENTRY
861 # LIBCFS_NEW_KERNEL_WRITE
863 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
864 # changed kernel_write prototype to make is plug compatible
865 # with the unexported vfs_write()
867 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
868 tmp_flags="$EXTRA_KCFLAGS"
869 EXTRA_KCFLAGS="-Werror"
870 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
871 kernel_write_match, [
872 #include <linux/fs.h>
874 const void *buf = NULL;
876 return kernel_write(NULL, buf, 0, &pos);
878 AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
879 ['kernel_write' aligns with read/write helpers])
881 EXTRA_KCFLAGS="$tmp_flags"
882 ]) # LIBCFS_NEW_KERNEL_WRITE
887 # LibCFS linux kernel checks
889 AC_DEFUN([LIBCFS_PROG_LINUX], [
890 AC_MSG_NOTICE([LibCFS kernel checks
891 ==============================================================================])
892 LIBCFS_CONFIG_PANIC_DUMPLOG
895 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
896 LC_SHRINKER_WANT_SHRINK_PTR
898 LIBCFS_SYSCTL_CTLNAME
900 LIBCFS_MODULE_LOCKING
904 LIBCFS_DUMP_TRACE_ADDRESS
908 LIBCFS_STACKTRACE_WARNING
909 LIBCFS_REINIT_COMPLETION
911 LIBCFS_PROCESS_NAMESPACE
914 LIBCFS_SOCK_ALLOC_FILE
917 LIBCFS_ENABLE_CRC32_ACCEL
919 LIBCFS_ENABLE_CRC32C_ACCEL
921 LIBCFS_KTIME_GET_TS64
923 LIBCFS_KERNEL_PARAM_OPS
928 LIBCFS_SHRINKER_COUNT
930 LIBCFS_HLIST_ADD_AFTER
933 LIBCFS_KTIME_GET_REAL_TS64
934 LIBCFS_KTIME_GET_REAL_SECONDS
935 LIBCFS_KTIME_GET_REAL_NS
936 LIBCFS_KTIME_TO_TIMESPEC64
937 LIBCFS_TIMESPEC64_SUB
938 LIBCFS_TIMESPEC64_TO_KTIME
940 LIBCFS_KTIME_GET_SECONDS
941 LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
943 LIBCFS_KTIME_MS_DELTA
945 LIBCFS_KERNEL_PARAM_LOCK
947 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
950 LIBCFS_KSTRTOBOOL_FROM_USER
952 LIBCFS_CRYPTO_HASH_HELPERS
953 LIBCFS_EXPORT_KSET_FIND_OBJ
955 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
956 LIBCFS_GET_USER_PAGES_6ARG
958 LIBCFS_STACKTRACE_OPS
960 LIBCFS_GET_USER_PAGES_GUP_FLAGS
962 LIBCFS_HOTPLUG_STATE_MACHINE
966 LIBCFS_WAIT_QUEUE_ENTRY
968 LIBCFS_NEW_KERNEL_WRITE
969 ]) # LIBCFS_PROG_LINUX
972 # LIBCFS_PATH_DEFAULTS
974 # default paths for installed files
976 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
977 ]) # LIBCFS_PATH_DEFAULTS
982 # other configure checks
984 AC_DEFUN([LIBCFS_CONFIGURE], [
985 AC_MSG_NOTICE([LibCFS core checks
986 ==============================================================================])
988 # libcfs/libcfs/util/nidstrings.c
989 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
990 AC_CHECK_FUNCS([gethostbyname])
992 # -------- Check for required packages --------------
994 AC_MSG_NOTICE([LibCFS required packages checks
995 ==============================================================================])
997 AC_MSG_CHECKING([whether to enable readline support])
998 AC_ARG_ENABLE(readline,
999 AC_HELP_STRING([--disable-readline],
1000 [disable readline support]),
1001 [], [enable_readline="yes"])
1002 AC_MSG_RESULT([$enable_readline])
1005 AS_IF([test "x$enable_readline" = xyes], [
1006 AC_CHECK_LIB([readline], [readline], [
1007 LIBREADLINE="-lreadline"
1008 AC_DEFINE(HAVE_LIBREADLINE, 1,
1009 [readline library is available])
1012 AC_SUBST(LIBREADLINE)
1014 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1015 AC_ARG_ENABLE([libpthread],
1016 AC_HELP_STRING([--disable-libpthread],
1017 [disable libpthread]),
1018 [], [enable_libpthread="yes"])
1019 AC_MSG_RESULT([$enable_libpthread])
1022 AS_IF([test "x$enable_libpthread" = xyes], [
1023 AC_CHECK_LIB([pthread], [pthread_create], [
1024 PTHREAD_LIBS="-lpthread"
1025 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1026 [use libpthread for libcfs library])
1029 AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1031 AC_SUBST(PTHREAD_LIBS)
1032 ]) # LIBCFS_CONFIGURE
1035 # LIBCFS_CONDITIONALS
1037 AC_DEFUN([LIBCFS_CONDITIONALS], [
1038 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
1039 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
1040 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
1041 ]) # LIBCFS_CONDITIONALS
1044 # LIBCFS_CONFIG_FILES
1046 # files that should be generated with AC_OUTPUT
1048 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1052 libcfs/autoconf/Makefile
1053 libcfs/include/Makefile
1054 libcfs/include/libcfs/Makefile
1055 libcfs/include/libcfs/linux/Makefile
1056 libcfs/include/libcfs/util/Makefile
1057 libcfs/libcfs/Makefile
1058 libcfs/libcfs/autoMakefile
1059 libcfs/libcfs/linux/Makefile
1060 libcfs/libcfs/util/Makefile
1062 ]) # LIBCFS_CONFIG_FILES