Whamcloud - gitweb
1e6f326b40d11b30de2db5f0beff0e2ce1659424
[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_KSTRTOUL
141 #
142 # 2.6.38 kstrtoul is added
143 #
144 AC_DEFUN([LIBCFS_KSTRTOUL], [
145 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
146 kstrtoul, [
147         #include <linux/kernel.h>
148 ],[
149         unsigned long result;
150         return kstrtoul("12345", 0, &result);
151 ],[
152         AC_DEFINE(HAVE_KSTRTOUL, 1,
153                 [kernel has kstrtoul])
154 ])
155 ]) # LIBCFS_KSTRTOUL
156
157 #
158 # LIBCFS_DUMP_TRACE_ADDRESS
159 #
160 # 2.6.39 adds a base pointer address argument to dump_trace
161 #
162 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
163 LB_CHECK_COMPILE([if 'dump_trace' want address],
164 dump_trace_address, [
165         struct task_struct;
166         struct pt_regs;
167         #include <asm/stacktrace.h>
168 ],[
169         dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
170 ],[
171         AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
172                 [dump_trace want address argument])
173 ])
174 ]) # LIBCFS_DUMP_TRACE_ADDRESS
175
176 #
177 # LC_SHRINK_CONTROL
178 #
179 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
180 # pressure shrinker from Linux 3.0
181 #
182 AC_DEFUN([LC_SHRINK_CONTROL], [
183 LB_CHECK_COMPILE([if 'shrink_control' is present],
184 shrink_control, [
185         #include <linux/atomic.h>
186         #include <linux/mm.h>
187 ],[
188         struct shrink_control tmp = {0};
189         tmp.nr_to_scan = sizeof(tmp);
190 ],[
191         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
192                 [shrink_control is present])
193 ])
194 ]) # LC_SHRINK_CONTROL
195
196 #
197 # LIBCFS_PROCESS_NAMESPACE
198 #
199 # 3.5 introduced process namespace
200 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
201 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
202         AC_DEFINE(HAVE_UIDGID_HEADER, 1,
203                 [uidgid.h is present])])
204 ]) # LIBCFS_PROCESS_NAMESPACE
205
206 #
207 # LIBCFS_I_UID_READ
208 #
209 # 3.5 added helpers to read the new uid/gid types from VFS structures
210 # SLE11 SP3 has uidgid.h but not the helpers
211 #
212 AC_DEFUN([LIBCFS_I_UID_READ], [
213 LB_CHECK_COMPILE([if 'i_uid_read' is present],
214 i_uid_read, [
215         #include <linux/fs.h>
216 ],[
217         i_uid_read(NULL);
218 ],[
219         AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
220 ])
221 ]) # LIBCFS_I_UID_READ
222
223 #
224 # LIBCFS_SOCK_ALLOC_FILE
225 #
226 # FC18 3.7.2-201 unexport sock_map_fd() change to
227 # use sock_alloc_file().
228 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
229 #
230 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE], [
231 LB_CHECK_EXPORT([sock_alloc_file], [net/socket.c], [
232         LB_CHECK_COMPILE([if 'sock_alloc_file' takes 3 arguments],
233         sock_alloc_file_3args, [
234                 #include <linux/net.h>
235         ],[
236                 sock_alloc_file(NULL, 0, NULL);
237         ],[
238                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
239                         [sock_alloc_file takes 3 arguments])
240         ],[
241                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
242                         [sock_alloc_file is exported])
243         ])
244 ])
245 ]) # LIBCFS_SOCK_ALLOC_FILE
246
247 #
248 # LIBCFS_HAVE_CRC32
249 #
250 AC_DEFUN([LIBCFS_HAVE_CRC32], [
251 LB_CHECK_CONFIG_IM([CRC32],
252         [have_crc32="yes"], [have_crc32="no"])
253 AS_IF([test "x$have_crc32" = xyes],
254         [AC_DEFINE(HAVE_CRC32, 1,
255                 [kernel compiled with CRC32 functions])])
256 ]) # LIBCFS_HAVE_CRC32
257
258 #
259 # LIBCFS_ENABLE_CRC32_ACCEL
260 #
261 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
262 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
263         [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
264 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
265         AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
266         AC_MSG_WARN([No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32])])
267 ]) # LIBCFS_ENABLE_CRC32_ACCEL
268
269 #
270 # LIBCFS_ENABLE_CRC32C_ACCEL
271 #
272 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
273 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
274         [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
275 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
276         AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
277         AC_MSG_WARN([No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c])])
278 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
279
280 #
281 # Kernel version 3.11 introduced ktime_get_ts64
282 #
283 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
284 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
285 ktime_get_ts64, [
286         #include <linux/ktime.h>
287 ],[
288         struct timespec64 *ts = NULL;
289
290         ktime_get_ts64(ts);
291 ],[
292         AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
293                 ['ktime_get_ts64' is available])
294 ])
295 ]) # LIBCFS_KTIME_GET_TS64
296
297 #
298 # Kernel version 3.12 introduced ktime_add
299 #
300 AC_DEFUN([LIBCFS_KTIME_ADD],[
301 LB_CHECK_COMPILE([does function 'ktime_add' exist],
302 ktime_add, [
303         #include <linux/ktime.h>
304 ],[
305         ktime_t start = ktime_set(0, 0);
306         ktime_t end = start;
307         ktime_t total;
308
309         total = ktime_add(start, end);
310 ],[
311         AC_DEFINE(HAVE_KTIME_ADD, 1,
312                 [ktime_add is available])
313 ])
314 ]) # LIBCFS_KTIME_ADD
315
316 #
317 # Kernel version 3.12 introduced ktime_after
318 #
319 AC_DEFUN([LIBCFS_KTIME_AFTER],[
320 LB_CHECK_COMPILE([does function 'ktime_after' exist],
321 ktime_after, [
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 # FC19 3.12 kernel struct shrinker change
336 #
337 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
338 LB_CHECK_COMPILE([shrinker has 'count_objects'],
339 shrinker_count_objects, [
340         #include <linux/mmzone.h>
341         #include <linux/shrinker.h>
342 ],[
343         ((struct shrinker*)0)->count_objects(NULL, NULL);
344 ],[
345         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
346                 [shrinker has count_objects member])
347 ])
348 ]) # LIBCFS_SHRINKER_COUNT
349
350 #
351 # Kernel version 3.17 changed hlist_add_after to
352 # hlist_add_behind
353 #
354 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
355 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
356 hlist_add_after, [
357         #include <linux/list.h>
358 ],[
359         hlist_add_after(NULL, NULL);
360 ],[
361         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
362                 [hlist_add_after is available])
363 ])
364 ]) # LIBCFS_HLIST_ADD_AFTER
365
366 #
367 # Kernel version 3.17 introduced struct timespec64
368 #
369 AC_DEFUN([LIBCFS_TIMESPEC64],[
370 LB_CHECK_COMPILE([does 'struct timespec64' exist],
371 timespec64, [
372         #include <linux/time.h>
373 ],[
374         struct timespec64 ts;
375
376         ts.tv_sec = 0;
377         ts.tv_nsec = 0;
378 ],[
379         AC_DEFINE(HAVE_TIMESPEC64, 1,
380                 ['struct timespec64' is available])
381 ])
382 ]) # LIBCFS_TIMESPEC64
383
384 #
385 # Kernel version 3.17 introduced ktime_get_real_ts64
386 #
387 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
388 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
389 ktime_get_real_ts64, [
390         #include <linux/ktime.h>
391 ],[
392         struct timespec64 *ts = NULL;
393
394         ktime_get_real_ts64(ts);
395 ],[
396         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
397                 ['ktime_get_real_ts64' is available])
398 ])
399 ]) # LIBCFS_KTIME_GET_REAL_TS64
400
401 #
402 # Kernel version 3.17 introduced ktime_get_real_seconds
403 #
404 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
405 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
406 ktime_get_real_seconds, [
407         #include <linux/ktime.h>
408 ],[
409         time64_t now;
410
411         now = ktime_get_real_seconds();
412 ],[
413         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
414                 ['ktime_get_real_seconds' is available])
415 ])
416 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
417
418 #
419 # Kernel version 3.17 created ktime_get_real_ns wrapper
420 #
421 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
422 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
423 ktime_get_real_ns, [
424         #include <linux/ktime.h>
425 ],[
426         u64 nanoseconds;
427
428         nanoseconds = ktime_get_real_ns();
429 ],[],[
430         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
431                 ['ktime_get_real_ns' is not available])
432 ])
433 ]) # LIBCFS_KTIME_GET_REAL_NS
434
435 #
436 # Kernel version 3.17 introduced ktime_to_timespec64
437 #
438 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
439 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
440 ktime_to_timespec64, [
441         #include <linux/ktime.h>
442 ],[
443         struct timespec64 ts;
444         ktime_t now;
445
446         ts = ktime_to_timespec64(now);
447 ],[
448         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
449                 ['ktime_to_timespec64' is available])
450 ])
451 ]) # LIBCFS_KTIME_TO_TIMESPEC64
452
453 #
454 # Kernel version 3.17 introduced timespec64_sub
455 #
456 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
457 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
458 timespec64_sub, [
459         #include <linux/time.h>
460 ],[
461         struct timespec64 later,earlier,diff;
462
463         diff = timespec64_sub(later, earlier);
464 ],[
465         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
466                 ['timespec64_sub' is available])
467 ])
468 ]) # LIBCFS_TIMESPEC64_SUB
469
470 #
471 # Kernel version 3.17 introduced timespec64_to_ktime
472 #
473 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
474 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
475 timespec64_to_ktime, [
476         #include <linux/ktime.h>
477 ],[
478         struct timespec64 ts;
479         ktime_t now;
480
481         now = timespec64_to_ktime(ts);
482 ],[
483         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
484                 ['timespec64_to_ktime' is available])
485 ])
486 ]) # LIBCFS_TIMESPEC64_TO_KTIME
487
488 #
489 # Kernel version 3.19 introduced ktime_get_seconds
490 #
491 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
492 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
493 ktime_get_seconds, [
494         #include <linux/ktime.h>
495 ],[
496         time64_t now;
497
498         now = ktime_get_seconds();
499 ],[
500         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
501                 ['ktime_get_seconds' is available])
502 ])
503 ]) # LIBCFS_KTIME_GET_SECONDS
504
505 #
506 # Kernel version 3.19 commit 5aaba36318e5995e8c95d077a46d9a4d00fcc1cd
507 # This patch creates a new helper function cpumap_print_to_pagebuf in
508 # cpumask.h using newly added bitmap_print_to_pagebuf and consolidates
509 # most of those sysfs functions using the new helper function.
510 #
511 AC_DEFUN([LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF],[
512 LB_CHECK_COMPILE([does function 'cpumap_print_to_pagebuf' exist],
513 cpumap_print_to_pagebuf, [
514         #include <linux/topology.h>
515 ],[
516         int n;
517         char *buf = NULL;
518         const struct cpumask *mask = NULL;
519         n = cpumap_print_to_pagebuf(true, buf, mask);
520 ],[
521         AC_DEFINE(HAVE_CPUMASK_PRINT_TO_PAGEBUF, 1,
522                 [cpumap_print_to_pagebuf is available])
523 ])
524 ]) # LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
525
526 #
527 # Kernel version 4.2 changed topology_thread_cpumask
528 # to topology_sibling_cpumask
529 #
530 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
531 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
532 topology_sibling_cpumask, [
533         #include <linux/topology.h>
534 ],[
535         const struct cpumask *mask;
536
537         mask = topology_sibling_cpumask(0);
538 ],[
539         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
540                 [topology_sibling_cpumask is available])
541 ])
542 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
543
544 #
545 # Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
546 # header file i387.h was renamed to fpu/api.h
547 #
548 AC_DEFUN([LIBCFS_FPU_API], [
549 LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
550         AC_DEFINE(HAVE_FPU_API_HEADER, 1,
551                 [fpu/api.h is present])])
552 ]) # LIBCFS_FPU_API
553
554 #
555 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
556 # added crypto hash helpers
557 #
558 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
559 LB_CHECK_COMPILE([does crypto hash helper functions exist],
560 crypto_hash_helpers, [
561         #include <crypto/hash.h>
562 ],[
563         crypto_ahash_alg_name(NULL);
564         crypto_ahash_driver_name(NULL);
565 ],[
566         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
567                 [crypto hash helper functions are available])
568 ])
569 ]) # LIBCFS_CRYPTO_HASH_HELPERS
570
571 #
572 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
573 #
574 # linux 4.6 kernel changed stacktrace_ops address to return an int
575 #
576 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
577 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
578 stacktrace_ops_address_return_int, [
579         #include <asm/stacktrace.h>
580 ],[
581         int rc;
582
583         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
584 ],[
585         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
586                 ['struct stacktrace_ops' address function returns an int])
587 ])
588 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
589
590 #
591 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
592 # arguments to get_user_pages
593 #
594 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
595 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
596 get_user_pages_6arg, [
597         #include <linux/mm.h>
598 ],[
599         int rc;
600
601         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
602 ],[
603         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
604                 [get_user_pages takes 6 arguments])
605 ])
606 ]) # LIBCFS_GET_USER_PAGES_6ARG
607
608 #
609 # LIBCFS_STACKTRACE_OPS
610 #
611 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
612 # removed both struct stacktrace_ops and dump_trace() function
613 #
614 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
615 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
616 stacktrace_ops, [
617         struct task_struct;
618         struct pt_regs;
619         #include <asm/stacktrace.h>
620 ],[
621         struct stacktrace_ops ops;
622         ops.stack = NULL;
623 ],[
624         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
625                 [struct stacktrace_ops exists])
626 ])
627 ]) # LIBCFS_STACKTRACE_OPS
628
629 #
630 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
631 # mm: replace get_user_pages() write/force parameters with gup_flags
632 #
633 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
634 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
635 get_user_pages_gup_flags, [
636         #include <linux/mm.h>
637 ],[
638         int rc;
639         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
640 ],[
641         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
642                 [get_user_pages takes gup_flags in arguments])
643 ])
644 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
645
646 #
647 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
648 # libcfs: Convert to hotplug state machine
649 #
650 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
651 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
652 cpu_hotplug_state_machine, [
653         #include <linux/cpuhotplug.h>
654 ],[
655         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
656 ],[
657         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
658                 [hotplug state machine is supported])
659 ])
660 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
661
662 #
663 # LIBCFS_SCHED_HEADERS
664 #
665 # 4.11 has broken up sched.h into more headers.
666 #
667 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
668 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
669         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
670                 [linux/sched header directory exist])])
671 ]) # LIBCFS_SCHED_HEADERS
672
673 #
674 # LIBCFS_PROG_LINUX
675 #
676 # LibCFS linux kernel checks
677 #
678 AC_DEFUN([LIBCFS_PROG_LINUX], [
679 AC_MSG_NOTICE([LibCFS kernel checks
680 ==============================================================================])
681 LIBCFS_CONFIG_PANIC_DUMPLOG
682
683 # 2.6.32
684 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
685 LC_SHRINKER_WANT_SHRINK_PTR
686 # 2.6.33
687 LIBCFS_SYSCTL_CTLNAME
688 # 2.6.38
689 LIBCFS_KSTRTOUL
690 # 2.6.39
691 LIBCFS_DUMP_TRACE_ADDRESS
692 # 2.6.40 fc15
693 LC_SHRINK_CONTROL
694 # 3.0
695 LIBCFS_STACKTRACE_WARNING
696 LIBCFS_REINIT_COMPLETION
697 # 3.5
698 LIBCFS_PROCESS_NAMESPACE
699 LIBCFS_I_UID_READ
700 # 3.7
701 LIBCFS_SOCK_ALLOC_FILE
702 # 3.8
703 LIBCFS_HAVE_CRC32
704 LIBCFS_ENABLE_CRC32_ACCEL
705 # 3.10
706 LIBCFS_ENABLE_CRC32C_ACCEL
707 # 3.11
708 LIBCFS_KTIME_GET_TS64
709 # 3.12
710 LIBCFS_KTIME_ADD
711 LIBCFS_KTIME_AFTER
712 LIBCFS_SHRINKER_COUNT
713 # 3.17
714 LIBCFS_HLIST_ADD_AFTER
715 LIBCFS_TIMESPEC64
716 LIBCFS_KTIME_GET_REAL_TS64
717 LIBCFS_KTIME_GET_REAL_SECONDS
718 LIBCFS_KTIME_GET_REAL_NS
719 LIBCFS_KTIME_TO_TIMESPEC64
720 LIBCFS_TIMESPEC64_SUB
721 LIBCFS_TIMESPEC64_TO_KTIME
722 # 3.19
723 LIBCFS_KTIME_GET_SECONDS
724 LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
725 # 4.2
726 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
727 LIBCFS_FPU_API
728 # 4.5
729 LIBCFS_CRYPTO_HASH_HELPERS
730 # 4.6
731 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
732 LIBCFS_GET_USER_PAGES_6ARG
733 # 4.8
734 LIBCFS_STACKTRACE_OPS
735 # 4.9
736 LIBCFS_GET_USER_PAGES_GUP_FLAGS
737 # 4.10
738 LIBCFS_HOTPLUG_STATE_MACHINE
739 # 4.11
740 LIBCFS_SCHED_HEADERS
741 ]) # LIBCFS_PROG_LINUX
742
743 #
744 # LIBCFS_PATH_DEFAULTS
745 #
746 # default paths for installed files
747 #
748 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
749 ]) # LIBCFS_PATH_DEFAULTS
750
751 #
752 # LIBCFS_CONFIGURE
753 #
754 # other configure checks
755 #
756 AC_DEFUN([LIBCFS_CONFIGURE], [
757 AC_MSG_NOTICE([LibCFS core checks
758 ==============================================================================])
759
760 # lnet/utils/portals.c
761 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
762
763 # lnet/utils/debug.c
764 AC_CHECK_HEADERS([linux/version.h])
765
766 AC_CHECK_TYPE([spinlock_t],
767         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
768         [],
769         [#include <linux/spinlock.h>])
770
771 # lnet/utils/wirecheck.c
772 AC_CHECK_FUNCS([strnlen])
773
774 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
775 AC_CHECK_FUNCS([strlcpy])
776
777 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
778 AC_CHECK_FUNCS([strlcat])
779
780 # libcfs/include/libcfs/linux/linux-prim.h, ...
781 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
782
783 # libcfs/include/libcfs/linux/linux-prim.h
784 AC_CHECK_HEADERS([linux/random.h], [], [],
785                  [#ifdef HAVE_LINUX_TYPES_H
786                   #include <linux/types.h>
787                   #endif
788                  ])
789
790 # libcfs/include/libcfs/linux/libcfs.h
791 # libcfs/include/libcfs/byteorder.h
792 # libcfs/libcfs/util/nidstrings.c
793 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
794 AC_CHECK_FUNCS([gethostbyname])
795
796 # --------  Check for required packages  --------------
797
798 AC_MSG_NOTICE([LibCFS required packages checks
799 ==============================================================================])
800
801 AC_MSG_CHECKING([whether to enable readline support])
802 AC_ARG_ENABLE(readline,
803         AC_HELP_STRING([--disable-readline],
804                 [disable readline support]),
805         [], [enable_readline="yes"])
806 AC_MSG_RESULT([$enable_readline])
807
808 LIBREADLINE=""
809 AS_IF([test "x$enable_readline" = xyes], [
810         AC_CHECK_LIB([readline], [readline], [
811                 LIBREADLINE="-lreadline"
812                 AC_DEFINE(HAVE_LIBREADLINE, 1,
813                         [readline library is available])
814         ])
815 ])
816 AC_SUBST(LIBREADLINE)
817
818 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
819 AC_ARG_ENABLE([libpthread],
820         AC_HELP_STRING([--disable-libpthread],
821                 [disable libpthread]),
822         [], [enable_libpthread="yes"])
823 AC_MSG_RESULT([$enable_libpthread])
824
825 PTHREAD_LIBS=""
826 AS_IF([test "x$enable_libpthread" = xyes], [
827         AC_CHECK_LIB([pthread], [pthread_create], [
828                 PTHREAD_LIBS="-lpthread"
829                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
830                         [use libpthread for libcfs library])
831         ])
832 ], [
833         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
834 ])
835 AC_SUBST(PTHREAD_LIBS)
836 ]) # LIBCFS_CONFIGURE
837
838 #
839 # LIBCFS_CONDITIONALS
840 #
841 AC_DEFUN([LIBCFS_CONDITIONALS], [
842 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
843 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
844 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
845 ]) # LIBCFS_CONDITIONALS
846
847 #
848 # LIBCFS_CONFIG_FILES
849 #
850 # files that should be generated with AC_OUTPUT
851 #
852 AC_DEFUN([LIBCFS_CONFIG_FILES], [
853 AC_CONFIG_FILES([
854 libcfs/Makefile
855 libcfs/autoMakefile
856 libcfs/autoconf/Makefile
857 libcfs/include/Makefile
858 libcfs/include/libcfs/Makefile
859 libcfs/include/libcfs/linux/Makefile
860 libcfs/include/libcfs/util/Makefile
861 libcfs/libcfs/Makefile
862 libcfs/libcfs/autoMakefile
863 libcfs/libcfs/linux/Makefile
864 libcfs/libcfs/util/Makefile
865 ])
866 ]) # LIBCFS_CONFIG_FILES