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