Whamcloud - gitweb
1231e90ece94218a93874004d99b25fddb71b769
[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_SOCK_ALLOC_FILE
243 #
244 # FC18 3.7.2-201 unexport sock_map_fd() change to
245 # use sock_alloc_file().
246 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
247 #
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>
253         ],[
254                 sock_alloc_file(NULL, 0, NULL);
255         ],[
256                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
257                         [sock_alloc_file takes 3 arguments])
258         ],[
259                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
260                         [sock_alloc_file is exported])
261         ])
262 ])
263 ]) # LIBCFS_SOCK_ALLOC_FILE
264
265 #
266 # LIBCFS_HAVE_CRC32
267 #
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
275
276 #
277 # LIBCFS_ENABLE_CRC32_ACCEL
278 #
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
286
287 #
288 # LIBCFS_ENABLE_CRC32C_ACCEL
289 #
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
297
298 #
299 # Kernel version 3.11 introduced ktime_get_ts64
300 #
301 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
302 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
303 ktime_get_ts64, [
304         #include <linux/hrtimer.h>
305         #include <linux/ktime.h>
306 ],[
307         struct timespec64 *ts = NULL;
308
309         ktime_get_ts64(ts);
310 ],[
311         AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
312                 ['ktime_get_ts64' is available])
313 ])
314 ]) # LIBCFS_KTIME_GET_TS64
315
316 #
317 # Linux kernel 3.12 introduced struct kernel_param_ops
318 # This has been backported to all lustre supported
319 # clients expect RHEL6. We have to handle the differences.
320 #
321 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
322 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
323 kernel_param_ops, [
324         #include <linux/module.h>
325 ],[
326         struct kernel_param_ops ops;
327 ],[
328         AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
329                 ['struct kernel_param_ops' is available])
330 ])
331 ]) # LIBCFS_KERNEL_PARAM_OPS
332
333 #
334 # Kernel version 3.12 introduced ktime_add
335 #
336 AC_DEFUN([LIBCFS_KTIME_ADD],[
337 LB_CHECK_COMPILE([does function 'ktime_add' exist],
338 ktime_add, [
339         #include <linux/hrtimer.h>
340         #include <linux/ktime.h>
341 ],[
342         ktime_t start = ktime_set(0, 0);
343         ktime_t end = start;
344         ktime_t total;
345
346         total = ktime_add(start, end);
347 ],[
348         AC_DEFINE(HAVE_KTIME_ADD, 1,
349                 [ktime_add is available])
350 ])
351 ]) # LIBCFS_KTIME_ADD
352
353 #
354 # Kernel version 3.12 introduced ktime_after
355 #
356 AC_DEFUN([LIBCFS_KTIME_AFTER],[
357 LB_CHECK_COMPILE([does function 'ktime_after' exist],
358 ktime_after, [
359         #include <linux/hrtimer.h>
360         #include <linux/ktime.h>
361 ],[
362         ktime_t start = ktime_set(0, 0);
363         ktime_t end = start;
364
365         ktime_after(start, end);
366 ],[
367         AC_DEFINE(HAVE_KTIME_AFTER, 1,
368                 [ktime_after is available])
369 ])
370 ]) # LIBCFS_KTIME_AFTER
371
372 #
373 # Kernel version 3.12 introduced ktime_before
374 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
375 #
376 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
377 LB_CHECK_COMPILE([does function 'ktime_before' exist],
378 ktime_before, [
379         #include <linux/hrtimer.h>
380         #include <linux/ktime.h>
381 ],[
382         ktime_t start = ktime_set(0, 0);
383         ktime_t end = start;
384
385         ktime_before(start, end);
386 ],[
387         AC_DEFINE(HAVE_KTIME_BEFORE, 1,
388                 [ktime_before is available])
389 ])
390 ]) # LIBCFS_KTIME_BEFORE
391
392 #
393 # Kernel version 3.12 introduced ktime_compare
394 #
395 AC_DEFUN([LIBCFS_KTIME_COMPARE],[
396 LB_CHECK_COMPILE([does function 'ktime_compare' exist],
397 ktime_compare, [
398         #include <linux/hrtimer.h>
399         #include <linux/ktime.h>
400 ],[
401         ktime_t start = ktime_set(0, 0);
402         ktime_t end = start;
403
404         ktime_compare(start, end);
405 ],[
406         AC_DEFINE(HAVE_KTIME_COMPARE, 1,
407                 [ktime_compare is available])
408 ])
409 ]) # LIBCFS_KTIME_COMPARE
410
411 #
412 # FC19 3.12 kernel struct shrinker change
413 #
414 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
415 LB_CHECK_COMPILE([shrinker has 'count_objects'],
416 shrinker_count_objects, [
417         #include <linux/mmzone.h>
418         #include <linux/shrinker.h>
419 ],[
420         ((struct shrinker*)0)->count_objects(NULL, NULL);
421 ],[
422         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
423                 [shrinker has count_objects member])
424 ])
425 ]) # LIBCFS_SHRINKER_COUNT
426
427 #
428 # Kernel version 3.17 changed hlist_add_after to
429 # hlist_add_behind
430 #
431 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
432 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
433 hlist_add_after, [
434         #include <linux/list.h>
435 ],[
436         hlist_add_after(NULL, NULL);
437 ],[
438         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
439                 [hlist_add_after is available])
440 ])
441 ]) # LIBCFS_HLIST_ADD_AFTER
442
443 #
444 # Kernel version 3.17 introduced struct timespec64
445 #
446 AC_DEFUN([LIBCFS_TIMESPEC64],[
447 LB_CHECK_COMPILE([does 'struct timespec64' exist],
448 timespec64, [
449         #include <linux/time.h>
450 ],[
451         struct timespec64 ts;
452
453         ts.tv_sec = 0;
454         ts.tv_nsec = 0;
455 ],[
456         AC_DEFINE(HAVE_TIMESPEC64, 1,
457                 ['struct timespec64' is available])
458 ])
459 ]) # LIBCFS_TIMESPEC64
460
461 #
462 # Kernel version 3.17 introduced ktime_get_real_ts64
463 #
464 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
465 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
466 ktime_get_real_ts64, [
467         #include <linux/ktime.h>
468 ],[
469         struct timespec64 *ts = NULL;
470
471         ktime_get_real_ts64(ts);
472 ],[
473         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
474                 ['ktime_get_real_ts64' is available])
475 ])
476 ]) # LIBCFS_KTIME_GET_REAL_TS64
477
478 #
479 # Kernel version 3.17 introduced ktime_get_real_seconds
480 #
481 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
482 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
483 ktime_get_real_seconds, [
484         #include <linux/hrtimer.h>
485         #include <linux/ktime.h>
486 ],[
487         time64_t now;
488
489         now = ktime_get_real_seconds();
490 ],[
491         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
492                 ['ktime_get_real_seconds' is available])
493 ])
494 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
495
496 #
497 # Kernel version 3.17 created ktime_get_ns wrapper
498 #
499 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
500 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
501 ktime_get_ns, [
502         #include <linux/hrtimer.h>
503         #include <linux/ktime.h>
504 ],[
505         u64 nanoseconds;
506
507         nanoseconds = ktime_get_ns();
508 ],[],[
509         AC_DEFINE(NEED_KTIME_GET_NS, 1,
510                 ['ktime_get_ns' is not available])
511 ])
512 ]) # LIBCFS_KTIME_GET_NS
513
514 #
515 # Kernel version 3.17 created ktime_get_real_ns wrapper
516 #
517 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
518 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
519 ktime_get_real_ns, [
520         #include <linux/hrtimer.h>
521         #include <linux/ktime.h>
522 ],[
523         u64 nanoseconds;
524
525         nanoseconds = ktime_get_real_ns();
526 ],[],[
527         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
528                 ['ktime_get_real_ns' is not available])
529 ])
530 ]) # LIBCFS_KTIME_GET_REAL_NS
531
532 #
533 # Kernel version 3.17 introduced ktime_to_timespec64
534 #
535 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
536 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
537 ktime_to_timespec64, [
538         #include <linux/hrtimer.h>
539         #include <linux/ktime.h>
540 ],[
541         struct timespec64 ts;
542         ktime_t now;
543
544         ts = ktime_to_timespec64(now);
545 ],[
546         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
547                 ['ktime_to_timespec64' is available])
548 ])
549 ]) # LIBCFS_KTIME_TO_TIMESPEC64
550
551 #
552 # Kernel version 3.17 introduced timespec64_sub
553 #
554 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
555 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
556 timespec64_sub, [
557         #include <linux/time.h>
558 ],[
559         struct timespec64 later,earlier,diff;
560
561         diff = timespec64_sub(later, earlier);
562 ],[
563         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
564                 ['timespec64_sub' is available])
565 ])
566 ]) # LIBCFS_TIMESPEC64_SUB
567
568 #
569 # Kernel version 3.17 introduced timespec64_to_ktime
570 #
571 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
572 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
573 timespec64_to_ktime, [
574         #include <linux/ktime.h>
575 ],[
576         struct timespec64 ts;
577         ktime_t now;
578
579         now = timespec64_to_ktime(ts);
580 ],[
581         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
582                 ['timespec64_to_ktime' is available])
583 ])
584 ]) # LIBCFS_TIMESPEC64_TO_KTIME
585
586 #
587 # Kernel version 3.19 introduced ktime_get_seconds
588 #
589 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
590 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
591 ktime_get_seconds, [
592         #include <linux/ktime.h>
593 ],[
594         time64_t now;
595
596         now = ktime_get_seconds();
597 ],[
598         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
599                 ['ktime_get_seconds' is available])
600 ])
601 ]) # LIBCFS_KTIME_GET_SECONDS
602
603 #
604 # Kernel version 3.19 commit 5aaba36318e5995e8c95d077a46d9a4d00fcc1cd
605 # This patch creates a new helper function cpumap_print_to_pagebuf in
606 # cpumask.h using newly added bitmap_print_to_pagebuf and consolidates
607 # most of those sysfs functions using the new helper function.
608 #
609 AC_DEFUN([LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF],[
610 LB_CHECK_COMPILE([does function 'cpumap_print_to_pagebuf' exist],
611 cpumap_print_to_pagebuf, [
612         #include <linux/topology.h>
613 ],[
614         int n;
615         char *buf = NULL;
616         const struct cpumask *mask = NULL;
617         n = cpumap_print_to_pagebuf(true, buf, mask);
618 ],[
619         AC_DEFINE(HAVE_CPUMASK_PRINT_TO_PAGEBUF, 1,
620                 [cpumap_print_to_pagebuf is available])
621 ])
622 ]) # LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
623
624 #
625 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
626 # introduced the helper function ktime_ms_delta.
627 #
628 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
629 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
630 ktime_ms_delta, [
631         #include <linux/ktime.h>
632 ],[
633         ktime_t start = ktime_set(0, 0);
634         ktime_t end = start;
635
636         ktime_ms_delta(start, end);
637 ],[
638         AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
639                 ['ktime_ms_delta' is available])
640 ])
641 ]) # LIBCFS_KTIME_MS_DELTA
642
643 #
644 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
645 # create per module locks which added kernel_param_[un]lock(). Older
646 # kernels you have to use __kernel_param_[un]lock(). In that case its
647 # a global lock for all modules but that is okay since its a rare event.
648 #
649 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
650 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
651 kernel_param_lock, [
652         #include <linux/moduleparam.h>
653 ],[
654         kernel_param_lock(NULL);
655         kernel_param_unlock(NULL);
656 ],[
657         AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
658                 ['kernel_param_[un]lock' is available])
659 ])
660 ]) # LIBCFS_KERNEL_PARAM_LOCK
661
662 #
663 # Kernel version 4.2 changed topology_thread_cpumask
664 # to topology_sibling_cpumask
665 #
666 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
667 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
668 topology_sibling_cpumask, [
669         #include <linux/topology.h>
670 ],[
671         const struct cpumask *mask;
672
673         mask = topology_sibling_cpumask(0);
674 ],[
675         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
676                 [topology_sibling_cpumask is available])
677 ])
678 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
679
680 #
681 # Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
682 # header file i387.h was renamed to fpu/api.h
683 #
684 AC_DEFUN([LIBCFS_FPU_API], [
685 LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
686         AC_DEFINE(HAVE_FPU_API_HEADER, 1,
687                 [fpu/api.h is present])])
688 ]) # LIBCFS_FPU_API
689
690 #
691 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
692 # added crypto hash helpers
693 #
694 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
695 LB_CHECK_COMPILE([does crypto hash helper functions exist],
696 crypto_hash_helpers, [
697         #include <crypto/hash.h>
698 ],[
699         crypto_ahash_alg_name(NULL);
700         crypto_ahash_driver_name(NULL);
701 ],[
702         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
703                 [crypto hash helper functions are available])
704 ])
705 ]) # LIBCFS_CRYPTO_HASH_HELPERS
706
707 #
708 # Kernerl version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
709 # made kset_find_obj() exportable to modules
710 #
711 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
712 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
713         [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
714                 [kset_find_obj is exported by the kernel])])
715 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
716
717 #
718 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
719 #
720 # linux 4.6 kernel changed stacktrace_ops address to return an int
721 #
722 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
723 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
724 stacktrace_ops_address_return_int, [
725         #include <asm/stacktrace.h>
726 ],[
727         int rc;
728
729         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
730 ],[
731         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
732                 ['struct stacktrace_ops' address function returns an int])
733 ])
734 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
735
736 #
737 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
738 # arguments to get_user_pages
739 #
740 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
741 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
742 get_user_pages_6arg, [
743         #include <linux/mm.h>
744 ],[
745         int rc;
746
747         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
748 ],[
749         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
750                 [get_user_pages takes 6 arguments])
751 ])
752 ]) # LIBCFS_GET_USER_PAGES_6ARG
753
754 #
755 # LIBCFS_STACKTRACE_OPS
756 #
757 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
758 # removed both struct stacktrace_ops and dump_trace() function
759 #
760 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
761 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
762 stacktrace_ops, [
763         struct task_struct;
764         struct pt_regs;
765         #include <asm/stacktrace.h>
766 ],[
767         struct stacktrace_ops ops;
768         ops.stack = NULL;
769 ],[
770         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
771                 [struct stacktrace_ops exists])
772 ])
773 ]) # LIBCFS_STACKTRACE_OPS
774
775 #
776 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
777 # mm: replace get_user_pages() write/force parameters with gup_flags
778 #
779 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
780 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
781 get_user_pages_gup_flags, [
782         #include <linux/mm.h>
783 ],[
784         int rc;
785         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
786 ],[
787         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
788                 [get_user_pages takes gup_flags in arguments])
789 ])
790 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
791
792 #
793 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
794 # libcfs: Convert to hotplug state machine
795 #
796 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
797 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
798 cpu_hotplug_state_machine, [
799         #include <linux/cpuhotplug.h>
800 ],[
801         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
802 ],[
803         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
804                 [hotplug state machine is supported])
805 ])
806 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
807
808 #
809 # LIBCFS_SCHED_HEADERS
810 #
811 # 4.11 has broken up sched.h into more headers.
812 #
813 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
814 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
815         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
816                 [linux/sched header directory exist])])
817 ]) # LIBCFS_SCHED_HEADERS
818
819 #
820 # LIBCFS_WAIT_QUEUE_ENTRY
821 #
822 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
823 # Rename wait_queue_t => wait_queue_entry_t
824 #
825 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
826 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
827 wait_queue_entry, [
828         #include <linux/wait.h>
829 ],[
830         wait_queue_entry_t e;
831 ],[
832         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
833                 ['wait_queue_entry_t' is available])
834 ])
835 ]) # LIBCFS_WAIT_QUEUE_ENTRY
836
837 #
838 # LIBCFS_PROG_LINUX
839 #
840 # LibCFS linux kernel checks
841 #
842 AC_DEFUN([LIBCFS_PROG_LINUX], [
843 AC_MSG_NOTICE([LibCFS kernel checks
844 ==============================================================================])
845 LIBCFS_CONFIG_PANIC_DUMPLOG
846
847 # 2.6.32
848 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
849 LC_SHRINKER_WANT_SHRINK_PTR
850 # 2.6.33
851 LIBCFS_SYSCTL_CTLNAME
852 # 2.6.36
853 LIBCFS_MODULE_LOCKING
854 # 2.6.38
855 LIBCFS_KSTRTOUL
856 # 2.6.39
857 LIBCFS_DUMP_TRACE_ADDRESS
858 # 2.6.40 fc15
859 LC_SHRINK_CONTROL
860 # 3.0
861 LIBCFS_STACKTRACE_WARNING
862 LIBCFS_REINIT_COMPLETION
863 # 3.5
864 LIBCFS_PROCESS_NAMESPACE
865 LIBCFS_I_UID_READ
866 # 3.7
867 LIBCFS_SOCK_ALLOC_FILE
868 # 3.8
869 LIBCFS_HAVE_CRC32
870 LIBCFS_ENABLE_CRC32_ACCEL
871 # 3.10
872 LIBCFS_ENABLE_CRC32C_ACCEL
873 # 3.11
874 LIBCFS_KTIME_GET_TS64
875 # 3.12
876 LIBCFS_KERNEL_PARAM_OPS
877 LIBCFS_KTIME_ADD
878 LIBCFS_KTIME_AFTER
879 LIBCFS_KTIME_BEFORE
880 LIBCFS_KTIME_COMPARE
881 LIBCFS_SHRINKER_COUNT
882 # 3.17
883 LIBCFS_HLIST_ADD_AFTER
884 LIBCFS_TIMESPEC64
885 LIBCFS_KTIME_GET_NS
886 LIBCFS_KTIME_GET_REAL_TS64
887 LIBCFS_KTIME_GET_REAL_SECONDS
888 LIBCFS_KTIME_GET_REAL_NS
889 LIBCFS_KTIME_TO_TIMESPEC64
890 LIBCFS_TIMESPEC64_SUB
891 LIBCFS_TIMESPEC64_TO_KTIME
892 # 3.19
893 LIBCFS_KTIME_GET_SECONDS
894 LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
895 # 4.0
896 LIBCFS_KTIME_MS_DELTA
897 # 4.1
898 LIBCFS_KERNEL_PARAM_LOCK
899 # 4.2
900 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
901 LIBCFS_FPU_API
902 # 4.5
903 LIBCFS_CRYPTO_HASH_HELPERS
904 LIBCFS_EXPORT_KSET_FIND_OBJ
905 # 4.6
906 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
907 LIBCFS_GET_USER_PAGES_6ARG
908 # 4.8
909 LIBCFS_STACKTRACE_OPS
910 # 4.9
911 LIBCFS_GET_USER_PAGES_GUP_FLAGS
912 # 4.10
913 LIBCFS_HOTPLUG_STATE_MACHINE
914 # 4.11
915 LIBCFS_SCHED_HEADERS
916 # 4.13
917 LIBCFS_WAIT_QUEUE_ENTRY
918 ]) # LIBCFS_PROG_LINUX
919
920 #
921 # LIBCFS_PATH_DEFAULTS
922 #
923 # default paths for installed files
924 #
925 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
926 ]) # LIBCFS_PATH_DEFAULTS
927
928 #
929 # LIBCFS_CONFIGURE
930 #
931 # other configure checks
932 #
933 AC_DEFUN([LIBCFS_CONFIGURE], [
934 AC_MSG_NOTICE([LibCFS core checks
935 ==============================================================================])
936
937 # libcfs/libcfs/util/nidstrings.c
938 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
939 AC_CHECK_FUNCS([gethostbyname])
940
941 # --------  Check for required packages  --------------
942
943 AC_MSG_NOTICE([LibCFS required packages checks
944 ==============================================================================])
945
946 AC_MSG_CHECKING([whether to enable readline support])
947 AC_ARG_ENABLE(readline,
948         AC_HELP_STRING([--disable-readline],
949                 [disable readline support]),
950         [], [enable_readline="yes"])
951 AC_MSG_RESULT([$enable_readline])
952
953 LIBREADLINE=""
954 AS_IF([test "x$enable_readline" = xyes], [
955         AC_CHECK_LIB([readline], [readline], [
956                 LIBREADLINE="-lreadline"
957                 AC_DEFINE(HAVE_LIBREADLINE, 1,
958                         [readline library is available])
959         ])
960 ])
961 AC_SUBST(LIBREADLINE)
962
963 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
964 AC_ARG_ENABLE([libpthread],
965         AC_HELP_STRING([--disable-libpthread],
966                 [disable libpthread]),
967         [], [enable_libpthread="yes"])
968 AC_MSG_RESULT([$enable_libpthread])
969
970 PTHREAD_LIBS=""
971 AS_IF([test "x$enable_libpthread" = xyes], [
972         AC_CHECK_LIB([pthread], [pthread_create], [
973                 PTHREAD_LIBS="-lpthread"
974                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
975                         [use libpthread for libcfs library])
976         ])
977 ], [
978         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
979 ])
980 AC_SUBST(PTHREAD_LIBS)
981 ]) # LIBCFS_CONFIGURE
982
983 #
984 # LIBCFS_CONDITIONALS
985 #
986 AC_DEFUN([LIBCFS_CONDITIONALS], [
987 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
988 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
989 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
990 ]) # LIBCFS_CONDITIONALS
991
992 #
993 # LIBCFS_CONFIG_FILES
994 #
995 # files that should be generated with AC_OUTPUT
996 #
997 AC_DEFUN([LIBCFS_CONFIG_FILES], [
998 AC_CONFIG_FILES([
999 libcfs/Makefile
1000 libcfs/autoMakefile
1001 libcfs/autoconf/Makefile
1002 libcfs/include/Makefile
1003 libcfs/include/libcfs/Makefile
1004 libcfs/include/libcfs/linux/Makefile
1005 libcfs/include/libcfs/util/Makefile
1006 libcfs/libcfs/Makefile
1007 libcfs/libcfs/autoMakefile
1008 libcfs/libcfs/linux/Makefile
1009 libcfs/libcfs/util/Makefile
1010 ])
1011 ]) # LIBCFS_CONFIG_FILES