Whamcloud - gitweb
LU-2221 ptlrpc: kerberos support for kernel>=2.6.24
[fs/lustre-release.git] / libcfs / autoconf / lustre-libcfs.m4
1 #
2 # LN_CONFIG_CDEBUG
3 #
4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
5 #
6 AC_DEFUN([LN_CONFIG_CDEBUG],
7 [
8 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
9 AC_ARG_ENABLE([libcfs_cdebug],
10         AC_HELP_STRING([--disable-libcfs-cdebug],
11                         [disable libcfs CDEBUG, CWARN]),
12         [],[enable_libcfs_cdebug='yes'])
13 AC_MSG_RESULT([$enable_libcfs_cdebug])
14 if test x$enable_libcfs_cdebug = xyes; then
15    AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
16 else
17    AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
18 fi
19
20 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
21 AC_ARG_ENABLE([libcfs_trace],
22         AC_HELP_STRING([--disable-libcfs-trace],
23                         [disable libcfs ENTRY/EXIT]),
24         [],[enable_libcfs_trace='yes'])
25 AC_MSG_RESULT([$enable_libcfs_trace])
26 if test x$enable_libcfs_trace = xyes; then
27    AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
28 else
29    AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
30 fi
31
32 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
33 AC_ARG_ENABLE([libcfs_assert],
34         AC_HELP_STRING([--disable-libcfs-assert],
35                         [disable libcfs LASSERT, LASSERTF]),
36         [],[enable_libcfs_assert='yes'])
37 AC_MSG_RESULT([$enable_libcfs_assert])
38 if test x$enable_libcfs_assert = xyes; then
39    AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
40 fi
41 ])
42
43 #
44 # LIBCFS_CONFIG_PANIC_DUMPLOG
45 #
46 # check if tunable panic_dumplog is wanted
47 #
48 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG],
49 [AC_MSG_CHECKING([for tunable panic_dumplog support])
50 AC_ARG_ENABLE([panic_dumplog],
51        AC_HELP_STRING([--enable-panic_dumplog],
52                       [enable panic_dumplog]),
53        [],[enable_panic_dumplog='no'])
54 if test x$enable_panic_dumplog = xyes ; then
55        AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
56        AC_MSG_RESULT([yes (by request)])
57 else
58        AC_MSG_RESULT([no])
59 fi
60 ])
61
62 # check kernel __u64 type
63 AC_DEFUN([LIBCFS_U64_LONG_LONG_LINUX],
64 [
65 AC_MSG_CHECKING([kernel __u64 is long long type])
66 tmp_flags="$EXTRA_KCFLAGS"
67 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
68 LB_LINUX_TRY_COMPILE([
69         #include <linux/types.h>
70         #include <linux/stddef.h>
71 ],[
72         unsigned long long *data;
73
74         data = (__u64*)sizeof(data);
75 ],[
76         AC_MSG_RESULT([yes])
77         AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
78                   [kernel __u64 is long long type])
79 ],[
80         AC_MSG_RESULT([no])
81 ])
82 EXTRA_KCFLAGS="$tmp_flags"
83 ])
84
85 # LIBCFS_TASKLIST_LOCK
86 # 2.6.18 remove tasklist_lock export
87 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
88 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
89 [kernel/fork.c],[
90 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
91          [tasklist_lock exported])
92 ],[
93 ])
94 ])
95
96 # LIBCFS_DIGEST_SETKEY_FLAGS
97 # digest_alg.dia_setkey takes 4 args (2.6.18)
98 #
99 AC_DEFUN([LIBCFS_DIGEST_SETKEY_FLAGS],
100 [AC_MSG_CHECKING([if kernel dia_setkey takes 4 args])
101 LB_LINUX_TRY_COMPILE([
102         #include <linux/err.h>
103         #include <linux/crypto.h>
104 ],[
105         struct digest_alg alg;
106
107         alg.dia_setkey(NULL, NULL, 0, NULL);
108 ],[
109         AC_MSG_RESULT([yes])
110         AC_DEFINE(HAVE_DIGEST_SETKEY_FLAGS, 1, [kernel dia_setkey takes 4 args])
111 ],[
112         AC_MSG_RESULT([no])
113 ])
114 ])
115
116 # 2.6.19 API changes
117 # kmem_cache_destroy(cachep) return void instead of
118 # int
119 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
120 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
121 LB_LINUX_TRY_COMPILE([
122         #include <linux/slab.h>
123 ],[
124         int i __attribute__ ((unused));
125         i = kmem_cache_destroy(NULL);
126 ],[
127         AC_MSG_RESULT(yes)
128         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
129                 [kmem_cache_destroy(cachep) return int])
130 ],[
131         AC_MSG_RESULT(NO)
132 ])
133 ])
134
135 # check cpumask_size (2.6.28)
136 AC_DEFUN([LIBCFS_CPUMASK_SIZE],
137 [AC_MSG_CHECKING([whether have cpumask_size()])
138 LB_LINUX_TRY_COMPILE([
139         #include <linux/cpumask.h>
140 ],[
141         int size = cpumask_size();
142 ],[
143         AC_MSG_RESULT(yes)
144         AC_DEFINE(HAVE_CPUMASK_SIZE, 1, [have cpumask_size()])
145 ],[
146         AC_MSG_RESULT(NO)
147 ])
148 ])
149
150 # check cpu topology functions
151 #
152 # topology_core_cpumask (2.6.29, not on all archs)
153 # topology_core_siblings (not on all archs)
154 # topology_thread_cpumask (2.6.29, not on all archs)
155 # topology_thread_siblings (not on all archs)
156 # cpumask_of_node/node_to_cpumask (not always exported)
157 AC_DEFUN([LIBCFS_CPU_TOPOLOGY],
158 [AC_MSG_CHECKING([whether have topology.h])
159 LB_LINUX_TRY_COMPILE([
160         #include <linux/topology.h>
161 ],[],[
162         AC_DEFINE(HAVE_CPU_TOPOLOGY, 1, [have CPU topology])
163         AC_MSG_RESULT(yes)
164
165         AC_MSG_CHECKING([whether have topology_core_cpumask])
166         LB_LINUX_TRY_COMPILE([
167                 #include <linux/topology.h>
168         ],[
169                 cpumask_t *mask = topology_core_cpumask(0);
170         ],[
171                 AC_DEFINE(HAVE_TOPOLOGY_CORE_CPUMASK, 1,
172                           [have topology_core_cpumask])
173                 AC_MSG_RESULT(yes)
174         ],[
175                 AC_MSG_RESULT(no)
176         ])
177
178         AC_MSG_CHECKING([whether have topology_core_siblings])
179         LB_LINUX_TRY_COMPILE([
180                 #include <linux/topology.h>
181         ],[
182                 cpumask_t mask = topology_core_siblings(0);
183         ],[
184                 AC_DEFINE(HAVE_TOPOLOGY_CORE_SIBLINGS, 1,
185                           [have topology_core_siblings])
186                 AC_MSG_RESULT(yes)
187         ],[
188                 AC_MSG_RESULT(no)
189         ])
190
191         AC_MSG_CHECKING([whether have topology_thread_cpumask])
192         LB_LINUX_TRY_COMPILE([
193                 #include <linux/topology.h>
194         ],[
195                 cpumask_t *mask = topology_thread_cpumask(0);
196         ],[
197                 AC_DEFINE(HAVE_TOPOLOGY_THREAD_CPUMASK, 1,
198                           [have topology_thread_cpumask])
199                 AC_MSG_RESULT(yes)
200         ],[
201                 AC_MSG_RESULT(no)
202         ])
203
204         AC_MSG_CHECKING([whether have topology_thread_siblings])
205         LB_LINUX_TRY_COMPILE([
206                 #include <linux/topology.h>
207         ],[
208                 cpumask_t mask = topology_thread_siblings(0);
209         ],[
210                 AC_DEFINE(HAVE_TOPOLOGY_THREAD_SIBLINGS, 1,
211                           [have topology_thread_siblings])
212                 AC_MSG_RESULT(yes)
213         ],[
214                 AC_MSG_RESULT(no)
215         ])
216
217         AC_MSG_CHECKING([whether OFED backports have cpumask_of_node])
218         # Some OFED has cpumask_of_node backports defined in
219         # its private include/linux/cpumask.h. However, it is
220         # defined conflictingly with kernel's cpumask_of_node.
221         if test -f $OFED_BACKPORT_PATH/linux/cpumask.h; then
222                 grep -q cpumask_of_node $OFED_BACKPORT_PATH/linux/cpumask.h 2>/dev/null
223                 rc=$?
224                 if test $rc -eq 0; then
225                         AC_DEFINE(HAVE_OFED_CPUMASK_OF_NODE, 1, [have cpumask_of_node])
226                         AC_MSG_RESULT(yes)
227                 else
228                         AC_MSG_RESULT(no)
229                 fi
230         fi
231
232         AC_MSG_CHECKING([whether have cpumask_of_node])
233         LB_LINUX_TRY_COMPILE([
234                 #include <linux/topology.h>
235         ],[
236                 cpumask_t *mask = cpumask_of_node(0);
237         ],[
238                 AC_DEFINE(HAVE_CPUMASK_OF_NODE, 1, [have cpumask_of_node])
239                 AC_MSG_RESULT(yes)
240         ],[
241                 AC_MSG_RESULT(no)
242         ])
243
244         AC_MSG_CHECKING([whether have cpumask_copy])
245         LB_LINUX_TRY_COMPILE([
246                 #include <linux/cpumask.h>
247         ],[
248                 cpumask_copy(NULL, NULL);
249         ],[
250                 AC_DEFINE(HAVE_CPUMASK_COPY, 1, [have cpumask_copy])
251                 AC_MSG_RESULT(yes)
252         ],[
253                 AC_MSG_RESULT(no)
254         ])
255
256         AC_MSG_CHECKING([whether have node_to_cpumask])
257         LB_LINUX_TRY_COMPILE([
258                 #include <linux/topology.h>
259         ],[
260                 cpumask_t mask = node_to_cpumask(0);
261         ],[
262                 AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1, [have node_to_cpumask])
263                 AC_MSG_RESULT(yes)
264         ],[
265                 AC_MSG_RESULT(no)
266         ])
267 ],[
268         AC_MSG_RESULT(NO)
269 ])
270 ])
271
272
273 # 2.6.20 API change INIT_WORK use 2 args and not
274 # store data inside
275 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
276 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
277 LB_LINUX_TRY_COMPILE([
278         #include <linux/workqueue.h>
279 ],[
280         struct work_struct work __attribute__ ((unused));
281
282         INIT_WORK(&work, NULL, NULL);
283 ],[
284         AC_MSG_RESULT(yes)
285         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
286                   [INIT_WORK use 3 args and store data inside])
287 ],[
288         AC_MSG_RESULT(NO)
289 ])
290 ])
291
292 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
293 # instead of more old which need two.
294 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
295 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
296 LB_LINUX_TRY_COMPILE([
297         #include <linux/sysctl.h>
298 ],[
299         register_sysctl_table(NULL,0);
300 ],[
301         AC_MSG_RESULT(yes)
302         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
303                   [register_sysctl_table want 2 args])
304 ],[
305         AC_MSG_RESULT(NO)
306 ])
307 ])
308
309 # 2.6.23 lost dtor argument
310 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
311 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
312 LB_LINUX_TRY_COMPILE([
313         #include <linux/slab.h>
314 ],[
315         kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
316 ],[
317         AC_MSG_RESULT(yes)
318         AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
319                   [kmem_cache_create has dtor argument])
320 ],[
321         AC_MSG_RESULT(NO)
322 ])
323 ])
324
325 #2.6.23 has new shrinker API
326 AC_DEFUN([LC_REGISTER_SHRINKER],
327 [AC_MSG_CHECKING([if kernel has register_shrinker])
328 LB_LINUX_TRY_COMPILE([
329         #include <linux/mm.h>
330 ],[
331         register_shrinker(NULL);
332 ], [
333         AC_MSG_RESULT([yes])
334         AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
335                 [kernel has register_shrinker])
336 ],[
337         AC_MSG_RESULT([no])
338 ])
339 ])
340
341 # 2.6.24 request not use real numbers for ctl_name
342 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
343 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
344 LB_LINUX_TRY_COMPILE([
345         #include <linux/sysctl.h>
346 ],[
347         #ifndef CTL_UNNUMBERED
348         #error CTL_UNNUMBERED not exist in kernel
349         #endif
350 ],[
351         AC_MSG_RESULT(yes)
352         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
353                   [sysctl has CTL_UNNUMBERED])
354 ],[
355         AC_MSG_RESULT(NO)
356 ])
357 ])
358
359 # 2.6.24 lost scatterlist->page
360 AC_DEFUN([LIBCFS_SCATTERLIST_SETPAGE],
361 [AC_MSG_CHECKING([for exist sg_set_page])
362 LB_LINUX_TRY_COMPILE([
363         #include <asm/types.h>
364         #include <linux/scatterlist.h>
365 ],[
366         sg_set_page(NULL,NULL,0,0);
367 ],[
368         AC_MSG_RESULT(yes)
369         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
370                   [struct scatterlist has no page member])
371 ],[
372         AC_MSG_RESULT(NO)
373 ])
374 ])
375
376 # 2.6.24-rc1 sg_init_table
377 AC_DEFUN([LIBCFS_SCATTERLIST_INITTABLE],
378 [AC_MSG_CHECKING([for sg_init_table])
379 LB_LINUX_TRY_COMPILE([
380         #include <asm/types.h>
381         #include <linux/scatterlist.h>
382 ],[
383         sg_init_table(NULL,0);
384 ],[
385         AC_MSG_RESULT(yes)
386         AC_DEFINE(HAVE_SCATTERLIST_INITTABLE, 1,
387                   [scatterlist has sg_init_table])
388 ],[
389         AC_MSG_RESULT(NO)
390 ])
391 ])
392
393 # 2.6.24
394 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
395 [AC_MSG_CHECKING([for network stack has namespaces])
396 LB_LINUX_TRY_COMPILE([
397         #include <net/net_namespace.h>
398 ],[
399         struct net *net __attribute__ ((unused));
400         net = &init_net;
401 ],[
402         AC_MSG_RESULT(yes)
403         AC_DEFINE(HAVE_INIT_NET, 1,
404                   [kernel is support network namespaces ])
405 ],[
406         AC_MSG_RESULT(NO)
407 ])
408 ])
409
410 #
411 # LIBCFS_FUNC_DUMP_TRACE
412 #
413 # 2.6.23 exports dump_trace() so we can dump_stack() on any task
414 # 2.6.24 has stacktrace_ops.address with "reliable" parameter
415 #
416 AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
417 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
418 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c arch/x86/kernel/dumpstack_32.c arch/x86/kernel/dumpstack_64.c],[
419         tmp_flags="$EXTRA_KCFLAGS"
420         EXTRA_KCFLAGS="-Werror"
421         AC_MSG_CHECKING([whether we can really use dump_trace])
422         LB_LINUX_TRY_COMPILE([
423                 struct task_struct;
424                 struct pt_regs;
425                 #include <asm/stacktrace.h>
426         ],[
427         ],[
428                 AC_MSG_RESULT(yes)
429                 AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
430         ],[
431                 AC_MSG_RESULT(no)
432         ],[
433         ])
434         AC_MSG_CHECKING([whether print_trace_address has reliable argument])
435         LB_LINUX_TRY_COMPILE([
436                 struct task_struct;
437                 struct pt_regs;
438                 #include <asm/stacktrace.h>
439         ],[
440                 ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
441         ],[
442                 AC_MSG_RESULT(yes)
443                 AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
444                           [print_trace_address has reliable argument])
445         ],[
446                 AC_MSG_RESULT(no)
447         ],[
448         ])
449         AC_MSG_CHECKING([whether stacktrace_ops.warning is exist])
450         LB_LINUX_TRY_COMPILE([
451                 struct task_struct;
452                 struct pt_regs;
453                 #include <asm/stacktrace.h>
454         ],[
455                 ((struct stacktrace_ops *)0)->warning(NULL, NULL);
456         ],[
457                 AC_MSG_RESULT(yes)
458                 AC_DEFINE(HAVE_STACKTRACE_WARNING, 1, [stacktrace_ops.warning is exist])
459         ],[
460                 AC_MSG_RESULT(no)
461         ],[
462         ])
463         AC_MSG_CHECKING([dump_trace want address])
464         LB_LINUX_TRY_COMPILE([
465                 struct task_struct;
466                 struct pt_regs;
467                 #include <asm/stacktrace.h>
468         ],[
469                 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
470         ],[
471                 AC_MSG_RESULT(yes)
472                 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
473                           [dump_trace want address argument])
474         ],[
475                 AC_MSG_RESULT(no)
476         ],[
477         ])
478
479 EXTRA_KCFLAGS="$tmp_flags"
480 ])
481 ])
482
483
484 # 2.6.26 use int instead of atomic for sem.count
485 AC_DEFUN([LIBCFS_SEM_COUNT],
486 [AC_MSG_CHECKING([atomic sem.count])
487 LB_LINUX_TRY_COMPILE([
488         #include <asm/semaphore.h>
489 ],[
490         struct semaphore s __attribute__ ((unused));
491
492         atomic_read(&s.count);
493 ],[
494         AC_MSG_RESULT(yes)
495         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
496                   [semaphore counter is atomic])
497 ],[
498         AC_MSG_RESULT(NO)
499 ])
500 ])
501
502 # 2.6.27 have second argument to sock_map_fd
503 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
504 [AC_MSG_CHECKING([sock_map_fd have second argument])
505 LB_LINUX_TRY_COMPILE([
506         #include <linux/net.h>
507 ],[
508         sock_map_fd(NULL, 0);
509 ],[
510         AC_MSG_RESULT(yes)
511         AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
512                   [sock_map_fd have second argument])
513 ],[
514         AC_MSG_RESULT(NO)
515 ])
516 ])
517
518 # LIBCFS_CRED_WRAPPERS
519 #
520 # wrappers for task's credentials are in sles11
521 #
522 AC_DEFUN([LIBCFS_CRED_WRAPPERS],
523 [AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
524 LB_LINUX_TRY_COMPILE([
525        #include <linux/sched.h>
526 ],[
527        uid_t uid;
528
529        uid = current_uid() + sizeof(uid);
530 ],[
531        AC_MSG_RESULT([yes])
532        AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
533 ],[
534        AC_MSG_RESULT([no])
535 ])
536 ])
537
538 #
539 # LN_STRUCT_CRED_IN_TASK
540 #
541 # struct cred was introduced in 2.6.29 to streamline credentials in task struct
542 #
543 AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
544 [AC_MSG_CHECKING([if kernel has struct cred])
545 LB_LINUX_TRY_COMPILE([
546        #include <linux/sched.h>
547 ],[
548        struct task_struct *tsk = NULL;
549        tsk->real_cred = NULL;
550 ],[
551        AC_MSG_RESULT([yes])
552        AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
553 ],[
554        AC_MSG_RESULT([no])
555 ])
556 ])
557
558 # LIBCFS_STRUCT_SHASH_ALG
559 # struct shash_alg was introduced in 2.6.29
560 #
561 AC_DEFUN([LIBCFS_STRUCT_SHASH_ALG],
562 [AC_MSG_CHECKING([if kernel has struct shash_alg])
563 LB_LINUX_TRY_COMPILE([
564         #include <linux/err.h>
565         #include <crypto/internal/hash.h>
566 ],[
567         struct shash_alg foo;
568 ],[
569         AC_MSG_RESULT([yes])
570         AC_DEFINE(HAVE_STRUCT_SHASH_ALG, 1, [kernel has struct shash_alg])
571 ],[
572         AC_MSG_RESULT([no])
573 ])
574 ])
575
576
577 #
578 # LIBCFS_FUNC_UNSHARE_FS_STRUCT
579 #
580 # unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
581 # mess with copy_fs_struct
582 #
583 AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
584 [AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
585 tmp_flags="$EXTRA_KCFLAGS"
586 EXTRA_KCFLAGS="-Werror"
587 LB_LINUX_TRY_COMPILE([
588        #include <linux/sched.h>
589        #include <linux/fs_struct.h>
590 ],[
591        unshare_fs_struct();
592 ],[
593        AC_MSG_RESULT([yes])
594        AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
595 ],[
596        AC_MSG_RESULT([no])
597 ])
598 EXTRA_KCFLAGS="$tmp_flags"
599 ])
600
601 #
602 # LIBCFS_HAVE_IS_COMPAT_TASK
603 #
604 # Added in 2.6.17, it wasn't until 2.6.29 that all
605 # Linux architectures have is_compat_task()
606 #
607 AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
608 [AC_MSG_CHECKING([if is_compat_task() is declared])
609 LB_LINUX_TRY_COMPILE([
610         #include <linux/compat.h>
611 ],[
612         int i __attribute__ ((unused));
613         i = is_compat_task();
614 ],[
615         AC_MSG_RESULT([yes])
616         AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
617 ],[
618         AC_MSG_RESULT([no])
619 ])
620 ])
621
622 #
623 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
624 #
625 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
626 #
627 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
628 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
629 LB_LINUX_TRY_COMPILE([
630         #include <asm/stacktrace.h>
631 ],[
632         ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
633 ],[
634         AC_MSG_RESULT([yes])
635         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
636 ],[
637         AC_MSG_RESULT([no])
638 ])
639 ])
640
641 AC_DEFUN([LIBCFS_HAVE_OOM_H],
642 [LB_CHECK_FILE([$LINUX/include/linux/oom.h], [
643         AC_DEFINE(HAVE_LINUX_OOM_H, 1,
644                 [kernel has include/oom.h])
645 ],[
646         AC_MSG_RESULT([no])
647 ])
648 ])
649
650 #
651 # check set_mems_allowed
652 # 2.6.31 adds function set_mems_allowed in cpuset.h
653 #
654 AC_DEFUN([LIBCFS_HAVE_SET_MEMS_ALLOWED],
655 [AC_MSG_CHECKING([whether have set_mems_allowed()])
656 LB_LINUX_TRY_COMPILE([
657         #include <linux/cpuset.h>
658 ],[
659         nodemask_t mask;
660
661         set_mems_allowed(mask);
662 ],[
663         AC_MSG_RESULT(yes)
664         AC_DEFINE(HAVE_SET_MEMS_ALLOWED, 1, [have set_mems_allowed()])
665 ],[
666         AC_MSG_RESULT(NO)
667 ])
668 ])
669
670
671 #
672 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
673 #
674 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR],
675 [AC_MSG_CHECKING([shrinker want self pointer in handler])
676 LB_LINUX_TRY_COMPILE([
677         #include <linux/mm.h>
678 ],[
679         struct shrinker *tmp = NULL;
680         tmp->shrink(tmp, 0, 0);
681 ],[
682         AC_MSG_RESULT(yes)
683         AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
684                   [shrinker want self pointer in handler])
685 ],[
686         AC_MSG_RESULT(no)
687 ])
688 ])
689
690 # 2.6.18 store oom parameters in task struct.
691 # 2.6.32 store oom parameters in signal struct
692 AC_DEFUN([LIBCFS_OOMADJ_IN_SIG],
693 [AC_MSG_CHECKING([kernel store oom parameters in task])
694 LB_LINUX_TRY_COMPILE([
695         #include <linux/sched.h>
696 ],[
697         ((struct signal_struct *)0)->oom_adj = 0;
698 ],[
699         AC_MSG_RESULT(yes)
700         AC_DEFINE(HAVE_OOMADJ_IN_SIG, 1,
701                   [kernel store a oom parameters in signal struct])
702 ],[
703         AC_MSG_RESULT(no)
704 ])
705 ])
706
707 #
708 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
709 #
710 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME],
711 [AC_MSG_CHECKING([if ctl_table has a ctl_name field])
712 LB_LINUX_TRY_COMPILE([
713         #include <linux/sysctl.h>
714 ],[
715         struct ctl_table ct;
716         ct.ctl_name = sizeof(ct);
717 ],[
718         AC_MSG_RESULT(yes)
719         AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
720                   [ctl_table has ctl_name field])
721 ],[
722         AC_MSG_RESULT(no)
723 ])
724 ])
725
726 #
727 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
728 #
729 # 2.6.34 adds __add_wait_queue_exclusive
730 #
731 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
732 [AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
733 LB_LINUX_TRY_COMPILE([
734         #include <linux/wait.h>
735 ],[
736         wait_queue_head_t queue;
737         wait_queue_t      wait;
738
739         __add_wait_queue_exclusive(&queue, &wait);
740 ],[
741         AC_MSG_RESULT(yes)
742         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
743                   [__add_wait_queue_exclusive exists])
744 ],[
745         AC_MSG_RESULT(no)
746 ])
747 ])
748
749 #
750 # 2.6.35 kernel has sk_sleep function
751 #
752 AC_DEFUN([LC_SK_SLEEP],
753 [AC_MSG_CHECKING([if kernel has sk_sleep])
754 LB_LINUX_TRY_COMPILE([
755         #include <net/sock.h>
756 ],[
757         sk_sleep(NULL);
758 ],[
759         AC_MSG_RESULT(yes)
760         AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
761 ],[
762         AC_MSG_RESULT(no)
763 ])
764 ])
765
766 #
767 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
768 # pressure shrinker from Linux 3.0
769 #
770 AC_DEFUN([LC_SHRINK_CONTROL],
771 [AC_MSG_CHECKING([shrink_control is present])
772 LB_LINUX_TRY_COMPILE([
773         #include <linux/mm.h>
774 ],[
775         struct shrink_control tmp = {0};
776         tmp.nr_to_scan = sizeof(tmp);
777 ],[
778         AC_MSG_RESULT(yes)
779         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
780                   [shrink_control is present])
781 ],[
782         AC_MSG_RESULT(no)
783 ])
784 ])
785
786 #
787 # LIBCFS_PROG_LINUX
788 #
789 # LNet linux kernel checks
790 #
791 AC_DEFUN([LIBCFS_PROG_LINUX],
792 [
793 LIBCFS_CONFIG_PANIC_DUMPLOG
794
795 LIBCFS_U64_LONG_LONG_LINUX
796 # 2.6.18
797 LIBCFS_TASKLIST_LOCK
798 LIBCFS_HAVE_IS_COMPAT_TASK
799 LIBCFS_DIGEST_SETKEY_FLAGS
800 # 2.6.19
801 LIBCFS_KMEM_CACHE_DESTROY_INT
802 # 2.6.20
803 LIBCFS_3ARGS_INIT_WORK
804 # 2.6.21
805 LIBCFS_2ARGS_REGISTER_SYSCTL
806 # 2.6.23
807 LIBCFS_KMEM_CACHE_CREATE_DTOR
808 LC_REGISTER_SHRINKER
809 # 2.6.24
810 LIBCFS_SYSCTL_UNNUMBERED
811 LIBCFS_SCATTERLIST_SETPAGE
812 LIBCFS_SCATTERLIST_INITTABLE
813 LIBCFS_NETWORK_NAMESPACE
814 LIBCFS_FUNC_DUMP_TRACE
815 # 2.6.26
816 LIBCFS_SEM_COUNT
817 # 2.6.27
818 LIBCFS_CRED_WRAPPERS
819 # 2.6.28
820 LIBCFS_CPUMASK_SIZE
821 # 2.6.29
822 LIBCFS_STRUCT_CRED_IN_TASK
823 LIBCFS_CPU_TOPOLOGY
824 LIBCFS_STRUCT_SHASH_ALG
825 # 2.6.30
826 LIBCFS_FUNC_UNSHARE_FS_STRUCT
827 LIBCFS_SOCK_MAP_FD_2ARG
828 # 2.6.31
829 LIBCFS_HAVE_SET_MEMS_ALLOWED
830 # 2.6.32
831 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
832 LC_SHRINKER_WANT_SHRINK_PTR
833 LIBCFS_HAVE_OOM_H
834 LIBCFS_OOMADJ_IN_SIG
835 # 2.6.33
836 LIBCFS_SYSCTL_CTLNAME
837 # 2.6.34
838 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
839 # 2.6.35
840 LC_SK_SLEEP
841 # 2.6.40 fc15
842 LC_SHRINK_CONTROL
843 ])
844
845 #
846 # LIBCFS_PROG_DARWIN
847 #
848 # Darwin checks
849 #
850 AC_DEFUN([LIBCFS_PROG_DARWIN],
851 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
852 ])
853
854 #
855 # LIBCFS_PATH_DEFAULTS
856 #
857 # default paths for installed files
858 #
859 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
860 [
861 ])
862
863 #
864 # LIBCFS_CONFIGURE
865 #
866 # other configure checks
867 #
868 AC_DEFUN([LIBCFS_CONFIGURE],
869 [# lnet/utils/portals.c
870 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
871
872 # lnet/utils/debug.c
873 AC_CHECK_HEADERS([linux/version.h])
874
875 AC_CHECK_TYPE([spinlock_t],
876         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
877         [],
878         [#include <linux/spinlock.h>])
879
880 # lnet/utils/wirecheck.c
881 AC_CHECK_FUNCS([strnlen])
882
883 # lnet/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
884 AC_CHECK_FUNCS([strlcpy])
885
886 # libcfs/libcfs/user-prim.c, missing for RHEL5 and earlier userspace
887 AC_CHECK_FUNCS([strlcat])
888
889 AC_CHECK_TYPE([umode_t],
890         [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
891         [],
892         [#include <asm/types.h>])
893
894 AC_CHECK_TYPE([__s8],
895         [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
896         [],
897         [#include <asm/types.h>])
898
899 AC_CHECK_TYPE([__u8],
900         [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
901         [],
902         [#include <asm/types.h>])
903
904 AC_CHECK_TYPE([__s16],
905         [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
906         [],
907         [#include <asm/types.h>])
908
909 AC_CHECK_TYPE([__u16],
910         [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
911         [],
912         [#include <asm/types.h>])
913
914 AC_CHECK_TYPE([__s32],
915         [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
916         [],
917         [#include <asm/types.h>])
918
919 AC_CHECK_TYPE([__u32],
920         [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
921         [],
922         [#include <asm/types.h>])
923
924 AC_CHECK_TYPE([__u64],
925         [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
926         [],
927         [#include <asm/types.h>])
928
929 AC_CHECK_TYPE([__s64],
930         [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
931         [],
932         [#include <asm/types.h>])
933
934 # check userland __u64 type
935 AC_MSG_CHECKING([userspace __u64 is long long type])
936 tmp_flags="$CFLAGS"
937 CFLAGS="$CFLAGS -Werror"
938 AC_COMPILE_IFELSE([
939         #include <stdio.h>
940         #include <linux/types.h>
941         #include <linux/stddef.h>
942         int main(void) {
943                 unsigned long long *data1;
944                 __u64 *data2 = NULL;
945
946                 data1 = data2;
947                 return 0;
948         }
949 ],[
950         AC_MSG_RESULT([yes])
951         AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
952                   [__u64 is long long type])
953 ],[
954         AC_MSG_RESULT([no])
955 ])
956 CFLAGS="$tmp_flags"
957
958 # --------  Check for required packages  --------------
959
960
961 AC_MSG_CHECKING([if efence debugging support is requested])
962 AC_ARG_ENABLE(efence,
963         AC_HELP_STRING([--enable-efence],
964                         [use efence library]),
965         [],[enable_efence='no'])
966 AC_MSG_RESULT([$enable_efence])
967 if test "$enable_efence" = "yes" ; then
968         LIBEFENCE="-lefence"
969         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
970 else
971         LIBEFENCE=""
972 fi
973 AC_SUBST(LIBEFENCE)
974
975
976 # -------- check for -lpthread support ----
977 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
978 AC_ARG_ENABLE([libpthread],
979         AC_HELP_STRING([--disable-libpthread],
980                 [disable libpthread]),
981         [],[enable_libpthread=yes])
982 if test "$enable_libpthread" = "yes" ; then
983         AC_CHECK_LIB([pthread], [pthread_create],
984                 [ENABLE_LIBPTHREAD="yes"],
985                 [ENABLE_LIBPTHREAD="no"])
986         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
987                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
988                 PTHREAD_LIBS="-lpthread"
989                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
990         else
991                 PTHREAD_LIBS=""
992                 AC_MSG_RESULT([no libpthread is found])
993         fi
994         AC_SUBST(PTHREAD_LIBS)
995 else
996         AC_MSG_RESULT([no (disabled explicitly)])
997         ENABLE_LIBPTHREAD="no"
998 fi
999 AC_SUBST(ENABLE_LIBPTHREAD)
1000
1001
1002 ])
1003
1004 #
1005 # LIBCFS_CONDITIONALS
1006 #
1007 # AM_CONDITOINAL defines for lnet
1008 #
1009 AC_DEFUN([LIBCFS_CONDITIONALS],
1010 [
1011 ])
1012
1013 #
1014 # LIBCFS_CONFIG_FILES
1015 #
1016 # files that should be generated with AC_OUTPUT
1017 #
1018 AC_DEFUN([LIBCFS_CONFIG_FILES],
1019 [AC_CONFIG_FILES([
1020 libcfs/Kernelenv
1021 libcfs/Makefile
1022 libcfs/autoMakefile
1023 libcfs/autoconf/Makefile
1024 libcfs/include/Makefile
1025 libcfs/include/libcfs/Makefile
1026 libcfs/include/libcfs/linux/Makefile
1027 libcfs/include/libcfs/posix/Makefile
1028 libcfs/include/libcfs/util/Makefile
1029 libcfs/libcfs/Makefile
1030 libcfs/libcfs/autoMakefile
1031 libcfs/libcfs/linux/Makefile
1032 libcfs/libcfs/posix/Makefile
1033 libcfs/libcfs/util/Makefile
1034 libcfs/include/libcfs/darwin/Makefile
1035 libcfs/libcfs/darwin/Makefile
1036 ])
1037 ])