Whamcloud - gitweb
b=23289 new API: cfs_waitq_add_exclusive_head
[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 #
63 # LIBCFS_FUNC_CPU_ONLINE
64 #
65 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
66 #
67 AC_DEFUN([LIBCFS_FUNC_CPU_ONLINE],
68 [AC_MSG_CHECKING([if kernel defines cpu_online()])
69 LB_LINUX_TRY_COMPILE([
70        #include <linux/sched.h>
71 ],[
72        cpu_online(0);
73 ],[
74        AC_MSG_RESULT([yes])
75        AC_DEFINE(HAVE_CPU_ONLINE, 1, [cpu_online found])
76 ],[
77        AC_MSG_RESULT([no])
78 ])
79 ])
80
81 #
82 # LIBCFS_TYPE_GFP_T
83 #
84 # check if gfp_t is typedef-ed
85 #
86 AC_DEFUN([LIBCFS_TYPE_GFP_T],
87 [AC_MSG_CHECKING([if kernel defines gfp_t])
88 LB_LINUX_TRY_COMPILE([
89         #include <linux/gfp.h>
90 ],[
91         return sizeof(gfp_t);
92 ],[
93         AC_MSG_RESULT([yes])
94         AC_DEFINE(HAVE_GFP_T, 1, [gfp_t found])
95 ],[
96         AC_MSG_RESULT([no])
97 ])
98 ])
99
100 #
101 # LIBCFS_FUNC_SHOW_TASK
102 #
103 # we export show_task(), but not all kernels have it (yet)
104 #
105 AC_DEFUN([LIBCFS_FUNC_SHOW_TASK],
106 [LB_CHECK_SYMBOL_EXPORT([show_task],
107 [kernel/ksyms.c kernel/sched.c],[
108 AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
109 ],[
110         LB_CHECK_SYMBOL_EXPORT([sched_show_task],
111         [kernel/ksyms.c kernel/sched.c],[
112         AC_DEFINE(HAVE_SCHED_SHOW_TASK, 1, [sched_show_task is exported])
113         ],[])
114 ])
115 ])
116
117 # check kernel __u64 type
118 AC_DEFUN([LIBCFS_U64_LONG_LONG_LINUX],
119 [
120 AC_MSG_CHECKING([kernel __u64 is long long type])
121 tmp_flags="$EXTRA_KCFLAGS"
122 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
123 LB_LINUX_TRY_COMPILE([
124         #include <linux/types.h>
125         #include <linux/stddef.h>
126 ],[
127         unsigned long long *data1;
128         __u64 *data2 = NULL;
129
130         data1 = data2;
131 ],[
132         AC_MSG_RESULT([yes])
133         AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
134                   [kernel __u64 is long long type])
135 ],[
136         AC_MSG_RESULT([no])
137 ])
138 EXTRA_KCFLAGS="$tmp_flags"
139 ])
140
141 # check if task_struct with rcu memeber
142 AC_DEFUN([LIBCFS_TASK_RCU],
143 [AC_MSG_CHECKING([if task_struct has a rcu field])
144 LB_LINUX_TRY_COMPILE([
145         #include <linux/sched.h>
146 ],[
147         struct task_struct tsk;
148
149         tsk.rcu.next = NULL;
150 ],[
151         AC_MSG_RESULT([yes])
152         AC_DEFINE(HAVE_TASK_RCU, 1,
153                   [task_struct has rcu field])
154 ],[
155         AC_MSG_RESULT([no])
156 ])
157 ])
158
159 # LIBCFS_TASKLIST_LOCK
160 # 2.6.18 remove tasklist_lock export
161 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
162 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
163 [kernel/fork.c],[
164 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
165          [tasklist_lock exported])
166 ],[
167 ])
168 ])
169
170 # 2.6.19 API changes
171 # kmem_cache_destroy(cachep) return void instead of
172 # int
173 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
174 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
175 LB_LINUX_TRY_COMPILE([
176         #include <linux/slab.h>
177 ],[
178         int i = kmem_cache_destroy(NULL);
179 ],[
180         AC_MSG_RESULT(yes)
181         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
182                 [kmem_cache_destroy(cachep) return int])
183 ],[
184         AC_MSG_RESULT(NO)
185 ])
186 ])
187
188 # 2.6.19 API change
189 #panic_notifier_list use atomic_notifier operations
190 #
191 AC_DEFUN([LIBCFS_ATOMIC_PANIC_NOTIFIER],
192 [AC_MSG_CHECKING([panic_notifier_list is atomic])
193 LB_LINUX_TRY_COMPILE([
194         #include <linux/notifier.h>
195         #include <linux/kernel.h>
196 ],[
197         struct atomic_notifier_head panic_notifier_list;
198 ],[
199         AC_MSG_RESULT(yes)
200         AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
201                 [panic_notifier_list is atomic_notifier_head])
202 ],[
203         AC_MSG_RESULT(NO)
204 ])
205 ])
206
207 # since 2.6.19 nlmsg_multicast() needs 5 argument.
208 AC_DEFUN([LIBCFS_NLMSG_MULTICAST],
209 [AC_MSG_CHECKING([nlmsg_multicast needs 5 argument])
210 LB_LINUX_TRY_COMPILE([
211         #include <net/netlink.h>
212 ],[
213         nlmsg_multicast(NULL, NULL, 0, 0, 0);
214 ],[
215         AC_MSG_RESULT(yes)
216         AC_DEFINE(HAVE_NLMSG_MULTICAST_5ARGS, 1,
217                   [nlmsg_multicast needs 5 argument])
218 ],[
219         AC_MSG_RESULT(NO)
220 ])
221 ])
222
223 #
224 # LIBCFS_NETLINK
225 #
226 # If we have netlink.h, and nlmsg_new takes 2 args (2.6.19)
227 #
228 AC_DEFUN([LIBCFS_NETLINK],
229 [AC_MSG_CHECKING([if netlink.h can be compiled])
230 LB_LINUX_TRY_COMPILE([
231         #include <net/netlink.h>
232 ],[],[
233         AC_MSG_RESULT([yes])
234         AC_DEFINE(HAVE_NETLINK, 1, [net/netlink.h found])
235
236         AC_MSG_CHECKING([if nlmsg_new takes a 2nd argument])
237         LB_LINUX_TRY_COMPILE([
238                 #include <net/netlink.h>
239         ],[
240                 nlmsg_new(100, GFP_KERNEL);
241         ],[
242                 AC_MSG_RESULT([yes])
243                 AC_DEFINE(HAVE_NETLINK_NL2, 1, [nlmsg_new takes 2 args])
244         ],[
245                 AC_MSG_RESULT([no])
246         ])
247 ],[
248         AC_MSG_RESULT([no])
249 ])
250 ])
251
252 # 2.6.20 API change INIT_WORK use 2 args and not
253 # store data inside
254 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
255 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
256 LB_LINUX_TRY_COMPILE([
257         #include <linux/workqueue.h>
258 ],[
259         struct work_struct work;
260
261         INIT_WORK(&work, NULL, NULL);
262 ],[
263         AC_MSG_RESULT(yes)
264         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
265                   [INIT_WORK use 3 args and store data inside])
266 ],[
267         AC_MSG_RESULT(NO)
268 ])
269 ])
270
271 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
272 # instead of more old which need two.
273 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
274 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
275 LB_LINUX_TRY_COMPILE([
276         #include <linux/sysctl.h>
277 ],[
278         return register_sysctl_table(NULL,0);
279 ],[
280         AC_MSG_RESULT(yes)
281         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
282                   [register_sysctl_table want 2 args])
283 ],[
284         AC_MSG_RESULT(NO)
285 ])
286 ])
287
288 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
289 # instead
290 AC_DEFUN([LIBCFS_KMEM_CACHE],
291 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
292 tmp_flags="$EXTRA_KCFLAGS"
293 EXTRA_KCFLAGS="-Werror"
294 LB_LINUX_TRY_COMPILE([
295         #include <linux/slab.h>
296         typedef struct kmem_cache cache_t;
297 ],[
298         cache_t *cachep = NULL;
299
300         kmem_cache_alloc(cachep, 0);
301 ],[
302         AC_MSG_RESULT(yes)
303         AC_DEFINE(HAVE_KMEM_CACHE, 1,
304                   [kernel has struct kmem_cache])
305 ],[
306         AC_MSG_RESULT(NO)
307 ])
308 EXTRA_KCFLAGS="$tmp_flags"
309 ])
310
311 # 2.6.23 lost dtor argument
312 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
313 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
314 LB_LINUX_TRY_COMPILE([
315         #include <linux/slab.h>
316 ],[
317         kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
318 ],[
319         AC_MSG_RESULT(yes)
320         AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
321                   [kmem_cache_create has dtor argument])
322 ],[
323         AC_MSG_RESULT(NO)
324 ])
325 ])
326
327 # 2.6.24 
328 AC_DEFUN([LIBCFS_NETLINK_CBMUTEX],
329 [AC_MSG_CHECKING([for mutex in netlink_kernel_create])
330 LB_LINUX_TRY_COMPILE([
331         #include <linux/netlink.h>
332 ],[
333         struct mutex *lock = NULL;
334
335         netlink_kernel_create(0, 0, NULL, lock, NULL);
336 ],[
337         AC_MSG_RESULT(yes)
338         AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
339                   [netlink_kernel_create want mutex for callback])
340 ],[
341         AC_MSG_RESULT(NO)
342 ])
343 ])
344
345 # 2.6.24 request not use real numbers for ctl_name
346 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
347 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
348 LB_LINUX_TRY_COMPILE([
349         #include <linux/sysctl.h>
350 ],[
351         #ifndef CTL_UNNUMBERED
352         #error CTL_UNNUMBERED not exist in kernel
353         #endif
354 ],[
355         AC_MSG_RESULT(yes)
356         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
357                   [sysctl has CTL_UNNUMBERED])
358 ],[
359         AC_MSG_RESULT(NO)
360 ])
361 ])
362
363 # 2.6.24 lost scatterlist->page
364 AC_DEFUN([LIBCFS_SCATTERLIST_SETPAGE],
365 [AC_MSG_CHECKING([for exist sg_set_page])
366 LB_LINUX_TRY_COMPILE([
367         #include <asm/types.h>
368         #include <linux/scatterlist.h>
369 ],[
370         sg_set_page(NULL,NULL,0,0);
371 ],[
372         AC_MSG_RESULT(yes)
373         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
374                   [struct scatterlist has page member])
375 ],[
376         AC_MSG_RESULT(NO)
377 ])
378 ])
379
380 # 2.6.24 
381 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
382 [AC_MSG_CHECKING([for network stack has namespaces])
383 LB_LINUX_TRY_COMPILE([
384         #include <net/net_namespace.h>
385 ],[
386         struct net *net = &init_net;
387 ],[
388         AC_MSG_RESULT(yes)
389         AC_DEFINE(HAVE_INIT_NET, 1,
390                   [kernel is support network namespaces ])
391 ],[
392         AC_MSG_RESULT(NO)
393 ])
394 ])
395
396
397 # 2.6.24 
398 AC_DEFUN([LIBCFS_NETLINK_NETNS],
399 [AC_MSG_CHECKING([for netlink support net ns])
400 LB_LINUX_TRY_COMPILE([
401         #include <linux/netlink.h>
402 ],[
403         struct net *net = NULL;
404         struct mutex *lock = NULL;
405
406         netlink_kernel_create(net, 0, 0, NULL,
407                               lock,
408                               NULL);
409 ],[
410         AC_MSG_RESULT(yes)
411         AC_DEFINE(HAVE_NETLINK_NS, 1,
412                   [netlink is support network namespace])
413 # XXX
414 # for now - if kernel have netlink ns - he uses cbmutex
415         AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
416                   [netlink_kernel_create want mutex for callback])
417
418 ],[
419         AC_MSG_RESULT(NO)
420 ])
421 ])
422
423 # ~2.6.24
424 AC_DEFUN([LIBCFS_NL_BROADCAST_GFP],
425 [AC_MSG_CHECKING([for netlink_broadcast is want to have gfp parameter])
426 LB_LINUX_TRY_COMPILE([
427         #include <linux/netlink.h>
428 ],[
429         gfp_t gfp = GFP_KERNEL;
430
431         netlink_broadcast(NULL, NULL, 0, 0, gfp);
432 ],[
433         AC_MSG_RESULT(yes)
434         AC_DEFINE(HAVE_NL_BROADCAST_GFP, 1,
435                   [netlink brouacast is want to have gfp paramter])
436 ],[
437         AC_MSG_RESULT(NO)
438 ])
439 ])
440
441 #
442 # LIBCFS_FUNC_DUMP_TRACE
443 #
444 # 2.6.23 exports dump_trace() so we can dump_stack() on any task
445 # 2.6.24 has stacktrace_ops.address with "reliable" parameter
446 #
447 AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
448 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
449 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c arch/x86/kernel/dumpstack_32.c arch/x86/kernel/dumpstack_64.c],[
450         tmp_flags="$EXTRA_KCFLAGS"
451         EXTRA_KCFLAGS="-Werror"
452         AC_MSG_CHECKING([whether we can really use dump_trace])
453         LB_LINUX_TRY_COMPILE([
454                 struct task_struct;
455                 struct pt_regs;
456                 #include <asm/stacktrace.h>
457         ],[
458         ],[
459                 AC_MSG_RESULT(yes)
460                 AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
461         ],[
462                 AC_MSG_RESULT(no)
463         ],[
464         ])
465         AC_MSG_CHECKING([whether print_trace_address has reliable argument])
466         LB_LINUX_TRY_COMPILE([
467                 struct task_struct;
468                 struct pt_regs;
469                 void print_addr(void *data, unsigned long addr, int reliable);
470                 #include <asm/stacktrace.h>
471         ],[
472                 struct stacktrace_ops ops;
473
474                 ops.address = print_addr;
475         ],[
476                 AC_MSG_RESULT(yes)
477                 AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
478                           [print_trace_address has reliable argument])
479         ],[
480                 AC_MSG_RESULT(no)
481         ],[
482         ])
483 EXTRA_KCFLAGS="$tmp_flags"
484 ])
485 ])
486
487
488 # 2.6.26 use int instead of atomic for sem.count
489 AC_DEFUN([LIBCFS_SEM_COUNT],
490 [AC_MSG_CHECKING([atomic sem.count])
491 LB_LINUX_TRY_COMPILE([
492         #include <asm/semaphore.h>
493 ],[
494         struct semaphore s;
495         
496         atomic_read(&s.count);
497 ],[
498         AC_MSG_RESULT(yes)
499         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
500                   [semaphore counter is atomic])
501 ],[
502         AC_MSG_RESULT(NO)
503 ])
504 ])
505
506 # 2.6.27 have second argument to sock_map_fd
507 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
508 [AC_MSG_CHECKING([sock_map_fd have second argument])
509 LB_LINUX_TRY_COMPILE([
510         #include <linux/net.h>
511 ],[
512         sock_map_fd(NULL, 0);
513 ],[
514         AC_MSG_RESULT(yes)
515         AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
516                   [sock_map_fd have second argument])
517 ],[
518         AC_MSG_RESULT(NO)
519 ])
520 ])
521
522 # LIBCFS_CRED_WRAPPERS
523 #
524 # wrappers for task's credentials are in sles11
525 #
526 AC_DEFUN([LIBCFS_CRED_WRAPPERS],
527 [AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
528 LB_LINUX_TRY_COMPILE([
529        #include <linux/sched.h>
530 ],[
531        uid_t uid;
532
533        uid = current_uid();
534 ],[
535        AC_MSG_RESULT([yes])
536        AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
537 ],[
538        AC_MSG_RESULT([no])
539 ])
540 ])
541
542 #
543 # LN_STRUCT_CRED_IN_TASK
544 #
545 # struct cred was introduced in 2.6.29 to streamline credentials in task struct
546 #
547 AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
548 [AC_MSG_CHECKING([if kernel has struct cred])
549 LB_LINUX_TRY_COMPILE([
550        #include <linux/sched.h>
551 ],[
552        struct task_struct *tsk = NULL;
553        tsk->real_cred = NULL;
554 ],[
555        AC_MSG_RESULT([yes])
556        AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
557 ],[
558        AC_MSG_RESULT([no])
559 ])
560 ])
561
562 #
563 # LIBCFS_FUNC_UNSHARE_FS_STRUCT
564 #
565 # unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
566 # mess with copy_fs_struct
567 #
568 AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
569 [AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
570 tmp_flags="$EXTRA_KCFLAGS"
571 EXTRA_KCFLAGS="-Werror"
572 LB_LINUX_TRY_COMPILE([
573        #include <linux/sched.h>
574        #include <linux/fs_struct.h>
575 ],[
576        unshare_fs_struct();
577 ],[
578        AC_MSG_RESULT([yes])
579        AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
580 ],[
581        AC_MSG_RESULT([no])
582 ])
583 EXTRA_KCFLAGS="$tmp_flags"
584 ])
585
586 #
587 # LIBCFS_HAVE_IS_COMPAT_TASK
588 #
589 # Added in 2.6.17, it wasn't until 2.6.29 that all
590 # Linux architectures have is_compat_task()
591 #
592 AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
593 [AC_MSG_CHECKING([if is_compat_task() is declared])
594 LB_LINUX_TRY_COMPILE([
595         #include <linux/compat.h>
596 ],[
597         int i = is_compat_task();
598 ],[
599         AC_MSG_RESULT([yes])
600         AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
601 ],[
602         AC_MSG_RESULT([no])
603 ])
604 ])
605
606 #
607 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
608 #
609 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
610 #
611 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
612 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
613 LB_LINUX_TRY_COMPILE([
614         #include <asm/stacktrace.h>
615         unsigned long walkstack(struct thread_info *tinfo,
616                                            unsigned long *stack,
617                                            unsigned long bp,
618                                            const struct stacktrace_ops *ops,
619                                            void *data,
620                                            unsigned long *end,
621                                            int *graph);
622 ],[
623         struct stacktrace_ops ops;
624
625         ops.walk_stack = walkstack;
626 ],[
627         AC_MSG_RESULT([yes])
628         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
629 ],[
630         AC_MSG_RESULT([no])
631 ])
632 ])
633
634 #
635 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
636 #
637 # 2.6.34 adds __add_wait_queue_exclusive
638 #
639 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
640 [AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
641 LB_LINUX_TRY_COMPILE([
642         #include <linux/wait.h>
643 ],[
644         wait_queue_head_t queue;
645         wait_queue_t      wait;
646
647         __add_wait_queue_exclusive(&queue, &wait);
648 ],[
649         AC_MSG_RESULT(yes)
650         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
651                   [__add_wait_queue_exclusive exists])
652 ],[
653         AC_MSG_RESULT(no)
654 ])
655 ])
656
657 #
658 # LIBCFS_PROG_LINUX
659 #
660 # LNet linux kernel checks
661 #
662 AC_DEFUN([LIBCFS_PROG_LINUX],
663 [
664 LIBCFS_FUNC_CPU_ONLINE
665 LIBCFS_TYPE_GFP_T
666 LIBCFS_CONFIG_PANIC_DUMPLOG
667
668 LIBCFS_FUNC_SHOW_TASK
669 LIBCFS_U64_LONG_LONG_LINUX
670 LIBCFS_TASK_RCU
671 # 2.6.18
672 LIBCFS_TASKLIST_LOCK
673 LIBCFS_HAVE_IS_COMPAT_TASK
674 # 2.6.19
675 LIBCFS_NETLINK
676 LIBCFS_NLMSG_MULTICAST
677 LIBCFS_KMEM_CACHE_DESTROY_INT
678 LIBCFS_ATOMIC_PANIC_NOTIFIER
679 # 2.6.20
680 LIBCFS_3ARGS_INIT_WORK
681 # 2.6.21
682 LIBCFS_2ARGS_REGISTER_SYSCTL
683 LIBCFS_KMEM_CACHE
684 # 2.6.23
685 LIBCFS_KMEM_CACHE_CREATE_DTOR
686 LIBCFS_NETLINK_CBMUTEX
687 # 2.6.24
688 LIBCFS_SYSCTL_UNNUMBERED
689 LIBCFS_SCATTERLIST_SETPAGE
690 LIBCFS_NL_BROADCAST_GFP
691 LIBCFS_NETWORK_NAMESPACE
692 LIBCFS_NETLINK_NETNS
693 LIBCFS_FUNC_DUMP_TRACE
694 # 2.6.26
695 LIBCFS_SEM_COUNT
696 # 2.6.27
697 LIBCFS_CRED_WRAPPERS
698 # 2.6.29
699 LIBCFS_STRUCT_CRED_IN_TASK
700 # 2.6.30
701 LIBCFS_FUNC_UNSHARE_FS_STRUCT
702 LIBCFS_SOCK_MAP_FD_2ARG
703 # 2.6.32
704 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
705 # 2.6.34
706 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
707 ])
708
709 #
710 # LIBCFS_PROG_DARWIN
711 #
712 # Darwin checks
713 #
714 AC_DEFUN([LIBCFS_PROG_DARWIN],
715 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
716 ])
717
718 #
719 # LIBCFS_PATH_DEFAULTS
720 #
721 # default paths for installed files
722 #
723 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
724 [
725 ])
726
727 #
728 # LIBCFS_CONFIGURE
729 #
730 # other configure checks
731 #
732 AC_DEFUN([LIBCFS_CONFIGURE],
733 [# lnet/utils/portals.c
734 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
735
736 # lnet/utils/debug.c
737 AC_CHECK_HEADERS([linux/version.h])
738
739 AC_CHECK_TYPE([spinlock_t],
740         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
741         [],
742         [#include <linux/spinlock.h>])
743
744 # lnet/utils/wirecheck.c
745 AC_CHECK_FUNCS([strnlen])
746
747 AC_CHECK_TYPE([umode_t],
748         [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
749         [],
750         [#include <asm/types.h>])
751
752 AC_CHECK_TYPE([__s8],
753         [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
754         [],
755         [#include <asm/types.h>])
756
757 AC_CHECK_TYPE([__u8],
758         [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
759         [],
760         [#include <asm/types.h>])
761
762 AC_CHECK_TYPE([__s16],
763         [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
764         [],
765         [#include <asm/types.h>])
766
767 AC_CHECK_TYPE([__u16],
768         [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
769         [],
770         [#include <asm/types.h>])
771
772 AC_CHECK_TYPE([__s32],
773         [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
774         [],
775         [#include <asm/types.h>])
776
777 AC_CHECK_TYPE([__u32],
778         [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
779         [],
780         [#include <asm/types.h>])
781
782 AC_CHECK_TYPE([__u64],
783         [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
784         [],
785         [#include <asm/types.h>])
786
787 AC_CHECK_TYPE([__s64],
788         [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
789         [],
790         [#include <asm/types.h>])
791
792 # check userland __u64 type
793 AC_MSG_CHECKING([userspace __u64 is long long type])
794 tmp_flags="$CFLAGS"
795 CFLAGS="$CFLAGS -Werror"
796 AC_COMPILE_IFELSE([
797         #include <stdio.h>
798         #include <linux/types.h>
799         #include <linux/stddef.h>
800         int main(void) {
801                 unsigned long long *data1;
802                 __u64 *data2 = NULL;
803
804                 data1 = data2;
805                 return 0;
806         }
807 ],[
808         AC_MSG_RESULT([yes])
809         AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
810                   [__u64 is long long type])
811 ],[
812         AC_MSG_RESULT([no])
813 ])
814 CFLAGS="$tmp_flags"
815
816 # --------  Check for required packages  --------------
817
818
819 AC_MSG_CHECKING([if efence debugging support is requested])
820 AC_ARG_ENABLE(efence,
821         AC_HELP_STRING([--enable-efence],
822                         [use efence library]),
823         [],[enable_efence='no'])
824 AC_MSG_RESULT([$enable_efence])
825 if test "$enable_efence" = "yes" ; then
826         LIBEFENCE="-lefence"
827         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
828 else
829         LIBEFENCE=""
830 fi
831 AC_SUBST(LIBEFENCE)
832
833
834 # -------- check for -lpthread support ----
835 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
836 AC_ARG_ENABLE([libpthread],
837         AC_HELP_STRING([--disable-libpthread],
838                 [disable libpthread]),
839         [],[enable_libpthread=yes])
840 if test "$enable_libpthread" = "yes" ; then
841         AC_CHECK_LIB([pthread], [pthread_create],
842                 [ENABLE_LIBPTHREAD="yes"],
843                 [ENABLE_LIBPTHREAD="no"])
844         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
845                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
846                 PTHREAD_LIBS="-lpthread"
847                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
848         else
849                 PTHREAD_LIBS=""
850                 AC_MSG_RESULT([no libpthread is found])
851         fi
852         AC_SUBST(PTHREAD_LIBS)
853 else
854         AC_MSG_RESULT([no (disabled explicitly)])
855         ENABLE_LIBPTHREAD="no"
856 fi
857 AC_SUBST(ENABLE_LIBPTHREAD)
858
859
860 ])
861
862 #
863 # LIBCFS_CONDITIONALS
864 #
865 # AM_CONDITOINAL defines for lnet
866 #
867 AC_DEFUN([LIBCFS_CONDITIONALS],
868 [
869 ])
870
871 #
872 # LIBCFS_CONFIG_FILES
873 #
874 # files that should be generated with AC_OUTPUT
875 #
876 AC_DEFUN([LIBCFS_CONFIG_FILES],
877 [AC_CONFIG_FILES([
878 libcfs/Kernelenv
879 libcfs/Makefile
880 libcfs/autoMakefile
881 libcfs/autoconf/Makefile
882 libcfs/include/Makefile
883 libcfs/include/libcfs/Makefile
884 libcfs/include/libcfs/linux/Makefile
885 libcfs/include/libcfs/posix/Makefile
886 libcfs/include/libcfs/util/Makefile
887 libcfs/libcfs/Makefile
888 libcfs/libcfs/autoMakefile
889 libcfs/libcfs/linux/Makefile
890 libcfs/libcfs/posix/Makefile
891 libcfs/libcfs/util/Makefile
892 libcfs/include/libcfs/darwin/Makefile
893 libcfs/libcfs/darwin/Makefile
894 ])
895 ])