Whamcloud - gitweb
LU-9019 sec: migrate to 64 bit time
[fs/lustre-release.git] / libcfs / autoconf / lustre-libcfs.m4
1 #
2 # LIBCFS_CONFIG_CDEBUG
3 #
4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
5 #
6 AC_DEFUN([LIBCFS_CONFIG_CDEBUG], [
7 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
8 AC_ARG_ENABLE([libcfs_cdebug],
9         AC_HELP_STRING([--disable-libcfs-cdebug],
10                 [disable libcfs CDEBUG, CWARN]),
11         [], [enable_libcfs_cdebug="yes"])
12 AC_MSG_RESULT([$enable_libcfs_cdebug])
13 AS_IF([test "x$enable_libcfs_cdebug" = xyes],
14         [AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])])
15
16 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
17 AC_ARG_ENABLE([libcfs_trace],
18         AC_HELP_STRING([--disable-libcfs-trace],
19                 [disable libcfs ENTRY/EXIT]),
20         [], [enable_libcfs_trace="yes"])
21 AC_MSG_RESULT([$enable_libcfs_trace])
22 AS_IF([test "x$enable_libcfs_trace" = xyes],
23         [AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])])
24
25 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
26 AC_ARG_ENABLE([libcfs_assert],
27         AC_HELP_STRING([--disable-libcfs-assert],
28                 [disable libcfs LASSERT, LASSERTF]),
29         [], [enable_libcfs_assert="yes"])
30 AC_MSG_RESULT([$enable_libcfs_assert])
31 AS_IF([test x$enable_libcfs_assert = xyes],
32         [AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])])
33 ]) # LIBCFS_CONFIG_CDEBUG
34
35 #
36 # LIBCFS_CONFIG_PANIC_DUMPLOG
37 #
38 # check if tunable panic_dumplog is wanted
39 #
40 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG], [
41 AC_MSG_CHECKING([whether to use tunable 'panic_dumplog' support])
42 AC_ARG_ENABLE([panic_dumplog],
43         AC_HELP_STRING([--enable-panic_dumplog],
44                 [enable panic_dumplog]),
45         [], [enable_panic_dumplog="no"])
46 AC_MSG_RESULT([$enable_panic_dumplog])
47 AS_IF([test "x$enable_panic_dumplog" = xyes],
48         [AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])])
49 ]) # LIBCFS_CONFIG_PANIC_DUMPLOG
50
51 #
52 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
53 #
54 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
55 #
56 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK], [
57 LB_CHECK_COMPILE([if 'struct stacktrace_ops' has 'walk_stack' field],
58 stacktrace_ops_walk_stack, [
59         #include <asm/stacktrace.h>
60 ],[
61         ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
62 ],[
63         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1,
64                 ['struct stacktrace_ops' has 'walk_stack' field])
65 ])
66 ]) # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
67
68 #
69 # LIBCFS_STACKTRACE_WARNING
70 #
71 # 3.0 removes stacktrace_ops warning* functions
72 #
73 AC_DEFUN([LIBCFS_STACKTRACE_WARNING], [
74 LB_CHECK_COMPILE([if 'stacktrace_ops.warning' is exist],
75 stacktrace_ops_warning, [
76         struct task_struct;
77         struct pt_regs;
78         #include <asm/stacktrace.h>
79 ],[
80         ((struct stacktrace_ops *)0)->warning(NULL, NULL);
81 ],[
82         AC_DEFINE(HAVE_STACKTRACE_WARNING, 1,
83                 [stacktrace_ops.warning is exist])
84 ])
85 ]) # LIBCFS_STACKTRACE_WARNING
86
87 #
88 # LIBCFS_REINIT_COMPLETION
89 #
90 AC_DEFUN([LIBCFS_REINIT_COMPLETION], [
91 LB_CHECK_COMPILE([if 'reinit_completion' exists],
92 reinit_completion, [
93         #include <linux/completion.h>
94 ],[
95         struct completion x;
96         reinit_completion(&x);
97 ],[
98         AC_DEFINE(HAVE_REINIT_COMPLETION, 1,
99                 [reinit_completion is exist])
100 ])
101 ]) # LIBCFS_REINIT_COMPLETION
102
103 #
104 # LC_SHRINKER_WANT_SHRINK_PTR
105 #
106 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
107 #
108 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR], [
109 LB_CHECK_COMPILE([if 'shrinker' want self pointer in handler],
110 shrink_self_pointer, [
111         #include <linux/mm.h>
112 ],[
113         struct shrinker *tmp = NULL;
114         tmp->shrink(tmp, 0, 0);
115 ],[
116         AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
117                 [shrinker want self pointer in handler])
118 ])
119 ]) # LC_SHRINKER_WANT_SHRINK_PTR
120
121 #
122 # LIBCFS_SYSCTL_CTLNAME
123 #
124 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
125 #
126 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME], [
127 LB_CHECK_COMPILE([if 'ctl_table' has a 'ctl_name' field],
128 ctl_table_ctl_name, [
129         #include <linux/sysctl.h>
130 ],[
131         struct ctl_table ct;
132         ct.ctl_name = sizeof(ct);
133 ],[
134         AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
135                 [ctl_table has ctl_name field])
136 ])
137 ]) # LIBCFS_SYSCTL_CTLNAME
138
139 #
140 # LIBCFS_MODULE_LOCKING
141 #
142 # 2.6.36 introduced locking to module params. RHEL6 lacks this support
143 #
144 AC_DEFUN([LIBCFS_MODULE_LOCKING],[
145 LB_CHECK_COMPILE([does the kernel support module param locking],
146 module_param_locking, [
147         #include <linux/moduleparam.h>
148 ],[
149         __kernel_param_lock(NULL);
150         __kernel_param_unlock(NULL);
151 ],[
152         AC_DEFINE(HAVE_MODULE_PARAM_LOCKING, 1,
153                 [locking module param is supported])
154 ])
155 ]) # LIBCFS_MODULE_LOCKING
156
157 #
158 # LIBCFS_KSTRTOUL
159 #
160 # 2.6.38 kstrtoul is added
161 #
162 AC_DEFUN([LIBCFS_KSTRTOUL], [
163 LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
164 kstrtoul, [
165         #include <linux/kernel.h>
166 ],[
167         unsigned long result;
168         return kstrtoul("12345", 0, &result);
169 ],[
170         AC_DEFINE(HAVE_KSTRTOUL, 1,
171                 [kernel has kstrtoul])
172 ])
173 ]) # LIBCFS_KSTRTOUL
174
175 #
176 # LIBCFS_DUMP_TRACE_ADDRESS
177 #
178 # 2.6.39 adds a base pointer address argument to dump_trace
179 #
180 AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
181 LB_CHECK_COMPILE([if 'dump_trace' want address],
182 dump_trace_address, [
183         struct task_struct;
184         struct pt_regs;
185         #include <asm/stacktrace.h>
186 ],[
187         dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
188 ],[
189         AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
190                 [dump_trace want address argument])
191 ])
192 ]) # LIBCFS_DUMP_TRACE_ADDRESS
193
194 #
195 # LC_SHRINK_CONTROL
196 #
197 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
198 # pressure shrinker from Linux 3.0
199 #
200 AC_DEFUN([LC_SHRINK_CONTROL], [
201 LB_CHECK_COMPILE([if 'shrink_control' is present],
202 shrink_control, [
203         #include <linux/atomic.h>
204         #include <linux/mm.h>
205 ],[
206         struct shrink_control tmp = {0};
207         tmp.nr_to_scan = sizeof(tmp);
208 ],[
209         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
210                 [shrink_control is present])
211 ])
212 ]) # LC_SHRINK_CONTROL
213
214 #
215 # LIBCFS_PROCESS_NAMESPACE
216 #
217 # 3.5 introduced process namespace
218 AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
219 LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
220         AC_DEFINE(HAVE_UIDGID_HEADER, 1,
221                 [uidgid.h is present])])
222 ]) # LIBCFS_PROCESS_NAMESPACE
223
224 #
225 # LIBCFS_I_UID_READ
226 #
227 # 3.5 added helpers to read the new uid/gid types from VFS structures
228 # SLE11 SP3 has uidgid.h but not the helpers
229 #
230 AC_DEFUN([LIBCFS_I_UID_READ], [
231 LB_CHECK_COMPILE([if 'i_uid_read' is present],
232 i_uid_read, [
233         #include <linux/fs.h>
234 ],[
235         i_uid_read(NULL);
236 ],[
237         AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
238 ])
239 ]) # LIBCFS_I_UID_READ
240
241 #
242 # LIBCFS_SOCK_ALLOC_FILE
243 #
244 # FC18 3.7.2-201 unexport sock_map_fd() change to
245 # use sock_alloc_file().
246 # upstream commit 56b31d1c9f1e6a3ad92e7bfe252721e05d92b285
247 #
248 AC_DEFUN([LIBCFS_SOCK_ALLOC_FILE], [
249 LB_CHECK_EXPORT([sock_alloc_file], [net/socket.c], [
250         LB_CHECK_COMPILE([if 'sock_alloc_file' takes 3 arguments],
251         sock_alloc_file_3args, [
252                 #include <linux/net.h>
253         ],[
254                 sock_alloc_file(NULL, 0, NULL);
255         ],[
256                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE_3ARGS, 1,
257                         [sock_alloc_file takes 3 arguments])
258         ],[
259                 AC_DEFINE(HAVE_SOCK_ALLOC_FILE, 1,
260                         [sock_alloc_file is exported])
261         ])
262 ])
263 ]) # LIBCFS_SOCK_ALLOC_FILE
264
265 #
266 # LIBCFS_HAVE_CRC32
267 #
268 AC_DEFUN([LIBCFS_HAVE_CRC32], [
269 LB_CHECK_CONFIG_IM([CRC32],
270         [have_crc32="yes"], [have_crc32="no"])
271 AS_IF([test "x$have_crc32" = xyes],
272         [AC_DEFINE(HAVE_CRC32, 1,
273                 [kernel compiled with CRC32 functions])])
274 ]) # LIBCFS_HAVE_CRC32
275
276 #
277 # LIBCFS_ENABLE_CRC32_ACCEL
278 #
279 AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
280 LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
281         [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
282 AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
283         AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
284         AC_MSG_WARN([No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32])])
285 ]) # LIBCFS_ENABLE_CRC32_ACCEL
286
287 #
288 # LIBCFS_ENABLE_CRC32C_ACCEL
289 #
290 AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
291 LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
292         [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
293 AS_IF([test "x$enable_crc32c_crypto" = xyes], [
294         AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
295         AC_MSG_WARN([No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c])])
296 ]) # LIBCFS_ENABLE_CRC32C_ACCEL
297
298 #
299 # Kernel version 3.11 introduced ktime_get_ts64
300 #
301 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
302 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
303 ktime_get_ts64, [
304         #include <linux/ktime.h>
305 ],[
306         struct timespec64 *ts = NULL;
307
308         ktime_get_ts64(ts);
309 ],[
310         AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
311                 ['ktime_get_ts64' is available])
312 ])
313 ]) # LIBCFS_KTIME_GET_TS64
314
315 #
316 # Linux kernel 3.12 introduced struct kernel_param_ops
317 # This has been backported to all lustre supported
318 # clients expect RHEL6. We have to handle the differences.
319 #
320 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
321 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
322 kernel_param_ops, [
323         #include <linux/module.h>
324 ],[
325         struct kernel_param_ops ops;
326 ],[
327         AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
328                 ['struct kernel_param_ops' is available])
329 ])
330 ]) # LIBCFS_KERNEL_PARAM_OPS
331
332 #
333 # Kernel version 3.12 introduced ktime_add
334 #
335 AC_DEFUN([LIBCFS_KTIME_ADD],[
336 LB_CHECK_COMPILE([does function 'ktime_add' exist],
337 ktime_add, [
338         #include <linux/ktime.h>
339 ],[
340         ktime_t start = ktime_set(0, 0);
341         ktime_t end = start;
342         ktime_t total;
343
344         total = ktime_add(start, end);
345 ],[
346         AC_DEFINE(HAVE_KTIME_ADD, 1,
347                 [ktime_add is available])
348 ])
349 ]) # LIBCFS_KTIME_ADD
350
351 #
352 # Kernel version 3.12 introduced ktime_after
353 #
354 AC_DEFUN([LIBCFS_KTIME_AFTER],[
355 LB_CHECK_COMPILE([does function 'ktime_after' exist],
356 ktime_after, [
357         #include <linux/ktime.h>
358 ],[
359         ktime_t start = ktime_set(0, 0);
360         ktime_t end = start;
361
362         ktime_after(start, end);
363 ],[
364         AC_DEFINE(HAVE_KTIME_AFTER, 1,
365                 [ktime_after is available])
366 ])
367 ]) # LIBCFS_KTIME_AFTER
368
369 #
370 # Kernel version 3.12 introduced ktime_before
371 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
372 #
373 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
374 LB_CHECK_COMPILE([does function 'ktime_before' exist],
375 ktime_before, [
376         #include <linux/ktime.h>
377 ],[
378         ktime_t start = ktime_set(0, 0);
379         ktime_t end = start;
380
381         ktime_before(start, end);
382 ],[
383         AC_DEFINE(HAVE_KTIME_BEFORE, 1,
384                 [ktime_before is available])
385 ])
386 ]) # LIBCFS_KTIME_BEFORE
387
388 #
389 # FC19 3.12 kernel struct shrinker change
390 #
391 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
392 LB_CHECK_COMPILE([shrinker has 'count_objects'],
393 shrinker_count_objects, [
394         #include <linux/mmzone.h>
395         #include <linux/shrinker.h>
396 ],[
397         ((struct shrinker*)0)->count_objects(NULL, NULL);
398 ],[
399         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
400                 [shrinker has count_objects member])
401 ])
402 ]) # LIBCFS_SHRINKER_COUNT
403
404 #
405 # Kernel version 3.17 changed hlist_add_after to
406 # hlist_add_behind
407 #
408 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
409 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
410 hlist_add_after, [
411         #include <linux/list.h>
412 ],[
413         hlist_add_after(NULL, NULL);
414 ],[
415         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
416                 [hlist_add_after is available])
417 ])
418 ]) # LIBCFS_HLIST_ADD_AFTER
419
420 #
421 # Kernel version 3.17 introduced struct timespec64
422 #
423 AC_DEFUN([LIBCFS_TIMESPEC64],[
424 LB_CHECK_COMPILE([does 'struct timespec64' exist],
425 timespec64, [
426         #include <linux/time.h>
427 ],[
428         struct timespec64 ts;
429
430         ts.tv_sec = 0;
431         ts.tv_nsec = 0;
432 ],[
433         AC_DEFINE(HAVE_TIMESPEC64, 1,
434                 ['struct timespec64' is available])
435 ])
436 ]) # LIBCFS_TIMESPEC64
437
438 #
439 # Kernel version 3.17 introduced ktime_get_real_ts64
440 #
441 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
442 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
443 ktime_get_real_ts64, [
444         #include <linux/ktime.h>
445 ],[
446         struct timespec64 *ts = NULL;
447
448         ktime_get_real_ts64(ts);
449 ],[
450         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
451                 ['ktime_get_real_ts64' is available])
452 ])
453 ]) # LIBCFS_KTIME_GET_REAL_TS64
454
455 #
456 # Kernel version 3.17 introduced ktime_get_real_seconds
457 #
458 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
459 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
460 ktime_get_real_seconds, [
461         #include <linux/ktime.h>
462 ],[
463         time64_t now;
464
465         now = ktime_get_real_seconds();
466 ],[
467         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
468                 ['ktime_get_real_seconds' is available])
469 ])
470 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
471
472 #
473 # Kernel version 3.17 created ktime_get_ns wrapper
474 #
475 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
476 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
477 ktime_get_ns, [
478         #include <linux/ktime.h>
479 ],[
480         u64 nanoseconds;
481
482         nanoseconds = ktime_get_ns();
483 ],[],[
484         AC_DEFINE(NEED_KTIME_GET_NS, 1,
485                 ['ktime_get_ns' is not available])
486 ])
487 ]) # LIBCFS_KTIME_GET_NS
488
489 #
490 # Kernel version 3.17 created ktime_get_real_ns wrapper
491 #
492 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
493 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
494 ktime_get_real_ns, [
495         #include <linux/ktime.h>
496 ],[
497         u64 nanoseconds;
498
499         nanoseconds = ktime_get_real_ns();
500 ],[],[
501         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
502                 ['ktime_get_real_ns' is not available])
503 ])
504 ]) # LIBCFS_KTIME_GET_REAL_NS
505
506 #
507 # Kernel version 3.17 introduced ktime_to_timespec64
508 #
509 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
510 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
511 ktime_to_timespec64, [
512         #include <linux/ktime.h>
513 ],[
514         struct timespec64 ts;
515         ktime_t now;
516
517         ts = ktime_to_timespec64(now);
518 ],[
519         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
520                 ['ktime_to_timespec64' is available])
521 ])
522 ]) # LIBCFS_KTIME_TO_TIMESPEC64
523
524 #
525 # Kernel version 3.17 introduced timespec64_sub
526 #
527 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
528 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
529 timespec64_sub, [
530         #include <linux/time.h>
531 ],[
532         struct timespec64 later,earlier,diff;
533
534         diff = timespec64_sub(later, earlier);
535 ],[
536         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
537                 ['timespec64_sub' is available])
538 ])
539 ]) # LIBCFS_TIMESPEC64_SUB
540
541 #
542 # Kernel version 3.17 introduced timespec64_to_ktime
543 #
544 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
545 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
546 timespec64_to_ktime, [
547         #include <linux/ktime.h>
548 ],[
549         struct timespec64 ts;
550         ktime_t now;
551
552         now = timespec64_to_ktime(ts);
553 ],[
554         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
555                 ['timespec64_to_ktime' is available])
556 ])
557 ]) # LIBCFS_TIMESPEC64_TO_KTIME
558
559 #
560 # Kernel version 3.19 introduced ktime_get_seconds
561 #
562 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
563 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
564 ktime_get_seconds, [
565         #include <linux/ktime.h>
566 ],[
567         time64_t now;
568
569         now = ktime_get_seconds();
570 ],[
571         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
572                 ['ktime_get_seconds' is available])
573 ])
574 ]) # LIBCFS_KTIME_GET_SECONDS
575
576 #
577 # Kernel version 3.19 commit 5aaba36318e5995e8c95d077a46d9a4d00fcc1cd
578 # This patch creates a new helper function cpumap_print_to_pagebuf in
579 # cpumask.h using newly added bitmap_print_to_pagebuf and consolidates
580 # most of those sysfs functions using the new helper function.
581 #
582 AC_DEFUN([LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF],[
583 LB_CHECK_COMPILE([does function 'cpumap_print_to_pagebuf' exist],
584 cpumap_print_to_pagebuf, [
585         #include <linux/topology.h>
586 ],[
587         int n;
588         char *buf = NULL;
589         const struct cpumask *mask = NULL;
590         n = cpumap_print_to_pagebuf(true, buf, mask);
591 ],[
592         AC_DEFINE(HAVE_CPUMASK_PRINT_TO_PAGEBUF, 1,
593                 [cpumap_print_to_pagebuf is available])
594 ])
595 ]) # LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
596
597 #
598 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
599 # create per module locks which added kernel_param_[un]lock(). Older
600 # kernels you have to use __kernel_param_[un]lock(). In that case its
601 # a global lock for all modules but that is okay since its a rare event.
602 #
603 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
604 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
605 kernel_param_lock, [
606         #include <linux/moduleparam.h>
607 ],[
608         kernel_param_lock(NULL);
609         kernel_param_unlock(NULL);
610 ],[
611         AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
612                 ['kernel_param_[un]lock' is available])
613 ])
614 ]) # LIBCFS_KERNEL_PARAM_LOCK
615
616 #
617 # Kernel version 4.2 changed topology_thread_cpumask
618 # to topology_sibling_cpumask
619 #
620 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
621 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
622 topology_sibling_cpumask, [
623         #include <linux/topology.h>
624 ],[
625         const struct cpumask *mask;
626
627         mask = topology_sibling_cpumask(0);
628 ],[
629         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
630                 [topology_sibling_cpumask is available])
631 ])
632 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
633
634 #
635 # Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
636 # header file i387.h was renamed to fpu/api.h
637 #
638 AC_DEFUN([LIBCFS_FPU_API], [
639 LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
640         AC_DEFINE(HAVE_FPU_API_HEADER, 1,
641                 [fpu/api.h is present])])
642 ]) # LIBCFS_FPU_API
643
644 #
645 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
646 # added crypto hash helpers
647 #
648 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
649 LB_CHECK_COMPILE([does crypto hash helper functions exist],
650 crypto_hash_helpers, [
651         #include <crypto/hash.h>
652 ],[
653         crypto_ahash_alg_name(NULL);
654         crypto_ahash_driver_name(NULL);
655 ],[
656         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
657                 [crypto hash helper functions are available])
658 ])
659 ]) # LIBCFS_CRYPTO_HASH_HELPERS
660
661 #
662 # Kernerl version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
663 # made kset_find_obj() exportable to modules
664 #
665 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
666 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
667         [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
668                 [kset_find_obj is exported by the kernel])])
669 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
670
671 #
672 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
673 #
674 # linux 4.6 kernel changed stacktrace_ops address to return an int
675 #
676 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
677 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
678 stacktrace_ops_address_return_int, [
679         #include <asm/stacktrace.h>
680 ],[
681         int rc;
682
683         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
684 ],[
685         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
686                 ['struct stacktrace_ops' address function returns an int])
687 ])
688 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
689
690 #
691 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
692 # arguments to get_user_pages
693 #
694 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
695 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
696 get_user_pages_6arg, [
697         #include <linux/mm.h>
698 ],[
699         int rc;
700
701         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
702 ],[
703         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
704                 [get_user_pages takes 6 arguments])
705 ])
706 ]) # LIBCFS_GET_USER_PAGES_6ARG
707
708 #
709 # LIBCFS_STACKTRACE_OPS
710 #
711 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
712 # removed both struct stacktrace_ops and dump_trace() function
713 #
714 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
715 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
716 stacktrace_ops, [
717         struct task_struct;
718         struct pt_regs;
719         #include <asm/stacktrace.h>
720 ],[
721         struct stacktrace_ops ops;
722         ops.stack = NULL;
723 ],[
724         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
725                 [struct stacktrace_ops exists])
726 ])
727 ]) # LIBCFS_STACKTRACE_OPS
728
729 #
730 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
731 # mm: replace get_user_pages() write/force parameters with gup_flags
732 #
733 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
734 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
735 get_user_pages_gup_flags, [
736         #include <linux/mm.h>
737 ],[
738         int rc;
739         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
740 ],[
741         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
742                 [get_user_pages takes gup_flags in arguments])
743 ])
744 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
745
746 #
747 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
748 # libcfs: Convert to hotplug state machine
749 #
750 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
751 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
752 cpu_hotplug_state_machine, [
753         #include <linux/cpuhotplug.h>
754 ],[
755         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
756 ],[
757         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
758                 [hotplug state machine is supported])
759 ])
760 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
761
762 #
763 # LIBCFS_SCHED_HEADERS
764 #
765 # 4.11 has broken up sched.h into more headers.
766 #
767 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
768 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
769         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
770                 [linux/sched header directory exist])])
771 ]) # LIBCFS_SCHED_HEADERS
772
773 #
774 # LIBCFS_PROG_LINUX
775 #
776 # LibCFS linux kernel checks
777 #
778 AC_DEFUN([LIBCFS_PROG_LINUX], [
779 AC_MSG_NOTICE([LibCFS kernel checks
780 ==============================================================================])
781 LIBCFS_CONFIG_PANIC_DUMPLOG
782
783 # 2.6.32
784 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
785 LC_SHRINKER_WANT_SHRINK_PTR
786 # 2.6.33
787 LIBCFS_SYSCTL_CTLNAME
788 # 2.6.36
789 LIBCFS_MODULE_LOCKING
790 # 2.6.38
791 LIBCFS_KSTRTOUL
792 # 2.6.39
793 LIBCFS_DUMP_TRACE_ADDRESS
794 # 2.6.40 fc15
795 LC_SHRINK_CONTROL
796 # 3.0
797 LIBCFS_STACKTRACE_WARNING
798 LIBCFS_REINIT_COMPLETION
799 # 3.5
800 LIBCFS_PROCESS_NAMESPACE
801 LIBCFS_I_UID_READ
802 # 3.7
803 LIBCFS_SOCK_ALLOC_FILE
804 # 3.8
805 LIBCFS_HAVE_CRC32
806 LIBCFS_ENABLE_CRC32_ACCEL
807 # 3.10
808 LIBCFS_ENABLE_CRC32C_ACCEL
809 # 3.11
810 LIBCFS_KTIME_GET_TS64
811 # 3.12
812 LIBCFS_KERNEL_PARAM_OPS
813 LIBCFS_KTIME_ADD
814 LIBCFS_KTIME_AFTER
815 LIBCFS_KTIME_BEFORE
816 LIBCFS_SHRINKER_COUNT
817 # 3.17
818 LIBCFS_HLIST_ADD_AFTER
819 LIBCFS_TIMESPEC64
820 LIBCFS_KTIME_GET_NS
821 LIBCFS_KTIME_GET_REAL_TS64
822 LIBCFS_KTIME_GET_REAL_SECONDS
823 LIBCFS_KTIME_GET_REAL_NS
824 LIBCFS_KTIME_TO_TIMESPEC64
825 LIBCFS_TIMESPEC64_SUB
826 LIBCFS_TIMESPEC64_TO_KTIME
827 # 3.19
828 LIBCFS_KTIME_GET_SECONDS
829 LIBCFS_HAVE_CPUMASK_PRINT_TO_PAGEBUF
830 # 4.1
831 LIBCFS_KERNEL_PARAM_LOCK
832 # 4.2
833 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
834 LIBCFS_FPU_API
835 # 4.5
836 LIBCFS_CRYPTO_HASH_HELPERS
837 LIBCFS_EXPORT_KSET_FIND_OBJ
838 # 4.6
839 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
840 LIBCFS_GET_USER_PAGES_6ARG
841 # 4.8
842 LIBCFS_STACKTRACE_OPS
843 # 4.9
844 LIBCFS_GET_USER_PAGES_GUP_FLAGS
845 # 4.10
846 LIBCFS_HOTPLUG_STATE_MACHINE
847 # 4.11
848 LIBCFS_SCHED_HEADERS
849 ]) # LIBCFS_PROG_LINUX
850
851 #
852 # LIBCFS_PATH_DEFAULTS
853 #
854 # default paths for installed files
855 #
856 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
857 ]) # LIBCFS_PATH_DEFAULTS
858
859 #
860 # LIBCFS_CONFIGURE
861 #
862 # other configure checks
863 #
864 AC_DEFUN([LIBCFS_CONFIGURE], [
865 AC_MSG_NOTICE([LibCFS core checks
866 ==============================================================================])
867
868 # lnet/utils/portals.c
869 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
870
871 # lnet/utils/debug.c
872 AC_CHECK_HEADERS([linux/version.h])
873
874 AC_CHECK_TYPE([spinlock_t],
875         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
876         [],
877         [#include <linux/spinlock.h>])
878
879 # lnet/utils/wirecheck.c
880 AC_CHECK_FUNCS([strnlen])
881
882 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
883 AC_CHECK_FUNCS([strlcpy])
884
885 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
886 AC_CHECK_FUNCS([strlcat])
887
888 # libcfs/include/libcfs/linux/linux-prim.h, ...
889 AC_CHECK_HEADERS([linux/types.h sys/types.h linux/unistd.h unistd.h])
890
891 # libcfs/include/libcfs/linux/linux-prim.h
892 AC_CHECK_HEADERS([linux/random.h], [], [],
893                  [#ifdef HAVE_LINUX_TYPES_H
894                   #include <linux/types.h>
895                   #endif
896                  ])
897
898 # libcfs/include/libcfs/linux/libcfs.h
899 # libcfs/include/libcfs/byteorder.h
900 # libcfs/libcfs/util/nidstrings.c
901 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
902 AC_CHECK_FUNCS([gethostbyname])
903
904 # --------  Check for required packages  --------------
905
906 AC_MSG_NOTICE([LibCFS required packages checks
907 ==============================================================================])
908
909 AC_MSG_CHECKING([whether to enable readline support])
910 AC_ARG_ENABLE(readline,
911         AC_HELP_STRING([--disable-readline],
912                 [disable readline support]),
913         [], [enable_readline="yes"])
914 AC_MSG_RESULT([$enable_readline])
915
916 LIBREADLINE=""
917 AS_IF([test "x$enable_readline" = xyes], [
918         AC_CHECK_LIB([readline], [readline], [
919                 LIBREADLINE="-lreadline"
920                 AC_DEFINE(HAVE_LIBREADLINE, 1,
921                         [readline library is available])
922         ])
923 ])
924 AC_SUBST(LIBREADLINE)
925
926 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
927 AC_ARG_ENABLE([libpthread],
928         AC_HELP_STRING([--disable-libpthread],
929                 [disable libpthread]),
930         [], [enable_libpthread="yes"])
931 AC_MSG_RESULT([$enable_libpthread])
932
933 PTHREAD_LIBS=""
934 AS_IF([test "x$enable_libpthread" = xyes], [
935         AC_CHECK_LIB([pthread], [pthread_create], [
936                 PTHREAD_LIBS="-lpthread"
937                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
938                         [use libpthread for libcfs library])
939         ])
940 ], [
941         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
942 ])
943 AC_SUBST(PTHREAD_LIBS)
944 ]) # LIBCFS_CONFIGURE
945
946 #
947 # LIBCFS_CONDITIONALS
948 #
949 AC_DEFUN([LIBCFS_CONDITIONALS], [
950 AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
951 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32,  [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
952 AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
953 ]) # LIBCFS_CONDITIONALS
954
955 #
956 # LIBCFS_CONFIG_FILES
957 #
958 # files that should be generated with AC_OUTPUT
959 #
960 AC_DEFUN([LIBCFS_CONFIG_FILES], [
961 AC_CONFIG_FILES([
962 libcfs/Makefile
963 libcfs/autoMakefile
964 libcfs/autoconf/Makefile
965 libcfs/include/Makefile
966 libcfs/include/libcfs/Makefile
967 libcfs/include/libcfs/linux/Makefile
968 libcfs/include/libcfs/util/Makefile
969 libcfs/libcfs/Makefile
970 libcfs/libcfs/autoMakefile
971 libcfs/libcfs/linux/Makefile
972 libcfs/libcfs/util/Makefile
973 ])
974 ]) # LIBCFS_CONFIG_FILES