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