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