Whamcloud - gitweb
b=24086 separate kernel and userspace __u64 checking
[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 ])
111 ])
112
113 # check kernel __u64 type
114 AC_DEFUN([LIBCFS_U64_LONG_LONG_LINUX],
115 [
116 AC_MSG_CHECKING([kernel __u64 is long long type])
117 tmp_flags="$EXTRA_KCFLAGS"
118 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
119 LB_LINUX_TRY_COMPILE([
120         #include <linux/types.h>
121         #include <linux/stddef.h>
122 ],[
123         unsigned long long *data1;
124         __u64 *data2 = NULL;
125
126         data1 = data2;
127 ],[
128         AC_MSG_RESULT([yes])
129         AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
130                   [kernel __u64 is long long type])
131 ],[
132         AC_MSG_RESULT([no])
133 ])
134 EXTRA_KCFLAGS="$tmp_flags"
135 ])
136
137 # check if task_struct with rcu memeber
138 AC_DEFUN([LIBCFS_TASK_RCU],
139 [AC_MSG_CHECKING([if task_struct has a rcu field])
140 LB_LINUX_TRY_COMPILE([
141         #include <linux/sched.h>
142 ],[
143         struct task_struct tsk;
144
145         tsk.rcu.next = NULL;
146 ],[
147         AC_MSG_RESULT([yes])
148         AC_DEFINE(HAVE_TASK_RCU, 1,
149                   [task_struct has rcu field])
150 ],[
151         AC_MSG_RESULT([no])
152 ])
153 ])
154
155 # LIBCFS_TASKLIST_LOCK
156 # 2.6.18 remove tasklist_lock export
157 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
158 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
159 [kernel/fork.c],[
160 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
161          [tasklist_lock exported])
162 ],[
163 ])
164 ])
165
166 # 2.6.19 API changes
167 # kmem_cache_destroy(cachep) return void instead of
168 # int
169 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
170 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
171 LB_LINUX_TRY_COMPILE([
172         #include <linux/slab.h>
173 ],[
174         int i = kmem_cache_destroy(NULL);
175 ],[
176         AC_MSG_RESULT(yes)
177         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
178                 [kmem_cache_destroy(cachep) return int])
179 ],[
180         AC_MSG_RESULT(NO)
181 ])
182 ])
183
184 # 2.6.19 API change
185 #panic_notifier_list use atomic_notifier operations
186 #
187 AC_DEFUN([LIBCFS_ATOMIC_PANIC_NOTIFIER],
188 [AC_MSG_CHECKING([panic_notifier_list is atomic])
189 LB_LINUX_TRY_COMPILE([
190         #include <linux/notifier.h>
191         #include <linux/kernel.h>
192 ],[
193         struct atomic_notifier_head panic_notifier_list;
194 ],[
195         AC_MSG_RESULT(yes)
196         AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
197                 [panic_notifier_list is atomic_notifier_head])
198 ],[
199         AC_MSG_RESULT(NO)
200 ])
201 ])
202
203 # since 2.6.19 nlmsg_multicast() needs 5 argument.
204 AC_DEFUN([LIBCFS_NLMSG_MULTICAST],
205 [AC_MSG_CHECKING([nlmsg_multicast needs 5 argument])
206 LB_LINUX_TRY_COMPILE([
207         #include <net/netlink.h>
208 ],[
209         nlmsg_multicast(NULL, NULL, 0, 0, 0);
210 ],[
211         AC_MSG_RESULT(yes)
212         AC_DEFINE(HAVE_NLMSG_MULTICAST_5ARGS, 1,
213                   [nlmsg_multicast needs 5 argument])
214 ],[
215         AC_MSG_RESULT(NO)
216 ])
217 ])
218
219 #
220 # LIBCFS_NETLINK
221 #
222 # If we have netlink.h, and nlmsg_new takes 2 args (2.6.19)
223 #
224 AC_DEFUN([LIBCFS_NETLINK],
225 [AC_MSG_CHECKING([if netlink.h can be compiled])
226 LB_LINUX_TRY_COMPILE([
227         #include <net/netlink.h>
228 ],[],[
229         AC_MSG_RESULT([yes])
230         AC_DEFINE(HAVE_NETLINK, 1, [net/netlink.h found])
231
232         AC_MSG_CHECKING([if nlmsg_new takes a 2nd argument])
233         LB_LINUX_TRY_COMPILE([
234                 #include <net/netlink.h>
235         ],[
236                 nlmsg_new(100, GFP_KERNEL);
237         ],[
238                 AC_MSG_RESULT([yes])
239                 AC_DEFINE(HAVE_NETLINK_NL2, 1, [nlmsg_new takes 2 args])
240         ],[
241                 AC_MSG_RESULT([no])
242         ])
243 ],[
244         AC_MSG_RESULT([no])
245 ])
246 ])
247
248 # 2.6.20 API change INIT_WORK use 2 args and not
249 # store data inside
250 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
251 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
252 LB_LINUX_TRY_COMPILE([
253         #include <linux/workqueue.h>
254 ],[
255         struct work_struct work;
256
257         INIT_WORK(&work, NULL, NULL);
258 ],[
259         AC_MSG_RESULT(yes)
260         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
261                   [INIT_WORK use 3 args and store data inside])
262 ],[
263         AC_MSG_RESULT(NO)
264 ])
265 ])
266
267 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
268 # instead of more old which need two.
269 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
270 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
271 LB_LINUX_TRY_COMPILE([
272         #include <linux/sysctl.h>
273 ],[
274         return register_sysctl_table(NULL,0);
275 ],[
276         AC_MSG_RESULT(yes)
277         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
278                   [register_sysctl_table want 2 args])
279 ],[
280         AC_MSG_RESULT(NO)
281 ])
282 ])
283
284 # 2.6.21 marks kmem_cache_t deprecated and uses struct kmem_cache
285 # instead
286 AC_DEFUN([LIBCFS_KMEM_CACHE],
287 [AC_MSG_CHECKING([check kernel has struct kmem_cache])
288 tmp_flags="$EXTRA_KCFLAGS"
289 EXTRA_KCFLAGS="-Werror"
290 LB_LINUX_TRY_COMPILE([
291         #include <linux/slab.h>
292         typedef struct kmem_cache cache_t;
293 ],[
294         cache_t *cachep = NULL;
295
296         kmem_cache_alloc(cachep, 0);
297 ],[
298         AC_MSG_RESULT(yes)
299         AC_DEFINE(HAVE_KMEM_CACHE, 1,
300                   [kernel has struct kmem_cache])
301 ],[
302         AC_MSG_RESULT(NO)
303 ])
304 EXTRA_KCFLAGS="$tmp_flags"
305 ])
306
307 # 2.6.23 lost dtor argument
308 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
309 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
310 LB_LINUX_TRY_COMPILE([
311         #include <linux/slab.h>
312 ],[
313         kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
314 ],[
315         AC_MSG_RESULT(yes)
316         AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
317                   [kmem_cache_create has dtor argument])
318 ],[
319         AC_MSG_RESULT(NO)
320 ])
321 ])
322
323 # 2.6.24 
324 AC_DEFUN([LIBCFS_NETLINK_CBMUTEX],
325 [AC_MSG_CHECKING([for mutex in netlink_kernel_create])
326 LB_LINUX_TRY_COMPILE([
327         #include <linux/netlink.h>
328 ],[
329         struct mutex *lock = NULL;
330
331         netlink_kernel_create(0, 0, NULL, lock, NULL);
332 ],[
333         AC_MSG_RESULT(yes)
334         AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
335                   [netlink_kernel_create want mutex for callback])
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 page member])
371 ],[
372         AC_MSG_RESULT(NO)
373 ])
374 ])
375
376 # 2.6.24 
377 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
378 [AC_MSG_CHECKING([for network stack has namespaces])
379 LB_LINUX_TRY_COMPILE([
380         #include <net/net_namespace.h>
381 ],[
382         struct net *net = &init_net;
383 ],[
384         AC_MSG_RESULT(yes)
385         AC_DEFINE(HAVE_INIT_NET, 1,
386                   [kernel is support network namespaces ])
387 ],[
388         AC_MSG_RESULT(NO)
389 ])
390 ])
391
392
393 # 2.6.24 
394 AC_DEFUN([LIBCFS_NETLINK_NETNS],
395 [AC_MSG_CHECKING([for netlink support net ns])
396 LB_LINUX_TRY_COMPILE([
397         #include <linux/netlink.h>
398 ],[
399         struct net *net = NULL;
400         struct mutex *lock = NULL;
401
402         netlink_kernel_create(net, 0, 0, NULL,
403                               lock,
404                               NULL);
405 ],[
406         AC_MSG_RESULT(yes)
407         AC_DEFINE(HAVE_NETLINK_NS, 1,
408                   [netlink is support network namespace])
409 # XXX
410 # for now - if kernel have netlink ns - he uses cbmutex
411         AC_DEFINE(HAVE_NETLINK_CBMUTEX, 1,
412                   [netlink_kernel_create want mutex for callback])
413
414 ],[
415         AC_MSG_RESULT(NO)
416 ])
417 ])
418
419 # ~2.6.24
420 AC_DEFUN([LIBCFS_NL_BROADCAST_GFP],
421 [AC_MSG_CHECKING([for netlink_broadcast is want to have gfp parameter])
422 LB_LINUX_TRY_COMPILE([
423         #include <linux/netlink.h>
424 ],[
425         gfp_t gfp = GFP_KERNEL;
426
427         netlink_broadcast(NULL, NULL, 0, 0, gfp);
428 ],[
429         AC_MSG_RESULT(yes)
430         AC_DEFINE(HAVE_NL_BROADCAST_GFP, 1,
431                   [netlink brouacast is want to have gfp paramter])
432 ],[
433         AC_MSG_RESULT(NO)
434 ])
435 ])
436
437 #
438 # LIBCFS_FUNC_DUMP_TRACE
439 #
440 # 2.6.23 exports dump_trace() so we can dump_stack() on any task
441 # 2.6.24 has stacktrace_ops.address with "reliable" parameter
442 #
443 AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
444 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
445 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c],[
446         tmp_flags="$EXTRA_KCFLAGS"
447         EXTRA_KCFLAGS="-Werror"
448         AC_MSG_CHECKING([whether we can really use dump_trace])
449         LB_LINUX_TRY_COMPILE([
450                 struct task_struct;
451                 struct pt_regs;
452                 #include <asm/stacktrace.h>
453         ],[
454         ],[
455                 AC_MSG_RESULT(yes)
456                 AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
457         ],[
458                 AC_MSG_RESULT(no)
459         ],[
460         ])
461         AC_MSG_CHECKING([whether print_trace_address has reliable argument])
462         LB_LINUX_TRY_COMPILE([
463                 struct task_struct;
464                 struct pt_regs;
465                 void print_addr(void *data, unsigned long addr, int reliable);
466                 #include <asm/stacktrace.h>
467         ],[
468                 struct stacktrace_ops ops;
469
470                 ops.address = print_addr;
471         ],[
472                 AC_MSG_RESULT(yes)
473                 AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
474                           [print_trace_address has reliable argument])
475         ],[
476                 AC_MSG_RESULT(no)
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;
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();
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 #
559 # LIBCFS_FUNC_UNSHARE_FS_STRUCT
560 #
561 # unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
562 # mess with copy_fs_struct
563 #
564 AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
565 [AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
566 tmp_flags="$EXTRA_KCFLAGS"
567 EXTRA_KCFLAGS="-Werror"
568 LB_LINUX_TRY_COMPILE([
569        #include <linux/sched.h>
570        #include <linux/fs_struct.h>
571 ],[
572        unshare_fs_struct();
573 ],[
574        AC_MSG_RESULT([yes])
575        AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
576 ],[
577        AC_MSG_RESULT([no])
578 ])
579 EXTRA_KCFLAGS="$tmp_flags"
580 ])
581
582 #
583 # LIBCFS_HAVE_IS_COMPAT_TASK
584 #
585 # Added in 2.6.17, it wasn't until 2.6.29 that all
586 # Linux architectures have is_compat_task()
587 #
588 AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
589 [AC_MSG_CHECKING([if is_compat_task() is declared])
590 LB_LINUX_TRY_COMPILE([
591         #include <linux/compat.h>
592 ],[
593         int i = is_compat_task();
594 ],[
595         AC_MSG_RESULT([yes])
596         AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
597 ],[
598         AC_MSG_RESULT([no])
599 ])
600 ])
601
602 #
603 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
604 #
605 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
606 #
607 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
608 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
609 LB_LINUX_TRY_COMPILE([
610         #include <asm/stacktrace.h>
611         unsigned long walkstack(struct thread_info *tinfo,
612                                            unsigned long *stack,
613                                            unsigned long bp,
614                                            const struct stacktrace_ops *ops,
615                                            void *data,
616                                            unsigned long *end,
617                                            int *graph);
618 ],[
619         struct stacktrace_ops ops;
620
621         ops.walk_stack = walkstack;
622 ],[
623         AC_MSG_RESULT([yes])
624         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
625 ],[
626         AC_MSG_RESULT([no])
627 ])
628 ])
629
630 #
631 # LIBCFS_PROG_LINUX
632 #
633 # LNet linux kernel checks
634 #
635 AC_DEFUN([LIBCFS_PROG_LINUX],
636 [
637 LIBCFS_FUNC_CPU_ONLINE
638 LIBCFS_TYPE_GFP_T
639 LIBCFS_CONFIG_PANIC_DUMPLOG
640
641 LIBCFS_FUNC_SHOW_TASK
642 LIBCFS_U64_LONG_LONG_LINUX
643 LIBCFS_TASK_RCU
644 # 2.6.18
645 LIBCFS_TASKLIST_LOCK
646 LIBCFS_HAVE_IS_COMPAT_TASK
647 # 2.6.19
648 LIBCFS_NETLINK
649 LIBCFS_NLMSG_MULTICAST
650 LIBCFS_KMEM_CACHE_DESTROY_INT
651 LIBCFS_ATOMIC_PANIC_NOTIFIER
652 # 2.6.20
653 LIBCFS_3ARGS_INIT_WORK
654 # 2.6.21
655 LIBCFS_2ARGS_REGISTER_SYSCTL
656 LIBCFS_KMEM_CACHE
657 # 2.6.23
658 LIBCFS_KMEM_CACHE_CREATE_DTOR
659 LIBCFS_NETLINK_CBMUTEX
660 # 2.6.24
661 LIBCFS_SYSCTL_UNNUMBERED
662 LIBCFS_SCATTERLIST_SETPAGE
663 LIBCFS_NL_BROADCAST_GFP
664 LIBCFS_NETWORK_NAMESPACE
665 LIBCFS_NETLINK_NETNS
666 LIBCFS_FUNC_DUMP_TRACE
667 # 2.6.26
668 LIBCFS_SEM_COUNT
669 # 2.6.27
670 LIBCFS_CRED_WRAPPERS
671 # 2.6.29
672 LIBCFS_STRUCT_CRED_IN_TASK
673 # 2.6.30
674 LIBCFS_FUNC_UNSHARE_FS_STRUCT
675 LIBCFS_SOCK_MAP_FD_2ARG
676 # 2.6.32
677 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
678 ])
679
680 #
681 # LIBCFS_PROG_DARWIN
682 #
683 # Darwin checks
684 #
685 AC_DEFUN([LIBCFS_PROG_DARWIN],
686 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
687 ])
688
689 #
690 # LIBCFS_PATH_DEFAULTS
691 #
692 # default paths for installed files
693 #
694 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
695 [
696 ])
697
698 #
699 # LIBCFS_CONFIGURE
700 #
701 # other configure checks
702 #
703 AC_DEFUN([LIBCFS_CONFIGURE],
704 [# lnet/utils/portals.c
705 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
706
707 # lnet/utils/debug.c
708 AC_CHECK_HEADERS([linux/version.h])
709
710 AC_CHECK_TYPE([spinlock_t],
711         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
712         [],
713         [#include <linux/spinlock.h>])
714
715 # lnet/utils/wirecheck.c
716 AC_CHECK_FUNCS([strnlen])
717
718 AC_CHECK_TYPE([umode_t],
719         [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
720         [],
721         [#include <asm/types.h>])
722
723 AC_CHECK_TYPE([__s8],
724         [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
725         [],
726         [#include <asm/types.h>])
727
728 AC_CHECK_TYPE([__u8],
729         [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
730         [],
731         [#include <asm/types.h>])
732
733 AC_CHECK_TYPE([__s16],
734         [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
735         [],
736         [#include <asm/types.h>])
737
738 AC_CHECK_TYPE([__u16],
739         [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
740         [],
741         [#include <asm/types.h>])
742
743 AC_CHECK_TYPE([__s32],
744         [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
745         [],
746         [#include <asm/types.h>])
747
748 AC_CHECK_TYPE([__u32],
749         [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
750         [],
751         [#include <asm/types.h>])
752
753 AC_CHECK_TYPE([__u64],
754         [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
755         [],
756         [#include <asm/types.h>])
757
758 AC_CHECK_TYPE([__s64],
759         [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
760         [],
761         [#include <asm/types.h>])
762
763 # check userland __u64 type
764 AC_MSG_CHECKING([userspace __u64 is long long type])
765 tmp_flags="$CFLAGS"
766 CFLAGS="$CFLAGS -Werror"
767 AC_COMPILE_IFELSE([
768         #include <stdio.h>
769         #include <linux/types.h>
770         #include <linux/stddef.h>
771         int main(void) {
772                 unsigned long long *data1;
773                 __u64 *data2 = NULL;
774
775                 data1 = data2;
776                 return 0;
777         }
778 ],[
779         AC_MSG_RESULT([yes])
780         AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
781                   [__u64 is long long type])
782 ],[
783         AC_MSG_RESULT([no])
784 ])
785 CFLAGS="$tmp_flags"
786
787 # --------  Check for required packages  --------------
788
789
790 AC_MSG_CHECKING([if efence debugging support is requested])
791 AC_ARG_ENABLE(efence,
792         AC_HELP_STRING([--enable-efence],
793                         [use efence library]),
794         [],[enable_efence='no'])
795 AC_MSG_RESULT([$enable_efence])
796 if test "$enable_efence" = "yes" ; then
797         LIBEFENCE="-lefence"
798         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
799 else
800         LIBEFENCE=""
801 fi
802 AC_SUBST(LIBEFENCE)
803
804
805 # -------- check for -lpthread support ----
806 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
807 AC_ARG_ENABLE([libpthread],
808         AC_HELP_STRING([--disable-libpthread],
809                 [disable libpthread]),
810         [],[enable_libpthread=yes])
811 if test "$enable_libpthread" = "yes" ; then
812         AC_CHECK_LIB([pthread], [pthread_create],
813                 [ENABLE_LIBPTHREAD="yes"],
814                 [ENABLE_LIBPTHREAD="no"])
815         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
816                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
817                 PTHREAD_LIBS="-lpthread"
818                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
819         else
820                 PTHREAD_LIBS=""
821                 AC_MSG_RESULT([no libpthread is found])
822         fi
823         AC_SUBST(PTHREAD_LIBS)
824 else
825         AC_MSG_RESULT([no (disabled explicitly)])
826         ENABLE_LIBPTHREAD="no"
827 fi
828 AC_SUBST(ENABLE_LIBPTHREAD)
829
830
831 ])
832
833 #
834 # LIBCFS_CONDITIONALS
835 #
836 # AM_CONDITOINAL defines for lnet
837 #
838 AC_DEFUN([LIBCFS_CONDITIONALS],
839 [
840 ])
841
842 #
843 # LIBCFS_CONFIG_FILES
844 #
845 # files that should be generated with AC_OUTPUT
846 #
847 AC_DEFUN([LIBCFS_CONFIG_FILES],
848 [AC_CONFIG_FILES([
849 libcfs/Kernelenv
850 libcfs/Makefile
851 libcfs/autoMakefile
852 libcfs/autoconf/Makefile
853 libcfs/include/Makefile
854 libcfs/include/libcfs/Makefile
855 libcfs/include/libcfs/linux/Makefile
856 libcfs/include/libcfs/posix/Makefile
857 libcfs/include/libcfs/util/Makefile
858 libcfs/libcfs/Makefile
859 libcfs/libcfs/autoMakefile
860 libcfs/libcfs/linux/Makefile
861 libcfs/libcfs/posix/Makefile
862 libcfs/libcfs/util/Makefile
863 libcfs/include/libcfs/darwin/Makefile
864 libcfs/libcfs/darwin/Makefile
865 ])
866 ])