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