Whamcloud - gitweb
LU-8130 libcfs: prepare rhashtable support
[fs/lustre-release.git] / libcfs / autoconf / lustre-libcfs.m4
1 #
2 # LIBCFS_CONFIG_CDEBUG
3 #
4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
5 #
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])])
15
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])])
24
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
34
35 #
36 # LIBCFS_CONFIG_PANIC_DUMPLOG
37 #
38 # check if tunable panic_dumplog is wanted
39 #
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
50
51 #
52 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
53 #
54 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
55 #
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>
60 ],[
61         ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
62 ],[
63         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1,
64                 ['struct stacktrace_ops' has 'walk_stack' field])
65 ])
66 ]) # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
67
68 #
69 # LIBCFS_STACKTRACE_WARNING
70 #
71 # 3.0 removes stacktrace_ops warning* functions
72 #
73 AC_DEFUN([LIBCFS_STACKTRACE_WARNING], [
74 LB_CHECK_COMPILE([if 'stacktrace_ops.warning' is exist],
75 stacktrace_ops_warning, [
76         struct task_struct;
77         struct pt_regs;
78         #include <asm/stacktrace.h>
79 ],[
80         ((struct stacktrace_ops *)0)->warning(NULL, NULL);
81 ],[
82         AC_DEFINE(HAVE_STACKTRACE_WARNING, 1,
83                 [stacktrace_ops.warning is exist])
84 ])
85 ]) # LIBCFS_STACKTRACE_WARNING
86
87 #
88 # LIBCFS_REINIT_COMPLETION
89 #
90 AC_DEFUN([LIBCFS_REINIT_COMPLETION], [
91 LB_CHECK_COMPILE([if 'reinit_completion' exists],
92 reinit_completion, [
93         #include <linux/completion.h>
94 ],[
95         struct completion x;
96         reinit_completion(&x);
97 ],[
98         AC_DEFINE(HAVE_REINIT_COMPLETION, 1,
99                 [reinit_completion is exist])
100 ])
101 ]) # LIBCFS_REINIT_COMPLETION
102
103 #
104 # LC_SHRINKER_WANT_SHRINK_PTR
105 #
106 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
107 #
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>
112 ],[
113         struct shrinker *tmp = NULL;
114         tmp->shrink(tmp, 0, 0);
115 ],[
116         AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
117                 [shrinker want self pointer in handler])
118 ])
119 ]) # LC_SHRINKER_WANT_SHRINK_PTR
120
121 #
122 # LIBCFS_SYSCTL_CTLNAME
123 #
124 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
125 #
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>
130 ],[
131         struct ctl_table ct;
132         ct.ctl_name = sizeof(ct);
133 ],[
134         AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
135                 [ctl_table has ctl_name field])
136 ])
137 ]) # LIBCFS_SYSCTL_CTLNAME
138
139 #
140 # LIBCFS_MODULE_LOCKING
141 #
142 # 2.6.36 introduced locking to module params. RHEL6 lacks this support
143 #
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>
148 ],[
149         __kernel_param_lock(NULL);
150         __kernel_param_unlock(NULL);
151 ],[
152         AC_DEFINE(HAVE_MODULE_PARAM_LOCKING, 1,
153                 [locking module param is supported])
154 ])
155 ]) # LIBCFS_MODULE_LOCKING
156
157 #
158 # LIBCFS_KSTRTOUL
159 #
160 # 2.6.38 kstrtoul is added
161 #
162 AC_DEFUN([LIBCFS_KSTRTOUL], [
163 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
164 kstrtoul, [
165         #include <linux/kernel.h>
166 ],[
167         unsigned long result;
168         return kstrtoul("12345", 0, &result);
169 ],[
170         AC_DEFINE(HAVE_KSTRTOUL, 1,
171                 [kernel has kstrtoul])
172 ])
173 ]) # LIBCFS_KSTRTOUL
174
175 #
176 # LIBCFS_DUMP_TRACE_ADDRESS
177 #
178 # 2.6.39 adds a base pointer address argument to dump_trace
179 #
180 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
181 LB_CHECK_COMPILE([if 'dump_trace' want address],
182 dump_trace_address, [
183         struct task_struct;
184         struct pt_regs;
185         #include <asm/stacktrace.h>
186 ],[
187         dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
188 ],[
189         AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
190                 [dump_trace want address argument])
191 ])
192 ]) # LIBCFS_DUMP_TRACE_ADDRESS
193
194 #
195 # LC_SHRINK_CONTROL
196 #
197 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
198 # pressure shrinker from Linux 3.0
199 #
200 AC_DEFUN([LC_SHRINK_CONTROL], [
201 LB_CHECK_COMPILE([if 'shrink_control' is present],
202 shrink_control, [
203         #include <linux/atomic.h>
204         #include <linux/mm.h>
205 ],[
206         struct shrink_control tmp = {0};
207         tmp.nr_to_scan = sizeof(tmp);
208 ],[
209         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
210                 [shrink_control is present])
211 ])
212 ]) # LC_SHRINK_CONTROL
213
214 #
215 # LIBCFS_PROCESS_NAMESPACE
216 #
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
223
224 #
225 # LIBCFS_I_UID_READ
226 #
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
229 #
230 AC_DEFUN([LIBCFS_I_UID_READ], [
231 LB_CHECK_COMPILE([if 'i_uid_read' is present],
232 i_uid_read, [
233         #include <linux/fs.h>
234 ],[
235         i_uid_read(NULL);
236 ],[
237         AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
238 ])
239 ]) # LIBCFS_I_UID_READ
240
241 #
242 # LIBCFS_HAVE_CRC32
243 #
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
251
252 #
253 # LIBCFS_ENABLE_CRC32_ACCEL
254 #
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
262
263 #
264 # LIBCFS_ENABLE_CRC32C_ACCEL
265 #
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
273
274 #
275 # Kernel version 3.11 introduced ktime_get_ts64
276 #
277 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
278 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
279 ktime_get_ts64, [
280         #include <linux/hrtimer.h>
281         #include <linux/ktime.h>
282 ],[
283         struct timespec64 *ts = NULL;
284
285         ktime_get_ts64(ts);
286 ],[
287         AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
288                 ['ktime_get_ts64' is available])
289 ])
290 ]) # LIBCFS_KTIME_GET_TS64
291
292 #
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.
296 #
297 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
298 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
299 kernel_param_ops, [
300         #include <linux/module.h>
301 ],[
302         struct kernel_param_ops ops;
303
304         ops.set = NULL;
305 ],[
306         AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
307                 ['struct kernel_param_ops' is available])
308 ])
309 ]) # LIBCFS_KERNEL_PARAM_OPS
310
311 #
312 # Kernel version 3.12 introduced ktime_add
313 #
314 AC_DEFUN([LIBCFS_KTIME_ADD],[
315 LB_CHECK_COMPILE([does function 'ktime_add' exist],
316 ktime_add, [
317         #include <linux/hrtimer.h>
318         #include <linux/ktime.h>
319 ],[
320         ktime_t start = ktime_set(0, 0);
321         ktime_t end = start;
322         ktime_t total;
323
324         total = ktime_add(start, end);
325 ],[
326         AC_DEFINE(HAVE_KTIME_ADD, 1,
327                 [ktime_add is available])
328 ])
329 ]) # LIBCFS_KTIME_ADD
330
331 #
332 # Kernel version 3.12 introduced ktime_after
333 #
334 AC_DEFUN([LIBCFS_KTIME_AFTER],[
335 LB_CHECK_COMPILE([does function 'ktime_after' exist],
336 ktime_after, [
337         #include <linux/hrtimer.h>
338         #include <linux/ktime.h>
339 ],[
340         ktime_t start = ktime_set(0, 0);
341         ktime_t end = start;
342
343         ktime_after(start, end);
344 ],[
345         AC_DEFINE(HAVE_KTIME_AFTER, 1,
346                 [ktime_after is available])
347 ])
348 ]) # LIBCFS_KTIME_AFTER
349
350 #
351 # Kernel version 3.12 introduced ktime_before
352 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
353 #
354 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
355 LB_CHECK_COMPILE([does function 'ktime_before' exist],
356 ktime_before, [
357         #include <linux/hrtimer.h>
358         #include <linux/ktime.h>
359 ],[
360         ktime_t start = ktime_set(0, 0);
361         ktime_t end = start;
362
363         ktime_before(start, end);
364 ],[
365         AC_DEFINE(HAVE_KTIME_BEFORE, 1,
366                 [ktime_before is available])
367 ])
368 ]) # LIBCFS_KTIME_BEFORE
369
370 #
371 # Kernel version 3.12 introduced ktime_compare
372 #
373 AC_DEFUN([LIBCFS_KTIME_COMPARE],[
374 LB_CHECK_COMPILE([does function 'ktime_compare' exist],
375 ktime_compare, [
376         #include <linux/hrtimer.h>
377         #include <linux/ktime.h>
378 ],[
379         ktime_t start = ktime_set(0, 0);
380         ktime_t end = start;
381
382         ktime_compare(start, end);
383 ],[
384         AC_DEFINE(HAVE_KTIME_COMPARE, 1,
385                 [ktime_compare is available])
386 ])
387 ]) # LIBCFS_KTIME_COMPARE
388
389 #
390 # FC19 3.12 kernel struct shrinker change
391 #
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>
397 ],[
398         struct shrinker shrinker;
399
400         shrinker.count_objects = NULL;
401 ],[
402         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
403                 [shrinker has count_objects member])
404 ])
405 ]) # LIBCFS_SHRINKER_COUNT
406
407 #
408 # Kernel version 3.17 changed hlist_add_after to
409 # hlist_add_behind
410 #
411 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
412 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
413 hlist_add_after, [
414         #include <linux/list.h>
415 ],[
416         hlist_add_after(NULL, NULL);
417 ],[
418         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
419                 [hlist_add_after is available])
420 ])
421 ]) # LIBCFS_HLIST_ADD_AFTER
422
423 #
424 # Kernel version 3.17 introduced struct timespec64
425 #
426 AC_DEFUN([LIBCFS_TIMESPEC64],[
427 LB_CHECK_COMPILE([does 'struct timespec64' exist],
428 timespec64, [
429         #include <linux/time.h>
430 ],[
431         struct timespec64 ts;
432
433         ts.tv_sec = 0;
434         ts.tv_nsec = 0;
435 ],[
436         AC_DEFINE(HAVE_TIMESPEC64, 1,
437                 ['struct timespec64' is available])
438 ])
439 ]) # LIBCFS_TIMESPEC64
440
441 #
442 # Kernel version 3.17 introduced ktime_get_real_ts64
443 #
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>
448 ],[
449         struct timespec64 *ts = NULL;
450
451         ktime_get_real_ts64(ts);
452 ],[
453         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
454                 ['ktime_get_real_ts64' is available])
455 ])
456 ]) # LIBCFS_KTIME_GET_REAL_TS64
457
458 #
459 # Kernel version 3.17 introduced ktime_get_real_seconds
460 #
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>
466 ],[
467         time64_t now;
468
469         now = ktime_get_real_seconds();
470 ],[
471         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
472                 ['ktime_get_real_seconds' is available])
473 ])
474 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
475
476 #
477 # Kernel version 3.17 created ktime_get_ns wrapper
478 #
479 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
480 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
481 ktime_get_ns, [
482         #include <linux/hrtimer.h>
483         #include <linux/ktime.h>
484 ],[
485         u64 nanoseconds;
486
487         nanoseconds = ktime_get_ns();
488 ],[],[
489         AC_DEFINE(NEED_KTIME_GET_NS, 1,
490                 ['ktime_get_ns' is not available])
491 ])
492 ]) # LIBCFS_KTIME_GET_NS
493
494 #
495 # Kernel version 3.17 created ktime_get_real_ns wrapper
496 #
497 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
498 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
499 ktime_get_real_ns, [
500         #include <linux/hrtimer.h>
501         #include <linux/ktime.h>
502 ],[
503         u64 nanoseconds;
504
505         nanoseconds = ktime_get_real_ns();
506 ],[],[
507         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
508                 ['ktime_get_real_ns' is not available])
509 ])
510 ]) # LIBCFS_KTIME_GET_REAL_NS
511
512 #
513 # Kernel version 3.17 introduced ktime_to_timespec64
514 #
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>
520 ],[
521         ktime_t now = ktime_set(0, 0);
522         struct timespec64 ts;
523
524         ts = ktime_to_timespec64(now);
525 ],[
526         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
527                 ['ktime_to_timespec64' is available])
528 ])
529 ]) # LIBCFS_KTIME_TO_TIMESPEC64
530
531 #
532 # Kernel version 3.17 introduced timespec64_sub
533 #
534 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
535 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
536 timespec64_sub, [
537         #include <linux/time.h>
538 ],[
539         struct timespec64 later = { }, earlier = { }, diff;
540
541         diff = timespec64_sub(later, earlier);
542 ],[
543         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
544                 ['timespec64_sub' is available])
545 ])
546 ]) # LIBCFS_TIMESPEC64_SUB
547
548 #
549 # Kernel version 3.17 introduced timespec64_to_ktime
550 #
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>
555 ],[
556         struct timespec64 ts;
557         ktime_t now;
558
559         now = timespec64_to_ktime(ts);
560 ],[
561         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
562                 ['timespec64_to_ktime' is available])
563 ])
564 ]) # LIBCFS_TIMESPEC64_TO_KTIME
565
566 #
567 # Kernel version 3.19 introduced ktime_get_seconds
568 #
569 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
570 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
571 ktime_get_seconds, [
572         #include <linux/ktime.h>
573 ],[
574         time64_t now;
575
576         now = ktime_get_seconds();
577 ],[
578         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
579                 ['ktime_get_seconds' is available])
580 ])
581 ]) # LIBCFS_KTIME_GET_SECONDS
582
583 #
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.
588 #
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>
593 ],[
594         int n;
595         char *buf = NULL;
596         const struct cpumask *mask = NULL;
597         n = cpumap_print_to_pagebuf(true, buf, mask);
598 ],[
599         AC_DEFINE(HAVE_CPUMASK_PRINT_TO_PAGEBUF, 1,
600                 [cpumap_print_to_pagebuf is available])
601 ])
602 ]) # LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
603
604 #
605 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
606 # introduced the helper function ktime_ms_delta.
607 #
608 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
609 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
610 ktime_ms_delta, [
611         #include <linux/ktime.h>
612 ],[
613         ktime_t start = ktime_set(0, 0);
614         ktime_t end = start;
615
616         ktime_ms_delta(start, end);
617 ],[
618         AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
619                 ['ktime_ms_delta' is available])
620 ])
621 ]) # LIBCFS_KTIME_MS_DELTA
622
623 #
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.
628 #
629 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
630 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
631 kernel_param_lock, [
632         #include <linux/moduleparam.h>
633 ],[
634         kernel_param_lock(NULL);
635         kernel_param_unlock(NULL);
636 ],[
637         AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
638                 ['kernel_param_[un]lock' is available])
639 ])
640 ]) # LIBCFS_KERNEL_PARAM_LOCK
641
642 #
643 # Kernel version 4.2 changed topology_thread_cpumask
644 # to topology_sibling_cpumask
645 #
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>
650 ],[
651         const struct cpumask *mask;
652
653         mask = topology_sibling_cpumask(0);
654 ],[
655         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
656                 [topology_sibling_cpumask is available])
657 ])
658 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
659
660 #
661 # Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
662 # header file i387.h was renamed to fpu/api.h
663 #
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])])
668 ]) # LIBCFS_FPU_API
669
670 #
671 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
672 # introduced kstrtobool and kstrtobool_from_user.
673 #
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>
678 ],[
679         bool result;
680         return kstrtobool_from_user(NULL, 0, &result);
681 ],[
682         AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
683                 [kernel has kstrtobool_from_user])
684 ])
685 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
686
687 #
688 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
689 # added crypto hash helpers
690 #
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>
695 ],[
696         crypto_ahash_alg_name(NULL);
697         crypto_ahash_driver_name(NULL);
698 ],[
699         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
700                 [crypto hash helper functions are available])
701 ])
702 ]) # LIBCFS_CRYPTO_HASH_HELPERS
703
704 #
705 # Kernerl version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
706 # made kset_find_obj() exportable to modules
707 #
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
713
714 #
715 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
716 #
717 # linux 4.6 kernel changed stacktrace_ops address to return an int
718 #
719 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
720 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
721 stacktrace_ops_address_return_int, [
722         #include <asm/stacktrace.h>
723 ],[
724         int rc;
725
726         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
727 ],[
728         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
729                 ['struct stacktrace_ops' address function returns an int])
730 ])
731 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
732
733 #
734 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
735 # arguments to get_user_pages
736 #
737 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
738 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
739 get_user_pages_6arg, [
740         #include <linux/mm.h>
741 ],[
742         int rc;
743
744         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
745 ],[
746         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
747                 [get_user_pages takes 6 arguments])
748 ])
749 ]) # LIBCFS_GET_USER_PAGES_6ARG
750
751 #
752 # LIBCFS_STRINGHASH
753 #
754 # 4.6 kernel created stringhash.h which moved stuff out of dcache.h
755 # commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
756 #
757 AC_DEFUN([LIBCFS_STRINGHASH], [
758 LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
759         AC_DEFINE(HAVE_STRINGHASH, 1,
760                 [stringhash.h is present])])
761 ]) # LIBCFS_STRINGHASH
762
763 #
764 # LIBCFS_STACKTRACE_OPS
765 #
766 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
767 # removed both struct stacktrace_ops and dump_trace() function
768 #
769 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
770 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
771 stacktrace_ops, [
772         struct task_struct;
773         struct pt_regs;
774         #include <asm/stacktrace.h>
775 ],[
776         struct stacktrace_ops ops;
777         ops.stack = NULL;
778 ],[
779         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
780                 [struct stacktrace_ops exists])
781 ])
782 ]) # LIBCFS_STACKTRACE_OPS
783
784 #
785 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
786 # mm: replace get_user_pages() write/force parameters with gup_flags
787 #
788 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
789 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
790 get_user_pages_gup_flags, [
791         #include <linux/mm.h>
792 ],[
793         int rc;
794         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
795 ],[
796         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
797                 [get_user_pages takes gup_flags in arguments])
798 ])
799 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
800
801 #
802 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
803 # libcfs: Convert to hotplug state machine
804 #
805 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
806 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
807 cpu_hotplug_state_machine, [
808         #include <linux/cpuhotplug.h>
809 ],[
810         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
811 ],[
812         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
813                 [hotplug state machine is supported])
814 ])
815 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
816
817 #
818 # LIBCFS_SCHED_HEADERS
819 #
820 # 4.11 has broken up sched.h into more headers.
821 #
822 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
823 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
824         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
825                 [linux/sched header directory exist])])
826 ]) # LIBCFS_SCHED_HEADERS
827
828 #
829 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
830 # introduced rhashtable_lookup_get_insert_fast
831 #
832 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
833 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
834 rhashtable_lookup_get_insert_fast, [
835         #include <linux/rhashtable.h>
836 ],[
837         const struct rhashtable_params params = { 0 };
838         void *ret;
839
840         ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
841 ],[
842         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
843                 [rhashtable_lookup_get_insert_fast() is available])
844 ])
845 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
846
847 #
848 # LIBCFS_WAIT_QUEUE_ENTRY
849 #
850 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
851 # Rename wait_queue_t => wait_queue_entry_t
852 #
853 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
854 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
855 wait_queue_entry, [
856         #include <linux/wait.h>
857 ],[
858         wait_queue_entry_t e;
859
860         e.flags = 0;
861 ],[
862         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
863                 ['wait_queue_entry_t' is available])
864 ])
865 ]) # LIBCFS_WAIT_QUEUE_ENTRY
866
867 #
868 # LIBCFS_NEW_KERNEL_WRITE
869 #
870 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
871 # changed kernel_write prototype to make is plug compatible
872 # with the unexported vfs_write()
873 #
874 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
875 tmp_flags="$EXTRA_KCFLAGS"
876 EXTRA_KCFLAGS="-Werror"
877 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
878 kernel_write_match, [
879         #include <linux/fs.h>
880 ],[
881         const void *buf = NULL;
882         loff_t pos = 0;
883         return kernel_write(NULL, buf, 0, &pos);
884 ],[
885         AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
886                 ['kernel_write' aligns with read/write helpers])
887 ])
888 EXTRA_KCFLAGS="$tmp_flags"
889 ]) # LIBCFS_NEW_KERNEL_WRITE
890
891 #
892 # LIBCFS_DEFINE_TIMER
893 #
894 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
895 # remove expires and data arguments from DEFINE_TIMER. Also the callback
896 # when from using unsigned long argument to using struct timer_list pointer.
897 #
898 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
899 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
900 define_timer, [
901         #include <linux/timer.h>
902 ],[
903         static DEFINE_TIMER(my_timer, NULL);
904 ],[
905         AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
906                 [DEFINE_TIMER uses only 2 arguements])
907 ])
908 ]) # LIBCFS_DEFINE_TIMER
909
910 #
911 # LIBCFS_TIMER_SETUP
912 #
913 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
914 # setup_timer() was replaced by timer_setup(), where the callback
915 # argument is the structure already holding the struct timer_list.
916 #
917 AC_DEFUN([LIBCFS_TIMER_SETUP], [
918 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
919 timer_setup, [
920         #include <linux/timer.h>
921 ],[
922         timer_setup(NULL, NULL, 0);
923 ],[
924         AC_DEFINE(HAVE_TIMER_SETUP, 1,
925                 [timer_setup has replaced setup_timer])
926 ])
927 ]) # LIBCFS_TIMER_SETUP
928
929 #
930 # LIBCFS_PROG_LINUX
931 #
932 # LibCFS linux kernel checks
933 #
934 AC_DEFUN([LIBCFS_PROG_LINUX], [
935 AC_MSG_NOTICE([LibCFS kernel checks
936 ==============================================================================])
937 LIBCFS_CONFIG_PANIC_DUMPLOG
938
939 # 2.6.32
940 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
941 LC_SHRINKER_WANT_SHRINK_PTR
942 # 2.6.33
943 LIBCFS_SYSCTL_CTLNAME
944 # 2.6.36
945 LIBCFS_MODULE_LOCKING
946 # 2.6.38
947 LIBCFS_KSTRTOUL
948 # 2.6.39
949 LIBCFS_DUMP_TRACE_ADDRESS
950 # 2.6.40 fc15
951 LC_SHRINK_CONTROL
952 # 3.0
953 LIBCFS_STACKTRACE_WARNING
954 LIBCFS_REINIT_COMPLETION
955 # 3.5
956 LIBCFS_PROCESS_NAMESPACE
957 LIBCFS_I_UID_READ
958 # 3.8
959 LIBCFS_HAVE_CRC32
960 LIBCFS_ENABLE_CRC32_ACCEL
961 # 3.10
962 LIBCFS_ENABLE_CRC32C_ACCEL
963 # 3.11
964 LIBCFS_KTIME_GET_TS64
965 # 3.12
966 LIBCFS_KERNEL_PARAM_OPS
967 LIBCFS_KTIME_ADD
968 LIBCFS_KTIME_AFTER
969 LIBCFS_KTIME_BEFORE
970 LIBCFS_KTIME_COMPARE
971 LIBCFS_SHRINKER_COUNT
972 # 3.17
973 LIBCFS_HLIST_ADD_AFTER
974 LIBCFS_TIMESPEC64
975 LIBCFS_KTIME_GET_NS
976 LIBCFS_KTIME_GET_REAL_TS64
977 LIBCFS_KTIME_GET_REAL_SECONDS
978 LIBCFS_KTIME_GET_REAL_NS
979 LIBCFS_KTIME_TO_TIMESPEC64
980 LIBCFS_TIMESPEC64_SUB
981 LIBCFS_TIMESPEC64_TO_KTIME
982 # 3.19
983 LIBCFS_KTIME_GET_SECONDS
984 LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
985 # 4.0
986 LIBCFS_KTIME_MS_DELTA
987 # 4.1
988 LIBCFS_KERNEL_PARAM_LOCK
989 # 4.2
990 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
991 LIBCFS_FPU_API
992 # 4.4
993 LIBCFS_KSTRTOBOOL_FROM_USER
994 # 4.5
995 LIBCFS_CRYPTO_HASH_HELPERS
996 LIBCFS_EXPORT_KSET_FIND_OBJ
997 # 4.6
998 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
999 LIBCFS_GET_USER_PAGES_6ARG
1000 LIBCFS_STRINGHASH
1001 # 4.8
1002 LIBCFS_STACKTRACE_OPS
1003 # 4.9
1004 LIBCFS_GET_USER_PAGES_GUP_FLAGS
1005 # 4.10
1006 LIBCFS_HOTPLUG_STATE_MACHINE
1007 # 4.11
1008 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
1009 LIBCFS_SCHED_HEADERS
1010 # 4.13
1011 LIBCFS_WAIT_QUEUE_ENTRY
1012 # 4.14
1013 LIBCFS_DEFINE_TIMER
1014 LIBCFS_NEW_KERNEL_WRITE
1015 # 4.15
1016 LIBCFS_TIMER_SETUP
1017 ]) # LIBCFS_PROG_LINUX
1018
1019 #
1020 # LIBCFS_PATH_DEFAULTS
1021 #
1022 # default paths for installed files
1023 #
1024 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
1025 ]) # LIBCFS_PATH_DEFAULTS
1026
1027 #
1028 # LIBCFS_CONFIGURE
1029 #
1030 # other configure checks
1031 #
1032 AC_DEFUN([LIBCFS_CONFIGURE], [
1033 AC_MSG_NOTICE([LibCFS core checks
1034 ==============================================================================])
1035
1036 # libcfs/libcfs/util/nidstrings.c
1037 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
1038 AC_CHECK_FUNCS([gethostbyname])
1039
1040 # --------  Check for required packages  --------------
1041
1042 AC_MSG_NOTICE([LibCFS required packages checks
1043 ==============================================================================])
1044
1045 AC_MSG_CHECKING([whether to enable readline support])
1046 AC_ARG_ENABLE(readline,
1047         AC_HELP_STRING([--disable-readline],
1048                 [disable readline support]),
1049         [], [enable_readline="yes"])
1050 AC_MSG_RESULT([$enable_readline])
1051
1052 LIBREADLINE=""
1053 AS_IF([test "x$enable_readline" = xyes], [
1054         AC_CHECK_LIB([readline], [readline], [
1055                 LIBREADLINE="-lreadline"
1056                 AC_DEFINE(HAVE_LIBREADLINE, 1,
1057                         [readline library is available])
1058         ])
1059 ])
1060 AC_SUBST(LIBREADLINE)
1061
1062 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1063 AC_ARG_ENABLE([libpthread],
1064         AC_HELP_STRING([--disable-libpthread],
1065                 [disable libpthread]),
1066         [], [enable_libpthread="yes"])
1067 AC_MSG_RESULT([$enable_libpthread])
1068
1069 PTHREAD_LIBS=""
1070 AS_IF([test "x$enable_libpthread" = xyes], [
1071         AC_CHECK_LIB([pthread], [pthread_create], [
1072                 PTHREAD_LIBS="-lpthread"
1073                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1074                         [use libpthread for libcfs library])
1075         ])
1076 ], [
1077         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1078 ])
1079 AC_SUBST(PTHREAD_LIBS)
1080 ]) # LIBCFS_CONFIGURE
1081
1082 #
1083 # LIBCFS_CONDITIONALS
1084 #
1085 AC_DEFUN([LIBCFS_CONDITIONALS], [
1086 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
1087 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
1088 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
1089 ]) # LIBCFS_CONDITIONALS
1090
1091 #
1092 # LIBCFS_CONFIG_FILES
1093 #
1094 # files that should be generated with AC_OUTPUT
1095 #
1096 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1097 AC_CONFIG_FILES([
1098 libcfs/Makefile
1099 libcfs/autoMakefile
1100 libcfs/autoconf/Makefile
1101 libcfs/include/Makefile
1102 libcfs/include/libcfs/Makefile
1103 libcfs/include/libcfs/linux/Makefile
1104 libcfs/include/libcfs/util/Makefile
1105 libcfs/libcfs/Makefile
1106 libcfs/libcfs/autoMakefile
1107 libcfs/libcfs/linux/Makefile
1108 libcfs/libcfs/util/Makefile
1109 ])
1110 ]) # LIBCFS_CONFIG_FILES