Whamcloud - gitweb
LU-9325 obd: replace lprocfs_str_to_s64
[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.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
692 # introduced kstrtobool and kstrtobool_from_user.
693 #
694 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
695 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
696 kstrtobool_from_user, [
697         #include <linux/kernel.h>
698 ],[
699         bool result;
700         return kstrtobool_from_user(NULL, 0, &result);
701 ],[
702         AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
703                 [kernel has kstrtobool_from_user])
704 ])
705 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
706
707 #
708 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
709 # added crypto hash helpers
710 #
711 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
712 LB_CHECK_COMPILE([does crypto hash helper functions exist],
713 crypto_hash_helpers, [
714         #include <crypto/hash.h>
715 ],[
716         crypto_ahash_alg_name(NULL);
717         crypto_ahash_driver_name(NULL);
718 ],[
719         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
720                 [crypto hash helper functions are available])
721 ])
722 ]) # LIBCFS_CRYPTO_HASH_HELPERS
723
724 #
725 # Kernerl version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
726 # made kset_find_obj() exportable to modules
727 #
728 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
729 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
730         [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
731                 [kset_find_obj is exported by the kernel])])
732 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
733
734 #
735 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
736 #
737 # linux 4.6 kernel changed stacktrace_ops address to return an int
738 #
739 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
740 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
741 stacktrace_ops_address_return_int, [
742         #include <asm/stacktrace.h>
743 ],[
744         int rc;
745
746         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
747 ],[
748         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
749                 ['struct stacktrace_ops' address function returns an int])
750 ])
751 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
752
753 #
754 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
755 # arguments to get_user_pages
756 #
757 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
758 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
759 get_user_pages_6arg, [
760         #include <linux/mm.h>
761 ],[
762         int rc;
763
764         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
765 ],[
766         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
767                 [get_user_pages takes 6 arguments])
768 ])
769 ]) # LIBCFS_GET_USER_PAGES_6ARG
770
771 #
772 # LIBCFS_STACKTRACE_OPS
773 #
774 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
775 # removed both struct stacktrace_ops and dump_trace() function
776 #
777 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
778 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
779 stacktrace_ops, [
780         struct task_struct;
781         struct pt_regs;
782         #include <asm/stacktrace.h>
783 ],[
784         struct stacktrace_ops ops;
785         ops.stack = NULL;
786 ],[
787         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
788                 [struct stacktrace_ops exists])
789 ])
790 ]) # LIBCFS_STACKTRACE_OPS
791
792 #
793 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
794 # mm: replace get_user_pages() write/force parameters with gup_flags
795 #
796 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
797 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
798 get_user_pages_gup_flags, [
799         #include <linux/mm.h>
800 ],[
801         int rc;
802         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
803 ],[
804         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
805                 [get_user_pages takes gup_flags in arguments])
806 ])
807 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
808
809 #
810 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
811 # libcfs: Convert to hotplug state machine
812 #
813 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
814 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
815 cpu_hotplug_state_machine, [
816         #include <linux/cpuhotplug.h>
817 ],[
818         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
819 ],[
820         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
821                 [hotplug state machine is supported])
822 ])
823 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
824
825 #
826 # LIBCFS_SCHED_HEADERS
827 #
828 # 4.11 has broken up sched.h into more headers.
829 #
830 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
831 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
832         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
833                 [linux/sched header directory exist])])
834 ]) # LIBCFS_SCHED_HEADERS
835
836 #
837 # LIBCFS_WAIT_QUEUE_ENTRY
838 #
839 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
840 # Rename wait_queue_t => wait_queue_entry_t
841 #
842 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
843 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
844 wait_queue_entry, [
845         #include <linux/wait.h>
846 ],[
847         wait_queue_entry_t e;
848 ],[
849         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
850                 ['wait_queue_entry_t' is available])
851 ])
852 ]) # LIBCFS_WAIT_QUEUE_ENTRY
853
854 #
855 # LIBCFS_PROG_LINUX
856 #
857 # LibCFS linux kernel checks
858 #
859 AC_DEFUN([LIBCFS_PROG_LINUX], [
860 AC_MSG_NOTICE([LibCFS kernel checks
861 ==============================================================================])
862 LIBCFS_CONFIG_PANIC_DUMPLOG
863
864 # 2.6.32
865 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
866 LC_SHRINKER_WANT_SHRINK_PTR
867 # 2.6.33
868 LIBCFS_SYSCTL_CTLNAME
869 # 2.6.36
870 LIBCFS_MODULE_LOCKING
871 # 2.6.38
872 LIBCFS_KSTRTOUL
873 # 2.6.39
874 LIBCFS_DUMP_TRACE_ADDRESS
875 # 2.6.40 fc15
876 LC_SHRINK_CONTROL
877 # 3.0
878 LIBCFS_STACKTRACE_WARNING
879 LIBCFS_REINIT_COMPLETION
880 # 3.5
881 LIBCFS_PROCESS_NAMESPACE
882 LIBCFS_I_UID_READ
883 # 3.7
884 LIBCFS_SOCK_ALLOC_FILE
885 # 3.8
886 LIBCFS_HAVE_CRC32
887 LIBCFS_ENABLE_CRC32_ACCEL
888 # 3.10
889 LIBCFS_ENABLE_CRC32C_ACCEL
890 # 3.11
891 LIBCFS_KTIME_GET_TS64
892 # 3.12
893 LIBCFS_KERNEL_PARAM_OPS
894 LIBCFS_KTIME_ADD
895 LIBCFS_KTIME_AFTER
896 LIBCFS_KTIME_BEFORE
897 LIBCFS_KTIME_COMPARE
898 LIBCFS_SHRINKER_COUNT
899 # 3.17
900 LIBCFS_HLIST_ADD_AFTER
901 LIBCFS_TIMESPEC64
902 LIBCFS_KTIME_GET_NS
903 LIBCFS_KTIME_GET_REAL_TS64
904 LIBCFS_KTIME_GET_REAL_SECONDS
905 LIBCFS_KTIME_GET_REAL_NS
906 LIBCFS_KTIME_TO_TIMESPEC64
907 LIBCFS_TIMESPEC64_SUB
908 LIBCFS_TIMESPEC64_TO_KTIME
909 # 3.19
910 LIBCFS_KTIME_GET_SECONDS
911 LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
912 # 4.0
913 LIBCFS_KTIME_MS_DELTA
914 # 4.1
915 LIBCFS_KERNEL_PARAM_LOCK
916 # 4.2
917 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
918 LIBCFS_FPU_API
919 # 4.4
920 LIBCFS_KSTRTOBOOL_FROM_USER
921 # 4.5
922 LIBCFS_CRYPTO_HASH_HELPERS
923 LIBCFS_EXPORT_KSET_FIND_OBJ
924 # 4.6
925 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
926 LIBCFS_GET_USER_PAGES_6ARG
927 # 4.8
928 LIBCFS_STACKTRACE_OPS
929 # 4.9
930 LIBCFS_GET_USER_PAGES_GUP_FLAGS
931 # 4.10
932 LIBCFS_HOTPLUG_STATE_MACHINE
933 # 4.11
934 LIBCFS_SCHED_HEADERS
935 # 4.13
936 LIBCFS_WAIT_QUEUE_ENTRY
937 ]) # LIBCFS_PROG_LINUX
938
939 #
940 # LIBCFS_PATH_DEFAULTS
941 #
942 # default paths for installed files
943 #
944 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
945 ]) # LIBCFS_PATH_DEFAULTS
946
947 #
948 # LIBCFS_CONFIGURE
949 #
950 # other configure checks
951 #
952 AC_DEFUN([LIBCFS_CONFIGURE], [
953 AC_MSG_NOTICE([LibCFS core checks
954 ==============================================================================])
955
956 # libcfs/libcfs/util/nidstrings.c
957 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
958 AC_CHECK_FUNCS([gethostbyname])
959
960 # --------  Check for required packages  --------------
961
962 AC_MSG_NOTICE([LibCFS required packages checks
963 ==============================================================================])
964
965 AC_MSG_CHECKING([whether to enable readline support])
966 AC_ARG_ENABLE(readline,
967         AC_HELP_STRING([--disable-readline],
968                 [disable readline support]),
969         [], [enable_readline="yes"])
970 AC_MSG_RESULT([$enable_readline])
971
972 LIBREADLINE=""
973 AS_IF([test "x$enable_readline" = xyes], [
974         AC_CHECK_LIB([readline], [readline], [
975                 LIBREADLINE="-lreadline"
976                 AC_DEFINE(HAVE_LIBREADLINE, 1,
977                         [readline library is available])
978         ])
979 ])
980 AC_SUBST(LIBREADLINE)
981
982 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
983 AC_ARG_ENABLE([libpthread],
984         AC_HELP_STRING([--disable-libpthread],
985                 [disable libpthread]),
986         [], [enable_libpthread="yes"])
987 AC_MSG_RESULT([$enable_libpthread])
988
989 PTHREAD_LIBS=""
990 AS_IF([test "x$enable_libpthread" = xyes], [
991         AC_CHECK_LIB([pthread], [pthread_create], [
992                 PTHREAD_LIBS="-lpthread"
993                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
994                         [use libpthread for libcfs library])
995         ])
996 ], [
997         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
998 ])
999 AC_SUBST(PTHREAD_LIBS)
1000 ]) # LIBCFS_CONFIGURE
1001
1002 #
1003 # LIBCFS_CONDITIONALS
1004 #
1005 AC_DEFUN([LIBCFS_CONDITIONALS], [
1006 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
1007 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
1008 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
1009 ]) # LIBCFS_CONDITIONALS
1010
1011 #
1012 # LIBCFS_CONFIG_FILES
1013 #
1014 # files that should be generated with AC_OUTPUT
1015 #
1016 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1017 AC_CONFIG_FILES([
1018 libcfs/Makefile
1019 libcfs/autoMakefile
1020 libcfs/autoconf/Makefile
1021 libcfs/include/Makefile
1022 libcfs/include/libcfs/Makefile
1023 libcfs/include/libcfs/linux/Makefile
1024 libcfs/include/libcfs/util/Makefile
1025 libcfs/libcfs/Makefile
1026 libcfs/libcfs/autoMakefile
1027 libcfs/libcfs/linux/Makefile
1028 libcfs/libcfs/util/Makefile
1029 ])
1030 ]) # LIBCFS_CONFIG_FILES