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