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