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