Whamcloud - gitweb
LU-14475 log: Rewrite some log messages
[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 # Kernel version 3.11 introduced ktime_get_ts64
53 #
54 AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
55 LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist],
56 ktime_get_ts64, [
57         #include <linux/hrtimer.h>
58         #include <linux/ktime.h>
59 ],[
60         struct timespec64 *ts = NULL;
61
62         ktime_get_ts64(ts);
63 ],[
64         AC_DEFINE(HAVE_KTIME_GET_TS64, 1,
65                 ['ktime_get_ts64' is available])
66 ])
67 ]) # LIBCFS_KTIME_GET_TS64
68
69 #
70 # Kernel version 3.12-rc4 commit c2d816443ef30 added prepare_to_wait_event()
71 #
72 AC_DEFUN([LIBCFS_PREPARE_TO_WAIT_EVENT],[
73 LB_CHECK_COMPILE([does function 'prepare_to_wait_event' exist],
74 prepare_to_wait_event, [
75         #include <linux/wait.h>
76 ],[
77         prepare_to_wait_event(NULL, NULL, 0);
78 ],[
79         AC_DEFINE(HAVE_PREPARE_TO_WAIT_EVENT, 1,
80                 ['prepare_to_wait_event' is available])
81 ])
82 ]) # LIBCFS_PREPARE_TO_WAIT_EVENT
83
84 #
85 # Linux kernel 3.12 introduced struct kernel_param_ops
86 # This has been backported to all lustre supported
87 # clients except RHEL6. We have to handle the differences.
88 #
89 AC_DEFUN([LIBCFS_KERNEL_PARAM_OPS],[
90 LB_CHECK_COMPILE([does 'struct kernel_param_ops' exist],
91 kernel_param_ops, [
92         #include <linux/module.h>
93 ],[
94         struct kernel_param_ops ops;
95
96         ops.set = NULL;
97 ],[
98         AC_DEFINE(HAVE_KERNEL_PARAM_OPS, 1,
99                 ['struct kernel_param_ops' is available])
100 ])
101 ]) # LIBCFS_KERNEL_PARAM_OPS
102
103 #
104 # Kernel version 3.12 introduced ktime_add
105 #
106 AC_DEFUN([LIBCFS_KTIME_ADD],[
107 LB_CHECK_COMPILE([does function 'ktime_add' exist],
108 ktime_add, [
109         #include <linux/hrtimer.h>
110         #include <linux/ktime.h>
111 ],[
112         ktime_t start = ktime_set(0, 0);
113         ktime_t end = start;
114         ktime_t total;
115
116         total = ktime_add(start, end);
117 ],[
118         AC_DEFINE(HAVE_KTIME_ADD, 1,
119                 [ktime_add is available])
120 ])
121 ]) # LIBCFS_KTIME_ADD
122
123 #
124 # Kernel version 3.12 introduced ktime_after
125 #
126 AC_DEFUN([LIBCFS_KTIME_AFTER],[
127 LB_CHECK_COMPILE([does function 'ktime_after' exist],
128 ktime_after, [
129         #include <linux/hrtimer.h>
130         #include <linux/ktime.h>
131 ],[
132         ktime_t start = ktime_set(0, 0);
133         ktime_t end = start;
134
135         ktime_after(start, end);
136 ],[
137         AC_DEFINE(HAVE_KTIME_AFTER, 1,
138                 [ktime_after is available])
139 ])
140 ]) # LIBCFS_KTIME_AFTER
141
142 #
143 # Kernel version 3.12 introduced ktime_before
144 # See linux commit 67cb9366ff5f99868100198efba5ca88aaa6ad25
145 #
146 AC_DEFUN([LIBCFS_KTIME_BEFORE],[
147 LB_CHECK_COMPILE([does function 'ktime_before' exist],
148 ktime_before, [
149         #include <linux/hrtimer.h>
150         #include <linux/ktime.h>
151 ],[
152         ktime_t start = ktime_set(0, 0);
153         ktime_t end = start;
154
155         ktime_before(start, end);
156 ],[
157         AC_DEFINE(HAVE_KTIME_BEFORE, 1,
158                 [ktime_before is available])
159 ])
160 ]) # LIBCFS_KTIME_BEFORE
161
162 #
163 # Kernel version 3.12 introduced ktime_compare
164 #
165 AC_DEFUN([LIBCFS_KTIME_COMPARE],[
166 LB_CHECK_COMPILE([does function 'ktime_compare' exist],
167 ktime_compare, [
168         #include <linux/hrtimer.h>
169         #include <linux/ktime.h>
170 ],[
171         ktime_t start = ktime_set(0, 0);
172         ktime_t end = start;
173
174         ktime_compare(start, end);
175 ],[
176         AC_DEFINE(HAVE_KTIME_COMPARE, 1,
177                 [ktime_compare is available])
178 ])
179 ]) # LIBCFS_KTIME_COMPARE
180
181 #
182 # FC19 3.12 kernel struct shrinker change
183 #
184 AC_DEFUN([LIBCFS_SHRINKER_COUNT],[
185 LB_CHECK_COMPILE([shrinker has 'count_objects'],
186 shrinker_count_objects, [
187         #include <linux/mmzone.h>
188         #include <linux/shrinker.h>
189 ],[
190         struct shrinker shrinker;
191
192         shrinker.count_objects = NULL;
193 ],[
194         AC_DEFINE(HAVE_SHRINKER_COUNT, 1,
195                 [shrinker has count_objects member])
196 ])
197 ]) # LIBCFS_SHRINKER_COUNT
198
199 #
200 # LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
201 #
202 # v3.14-7405-g91b0abe36a7b added AS_EXITING flag with
203 # mapping_exiting() and mapping_set_exiting()
204 #
205 AC_DEFUN([LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG], [
206 m4_pattern_allow([AS_EXITING])
207 tmp_flags="$EXTRA_KCFLAGS"
208 EXTRA_KCFLAGS="-Werror"
209 LB_CHECK_COMPILE([if enum mapping_flags has AS_EXITING flag],
210 mapping_exiting_exists, [
211         #include <linux/pagemap.h>
212 ],[
213         enum mapping_flags flag = AS_EXITING;
214         (void)flag;
215 ],[
216         AC_DEFINE(HAVE_MAPPING_AS_EXITING_FLAG, 1,
217                 [enum mapping_flags has AS_EXITING flag])
218 ])
219 EXTRA_KCFLAGS="$tmp_flags"
220 ]) # LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
221
222 #
223 # LIBCFS_IOV_ITER_HAS_TYPE
224 #
225 # kernel 3.15-rc4 commit 71d8e532b1549a478e6a6a8a44f309d050294d00
226 # start adding the tag to iov_iter
227 #
228 AC_DEFUN([LIBCFS_IOV_ITER_HAS_TYPE], [
229 tmp_flags="$EXTRA_KCFLAGS"
230 EXTRA_KCFLAGS="-Werror"
231 LB_CHECK_COMPILE([if iov_iter has member type],
232 iov_iter_has_type_member, [
233         #include <linux/uio.h>
234 ],[
235         struct iov_iter iter = { .type = ITER_KVEC };
236         (void)iter;
237 ],[
238         AC_DEFINE(HAVE_IOV_ITER_HAS_TYPE_MEMBER, 1,
239                 [if iov_iter has member type])
240 ])
241 EXTRA_KCFLAGS="$tmp_flags"
242 ]) # LIBCFS_IOV_ITER_HAS_TYPE
243
244 #
245 # LIBCFS_HAVE_NS_TO_TIMESPEC64
246 #
247 # Kernel version 4.16-rc3 commit a84d1169164b274f13b97a23ff235c000efe3b49
248 # introduced struct __kernel_old_timeval
249 #
250 AC_DEFUN([LIBCFS_HAVE_NS_TO_TIMESPEC64],[
251 LB_CHECK_COMPILE([does 'ns_to_timespec64()' exist],
252 kernel_old_timeval, [
253         #include <linux/time.h>
254 ],[
255         struct timespec64 kts;
256
257         kts = ns_to_timespec64(0);
258 ],[
259         AC_DEFINE(HAVE_NS_TO_TIMESPEC64, 1,
260                 [ns_to_timespec64() is available])
261 ])
262 ]) # LIBCFS_HAVE_NS_TO_TIMESPEC64
263
264 #
265 # Kernel version 3.17 changed hlist_add_after to
266 # hlist_add_behind
267 #
268 AC_DEFUN([LIBCFS_HLIST_ADD_AFTER],[
269 LB_CHECK_COMPILE([does function 'hlist_add_after' exist],
270 hlist_add_after, [
271         #include <linux/list.h>
272 ],[
273         hlist_add_after(NULL, NULL);
274 ],[
275         AC_DEFINE(HAVE_HLIST_ADD_AFTER, 1,
276                 [hlist_add_after is available])
277 ])
278 ]) # LIBCFS_HLIST_ADD_AFTER
279
280 #
281 # Kernel version 3.17 introduced struct timespec64
282 #
283 AC_DEFUN([LIBCFS_TIMESPEC64],[
284 LB_CHECK_COMPILE([does 'struct timespec64' exist],
285 timespec64, [
286         #include <linux/time.h>
287 ],[
288         struct timespec64 ts;
289
290         ts.tv_sec = 0;
291         ts.tv_nsec = 0;
292 ],[
293         AC_DEFINE(HAVE_TIMESPEC64, 1,
294                 ['struct timespec64' is available])
295 ])
296 ]) # LIBCFS_TIMESPEC64
297
298 #
299 # Kernel version 3.17 introduced ktime_get_real_ts64
300 #
301 AC_DEFUN([LIBCFS_KTIME_GET_REAL_TS64],[
302 LB_CHECK_COMPILE([does function 'ktime_get_real_ts64' exist],
303 ktime_get_real_ts64, [
304         #include <linux/ktime.h>
305 ],[
306         struct timespec64 *ts = NULL;
307
308         ktime_get_real_ts64(ts);
309 ],[
310         AC_DEFINE(HAVE_KTIME_GET_REAL_TS64, 1,
311                 ['ktime_get_real_ts64' is available])
312 ])
313 ]) # LIBCFS_KTIME_GET_REAL_TS64
314
315 #
316 # Kernel version 3.17 introduced ktime_get_real_seconds
317 #
318 AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[
319 LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist],
320 ktime_get_real_seconds, [
321         #include <linux/hrtimer.h>
322         #include <linux/ktime.h>
323 ],[
324         time64_t now;
325
326         now = ktime_get_real_seconds();
327 ],[
328         AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1,
329                 ['ktime_get_real_seconds' is available])
330 ])
331 ]) # LIBCFS_KTIME_GET_REAL_SECONDS
332
333 #
334 # Kernel version 3.17 created ktime_get_ns wrapper
335 #
336 AC_DEFUN([LIBCFS_KTIME_GET_NS],[
337 LB_CHECK_COMPILE([does function 'ktime_get_ns' exist],
338 ktime_get_ns, [
339         #include <linux/hrtimer.h>
340         #include <linux/ktime.h>
341 ],[
342         u64 nanoseconds;
343
344         nanoseconds = ktime_get_ns();
345 ],[],[
346         AC_DEFINE(NEED_KTIME_GET_NS, 1,
347                 ['ktime_get_ns' is not available])
348 ])
349 ]) # LIBCFS_KTIME_GET_NS
350
351 #
352 # Kernel version 3.17 created ktime_get_real_ns wrapper
353 #
354 AC_DEFUN([LIBCFS_KTIME_GET_REAL_NS],[
355 LB_CHECK_COMPILE([does function 'ktime_get_real_ns' exist],
356 ktime_get_real_ns, [
357         #include <linux/hrtimer.h>
358         #include <linux/ktime.h>
359 ],[
360         u64 nanoseconds;
361
362         nanoseconds = ktime_get_real_ns();
363 ],[],[
364         AC_DEFINE(NEED_KTIME_GET_REAL_NS, 1,
365                 ['ktime_get_real_ns' is not available])
366 ])
367 ]) # LIBCFS_KTIME_GET_REAL_NS
368
369 #
370 # Kernel version 3.17 introduced ktime_to_timespec64
371 #
372 AC_DEFUN([LIBCFS_KTIME_TO_TIMESPEC64],[
373 LB_CHECK_COMPILE([does function 'ktime_to_timespec64' exist],
374 ktime_to_timespec64, [
375         #include <linux/hrtimer.h>
376         #include <linux/ktime.h>
377 ],[
378         ktime_t now = ktime_set(0, 0);
379         struct timespec64 ts;
380
381         ts = ktime_to_timespec64(now);
382 ],[
383         AC_DEFINE(HAVE_KTIME_TO_TIMESPEC64, 1,
384                 ['ktime_to_timespec64' is available])
385 ])
386 ]) # LIBCFS_KTIME_TO_TIMESPEC64
387
388 #
389 # Kernel version 3.17 introduced timespec64_sub
390 #
391 AC_DEFUN([LIBCFS_TIMESPEC64_SUB],[
392 LB_CHECK_COMPILE([does function 'timespec64_sub' exist],
393 timespec64_sub, [
394         #include <linux/time.h>
395 ],[
396         struct timespec64 later = { }, earlier = { }, diff;
397
398         diff = timespec64_sub(later, earlier);
399 ],[
400         AC_DEFINE(HAVE_TIMESPEC64_SUB, 1,
401                 ['timespec64_sub' is available])
402 ])
403 ]) # LIBCFS_TIMESPEC64_SUB
404
405 #
406 # Kernel version 3.17 introduced timespec64_to_ktime
407 #
408 AC_DEFUN([LIBCFS_TIMESPEC64_TO_KTIME],[
409 LB_CHECK_COMPILE([does function 'timespec64_to_ktime' exist],
410 timespec64_to_ktime, [
411         #include <linux/ktime.h>
412 ],[
413         struct timespec64 ts;
414         ktime_t now;
415
416         now = timespec64_to_ktime(ts);
417 ],[
418         AC_DEFINE(HAVE_TIMESPEC64_TO_KTIME, 1,
419                 ['timespec64_to_ktime' is available])
420 ])
421 ]) # LIBCFS_TIMESPEC64_TO_KTIME
422
423 #
424 # Kernel version 3.19 introduced ktime_get_seconds
425 #
426 AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[
427 LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist],
428 ktime_get_seconds, [
429         #include <linux/ktime.h>
430 ],[
431         time64_t now;
432
433         now = ktime_get_seconds();
434 ],[
435         AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1,
436                 ['ktime_get_seconds' is available])
437 ])
438 ]) # LIBCFS_KTIME_GET_SECONDS
439
440 #
441 # Kernel version 3.19 commit v3.18-rc2-26-g61ada528dea0
442 # introduce wait_woken()
443 #
444 AC_DEFUN([LIBCFS_WAIT_WOKEN],[
445 LB_CHECK_COMPILE([does function 'wait_woken' exist],
446 wait_woken, [
447         #include <linux/wait.h>
448 ],[
449         wait_woken(NULL, 0, 0);
450 ],[
451         AC_DEFINE(HAVE_WAIT_WOKEN, 1,
452                 ['wait_woken, is available'])
453 ])
454 ]) # LIBCFS_WAIT_WOKEN
455
456 #
457 # Kernel version 4.0 commit 41fbf3b39d5eca01527338b4d0ee15ee1ae1023c
458 # introduced the helper function ktime_ms_delta.
459 #
460 AC_DEFUN([LIBCFS_KTIME_MS_DELTA],[
461 LB_CHECK_COMPILE([does function 'ktime_ms_delta' exist],
462 ktime_ms_delta, [
463         #include <linux/ktime.h>
464 ],[
465         ktime_t start = ktime_set(0, 0);
466         ktime_t end = start;
467
468         ktime_ms_delta(start, end);
469 ],[
470         AC_DEFINE(HAVE_KTIME_MS_DELTA, 1,
471                 ['ktime_ms_delta' is available])
472 ])
473 ]) # LIBCFS_KTIME_MS_DELTA
474
475 #
476 # Kernel version 4.1 commit b51d23e4e9fea6f264d39535c2a62d1f51e7ccc3
477 # create per module locks which added kernel_param_[un]lock(). Older
478 # kernels you have to use __kernel_param_[un]lock(). In that case its
479 # a global lock for all modules but that is okay since its a rare event.
480 #
481 AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
482 LB_CHECK_COMPILE([does function 'kernel_param_[un]lock' exist],
483 kernel_param_lock, [
484         #include <linux/moduleparam.h>
485 ],[
486         kernel_param_lock(NULL);
487         kernel_param_unlock(NULL);
488 ],[
489         AC_DEFINE(HAVE_KERNEL_PARAM_LOCK, 1,
490                 ['kernel_param_[un]lock' is available])
491 ])
492 ]) # LIBCFS_KERNEL_PARAM_LOCK
493
494 #
495 # Kernel version 4.2 changed topology_thread_cpumask
496 # to topology_sibling_cpumask
497 #
498 AC_DEFUN([LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK],[
499 LB_CHECK_COMPILE([does function 'topology_sibling_cpumask' exist],
500 topology_sibling_cpumask, [
501         #include <linux/topology.h>
502 ],[
503         const struct cpumask *mask;
504
505         mask = topology_sibling_cpumask(0);
506 ],[
507         AC_DEFINE(HAVE_TOPOLOGY_SIBLING_CPUMASK, 1,
508                 [topology_sibling_cpumask is available])
509 ])
510 ]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
511
512 #
513 # Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
514 # introduced kstrtobool and kstrtobool_from_user.
515 #
516 AC_DEFUN([LIBCFS_KSTRTOBOOL_FROM_USER], [
517 LB_CHECK_COMPILE([if Linux kernel has 'kstrtobool_from_user'],
518 kstrtobool_from_user, [
519         #include <linux/kernel.h>
520 ],[
521         bool result;
522         return kstrtobool_from_user(NULL, 0, &result);
523 ],[
524         AC_DEFINE(HAVE_KSTRTOBOOL_FROM_USER, 1,
525                 [kernel has kstrtobool_from_user])
526 ])
527 ]) # LIBCFS_KSTRTOBOOL_FROM_USER
528
529 #
530 # LIBCFS_NETLINK_CALLBACK_START
531 #
532 # Kernel version 4.4-rc3 commit fc9e50f5a5a4e1fa9ba2756f745a13e693cf6a06
533 # added a start function callback for struct netlink_callback
534 #
535 AC_DEFUN([LIBCFS_NETLINK_CALLBACK_START], [
536 LB_CHECK_COMPILE([if struct genl_ops has start callback],
537 cb_start, [
538         #include <net/genetlink.h>
539 ],[
540         struct genl_ops ops;
541
542         ops.start = NULL;
543 ],[
544         AC_DEFINE(HAVE_NETLINK_CALLBACK_START, 1,
545                 [struct genl_ops has 'start' callback])
546 ])
547 ]) # LIBCFS_NETLINK_CALLBACK_START
548
549 #
550 # Kernel version 4.5-rc1 commit d12481bc58fba89427565f8592e88446ec084a24
551 # added crypto hash helpers
552 #
553 AC_DEFUN([LIBCFS_CRYPTO_HASH_HELPERS], [
554 LB_CHECK_COMPILE([does crypto hash helper functions exist],
555 crypto_hash_helpers, [
556         #include <crypto/hash.h>
557 ],[
558         crypto_ahash_alg_name(NULL);
559         crypto_ahash_driver_name(NULL);
560 ],[
561         AC_DEFINE(HAVE_CRYPTO_HASH_HELPERS, 1,
562                 [crypto hash helper functions are available])
563 ])
564 ]) # LIBCFS_CRYPTO_HASH_HELPERS
565
566 #
567 # Kernel version 4.5-rc1 commit 3502cad73c4bbf8f6365d539e814159275252c59
568 # introduced rhashtable_replace_fast
569 #
570 AC_DEFUN([LIBCFS_RHASHTABLE_REPLACE], [
571 LB_CHECK_COMPILE([if 'rhashtable_replace_fast' exists],
572 rhashtable_replace_fast, [
573         #include <linux/rhashtable.h>
574 ],[
575         const struct rhashtable_params params = { 0 };
576
577         rhashtable_replace_fast(NULL, NULL, NULL, params);
578 ],[
579         AC_DEFINE(HAVE_RHASHTABLE_REPLACE, 1,
580                 [rhashtable_replace_fast() is available])
581 ])
582 ]) # LIBCFS_RHASHTABLE_REPLACE
583
584 #
585 # Kernel version 4.5-rc3 commit 2fe829aca9d7bed5fd6b49c6a1452e5e486b6cc3dd
586 # made kset_find_obj() exportable to modules
587 #
588 AC_DEFUN([LIBCFS_EXPORT_KSET_FIND_OBJ], [
589 LB_CHECK_EXPORT([kset_find_obj], [lib/kobject.c],
590         [AC_DEFINE(HAVE_KSET_FIND_OBJ, 1,
591                 [kset_find_obj is exported by the kernel])])
592 ]) # LIBCFS_EXPORT_KSET_FIND_OBJ
593
594 #
595 # Kernel version 4.6+ commit ef703f49a6c5b909a85149bb6625c4ed0d697186
596 # fixed the brokenness of hash_64(). The fix removed GOLDEN_RATIO_PRIME_64
597 # since it was a poor prime value.
598 #
599 AC_DEFUN([LIBCFS_BROKEN_HASH_64], [
600 LB_CHECK_COMPILE([kernel has fixed hash_64()],
601 broken_hash_64, [
602         #include <linux/hash.h>
603 ],[
604         int tmp = GOLDEN_RATIO_PRIME_64;
605 ],[
606         AC_DEFINE(HAVE_BROKEN_HASH_64, 1, [kernel hash_64() is broken])
607 ])
608 ]) # LIBCFS_BROKEN_HASH_64
609
610 #
611 # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
612 #
613 # linux 4.6 kernel changed stacktrace_ops address to return an int
614 #
615 AC_DEFUN([LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT], [
616 LB_CHECK_COMPILE([if 'struct stacktrace_ops' address function returns an int],
617 stacktrace_ops_address_return_int, [
618         #include <asm/stacktrace.h>
619 ],[
620         int rc;
621
622         rc = ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
623 ],[
624         AC_DEFINE(STACKTRACE_OPS_ADDRESS_RETURN_INT, 1,
625                 ['struct stacktrace_ops' address function returns an int])
626 ])
627 ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
628
629 #
630 # Kernel version 4.6 removed both struct task_struct and struct mm_struct
631 # arguments to get_user_pages
632 #
633 AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [
634 LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments],
635 get_user_pages_6arg, [
636         #include <linux/mm.h>
637 ],[
638         int rc;
639
640         rc = get_user_pages(0, 0, 0, 0, NULL, NULL);
641 ],[
642         AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1,
643                 [get_user_pages takes 6 arguments])
644 ])
645 ]) # LIBCFS_GET_USER_PAGES_6ARG
646
647 #
648 # LIBCFS_STRINGHASH
649 #
650 # 4.6 kernel created stringhash.h which moved stuff out of dcache.h
651 # commit f4bcbe792b8f434e32487cff9d9e30ab45a3ce02
652 #
653 AC_DEFUN([LIBCFS_STRINGHASH], [
654 LB_CHECK_LINUX_HEADER([linux/stringhash.h], [
655         AC_DEFINE(HAVE_STRINGHASH, 1,
656                 [stringhash.h is present])])
657 ]) # LIBCFS_STRINGHASH
658
659 #
660 # LIBCFS_RHASHTABLE_INSERT_FAST
661 #
662 # 4.7+ kernel commit 5ca8cc5bf11faed257c762018aea9106d529232f
663 # changed __rhashtable_insert_fast to support the new function
664 # rhashtable_lookup_get_insert_key().
665 #
666 AC_DEFUN([LIBCFS_RHASHTABLE_INSERT_FAST], [
667 tmp_flags="$EXTRA_KCFLAGS"
668 EXTRA_KCFLAGS="-Werror"
669 LB_CHECK_COMPILE([if internal '__rhashtable_insert_fast()' returns int],
670 rhashtable_insert_fast, [
671         #include <linux/rhashtable.h>
672 ],[
673         const struct rhashtable_params params = { 0 };
674         int rc;
675
676         rc = __rhashtable_insert_fast(NULL, NULL, NULL, params);
677 ],[
678         AC_DEFINE(HAVE_HASHTABLE_INSERT_FAST_RETURN_INT, 1,
679                   ['__rhashtable_insert_fast()' returns int])
680 ])
681 EXTRA_KCFLAGS="$tmp_flags"
682 ]) # LIBCFS_RHASHTABLE_INSERT_FAST
683
684 #
685 # Kernel version 4.7-rc1 commit 8f6fd83c6c5ec66a4a70c728535ddcdfef4f3697
686 # added 3rd arg to rhashtable_walk_init
687 #
688 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_INIT_3ARG], [
689 LB_CHECK_COMPILE([if 'rhashtable_walk_init' has 3 args],
690 rhashtable_walk_init, [
691         #include <linux/gfp.h>
692         #include <linux/rhashtable.h>
693 ],[
694         rhashtable_walk_init(NULL, NULL, GFP_KERNEL);
695 ],[
696         AC_DEFINE(HAVE_3ARG_RHASHTABLE_WALK_INIT, 1,
697                 [rhashtable_walk_init() has 3 args])
698 ])
699 ]) # LIBCFS_RHASHTABLE_WALK_INIT_3ARG
700
701 #
702 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
703 # introduced rhashtable_lookup
704 #
705 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP], [
706 LB_CHECK_COMPILE([if 'rhashtable_lookup' exist],
707 rhashtable_lookup, [
708         #include <linux/rhashtable.h>
709 ],[
710         const struct rhashtable_params params = { 0 };
711         void *ret;
712
713         ret = rhashtable_lookup(NULL, NULL, params);
714 ],[
715         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP, 1,
716                 [rhashtable_lookup() is available])
717 ])
718 ]) # LIBCFS_RHASHTABLE_LOOKUP
719
720 #
721 # LIBCFS_RHLTABLE
722 # Kernel version 4.8-rc6 commit ca26893f05e86497a86732768ec53cd38c0819ca
723 # created the rhlist interface to allow inserting duplicate objects
724 # into the same table.
725 #
726 AC_DEFUN([LIBCFS_RHLTABLE], [
727 LB_CHECK_COMPILE([does 'struct rhltable' exist],
728 rhtable, [
729         #include <linux/rhashtable.h>
730 ],[
731         struct rhltable *hlt;
732
733         rhltable_destroy(hlt);
734 ],[
735         AC_DEFINE(HAVE_RHLTABLE, 1,
736                   [struct rhltable exist])
737 ])
738 ]) # LIBCFS_RHLTABLE
739
740 #
741 # LIBCFS_STACKTRACE_OPS
742 #
743 # Kernel version 4.8 commit c8fe4609827aedc9c4b45de80e7cdc8ccfa8541b
744 # removed both struct stacktrace_ops and dump_trace() function
745 #
746 AC_DEFUN([LIBCFS_STACKTRACE_OPS], [
747 LB_CHECK_COMPILE([if 'struct stacktrace_ops' exists],
748 stacktrace_ops, [
749         struct task_struct;
750         struct pt_regs;
751         #include <asm/stacktrace.h>
752 ],[
753         struct stacktrace_ops ops;
754         ops.stack = NULL;
755 ],[
756         AC_DEFINE(HAVE_STACKTRACE_OPS, 1,
757                 [struct stacktrace_ops exists])
758 ])
759 ]) # LIBCFS_STACKTRACE_OPS
760
761 #
762 # Kernel version 4.9-rc1 commit 246779dd090bd1b74d2652b3a6ca7759f593b27a
763 # introduced rhashtable_walk_enter
764 #
765 AC_DEFUN([LIBCFS_RHASHTABLE_WALK_ENTER], [
766 LB_CHECK_COMPILE([if 'rhashtable_walk_enter' exists],
767 rhashtable_walk_enter, [
768         #include <linux/rhashtable.h>
769 ],[
770         rhashtable_walk_enter(NULL, NULL);
771 ],[
772         AC_DEFINE(HAVE_RHASHTABLE_WALK_ENTER, 1,
773                 [rhashtable_walk_enter() is available])
774 ])
775 ]) # LIBCFS_RHASHTABLE_WALK_ENTER
776
777 #
778 # Kernel version 4.9 commit 768ae309a96103ed02eb1e111e838c87854d8b51
779 # mm: replace get_user_pages() write/force parameters with gup_flags
780 #
781 AC_DEFUN([LIBCFS_GET_USER_PAGES_GUP_FLAGS], [
782 LB_CHECK_COMPILE([if 'get_user_pages()' takes gup_flags in arguments],
783 get_user_pages_gup_flags, [
784         #include <linux/mm.h>
785 ],[
786         int rc;
787         rc = get_user_pages(0, 0, FOLL_WRITE, NULL, NULL);
788 ],[
789         AC_DEFINE(HAVE_GET_USER_PAGES_GUP_FLAGS, 1,
790                 [get_user_pages takes gup_flags in arguments])
791 ])
792 ]) # LIBCFS_GET_USER_PAGES_GUP_FLAGS
793
794 #
795 # Kernel version 4.10 commit 7b737965b33188bd3dbb44e938535c4006d97fbb
796 # libcfs: Convert to hotplug state machine
797 #
798 AC_DEFUN([LIBCFS_HOTPLUG_STATE_MACHINE], [
799 LB_CHECK_COMPILE([if libcfs supports CPU hotplug state machine],
800 cpu_hotplug_state_machine, [
801         #include <linux/cpuhotplug.h>
802 ],[
803         cpuhp_remove_state(CPUHP_LUSTRE_CFS_DEAD);
804 ],[
805         AC_DEFINE(HAVE_HOTPLUG_STATE_MACHINE, 1,
806                 [hotplug state machine is supported])
807 ])
808 ]) # LIBCFS_HOTPLUG_STATE_MACHINE
809
810 #
811 # Kernel version 4.10-rc3 commit f405df5de3170c00e5c54f8b7cf4766044a032ba
812 # introduced refcount_t which is atomic_t plus over flow guards.
813 #
814 AC_DEFUN([LIBCFS_REFCOUNT_T], [
815 tmp_flags="$EXTRA_KCFLAGS"
816 EXTRA_KCFLAGS="-Werror"
817 LB_CHECK_LINUX_HEADER([linux/refcount.h], [
818         AC_DEFINE(HAVE_REFCOUNT_T, 1,
819                 [refcount_t is supported])
820 ])
821 EXTRA_KCFLAGS="$tmp_flags"
822 ]) # LIBCFS_REFCOUNT_T
823
824 #
825 # Kernel version 4.12 commit 499118e966f1d2150bd66647c8932343c4e9a0b8
826 # introduce memalloc_noreclaim_{save,restore}
827 #
828 AC_DEFUN([LIBCFS_MEMALLOC_NORECLAIM], [
829 LB_CHECK_COMPILE([if memalloc_noreclaim_{save,restore} exist],
830 memalloc_noreclaim, [
831         #include <linux/sched/mm.h>
832 ],[
833         int flag = memalloc_noreclaim_save();
834         memalloc_noreclaim_restore(flag);
835 ],[
836         AC_DEFINE(HAVE_MEMALLOC_RECLAIM, 1,
837                 [memalloc_noreclaim_{save,restore}() is supported])
838 ])
839 ]) # LIBCFS_MEMALLOC_NORECLAIM
840
841 #
842 # LIBCFS_SCHED_HEADERS
843 #
844 # 4.11 has broken up sched.h into more headers.
845 #
846 AC_DEFUN([LIBCFS_SCHED_HEADERS], [
847 LB_CHECK_LINUX_HEADER([linux/sched/signal.h], [
848         AC_DEFINE(HAVE_SCHED_HEADERS, 1,
849                 [linux/sched header directory exist])])
850 ]) # LIBCFS_SCHED_HEADERS
851
852 #
853 # Kernel version 4.11-rc1 commit 2c935bc57221cc2edc787c72ea0e2d30cdcd3d5e
854 # introduce kref_read
855 #
856 AC_DEFUN([LIBCFS_KREF_READ], [
857 LB_CHECK_COMPILE([if 'kref_read' exists],
858 kref_read, [
859         #include <linux/kref.h>
860 ],[
861         kref_read(NULL);
862 ],[
863         AC_DEFINE(HAVE_KREF_READ, 1,
864                 [kref_read() is available])
865 ])
866 ]) # LIBCFS_KREF_READ
867
868 #
869 # Kernel version 4.11-rc1 commit da20420f83ea0fbcf3d03afda08d971ea1d8a356
870 # introduced rht_bucket_var
871 #
872 AC_DEFUN([LIBCFS_RHT_BUCKET_VAR], [
873 LB_CHECK_COMPILE([if 'rht_bucket_var' exists],
874 rht_bucket_var, [
875         #include <linux/rhashtable.h>
876 ],[
877
878         rht_bucket_var(NULL, 0);
879 ],[
880         AC_DEFINE(HAVE_RHT_BUCKET_VAR, 1,
881                 [rht_bucket_var() is available])
882 ])
883 ]) # LIBCFS_RHT_BUCKET_VAR
884
885 #
886 # Kernel version 4.11-rc5 commit fceb6435e85298f747fee938415057af837f5a8a
887 # began the enhanchement of Netlink with extended ACK struct for advanced
888 # error handling. By commit 7ab606d1609dd6dfeae9c8ad0a8a4e051d831e46 we
889 # had full support for this new feature.
890 #
891 AC_DEFUN([LIBCFS_NL_EXT_ACK], [
892 LB_CHECK_COMPILE([if Netlink supports netlink_ext_ack],
893 netlink_ext_ack, [
894         #include <net/genetlink.h>
895 ],[
896         struct genl_info info;
897
898         info.extack = NULL;
899 ],[
900         AC_DEFINE(HAVE_NL_PARSE_WITH_EXT_ACK, 1,
901                 [netlink_ext_ack is an argument to nla_parse type function])
902 ])
903 ]) # LIBCFS_NL_EXT_ACK
904
905 #
906 # Kernel version 4.11 commit f9fe1c12d126f9887441fa5bb165046f30ddd4b5
907 # introduced rhashtable_lookup_get_insert_fast
908 #
909 AC_DEFUN([LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST], [
910 LB_CHECK_COMPILE([if 'rhashtable_lookup_get_insert_fast' exist],
911 rhashtable_lookup_get_insert_fast, [
912         #include <linux/rhashtable.h>
913 ],[
914         const struct rhashtable_params params = { 0 };
915         void *ret;
916
917         ret = rhashtable_lookup_get_insert_fast(NULL, NULL, params);
918 ],[
919         AC_DEFINE(HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST, 1,
920                 [rhashtable_lookup_get_insert_fast() is available])
921 ])
922 ]) # LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
923
924 #
925 # Kernel version 4.12-rc2 8f553c498e1772cccb39a114da4a498d22992758
926 # provide proper CPU hotplug locking
927 #
928 AC_DEFUN([LIBCFS_CPUS_READ_LOCK], [
929 LB_CHECK_COMPILE([if 'cpus_read_[un]lock' exist],
930 cpu_read_lock, [
931         #include <linux/cpu.h>
932 ],[
933         cpus_read_lock();
934         cpus_read_unlock();
935 ],[
936         AC_DEFINE(HAVE_CPUS_READ_LOCK, 1, ['cpus_read_lock' exist])
937 ])
938 ]) # LIBCFS_CPUS_READ_LOCK
939
940 #
941 # Kernel version 4.12-rc3 f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
942 # renamed uuid_be to uuid_t
943 #
944 AC_DEFUN([LIBCFS_UUID_T], [
945 LB_CHECK_COMPILE([if 'uuid_t' exist],
946 uuid_t, [
947         #include <linux/uuid.h>
948 ],[
949         uuid_t uuid;
950
951         memset(uuid.b, 0, 16);
952 ],[
953         AC_DEFINE(HAVE_UUID_T, 1, ['uuid_t' exist])
954 ])
955 ]) # LIBCFS_UUID_T
956
957 #
958 # Kernel version 4.12-rc3 commit fd851a3cdc196bfc1d229b5f22369069af532bf8
959 # introduce processor.h
960 #
961 AC_DEFUN([LIBCFS_HAVE_PROCESSOR_HEADER], [
962 tmp_flags="$EXTRA_KCFLAGS"
963 EXTRA_KCFLAGS="-Werror"
964 LB_CHECK_LINUX_HEADER([linux/processor.h], [
965         AC_DEFINE(HAVE_PROCESSOR_H, 1,
966                 [processor.h is present])
967 ])
968 EXTRA_KCFLAGS="$tmp_flags"
969 ]) # LIBCFS_HAVE_PROCESSOR_HEADER
970
971 #
972 # Kernel verison 4.12-rc6 commit 5dd43ce2f69d42a71dcacdb13d17d8c0ac1fe8f7
973 # created wait_bit.h
974 #
975 AC_DEFUN([LIBCFS_HAVE_WAIT_BIT_HEADER], [
976 LB_CHECK_LINUX_HEADER([linux/wait_bit.h], [
977         AC_DEFINE(HAVE_WAIT_BIT_HEADER_H, 1,
978                 [wait_bit.h is present])])
979 ]) # LIBCFS_HAVE_WAIT_BIT_HEADER
980
981 #
982 # Kernel version 4.12-rc6 commmit 2055da97389a605c8a00d163d40903afbe413921
983 # changed:
984 #       struct wait_queue_head::task_list       => ::head
985 #       struct wait_queue_entry::task_list      => ::entry
986 #
987 AC_DEFUN([LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME], [
988 LB_CHECK_COMPILE([if linux wait_queue_head list_head is named head],
989 wait_queue_task_list, [
990         #include <linux/wait.h>
991 ],[
992         wait_queue_head_t e;
993
994         INIT_LIST_HEAD(&e.head);
995 ],[
996         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY_LIST, 1,
997                 [linux wait_queue_head_t list_head is name head])
998 ])
999 ]) # LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
1000
1001 #
1002 # LIBCFS_NLA_STRDUP
1003 #
1004 # Kernel version 4.13-rc1 commit 2cf0c8b3e6942ecafe6ebb1a6d0328a81641bf39
1005 # created nla_strdup(). This is needed since push strings can be
1006 # any size.
1007 #
1008 AC_DEFUN([LIBCFS_NLA_STRDUP], [
1009 LB_CHECK_COMPILE([if 'nla_strdup()' exists],
1010 nla_strdup, [
1011         #include <net/netlink.h>
1012 ],[
1013         char *tmp = nla_strdup(NULL, GFP_KERNEL);
1014 ],[
1015         AC_DEFINE(HAVE_NLA_STRDUP, 1,
1016                 ['nla_strdup' is available])
1017 ])
1018 ]) # LIBCFS_NLA_STRDUP
1019
1020 #
1021 # LIBCFS_WAIT_QUEUE_ENTRY
1022 #
1023 # Kernel version 4.13 ac6424b981bce1c4bc55675c6ce11bfe1bbfa64f
1024 # Rename wait_queue_t => wait_queue_entry_t
1025 #
1026 AC_DEFUN([LIBCFS_WAIT_QUEUE_ENTRY], [
1027 LB_CHECK_COMPILE([if 'wait_queue_entry_t' exists],
1028 wait_queue_entry, [
1029         #include <linux/wait.h>
1030 ],[
1031         wait_queue_entry_t e;
1032
1033         e.flags = 0;
1034 ],[
1035         AC_DEFINE(HAVE_WAIT_QUEUE_ENTRY, 1,
1036                 ['wait_queue_entry_t' is available])
1037 ])
1038 ]) # LIBCFS_WAIT_QUEUE_ENTRY
1039
1040 #
1041 # LIBCFS_NEW_KERNEL_WRITE
1042 #
1043 # Kernel version 4.14 e13ec939e96b13e664bb6cee361cc976a0ee621a
1044 # changed kernel_write prototype to make is plug compatible
1045 # with the unexported vfs_write()
1046 #
1047 AC_DEFUN([LIBCFS_NEW_KERNEL_WRITE], [
1048 tmp_flags="$EXTRA_KCFLAGS"
1049 EXTRA_KCFLAGS="-Werror"
1050 LB_CHECK_COMPILE([if 'kernel_write' matches other read/write helpers],
1051 kernel_write_match, [
1052         #include <linux/fs.h>
1053 ],[
1054         const void *buf = NULL;
1055         loff_t pos = 0;
1056         return kernel_write(NULL, buf, 0, &pos);
1057 ],[
1058         AC_DEFINE(HAVE_NEW_KERNEL_WRITE, 1,
1059                 ['kernel_write' aligns with read/write helpers])
1060 ])
1061 EXTRA_KCFLAGS="$tmp_flags"
1062 ]) # LIBCFS_NEW_KERNEL_WRITE
1063
1064 #
1065 # LIBCFS_MM_TOTALRAM_PAGES_FUNC
1066 #
1067 # kernel 5.0 commit ca79b0c211af63fa3276f0e3fd7dd9ada2439839
1068 # mm: convert totalram_pages and totalhigh_pages variables to atomic
1069 #
1070 AC_DEFUN([LIBCFS_MM_TOTALRAM_PAGES_FUNC], [
1071 tmp_flags="$EXTRA_KCFLAGS"
1072 EXTRA_KCFLAGS="-Werror"
1073 LB_CHECK_COMPILE([if totalram_pages is a function],
1074 totalram_pages, [
1075         #include <linux/mm.h>
1076 ],[
1077         totalram_pages_inc();
1078 ],[
1079         AC_DEFINE(HAVE_TOTALRAM_PAGES_AS_FUNC, 1,
1080                 [if totalram_pages is a function])
1081 ])
1082 EXTRA_KCFLAGS="$tmp_flags"
1083 ]) # LIBCFS_MM_TOTALRAM_PAGES_FUNC
1084
1085 #
1086 # LIBCFS_NEW_KERNEL_READ
1087 #
1088 # 4.14 commit bdd1d2d3d251c65b74ac4493e08db18971c09240 changed
1089 # the signature of kernel_read to match other read/write helpers
1090 # and place offset last.
1091 #
1092 AC_DEFUN([LIBCFS_NEW_KERNEL_READ], [
1093 tmp_flags="$EXTRA_KCFLAGS"
1094 EXTRA_KCFLAGS="-Werror"
1095 LB_CHECK_COMPILE([if 'kernel_read()' has loff_t *pos as last parameter],
1096 kernel_read, [
1097         #include <linux/fs.h>
1098         ],[
1099         loff_t pos = 0;
1100         kernel_read(NULL, NULL, 0, &pos);
1101 ],[
1102         AC_DEFINE(HAVE_KERNEL_READ_LAST_POSP, 1,
1103                 [kernel_read() signature ends with loff_t *pos])
1104 ])
1105 EXTRA_KCFLAGS="$tmp_flags"
1106 ]) # LIBCFS_NEW_KERNEL_READ
1107
1108 #
1109 # LIBCFS_DEFINE_TIMER
1110 #
1111 # Kernel version 4.14 commit 1d27e3e2252ba9d949ca82fbdb73cde102cb2067
1112 # remove expires and data arguments from DEFINE_TIMER. Also the callback
1113 # when from using unsigned long argument to using struct timer_list pointer.
1114 #
1115 AC_DEFUN([LIBCFS_DEFINE_TIMER], [
1116 LB_CHECK_COMPILE([if DEFINE_TIMER takes only 2 arguments],
1117 define_timer, [
1118         #include <linux/timer.h>
1119 ],[
1120         static DEFINE_TIMER(my_timer, NULL);
1121 ],[
1122         AC_DEFINE(HAVE_NEW_DEFINE_TIMER, 1,
1123                 [DEFINE_TIMER uses only 2 arguements])
1124 ])
1125 ]) # LIBCFS_DEFINE_TIMER
1126
1127 #
1128 # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1129 #
1130 # Kernel 2.6.27 commit 8594698ebddeef5443b7da8258ae33b3eaca61d5
1131 # exported save_stack_trace_tsk for x86.
1132 # Kernel 2.6.27 commit 01f4b8b8b8db09b88be7df7e51192e4e678b69d3
1133 # exported save_stack_trace_tsk for powerpc
1134 # Kernel 4.13 commit e27c7fa015d61c8be6a2c32b2144aad2ae6ec975
1135 # exported save_stack_trace_tsk for arm64
1136 # Kernel 4.14 commit 9a3dc3186fc3795e076a4122da9e0258651a9631
1137 # exported save_stack_trace_tsk for arm
1138 #
1139 AC_DEFUN([LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK], [
1140 LB_CHECK_EXPORT([save_stack_trace_tsk], [arch/$SUBARCH/kernel/stacktrace.c],
1141         [AC_DEFINE(HAVE_SAVE_STACK_TRACE_TSK, 1,
1142                 [save_stack_trace_tsk is exported])])
1143 ]) # LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1144
1145 #
1146 # LIBCFS_LOCKDEP_IS_HELD
1147 #
1148 # Kernel v4.15-rc8-106-g08f36ff64234
1149 # lockdep: Make lockdep checking constant
1150 #
1151 AC_DEFUN([LIBCFS_LOCKDEP_IS_HELD], [
1152 tmp_flags="$EXTRA_KCFLAGS"
1153 EXTRA_KCFLAGS="-Werror"
1154 LB_CHECK_COMPILE([if 'lockdep_is_held()' uses const argument],
1155 lockdep_is_held, [
1156         #include <linux/lockdep.h>
1157 ],[
1158 #ifdef CONFIG_LOCKDEP
1159         const struct spinlock *lock = NULL;
1160
1161         lockdep_is_held(lock);
1162 #endif
1163 ],[],[
1164         AC_DEFINE(NEED_LOCKDEP_IS_HELD_DISCARD_CONST, 1,
1165                 [lockdep_is_held() argument is const])
1166 ])
1167 EXTRA_KCFLAGS="$tmp_flags"
1168 ]) # LIBCFS_LOCKDEP_IS_HELD
1169
1170 #
1171 # LIBCFS_TIMER_SETUP
1172 #
1173 # Kernel version 4.15 commit e99e88a9d2b067465adaa9c111ada99a041bef9a
1174 # setup_timer() was replaced by timer_setup(), where the callback
1175 # argument is the structure already holding the struct timer_list.
1176 #
1177 AC_DEFUN([LIBCFS_TIMER_SETUP], [
1178 LB_CHECK_COMPILE([if setup_timer has been replaced with timer_setup],
1179 timer_setup, [
1180         #include <linux/timer.h>
1181 ],[
1182         timer_setup(NULL, NULL, 0);
1183 ],[
1184         AC_DEFINE(HAVE_TIMER_SETUP, 1,
1185                 [timer_setup has replaced setup_timer])
1186 ])
1187 ]) # LIBCFS_TIMER_SETUP
1188
1189 #
1190 # LIBCFS_WAIT_VAR_EVENT
1191 #
1192 # Kernel version 4.16-rc4 commit 6b2bb7265f0b62605e8caee3613449ed0db270b9
1193 # added wait_var_event()
1194 #
1195 AC_DEFUN([LIBCFS_WAIT_VAR_EVENT], [
1196 LB_CHECK_COMPILE([if 'wait_var_event' exist],
1197 wait_var_event, [
1198         #ifdef HAVE_WAIT_BIT_HEADER_H
1199         #include <linux/wait_bit.h>
1200         #endif
1201         #include <linux/wait.h>
1202 ],[
1203         wake_up_var(NULL);
1204 ],[
1205         AC_DEFINE(HAVE_WAIT_VAR_EVENT, 1,
1206                 ['wait_var_event' is available])
1207 ])
1208 ]) # LIBCFS_WAIT_VAR_EVENT
1209
1210 #
1211 # LIBCFS_BITMAP_ALLOC
1212 #
1213 # Kernel version 4.17 commit c42b65e363ce97a828f81b59033c3558f8fa7f70
1214 # added bitmap memory allocation handling.
1215 #
1216 AC_DEFUN([LIBCFS_BITMAP_ALLOC], [
1217 LB_CHECK_COMPILE([if Linux bitmap memory management exist],
1218 bitmap_alloc, [
1219         #include <linux/bitmap.h>
1220 ],[
1221         unsigned long *map = bitmap_alloc(1, GFP_KERNEL);
1222 ],[
1223         AC_DEFINE(HAVE_BITMAP_ALLOC, 1,
1224                 [Linux bitmap can be allocated])
1225 ])
1226 ]) # LIBCFS_BITMAP_ALLOC
1227
1228 #
1229 # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1230 #
1231 # Kernel version 4.17-rc2 commit 8236b0ae31c837d2b3a2565c5f8d77f637e824cc
1232 # added clear_and_wake_up_bit()
1233 #
1234 AC_DEFUN([LIBCFS_CLEAR_AND_WAKE_UP_BIT], [
1235 LB_CHECK_COMPILE([if 'clear_and_wake_up_bit' exist],
1236 clear_and_wake_up_bit, [
1237         #ifdef HAVE_WAIT_BIT_HEADER_H
1238         #include <linux/wait_bit.h>
1239         #endif
1240         #include <linux/wait.h>
1241 ],[
1242         clear_and_wake_up_bit(0, NULL);
1243 ],[
1244         AC_DEFINE(HAVE_CLEAR_AND_WAKE_UP_BIT, 1,
1245                 ['clear_and_wake_up_bit' is available])
1246 ])
1247 ]) # LIBCFS_CLEAR_AND_WAKE_UP_BIT
1248
1249 #
1250 # LIBCFS_TCP_SOCK_SET_NODELAY
1251 #
1252 # kernel 4.18.0-293.el8
1253 # tcp_sock_set_nodelay() was added
1254 AC_DEFUN([LIBCFS_TCP_SOCK_SET_NODELAY], [
1255 tmp_flags="$EXTRA_KCFLAGS"
1256 EXTRA_KCFLAGS="-Werror"
1257 LB_CHECK_COMPILE([if 'tcp_sock_set_nodelay()' exists],
1258 tcp_sock_set_nodelay_exists, [
1259         #include <linux/tcp.h>
1260 ],[
1261         tcp_sock_set_nodelay(NULL);
1262 ],[
1263         AC_DEFINE(HAVE_TCP_SOCK_SET_NODELAY, 1,
1264                 ['tcp_sock_set_nodelay()' exists])
1265 ])
1266 EXTRA_KCFLAGS="$tmp_flags"
1267 ]) # LIBCFS_TCP_SOCK_SET_NODELAY
1268
1269 #
1270 # LIBCFS_TCP_SOCK_SET_KEEPIDLE
1271 #
1272 # kernel 4.18.0-293.el8
1273 # tcp_sock_set_keepidle() was added
1274 AC_DEFUN([LIBCFS_TCP_SOCK_SET_KEEPIDLE], [
1275 tmp_flags="$EXTRA_KCFLAGS"
1276 EXTRA_KCFLAGS="-Werror"
1277 LB_CHECK_COMPILE([if 'tcp_sock_set_keepidle()' exists],
1278 tcp_sock_set_keepidle_exists, [
1279         #include <linux/tcp.h>
1280 ],[
1281         tcp_sock_set_keepidle(NULL, 0);
1282 ],[
1283         AC_DEFINE(HAVE_TCP_SOCK_SET_KEEPIDLE, 1,
1284                 ['tcp_sock_set_keepidle()' exists])
1285 ])
1286 EXTRA_KCFLAGS="$tmp_flags"
1287 ]) # LIBCFS_TCP_SOCK_SET_KEEPIDLE
1288
1289 #
1290 # LIBCFS_TCP_SOCK_SET_QUICKACK
1291 # kernel v5.7-rc6-2504-gddd061b8daed
1292 #   tcp: add tcp_sock_set_quickack
1293 #
1294 AC_DEFUN([LIBCFS_TCP_SOCK_SET_QUICKACK], [
1295 tmp_flags="$EXTRA_KCFLAGS"
1296 EXTRA_KCFLAGS="-Werror"
1297 LB_CHECK_COMPILE([if 'tcp_sock_set_quickack()' exists],
1298 tcp_sock_set_quickack_exists, [
1299         #include <linux/tcp.h>
1300 ],[
1301         tcp_sock_set_quickack(NULL, 0);
1302 ],[
1303         AC_DEFINE(HAVE_TCP_SOCK_SET_QUICKACK, 1,
1304                 ['tcp_sock_set_quickack()' exists])
1305 ])
1306 EXTRA_KCFLAGS="$tmp_flags"
1307 ]) # LIBCFS_TCP_SOCK_SET_QUICKACK
1308
1309 #
1310 # LIBCFS_TCP_SOCK_SET_KEEPINTVL
1311 # v5.7-rc6-2508-gd41ecaac903c
1312 # tcp: add tcp_sock_set_keepintvl
1313 #
1314 AC_DEFUN([LIBCFS_TCP_SOCK_SET_KEEPINTVL], [
1315 tmp_flags="$EXTRA_KCFLAGS"
1316 EXTRA_KCFLAGS="-Werror"
1317 LB_CHECK_COMPILE([if 'tcp_sock_set_keepintvl()' exists],
1318 tcp_sock_set_keepintvl_exists, [
1319         #include <linux/tcp.h>
1320 ],[
1321         tcp_sock_set_keepintvl(NULL, 0);
1322 ],[
1323         AC_DEFINE(HAVE_TCP_SOCK_SET_KEEPINTVL, 1,
1324                 ['tcp_sock_set_keepintvl()' exists])
1325 ])
1326 EXTRA_KCFLAGS="$tmp_flags"
1327 ]) # LIBCFS_TCP_SOCK_SET_KEEPINTVL
1328
1329 #
1330 # LIBCFS_TCP_SOCK_SET_KEEPCNT
1331 # v5.7-rc6-2509-g480aeb9639d6
1332 # tcp: add tcp_sock_set_keepcnt
1333 #
1334 AC_DEFUN([LIBCFS_TCP_SOCK_SET_KEEPCNT], [
1335 tmp_flags="$EXTRA_KCFLAGS"
1336 EXTRA_KCFLAGS="-Werror"
1337 LB_CHECK_COMPILE([if 'tcp_sock_set_keepcnt()' exists],
1338 tcp_sock_set_keepcnt_exists, [
1339         #include <linux/tcp.h>
1340 ],[
1341         tcp_sock_set_keepcnt(NULL, 0);
1342 ],[
1343         AC_DEFINE(HAVE_TCP_SOCK_SET_KEEPCNT, 1,
1344                 ['tcp_sock_set_keepcnt()' exists])
1345 ])
1346 EXTRA_KCFLAGS="$tmp_flags"
1347 ]) # LIBCFS_TCP_SOCK_SET_KEEPCNT
1348
1349 #
1350 # LIBCFS_XARRAY_SUPPORT
1351 #
1352 # 4.19-rc5 kernel commit 3159f943aafdbacb2f94c38fdaadabf2bbde2a14
1353 # replaced the radix tree implementation with Xarrays. This change
1354 # introduced functionaly needed for general Xarray support
1355 #
1356 AC_DEFUN([LIBCFS_XARRAY_SUPPORT], [
1357 tmp_flags="$EXTRA_KCFLAGS"
1358 EXTRA_KCFLAGS="-Werror"
1359 LB_CHECK_COMPILE([if page cache uses Xarray],
1360 xarray_support, [
1361         #include <linux/xarray.h>
1362 ],[
1363         xa_is_value(NULL);
1364 ],[
1365         AC_DEFINE(HAVE_XARRAY_SUPPORT, 1,
1366                 [kernel Xarray implementation lacks 'xa_is_value'])
1367 ])
1368 EXTRA_KCFLAGS="$tmp_flags"
1369 ]) # LIBCFS_XARRAY_SUPPORT
1370
1371 #
1372 # Kernel version 4.19-rc6 commit 4a19edb60d0203cd5bf95a8b46ea8f63fd41194c
1373 # added extended ACK handling to Netlink dump handlers
1374 #
1375 AC_DEFUN([LIBCFS_NL_DUMP_EXT_ACK], [
1376 LB_CHECK_COMPILE([if Netlink dump handlers support ext_ack],
1377 netlink_dump_ext_ack, [
1378         #include <net/netlink.h>
1379 ],[
1380         struct netlink_callback *cb = NULL;
1381         cb->extack = NULL;
1382 ],[
1383         AC_DEFINE(HAVE_NL_DUMP_WITH_EXT_ACK, 1,
1384                 [netlink_ext_ack is handled for Netlink dump handlers])
1385 ])
1386 ]) # LIBCFS_NL_DUMP_EXT_ACK
1387
1388 #
1389 # LIBCFS_HAVE_IOV_ITER_TYPE
1390 #
1391 # kernel 4.20 commit 00e23707442a75b404392cef1405ab4fd498de6b
1392 # iov_iter: Use accessor functions to access an iterator's type and direction.
1393 #
1394 AC_DEFUN([LIBCFS_HAVE_IOV_ITER_TYPE], [
1395 tmp_flags="$EXTRA_KCFLAGS"
1396 EXTRA_KCFLAGS="-Werror"
1397 LB_CHECK_COMPILE([if iov_iter_type exists],
1398 macro_iov_iter_type_exists, [
1399         #include <linux/uio.h>
1400 ],[
1401         struct iov_iter iter = { .type = ITER_KVEC };
1402         enum iter_type type = iov_iter_type(&iter);
1403         (void)type;
1404 ],[
1405         AC_DEFINE(HAVE_IOV_ITER_TYPE, 1,
1406                 [if iov_iter_type exists])
1407 ])
1408 EXTRA_KCFLAGS="$tmp_flags"
1409 ]) # LIBCFS_HAVE_IOV_ITER_TYPE
1410
1411 #
1412 # LIBCFS_GET_REQUEST_KEY_AUTH
1413 #
1414 # kernel 5.0 commit 822ad64d7e46a8e2c8b8a796738d7b657cbb146d
1415 # keys: Fix dependency loop between construction record and auth key
1416 #
1417 # Added <keys/request_key_auth-type.h> and get_request_key_auth()
1418 # which was propagated to stable
1419 #
1420 AC_DEFUN([LIBCFS_GET_REQUEST_KEY_AUTH], [
1421 tmp_flags="$EXTRA_KCFLAGS"
1422 EXTRA_KCFLAGS="-Werror"
1423 LB_CHECK_COMPILE([if get_request_key_auth() is available],
1424 get_request_key_auth_exported, [
1425         #include <linux/key.h>
1426         #include <linux/keyctl.h>
1427         #include <keys/request_key_auth-type.h>
1428 ],[
1429         struct key *ring;
1430         const struct key *key = NULL;
1431         struct request_key_auth *rka = get_request_key_auth(key);
1432
1433         ring = key_get(rka->dest_keyring);
1434 ],[
1435         AC_DEFINE(HAVE_GET_REQUEST_KEY_AUTH, 1,
1436                 [get_request_key_auth() is available])
1437 ])
1438 EXTRA_KCFLAGS="$tmp_flags"
1439 ]) # LIBCFS_GET_REQUEST_KEY_AUTH
1440
1441 #
1442 # LIBCFS_LOOKUP_USER_KEY
1443 #
1444 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1445 # signal: Remove task parameter from force_sig
1446 #
1447 AC_DEFUN([LIBCFS_LOOKUP_USER_KEY], [
1448 tmp_flags="$EXTRA_KCFLAGS"
1449 EXTRA_KCFLAGS="-Werror"
1450 LB_CHECK_COMPILE([if lookup_user_key() is available],
1451 lookup_user_key_exported, [
1452         #include <linux/key.h>
1453         #include <linux/keyctl.h>
1454 ],[
1455         lookup_user_key(KEY_SPEC_USER_KEYRING, 0, 0);
1456 ],[
1457         AC_DEFINE(HAVE_LOOKUP_USER_KEY, 1,
1458                 [lookup_user_key() is available])
1459 ])
1460 EXTRA_KCFLAGS="$tmp_flags"
1461 ]) # LIBCFS_LOOKUP_USER_KEY
1462
1463 #
1464 # LIBCFS_FORCE_SIG_WITH_TASK
1465 #
1466 # kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740
1467 # signal: Remove task parameter from force_sig
1468 #
1469 AC_DEFUN([LIBCFS_FORCE_SIG_WITH_TASK], [
1470 tmp_flags="$EXTRA_KCFLAGS"
1471 EXTRA_KCFLAGS="-Werror"
1472 LB_CHECK_COMPILE([if force_sig has task parameter],
1473 force_sig_with_task, [
1474         #include <linux/sched/signal.h>
1475 ],[
1476         force_sig(SIGINT, NULL);
1477 ],[
1478         AC_DEFINE(HAVE_FORCE_SIG_WITH_TASK, 1,
1479                 [force_sig() has task parameter])
1480 ])
1481 EXTRA_KCFLAGS="$tmp_flags"
1482 ]) # LIBCFS_FORCE_SIG_WITH_TASK
1483
1484 #
1485 # LIBCFS_CACHE_DETAIL_WRITERS
1486 #
1487 # kernel v5.3-rc2-1-g64a38e840ce5
1488 # SUNRPC: Track writers of the 'channel' file to improve cache_listeners_exist
1489 #
1490 AC_DEFUN([LIBCFS_CACHE_DETAIL_WRITERS], [
1491 tmp_flags="$EXTRA_KCFLAGS"
1492 EXTRA_KCFLAGS="-Werror"
1493 LB_CHECK_COMPILE([if struct cache_detail has writers],
1494 cache_detail_writers_atomic, [
1495         #include <linux/sunrpc/cache.h>
1496
1497         static struct cache_detail rsi_cache;
1498 ],[
1499         atomic_set(&rsi_cache.writers, 0);
1500 ],[
1501         AC_DEFINE(HAVE_CACHE_DETAIL_WRITERS, 1,
1502                 [struct cache_detail has writers])
1503 ])
1504 EXTRA_KCFLAGS="$tmp_flags"
1505 ]) # LIBCFS_CACHE_DETAIL_WRITERS
1506
1507 #
1508 # LIBCFS_KALLSYMS_LOOKUP
1509 #
1510 # kernel v5.6-11591-g0bd476e6c671
1511 # kallsyms: unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()
1512 AC_DEFUN([LIBCFS_KALLSYMS_LOOKUP], [
1513 LB_CHECK_EXPORT([kallsyms_lookup_name], [kernel/kallsyms.c],
1514         [AC_DEFINE(HAVE_KALLSYMS_LOOKUP_NAME, 1,
1515                 [kallsyms_lookup_name is exported by kernel])])
1516 ]) # LIBCFS_KALLSYMS_LOOKUP
1517
1518 #
1519 # v5.5-8862-gd56c0d45f0e2
1520 # proc: decouple proc from VFS with "struct proc_ops"
1521 #
1522 AC_DEFUN([LIBCFS_SRC_HAVE_PROC_OPS], [
1523         LB2_LINUX_TEST_SRC([proc_ops], [
1524                 #include <linux/proc_fs.h>
1525
1526                 static struct proc_ops *my_proc;
1527         ],[
1528                 my_proc->proc_lseek = NULL;
1529         ],[-Werror])
1530 ]) # LIBCFS_SRC_HAVE_PROC_OPS
1531 AC_DEFUN([LIBCFS_HAVE_PROC_OPS], [
1532         AC_MSG_CHECKING([if struct proc_ops exists])
1533         LB2_LINUX_TEST_RESULT([proc_ops], [
1534                 AC_DEFINE(HAVE_PROC_OPS, 1,
1535                         [struct proc_ops exists])
1536                 AC_MSG_RESULT(yes)
1537         ],[
1538                 AC_MSG_RESULT(no)
1539         ])
1540 ]) # LIBCFS_HAVE_PROC_OPS
1541
1542 #
1543 # LIBCFS_VMALLOC_2ARGS
1544 #
1545 # kernel v5.8-rc1~201^2~19
1546 # mm: remove the pgprot argument to __vmalloc
1547 AC_DEFUN([LIBCFS_VMALLOC_2ARGS], [
1548 LB_CHECK_COMPILE([if __vmalloc has 2 args],
1549 vmalloc_2args, [
1550         #include <linux/vmalloc.h>
1551 ],[
1552         __vmalloc(0, 0);
1553 ],[
1554         AC_DEFINE(HAVE_VMALLOC_2ARGS, 1,
1555                 [__vmalloc only takes 2 args.])
1556 ])
1557 ]) # LIBCFS_VMALLOC_2ARGS
1558
1559 #
1560 # LIBCFS_HAVE_NR_UNSTABLE_NFS
1561 #
1562 # kernel v5.8-rc1~201^2~75
1563 # mm/writeback: discard NR_UNSTABLE_NFS, use NR_WRITEBACK instead
1564 #
1565 AC_DEFUN([LIBCFS_HAVE_NR_UNSTABLE_NFS], [
1566 tmp_flags="$EXTRA_KCFLAGS"
1567 EXTRA_KCFLAGS="-Werror"
1568 LB_CHECK_COMPILE([if NR_UNSTABLE_NFS still in use],
1569 nr_unstable_nfs_exists, [
1570         #include <linux/mm.h>
1571
1572         int i;
1573 ],[
1574         i = NR_UNSTABLE_NFS;
1575 ],[
1576         AC_DEFINE(HAVE_NR_UNSTABLE_NFS, 1,
1577                 [NR_UNSTABLE_NFS is still in use.])
1578 ])
1579 EXTRA_KCFLAGS="$tmp_flags"
1580 ]) # LIBCFS_HAVE_NR_UNSTABLE_NFS
1581
1582 #
1583 # LIBCFS_HAVE_MMAP_LOCK
1584 #
1585 # kernel v5.8-rc1~83^2~24
1586 # mmap locking API: rename mmap_sem to mmap_lock
1587 #
1588 AC_DEFUN([LIBCFS_HAVE_MMAP_LOCK], [
1589 LB_CHECK_COMPILE([if mmap_lock API is available],
1590 mmap_write_lock, [
1591         #include <linux/mm.h>
1592 ],[
1593         mmap_write_lock(NULL);
1594 ],[
1595         AC_DEFINE(HAVE_MMAP_LOCK, 1,
1596                 [mmap_lock API is available.])
1597 ])
1598 ]) # LIBCFS_HAVE_MMAP_LOCK
1599
1600 #
1601 # LIBCFS_KERNEL_SETSOCKOPT
1602 #
1603 # kernel v5.8-rc1~165^2~59^2
1604 # net: remove kernel_setsockopt
1605 AC_DEFUN([LIBCFS_KERNEL_SETSOCKOPT], [
1606 tmp_flags="$EXTRA_KCFLAGS"
1607 EXTRA_KCFLAGS="-Werror"
1608 LB_CHECK_COMPILE([if kernel_setsockopt still in use],
1609 kernel_setsockopt_exists, [
1610         #include <linux/net.h>
1611 ],[
1612         kernel_setsockopt(NULL, 0, 0, NULL, 0);
1613 ],[
1614         AC_DEFINE(HAVE_KERNEL_SETSOCKOPT, 1,
1615                 [kernel_setsockopt still in use])
1616 ])
1617 EXTRA_KCFLAGS="$tmp_flags"
1618 ]) # LIBCFS_KERNEL_SETSOCKOPT
1619
1620 #
1621 # LIBCFS_SEC_RELEASE_SECCTX
1622 #
1623 # kernel linux-hwe-5.8 (5.8.0-22.23~20.04.1)
1624 # LSM: Use lsmcontext in security_release_secctx
1625 AC_DEFUN([LIBCFS_SEC_RELEASE_SECCTX], [
1626 LB_CHECK_COMPILE([if security_release_secctx has 1 arg],
1627 security_release_secctx_1arg, [
1628         #include <linux/security.h>
1629 ],[
1630         security_release_secctx(NULL);
1631 ],[
1632         AC_DEFINE(HAVE_SEC_RELEASE_SECCTX_1ARG, 1,
1633                 [security_release_secctx has 1 arg.])
1634 ])
1635 ]) # LIBCFS_SEC_RELEASE_SECCTX
1636
1637 #
1638 # LIBCFS_HAVE_KFREE_SENSITIVE
1639 #
1640 # kernel v5.10-rc1~3
1641 # mm: remove kzfree() compatibility definition
1642 #
1643 AC_DEFUN([LIBCFS_HAVE_KFREE_SENSITIVE], [
1644 LB_CHECK_COMPILE([if kfree_sensitive() is available],
1645 kfree_sensitive_exists, [
1646         #include <linux/slab.h>
1647
1648 ],[
1649         kfree_sensitive(NULL);
1650 ],[
1651         AC_DEFINE(HAVE_KFREE_SENSITIVE, 1,
1652                 [kfree_sensitive() is available.])
1653 ])
1654 EXTRA_KCFLAGS="$tmp_flags"
1655 ]) # LIBCFS_HAVE_KFREE_SENSITIVE
1656
1657 #
1658 # LIBCFS_HAVE_CRYPTO_SHA2_HEADER
1659 #
1660 # Kernel v5.10-rc1-114-ga24d22b225ce
1661 # crypto: sha - split sha.h into sha1.h and sha2.h
1662 #
1663 AC_DEFUN([LIBCFS_HAVE_CRYPTO_SHA2_HEADER], [
1664 LB_CHECK_LINUX_HEADER([crypto/sha2.h], [
1665         AC_DEFINE(HAVE_CRYPTO_SHA2_HEADER, 1,
1666                 [crypto/sha2.h is present])])
1667 ]) # LIBCFS_HAVE_CRYPTO_SHA2_HEADER
1668
1669 AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
1670         LIBCFS_SRC_HAVE_PROC_OPS
1671
1672         AC_MSG_CHECKING([for available kernel interfaces to libcfs])
1673         LB2_LINUX_TEST_COMPILE_ALL([libcfs])
1674         AC_MSG_RESULT([done])
1675 ])
1676 AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [
1677         # 5.6
1678         LIBCFS_HAVE_PROC_OPS
1679 ])
1680
1681 #
1682 # LIBCFS_PROG_LINUX
1683 #
1684 # LibCFS linux kernel checks
1685 #
1686 AC_DEFUN([LIBCFS_PROG_LINUX], [
1687 AC_MSG_NOTICE([LibCFS kernel checks
1688 ==============================================================================])
1689 LIBCFS_CONFIG_PANIC_DUMPLOG
1690
1691 # 3.11
1692 LIBCFS_KTIME_GET_TS64
1693 # 3.12
1694 LIBCFS_PREPARE_TO_WAIT_EVENT
1695 LIBCFS_KERNEL_PARAM_OPS
1696 LIBCFS_KTIME_ADD
1697 LIBCFS_KTIME_AFTER
1698 LIBCFS_KTIME_BEFORE
1699 LIBCFS_KTIME_COMPARE
1700 LIBCFS_SHRINKER_COUNT
1701 # 3.15
1702 LIBCFS_HAVE_MAPPING_AS_EXITING_FLAG
1703 LIBCFS_IOV_ITER_HAS_TYPE
1704 # 3.16
1705 LIBCFS_HAVE_NS_TO_TIMESPEC64
1706 # 3.17
1707 LIBCFS_HLIST_ADD_AFTER
1708 LIBCFS_TIMESPEC64
1709 LIBCFS_KTIME_GET_NS
1710 LIBCFS_KTIME_GET_REAL_TS64
1711 LIBCFS_KTIME_GET_REAL_SECONDS
1712 LIBCFS_KTIME_GET_REAL_NS
1713 LIBCFS_KTIME_TO_TIMESPEC64
1714 LIBCFS_TIMESPEC64_SUB
1715 LIBCFS_TIMESPEC64_TO_KTIME
1716 # 3.19
1717 LIBCFS_KTIME_GET_SECONDS
1718 LIBCFS_WAIT_WOKEN
1719 # 4.0
1720 LIBCFS_KTIME_MS_DELTA
1721 # 4.1
1722 LIBCFS_KERNEL_PARAM_LOCK
1723 # 4.2
1724 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
1725 # 4.4
1726 LIBCFS_KSTRTOBOOL_FROM_USER
1727 LIBCFS_NETLINK_CALLBACK_START
1728 # 4.5
1729 LIBCFS_CRYPTO_HASH_HELPERS
1730 LIBCFS_EXPORT_KSET_FIND_OBJ
1731 LIBCFS_RHASHTABLE_REPLACE
1732 # 4.6
1733 LIBCFS_BROKEN_HASH_64
1734 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT
1735 LIBCFS_GET_USER_PAGES_6ARG
1736 LIBCFS_STRINGHASH
1737 # 4.7
1738 LIBCFS_RHASHTABLE_INSERT_FAST
1739 LIBCFS_RHASHTABLE_WALK_INIT_3ARG
1740 # 4.8
1741 LIBCFS_RHASHTABLE_LOOKUP
1742 LIBCFS_RHLTABLE
1743 LIBCFS_STACKTRACE_OPS
1744 # 4.9
1745 LIBCFS_GET_USER_PAGES_GUP_FLAGS
1746 LIBCFS_RHASHTABLE_WALK_ENTER
1747 # 4.10
1748 LIBCFS_HOTPLUG_STATE_MACHINE
1749 LIBCFS_REFCOUNT_T
1750 # 4.11
1751 LIBCFS_RHASHTABLE_LOOKUP_GET_INSERT_FAST
1752 LIBCFS_SCHED_HEADERS
1753 LIBCFS_KREF_READ
1754 LIBCFS_RHT_BUCKET_VAR
1755 # 4.12
1756 LIBCFS_HAVE_PROCESSOR_HEADER
1757 LIBCFS_HAVE_WAIT_BIT_HEADER
1758 LIBCFS_MEMALLOC_NORECLAIM
1759 LIBCFS_NL_EXT_ACK
1760 LIBCFS_WAIT_QUEUE_TASK_LIST_RENAME
1761 LIBCFS_CPUS_READ_LOCK
1762 LIBCFS_UUID_T
1763 # 4.13
1764 LIBCFS_NLA_STRDUP
1765 LIBCFS_WAIT_QUEUE_ENTRY
1766 # 4.14
1767 LIBCFS_DEFINE_TIMER
1768 LIBCFS_NEW_KERNEL_WRITE
1769 LIBCFS_NEW_KERNEL_READ
1770 LIBCFS_EXPORT_SAVE_STACK_TRACE_TSK
1771 # 4.15
1772 LIBCFS_LOCKDEP_IS_HELD
1773 LIBCFS_TIMER_SETUP
1774 # 4.16
1775 LIBCFS_WAIT_VAR_EVENT
1776 # 4.17
1777 LIBCFS_BITMAP_ALLOC
1778 LIBCFS_CLEAR_AND_WAKE_UP_BIT
1779 # 4.18
1780 LIBCFS_TCP_SOCK_SET_NODELAY
1781 LIBCFS_TCP_SOCK_SET_KEEPIDLE
1782 # 4.19
1783 LIBCFS_XARRAY_SUPPORT
1784 LIBCFS_NL_DUMP_EXT_ACK
1785 # 4.20
1786 LIBCFS_HAVE_IOV_ITER_TYPE
1787 # 5.0
1788 LIBCFS_MM_TOTALRAM_PAGES_FUNC
1789 LIBCFS_GET_REQUEST_KEY_AUTH
1790 # 5.3
1791 LIBCFS_LOOKUP_USER_KEY
1792 LIBCFS_FORCE_SIG_WITH_TASK
1793 LIBCFS_CACHE_DETAIL_WRITERS
1794 LIBCFS_HAVE_NR_UNSTABLE_NFS
1795 # 5.7
1796 LIBCFS_KALLSYMS_LOOKUP
1797 LIBCFS_TCP_SOCK_SET_QUICKACK
1798 LIBCFS_TCP_SOCK_SET_KEEPINTVL
1799 LIBCFS_TCP_SOCK_SET_KEEPCNT
1800 # 5.8
1801 LIBCFS_HAVE_MMAP_LOCK
1802 LIBCFS_KERNEL_SETSOCKOPT
1803 LIBCFS_VMALLOC_2ARGS
1804 LIBCFS_SEC_RELEASE_SECCTX
1805 # 5.10
1806 LIBCFS_HAVE_KFREE_SENSITIVE
1807 LIBCFS_HAVE_CRYPTO_SHA2_HEADER
1808 ]) # LIBCFS_PROG_LINUX
1809
1810 #
1811 # LIBCFS_PATH_DEFAULTS
1812 #
1813 # default paths for installed files
1814 #
1815 AC_DEFUN([LIBCFS_PATH_DEFAULTS], [
1816 ]) # LIBCFS_PATH_DEFAULTS
1817
1818 #
1819 # LIBCFS_CONFIGURE
1820 #
1821 # other configure checks
1822 #
1823 AC_DEFUN([LIBCFS_CONFIGURE], [
1824 AC_MSG_NOTICE([LibCFS core checks
1825 ==============================================================================])
1826
1827 # libcfs/libcfs/util/nidstrings.c
1828 AC_CHECK_HEADERS([netdb.h asm/types.h endian.h])
1829 AC_CHECK_FUNCS([gethostbyname])
1830
1831 # --------  Check for required packages  --------------
1832
1833 AC_MSG_NOTICE([LibCFS required packages checks
1834 ==============================================================================])
1835
1836 AC_MSG_CHECKING([whether to enable readline support])
1837 AC_ARG_ENABLE(readline,
1838         AC_HELP_STRING([--disable-readline],
1839                 [disable readline support]),
1840         [], [enable_readline="yes"])
1841 AC_MSG_RESULT([$enable_readline])
1842
1843 LIBREADLINE=""
1844 AS_IF([test "x$enable_readline" = xyes], [
1845         AC_CHECK_LIB([readline], [readline], [
1846                 LIBREADLINE="-lreadline"
1847                 AC_DEFINE(HAVE_LIBREADLINE, 1,
1848                         [readline library is available])
1849         ])
1850 ])
1851 AC_SUBST(LIBREADLINE)
1852
1853 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
1854 AC_ARG_ENABLE([libpthread],
1855         AC_HELP_STRING([--disable-libpthread],
1856                 [disable libpthread]),
1857         [], [enable_libpthread="yes"])
1858 AC_MSG_RESULT([$enable_libpthread])
1859
1860 PTHREAD_LIBS=""
1861 AS_IF([test "x$enable_libpthread" = xyes], [
1862         AC_CHECK_LIB([pthread], [pthread_create], [
1863                 PTHREAD_LIBS="-lpthread"
1864                 AC_DEFINE([HAVE_LIBPTHREAD], 1,
1865                         [use libpthread for libcfs library])
1866         ])
1867 ], [
1868         AC_MSG_WARN([Using libpthread for libcfs library is disabled explicitly])
1869 ])
1870 AC_SUBST(PTHREAD_LIBS)
1871 ]) # LIBCFS_CONFIGURE
1872
1873 #
1874 # LIBCFS_CONFIG_FILES
1875 #
1876 # files that should be generated with AC_OUTPUT
1877 #
1878 AC_DEFUN([LIBCFS_CONFIG_FILES], [
1879 AC_CONFIG_FILES([
1880 libcfs/Makefile
1881 libcfs/autoMakefile
1882 libcfs/autoconf/Makefile
1883 libcfs/include/Makefile
1884 libcfs/include/libcfs/Makefile
1885 libcfs/include/uapi/Makefile
1886 libcfs/include/libcfs/linux/Makefile
1887 libcfs/include/libcfs/util/Makefile
1888 libcfs/include/libcfs/crypto/Makefile
1889 libcfs/include/uapi/linux/Makefile
1890 libcfs/libcfs/Makefile
1891 libcfs/libcfs/autoMakefile
1892 libcfs/libcfs/linux/Makefile
1893 libcfs/libcfs/util/Makefile
1894 libcfs/libcfs/crypto/Makefile
1895 ])
1896 ]) # LIBCFS_CONFIG_FILES