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